babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359
  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. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1088. }
  1089. }
  1090. declare module "babylonjs/Meshes/dataBuffer" {
  1091. /**
  1092. * Class used to store gfx data (like WebGLBuffer)
  1093. */
  1094. export class DataBuffer {
  1095. /**
  1096. * Gets or sets the number of objects referencing this buffer
  1097. */
  1098. references: number;
  1099. /** Gets or sets the size of the underlying buffer */
  1100. capacity: number;
  1101. /**
  1102. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1103. */
  1104. is32Bits: boolean;
  1105. /**
  1106. * Gets the underlying buffer
  1107. */
  1108. get underlyingResource(): any;
  1109. }
  1110. }
  1111. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1112. /** @hidden */
  1113. export interface IShaderProcessor {
  1114. attributeProcessor?: (attribute: string) => string;
  1115. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1116. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1117. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1118. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1119. lineProcessor?: (line: string, isFragment: boolean) => string;
  1120. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1121. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1122. }
  1123. }
  1124. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1126. /** @hidden */
  1127. export interface ProcessingOptions {
  1128. defines: string[];
  1129. indexParameters: any;
  1130. isFragment: boolean;
  1131. shouldUseHighPrecisionShader: boolean;
  1132. supportsUniformBuffers: boolean;
  1133. shadersRepository: string;
  1134. includesShadersStore: {
  1135. [key: string]: string;
  1136. };
  1137. processor?: IShaderProcessor;
  1138. version: string;
  1139. platformName: string;
  1140. lookForClosingBracketForUniformBuffer?: boolean;
  1141. }
  1142. }
  1143. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1144. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1145. /** @hidden */
  1146. export class ShaderCodeNode {
  1147. line: string;
  1148. children: ShaderCodeNode[];
  1149. additionalDefineKey?: string;
  1150. additionalDefineValue?: string;
  1151. isValid(preprocessors: {
  1152. [key: string]: string;
  1153. }): boolean;
  1154. process(preprocessors: {
  1155. [key: string]: string;
  1156. }, options: ProcessingOptions): string;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1160. /** @hidden */
  1161. export class ShaderCodeCursor {
  1162. private _lines;
  1163. lineIndex: number;
  1164. get currentLine(): string;
  1165. get canRead(): boolean;
  1166. set lines(value: string[]);
  1167. }
  1168. }
  1169. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1170. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1171. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1190. /** @hidden */
  1191. export class ShaderCodeTestNode extends ShaderCodeNode {
  1192. testExpression: ShaderDefineExpression;
  1193. isValid(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1199. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1200. /** @hidden */
  1201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1202. define: string;
  1203. not: boolean;
  1204. constructor(define: string, not?: boolean);
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1211. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1212. /** @hidden */
  1213. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module "babylonjs/Offline/IOfflineProvider" {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module "babylonjs/Misc/filesInputStore" {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module "babylonjs/Misc/retryStrategy" {
  1297. import { WebRequest } from "babylonjs/Misc/webRequest";
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/baseError" {
  1312. /**
  1313. * @ignore
  1314. * Application error to support additional information when loading a file
  1315. */
  1316. export abstract class BaseError extends Error {
  1317. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1318. }
  1319. }
  1320. declare module "babylonjs/Misc/fileTools" {
  1321. import { WebRequest } from "babylonjs/Misc/webRequest";
  1322. import { Nullable } from "babylonjs/types";
  1323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1324. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1325. import { BaseError } from "babylonjs/Misc/baseError";
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. 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>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1444. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1445. import { WebRequest } from "babylonjs/Misc/webRequest";
  1446. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. /**
  1463. * Loads a file from a url
  1464. * @param url url to load
  1465. * @param onSuccess callback called when the file successfully loads
  1466. * @param onProgress callback called while file is loading (if the server supports this mode)
  1467. * @param offlineProvider defines the offline provider for caching
  1468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1469. * @param onError callback called when the file fails to load
  1470. * @returns a file request object
  1471. * @hidden
  1472. */
  1473. 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;
  1474. }
  1475. }
  1476. declare module "babylonjs/Maths/math.like" {
  1477. import { float, int, DeepImmutable } from "babylonjs/types";
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module "babylonjs/Materials/iEffectFallbacks" {
  1545. import { Effect } from "babylonjs/Materials/effect";
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module "babylonjs/Misc/tags" {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Maths/math.scalar" {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module "babylonjs/Maths/math.constants" {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. export { Epsilon };
  1850. }
  1851. declare module "babylonjs/Maths/math.viewport" {
  1852. /**
  1853. * Class used to represent a viewport on screen
  1854. */
  1855. export class Viewport {
  1856. /** viewport left coordinate */
  1857. x: number;
  1858. /** viewport top coordinate */
  1859. y: number;
  1860. /**viewport width */
  1861. width: number;
  1862. /** viewport height */
  1863. height: number;
  1864. /**
  1865. * Creates a Viewport object located at (x, y) and sized (width, height)
  1866. * @param x defines viewport left coordinate
  1867. * @param y defines viewport top coordinate
  1868. * @param width defines the viewport width
  1869. * @param height defines the viewport height
  1870. */
  1871. constructor(
  1872. /** viewport left coordinate */
  1873. x: number,
  1874. /** viewport top coordinate */
  1875. y: number,
  1876. /**viewport width */
  1877. width: number,
  1878. /** viewport height */
  1879. height: number);
  1880. /**
  1881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1882. * @param renderWidth defines the rendering width
  1883. * @param renderHeight defines the rendering height
  1884. * @returns a new Viewport
  1885. */
  1886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1887. /**
  1888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @param ref defines the target viewport
  1892. * @returns the current viewport
  1893. */
  1894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1895. /**
  1896. * Returns a new Viewport copied from the current one
  1897. * @returns a new Viewport
  1898. */
  1899. clone(): Viewport;
  1900. }
  1901. }
  1902. declare module "babylonjs/Misc/arrayTools" {
  1903. /**
  1904. * Class containing a set of static utilities functions for arrays.
  1905. */
  1906. export class ArrayTools {
  1907. /**
  1908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1909. * @param size the number of element to construct and put in the array
  1910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1911. * @returns a new array filled with new objects
  1912. */
  1913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1914. }
  1915. }
  1916. declare module "babylonjs/Maths/math.vector" {
  1917. import { Viewport } from "babylonjs/Maths/math.viewport";
  1918. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1919. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1920. /**
  1921. * Class representing a vector containing 2 coordinates
  1922. */
  1923. export class Vector2 {
  1924. /** defines the first coordinate */
  1925. x: number;
  1926. /** defines the second coordinate */
  1927. y: number;
  1928. /**
  1929. * Creates a new Vector2 from the given x and y coordinates
  1930. * @param x defines the first coordinate
  1931. * @param y defines the second coordinate
  1932. */
  1933. constructor(
  1934. /** defines the first coordinate */
  1935. x?: number,
  1936. /** defines the second coordinate */
  1937. y?: number);
  1938. /**
  1939. * Gets a string with the Vector2 coordinates
  1940. * @returns a string with the Vector2 coordinates
  1941. */
  1942. toString(): string;
  1943. /**
  1944. * Gets class name
  1945. * @returns the string "Vector2"
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * Gets current vector hash code
  1950. * @returns the Vector2 hash code as a number
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1955. * @param array defines the source array
  1956. * @param index defines the offset in source array
  1957. * @returns the current Vector2
  1958. */
  1959. toArray(array: FloatArray, index?: number): Vector2;
  1960. /**
  1961. * Copy the current vector to an array
  1962. * @returns a new array with 2 elements: the Vector2 coordinates.
  1963. */
  1964. asArray(): number[];
  1965. /**
  1966. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1967. * @param source defines the source Vector2
  1968. * @returns the current updated Vector2
  1969. */
  1970. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Sets the Vector2 coordinates with the given floats
  1973. * @param x defines the first coordinate
  1974. * @param y defines the second coordinate
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFromFloats(x: number, y: number): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. set(x: number, y: number): Vector2;
  1985. /**
  1986. * Add another vector with the current one
  1987. * @param otherVector defines the other vector
  1988. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1989. */
  1990. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1993. * @param otherVector defines the other vector
  1994. * @param result defines the target vector
  1995. * @returns the unmodified current Vector2
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1998. /**
  1999. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. addVector3(otherVector: Vector3): Vector2;
  2010. /**
  2011. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2012. * @param otherVector defines the other vector
  2013. * @returns a new Vector2
  2014. */
  2015. subtract(otherVector: Vector2): Vector2;
  2016. /**
  2017. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2018. * @param otherVector defines the other vector
  2019. * @param result defines the target vector
  2020. * @returns the unmodified current Vector2
  2021. */
  2022. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2023. /**
  2024. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @returns the current updated Vector2
  2027. */
  2028. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2029. /**
  2030. * Multiplies in place the current Vector2 coordinates by the given ones
  2031. * @param otherVector defines the other vector
  2032. * @returns the current updated Vector2
  2033. */
  2034. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2035. /**
  2036. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns a new Vector2
  2039. */
  2040. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @param result defines the target vector
  2045. * @returns the unmodified current Vector2
  2046. */
  2047. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2048. /**
  2049. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. * @returns a new Vector2
  2053. */
  2054. multiplyByFloats(x: number, y: number): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. divide(otherVector: Vector2): Vector2;
  2061. /**
  2062. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Divides the current Vector2 coordinates by the given ones
  2070. * @param otherVector defines the other vector
  2071. * @returns the current updated Vector2
  2072. */
  2073. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Gets a new Vector2 with current Vector2 negated coordinates
  2076. * @returns a new Vector2
  2077. */
  2078. negate(): Vector2;
  2079. /**
  2080. * Negate this vector in place
  2081. * @returns this
  2082. */
  2083. negateInPlace(): Vector2;
  2084. /**
  2085. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2086. * @param result defines the Vector3 object where to store the result
  2087. * @returns the current Vector2
  2088. */
  2089. negateToRef(result: Vector2): Vector2;
  2090. /**
  2091. * Multiply the Vector2 coordinates by scale
  2092. * @param scale defines the scaling factor
  2093. * @returns the current updated Vector2
  2094. */
  2095. scaleInPlace(scale: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2098. * @param scale defines the scaling factor
  2099. * @returns a new Vector2
  2100. */
  2101. scale(scale: number): Vector2;
  2102. /**
  2103. * Scale the current Vector2 values by a factor to a given Vector2
  2104. * @param scale defines the scale factor
  2105. * @param result defines the Vector2 object where to store the result
  2106. * @returns the unmodified current Vector2
  2107. */
  2108. scaleToRef(scale: number, result: Vector2): Vector2;
  2109. /**
  2110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2111. * @param scale defines the scale factor
  2112. * @param result defines the Vector2 object where to store the result
  2113. * @returns the unmodified current Vector2
  2114. */
  2115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2116. /**
  2117. * Gets a boolean if two vectors are equals
  2118. * @param otherVector defines the other vector
  2119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2120. */
  2121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2122. /**
  2123. * Gets a boolean if two vectors are equals (using an epsilon value)
  2124. * @param otherVector defines the other vector
  2125. * @param epsilon defines the minimal distance to consider equality
  2126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2127. */
  2128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2129. /**
  2130. * Gets a new Vector2 from current Vector2 floored values
  2131. * @returns a new Vector2
  2132. */
  2133. floor(): Vector2;
  2134. /**
  2135. * Gets a new Vector2 from current Vector2 floored values
  2136. * @returns a new Vector2
  2137. */
  2138. fract(): Vector2;
  2139. /**
  2140. * Gets the length of the vector
  2141. * @returns the vector length (float)
  2142. */
  2143. length(): number;
  2144. /**
  2145. * Gets the vector squared length
  2146. * @returns the vector squared length (float)
  2147. */
  2148. lengthSquared(): number;
  2149. /**
  2150. * Normalize the vector
  2151. * @returns the current updated Vector2
  2152. */
  2153. normalize(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 copied from the Vector2
  2156. * @returns a new Vector2
  2157. */
  2158. clone(): Vector2;
  2159. /**
  2160. * Gets a new Vector2(0, 0)
  2161. * @returns a new Vector2
  2162. */
  2163. static Zero(): Vector2;
  2164. /**
  2165. * Gets a new Vector2(1, 1)
  2166. * @returns a new Vector2
  2167. */
  2168. static One(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 set from the given index element of the given array
  2171. * @param array defines the data source
  2172. * @param offset defines the offset in the data source
  2173. * @returns a new Vector2
  2174. */
  2175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2176. /**
  2177. * Sets "result" from the given index element of the given array
  2178. * @param array defines the data source
  2179. * @param offset defines the offset in the data source
  2180. * @param result defines the target vector
  2181. */
  2182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2183. /**
  2184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2185. * @param value1 defines 1st point of control
  2186. * @param value2 defines 2nd point of control
  2187. * @param value3 defines 3rd point of control
  2188. * @param value4 defines 4th point of control
  2189. * @param amount defines the interpolation factor
  2190. * @returns a new Vector2
  2191. */
  2192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2193. /**
  2194. * 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".
  2195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2197. * @param value defines the value to clamp
  2198. * @param min defines the lower limit
  2199. * @param max defines the upper limit
  2200. * @returns a new Vector2
  2201. */
  2202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2205. * @param value1 defines the 1st control point
  2206. * @param tangent1 defines the outgoing tangent
  2207. * @param value2 defines the 2nd control point
  2208. * @param tangent2 defines the incoming tangent
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2215. * @param start defines the start vector
  2216. * @param end defines the end vector
  2217. * @param amount defines the interpolation factor
  2218. * @returns a new Vector2
  2219. */
  2220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2221. /**
  2222. * Gets the dot product of the vector "left" and the vector "right"
  2223. * @param left defines first vector
  2224. * @param right defines second vector
  2225. * @returns the dot product (float)
  2226. */
  2227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2228. /**
  2229. * Returns a new Vector2 equal to the normalized given vector
  2230. * @param vector defines the vector to normalize
  2231. * @returns a new Vector2
  2232. */
  2233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2236. * @param left defines 1st vector
  2237. * @param right defines 2nd vector
  2238. * @returns a new Vector2
  2239. */
  2240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2241. /**
  2242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2243. * @param left defines 1st vector
  2244. * @param right defines 2nd vector
  2245. * @returns a new Vector2
  2246. */
  2247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2250. * @param vector defines the vector to transform
  2251. * @param transformation defines the matrix to apply
  2252. * @returns a new Vector2
  2253. */
  2254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2255. /**
  2256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2257. * @param vector defines the vector to transform
  2258. * @param transformation defines the matrix to apply
  2259. * @param result defines the target vector
  2260. */
  2261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2262. /**
  2263. * Determines if a given vector is included in a triangle
  2264. * @param p defines the vector to test
  2265. * @param p0 defines 1st triangle point
  2266. * @param p1 defines 2nd triangle point
  2267. * @param p2 defines 3rd triangle point
  2268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2269. */
  2270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2271. /**
  2272. * Gets the distance between the vectors "value1" and "value2"
  2273. * @param value1 defines first vector
  2274. * @param value2 defines second vector
  2275. * @returns the distance between vectors
  2276. */
  2277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2278. /**
  2279. * Returns the squared distance between the vectors "value1" and "value2"
  2280. * @param value1 defines first vector
  2281. * @param value2 defines second vector
  2282. * @returns the squared distance between vectors
  2283. */
  2284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2285. /**
  2286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2287. * @param value1 defines first vector
  2288. * @param value2 defines second vector
  2289. * @returns a new Vector2
  2290. */
  2291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2292. /**
  2293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2294. * @param p defines the middle point
  2295. * @param segA defines one point of the segment
  2296. * @param segB defines the other point of the segment
  2297. * @returns the shortest distance
  2298. */
  2299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2300. }
  2301. /**
  2302. * Class used to store (x,y,z) vector representation
  2303. * A Vector3 is the main object used in 3D geometry
  2304. * It can represent etiher the coordinates of a point the space, either a direction
  2305. * Reminder: js uses a left handed forward facing system
  2306. */
  2307. export class Vector3 {
  2308. /**
  2309. * Defines the first coordinates (on X axis)
  2310. */
  2311. x: number;
  2312. /**
  2313. * Defines the second coordinates (on Y axis)
  2314. */
  2315. y: number;
  2316. /**
  2317. * Defines the third coordinates (on Z axis)
  2318. */
  2319. z: number;
  2320. private static _UpReadOnly;
  2321. private static _ZeroReadOnly;
  2322. /**
  2323. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2324. * @param x defines the first coordinates (on X axis)
  2325. * @param y defines the second coordinates (on Y axis)
  2326. * @param z defines the third coordinates (on Z axis)
  2327. */
  2328. constructor(
  2329. /**
  2330. * Defines the first coordinates (on X axis)
  2331. */
  2332. x?: number,
  2333. /**
  2334. * Defines the second coordinates (on Y axis)
  2335. */
  2336. y?: number,
  2337. /**
  2338. * Defines the third coordinates (on Z axis)
  2339. */
  2340. z?: number);
  2341. /**
  2342. * Creates a string representation of the Vector3
  2343. * @returns a string with the Vector3 coordinates.
  2344. */
  2345. toString(): string;
  2346. /**
  2347. * Gets the class name
  2348. * @returns the string "Vector3"
  2349. */
  2350. getClassName(): string;
  2351. /**
  2352. * Creates the Vector3 hash code
  2353. * @returns a number which tends to be unique between Vector3 instances
  2354. */
  2355. getHashCode(): number;
  2356. /**
  2357. * Creates an array containing three elements : the coordinates of the Vector3
  2358. * @returns a new array of numbers
  2359. */
  2360. asArray(): number[];
  2361. /**
  2362. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2363. * @param array defines the destination array
  2364. * @param index defines the offset in the destination array
  2365. * @returns the current Vector3
  2366. */
  2367. toArray(array: FloatArray, index?: number): Vector3;
  2368. /**
  2369. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2370. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2371. */
  2372. toQuaternion(): Quaternion;
  2373. /**
  2374. * Adds the given vector to the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Adds the given coordinates to the current Vector3
  2381. * @param x defines the x coordinate of the operand
  2382. * @param y defines the y coordinate of the operand
  2383. * @param z defines the z coordinate of the operand
  2384. * @returns the current updated Vector3
  2385. */
  2386. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2387. /**
  2388. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2389. * @param otherVector defines the second operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2395. * @param otherVector defines the second operand
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2400. /**
  2401. * Subtract the given vector from the current Vector3
  2402. * @param otherVector defines the second operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2406. /**
  2407. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2421. * @param x defines the x coordinate of the operand
  2422. * @param y defines the y coordinate of the operand
  2423. * @param z defines the z coordinate of the operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2427. /**
  2428. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2429. * @param x defines the x coordinate of the operand
  2430. * @param y defines the y coordinate of the operand
  2431. * @param z defines the z coordinate of the operand
  2432. * @param result defines the Vector3 object where to store the result
  2433. * @returns the current Vector3
  2434. */
  2435. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2436. /**
  2437. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2438. * @returns a new Vector3
  2439. */
  2440. negate(): Vector3;
  2441. /**
  2442. * Negate this vector in place
  2443. * @returns this
  2444. */
  2445. negateInPlace(): Vector3;
  2446. /**
  2447. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the current Vector3
  2450. */
  2451. negateToRef(result: Vector3): Vector3;
  2452. /**
  2453. * Multiplies the Vector3 coordinates by the float "scale"
  2454. * @param scale defines the multiplier factor
  2455. * @returns the current updated Vector3
  2456. */
  2457. scaleInPlace(scale: number): Vector3;
  2458. /**
  2459. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2460. * @param scale defines the multiplier factor
  2461. * @returns a new Vector3
  2462. */
  2463. scale(scale: number): Vector3;
  2464. /**
  2465. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2466. * @param scale defines the multiplier factor
  2467. * @param result defines the Vector3 object where to store the result
  2468. * @returns the current Vector3
  2469. */
  2470. scaleToRef(scale: number, result: Vector3): Vector3;
  2471. /**
  2472. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2473. * @param scale defines the scale factor
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the unmodified current Vector3
  2476. */
  2477. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2478. /**
  2479. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2480. * @param otherVector defines the second operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2484. /**
  2485. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2486. * @param otherVector defines the second operand
  2487. * @param epsilon defines the minimal distance to define values as equals
  2488. * @returns true if both vectors are distant less than epsilon
  2489. */
  2490. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2491. /**
  2492. * Returns true if the current Vector3 coordinates equals the given floats
  2493. * @param x defines the x coordinate of the operand
  2494. * @param y defines the y coordinate of the operand
  2495. * @param z defines the z coordinate of the operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equalsToFloats(x: number, y: number, z: number): boolean;
  2499. /**
  2500. * Multiplies the current Vector3 coordinates by the given ones
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2505. /**
  2506. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2528. * @param otherVector defines the second operand
  2529. * @returns the new Vector3
  2530. */
  2531. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Divides the current Vector3 coordinates by the given ones.
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. divideInPlace(otherVector: Vector3): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2547. * @param other defines the second operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2553. * @param other defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2575. * Check if is non uniform within a certain amount of decimal places to account for this
  2576. * @param epsilon the amount the values can differ
  2577. * @returns if the the vector is non uniform to a certain number of decimal places
  2578. */
  2579. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2580. /**
  2581. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2582. */
  2583. get isNonUniform(): boolean;
  2584. /**
  2585. * Gets a new Vector3 from current Vector3 floored values
  2586. * @returns a new Vector3
  2587. */
  2588. floor(): Vector3;
  2589. /**
  2590. * Gets a new Vector3 from current Vector3 floored values
  2591. * @returns a new Vector3
  2592. */
  2593. fract(): Vector3;
  2594. /**
  2595. * Gets the length of the Vector3
  2596. * @returns the length of the Vector3
  2597. */
  2598. length(): number;
  2599. /**
  2600. * Gets the squared length of the Vector3
  2601. * @returns squared length of the Vector3
  2602. */
  2603. lengthSquared(): number;
  2604. /**
  2605. * Normalize the current Vector3.
  2606. * Please note that this is an in place operation.
  2607. * @returns the current updated Vector3
  2608. */
  2609. normalize(): Vector3;
  2610. /**
  2611. * Reorders the x y z properties of the vector in place
  2612. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2613. * @returns the current updated vector
  2614. */
  2615. reorderInPlace(order: string): this;
  2616. /**
  2617. * Rotates the vector around 0,0,0 by a quaternion
  2618. * @param quaternion the rotation quaternion
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2623. /**
  2624. * Rotates a vector around a given point
  2625. * @param quaternion the rotation quaternion
  2626. * @param point the point to rotate around
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2631. /**
  2632. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2633. * The cross product is then orthogonal to both current and "other"
  2634. * @param other defines the right operand
  2635. * @returns the cross product
  2636. */
  2637. cross(other: Vector3): Vector3;
  2638. /**
  2639. * Normalize the current Vector3 with the given input length.
  2640. * Please note that this is an in place operation.
  2641. * @param len the length of the vector
  2642. * @returns the current updated Vector3
  2643. */
  2644. normalizeFromLength(len: number): Vector3;
  2645. /**
  2646. * Normalize the current Vector3 to a new vector
  2647. * @returns the new Vector3
  2648. */
  2649. normalizeToNew(): Vector3;
  2650. /**
  2651. * Normalize the current Vector3 to the reference
  2652. * @param reference define the Vector3 to update
  2653. * @returns the updated Vector3
  2654. */
  2655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Creates a new Vector3 copied from the current Vector3
  2658. * @returns the new Vector3
  2659. */
  2660. clone(): Vector3;
  2661. /**
  2662. * Copies the given vector coordinates to the current Vector3 ones
  2663. * @param source defines the source Vector3
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. set(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given float to the current Vector3 coordinates
  2685. * @param v defines the x, y and z coordinates of the operand
  2686. * @returns the current updated Vector3
  2687. */
  2688. setAll(v: number): Vector3;
  2689. /**
  2690. * Get the clip factor between two vectors
  2691. * @param vector0 defines the first operand
  2692. * @param vector1 defines the second operand
  2693. * @param axis defines the axis to use
  2694. * @param size defines the size along the axis
  2695. * @returns the clip factor
  2696. */
  2697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2698. /**
  2699. * Get angle between two vectors
  2700. * @param vector0 angle between vector0 and vector1
  2701. * @param vector1 angle between vector0 and vector1
  2702. * @param normal direction of the normal
  2703. * @return the angle between vector0 and vector1
  2704. */
  2705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2706. /**
  2707. * Returns a new Vector3 set from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @returns the new Vector3
  2711. */
  2712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @returns the new Vector3
  2718. * @deprecated Please use FromArray instead.
  2719. */
  2720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2721. /**
  2722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @param result defines the Vector3 where to store the result
  2726. */
  2727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @param result defines the Vector3 where to store the result
  2733. * @deprecated Please use FromArrayToRef instead.
  2734. */
  2735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the given floats.
  2738. * @param x defines the x coordinate of the source
  2739. * @param y defines the y coordinate of the source
  2740. * @param z defines the z coordinate of the source
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2746. * @returns a new empty Vector3
  2747. */
  2748. static Zero(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2751. * @returns a new unit Vector3
  2752. */
  2753. static One(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2756. * @returns a new up Vector3
  2757. */
  2758. static Up(): Vector3;
  2759. /**
  2760. * Gets a up Vector3 that must not be updated
  2761. */
  2762. static get UpReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Gets a zero Vector3 that must not be updated
  2765. */
  2766. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2769. * @returns a new down Vector3
  2770. */
  2771. static Down(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2774. * @returns a new forward Vector3
  2775. */
  2776. static Forward(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2779. * @returns a new forward Vector3
  2780. */
  2781. static Backward(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2784. * @returns a new right Vector3
  2785. */
  2786. static Right(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2789. * @returns a new left Vector3
  2790. */
  2791. static Left(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the transformed Vector3
  2798. */
  2799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2810. * This method computes tranformed coordinates only, not transformed direction vectors
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @returns the new Vector3
  2824. */
  2825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param x define the x coordinate of the source vector
  2838. * @param y define the y coordinate of the source vector
  2839. * @param z define the z coordinate of the source vector
  2840. * @param transformation defines the transformation matrix
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2846. * @param value1 defines the first control point
  2847. * @param value2 defines the second control point
  2848. * @param value3 defines the third control point
  2849. * @param value4 defines the fourth control point
  2850. * @param amount defines the amount on the spline to use
  2851. * @returns the new Vector3
  2852. */
  2853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * 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"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @returns the new Vector3
  2862. */
  2863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2864. /**
  2865. * 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"
  2866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2868. * @param value defines the current value
  2869. * @param min defines the lower range value
  2870. * @param max defines the upper range value
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2874. /**
  2875. * Checks if a given vector is inside a specific range
  2876. * @param v defines the vector to test
  2877. * @param min defines the minimum range
  2878. * @param max defines the maximum range
  2879. */
  2880. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2883. * @param value1 defines the first control point
  2884. * @param tangent1 defines the first tangent vector
  2885. * @param value2 defines the second control point
  2886. * @param tangent2 defines the second tangent vector
  2887. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2907. /**
  2908. * Returns the dot product (float) between the vectors "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the dot product
  2912. */
  2913. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2914. /**
  2915. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the cross product
  2920. */
  2921. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2922. /**
  2923. * Sets the given vector "result" with the cross product of "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 as the normalization of the given vector
  2932. * @param vector defines the Vector3 to normalize
  2933. * @returns the new Vector3
  2934. */
  2935. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the normalization of the given first vector
  2938. * @param vector defines the Vector3 to normalize
  2939. * @param result defines the Vector3 where to store the result
  2940. */
  2941. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2942. /**
  2943. * Project a Vector3 onto screen space
  2944. * @param vector defines the Vector3 to project
  2945. * @param world defines the world matrix to use
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @param viewport defines the screen viewport to use
  2948. * @returns the new Vector3
  2949. */
  2950. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2951. /** @hidden */
  2952. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param sourceX defines the screen space x coordinate to use
  2988. * @param sourceY defines the screen space y coordinate to use
  2989. * @param sourceZ defines the screen space z coordinate to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Gets the minimal coordinate values between two Vector3
  3000. * @param left defines the first operand
  3001. * @param right defines the second operand
  3002. * @returns the new Vector3
  3003. */
  3004. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3005. /**
  3006. * Gets the maximal coordinate values between two Vector3
  3007. * @param left defines the first operand
  3008. * @param right defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Returns the distance between the vectors "value1" and "value2"
  3014. * @param value1 defines the first operand
  3015. * @param value2 defines the second operand
  3016. * @returns the distance
  3017. */
  3018. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3019. /**
  3020. * Returns the squared distance between the vectors "value1" and "value2"
  3021. * @param value1 defines the first operand
  3022. * @param value2 defines the second operand
  3023. * @returns the squared distance
  3024. */
  3025. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 located at the center between "value1" and "value2"
  3028. * @param value1 defines the first operand
  3029. * @param value2 defines the second operand
  3030. * @returns the new Vector3
  3031. */
  3032. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3036. * to something in order to rotate it from its local system to the given target system
  3037. * Note: axis1, axis2 and axis3 are normalized during this operation
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @returns a new Vector3
  3042. */
  3043. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @param ref defines the Vector3 where to store the result
  3050. */
  3051. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3052. }
  3053. /**
  3054. * Vector4 class created for EulerAngle class conversion to Quaternion
  3055. */
  3056. export class Vector4 {
  3057. /** x value of the vector */
  3058. x: number;
  3059. /** y value of the vector */
  3060. y: number;
  3061. /** z value of the vector */
  3062. z: number;
  3063. /** w value of the vector */
  3064. w: number;
  3065. /**
  3066. * Creates a Vector4 object from the given floats.
  3067. * @param x x value of the vector
  3068. * @param y y value of the vector
  3069. * @param z z value of the vector
  3070. * @param w w value of the vector
  3071. */
  3072. constructor(
  3073. /** x value of the vector */
  3074. x: number,
  3075. /** y value of the vector */
  3076. y: number,
  3077. /** z value of the vector */
  3078. z: number,
  3079. /** w value of the vector */
  3080. w: number);
  3081. /**
  3082. * Returns the string with the Vector4 coordinates.
  3083. * @returns a string containing all the vector values
  3084. */
  3085. toString(): string;
  3086. /**
  3087. * Returns the string "Vector4".
  3088. * @returns "Vector4"
  3089. */
  3090. getClassName(): string;
  3091. /**
  3092. * Returns the Vector4 hash code.
  3093. * @returns a unique hash code
  3094. */
  3095. getHashCode(): number;
  3096. /**
  3097. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3098. * @returns the resulting array
  3099. */
  3100. asArray(): number[];
  3101. /**
  3102. * Populates the given array from the given index with the Vector4 coordinates.
  3103. * @param array array to populate
  3104. * @param index index of the array to start at (default: 0)
  3105. * @returns the Vector4.
  3106. */
  3107. toArray(array: FloatArray, index?: number): Vector4;
  3108. /**
  3109. * Adds the given vector to the current Vector4.
  3110. * @param otherVector the vector to add
  3111. * @returns the updated Vector4.
  3112. */
  3113. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3114. /**
  3115. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3116. * @param otherVector the vector to add
  3117. * @returns the resulting vector
  3118. */
  3119. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3122. * @param otherVector the vector to add
  3123. * @param result the vector to store the result
  3124. * @returns the current Vector4.
  3125. */
  3126. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3127. /**
  3128. * Subtract in place the given vector from the current Vector4.
  3129. * @param otherVector the vector to subtract
  3130. * @returns the updated Vector4.
  3131. */
  3132. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3135. * @param otherVector the vector to add
  3136. * @returns the new vector with the result
  3137. */
  3138. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3139. /**
  3140. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3141. * @param otherVector the vector to subtract
  3142. * @param result the vector to store the result
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3148. */
  3149. /**
  3150. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3151. * @param x value to subtract
  3152. * @param y value to subtract
  3153. * @param z value to subtract
  3154. * @param w value to subtract
  3155. * @returns new vector containing the result
  3156. */
  3157. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3158. /**
  3159. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3160. * @param x value to subtract
  3161. * @param y value to subtract
  3162. * @param z value to subtract
  3163. * @param w value to subtract
  3164. * @param result the vector to store the result in
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3170. * @returns a new vector with the negated values
  3171. */
  3172. negate(): Vector4;
  3173. /**
  3174. * Negate this vector in place
  3175. * @returns this
  3176. */
  3177. negateInPlace(): Vector4;
  3178. /**
  3179. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3180. * @param result defines the Vector3 object where to store the result
  3181. * @returns the current Vector4
  3182. */
  3183. negateToRef(result: Vector4): Vector4;
  3184. /**
  3185. * Multiplies the current Vector4 coordinates by scale (float).
  3186. * @param scale the number to scale with
  3187. * @returns the updated Vector4.
  3188. */
  3189. scaleInPlace(scale: number): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3192. * @param scale the number to scale with
  3193. * @returns a new vector with the result
  3194. */
  3195. scale(scale: number): Vector4;
  3196. /**
  3197. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3198. * @param scale the number to scale with
  3199. * @param result a vector to store the result in
  3200. * @returns the current Vector4.
  3201. */
  3202. scaleToRef(scale: number, result: Vector4): Vector4;
  3203. /**
  3204. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3205. * @param scale defines the scale factor
  3206. * @param result defines the Vector4 object where to store the result
  3207. * @returns the unmodified current Vector4
  3208. */
  3209. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3210. /**
  3211. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3212. * @param otherVector the vector to compare against
  3213. * @returns true if they are equal
  3214. */
  3215. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3216. /**
  3217. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3218. * @param otherVector vector to compare against
  3219. * @param epsilon (Default: very small number)
  3220. * @returns true if they are equal
  3221. */
  3222. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3223. /**
  3224. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3225. * @param x x value to compare against
  3226. * @param y y value to compare against
  3227. * @param z z value to compare against
  3228. * @param w w value to compare against
  3229. * @returns true if equal
  3230. */
  3231. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3232. /**
  3233. * Multiplies in place the current Vector4 by the given one.
  3234. * @param otherVector vector to multiple with
  3235. * @returns the updated Vector4.
  3236. */
  3237. multiplyInPlace(otherVector: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3240. * @param otherVector vector to multiple with
  3241. * @returns resulting new vector
  3242. */
  3243. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3246. * @param otherVector vector to multiple with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3253. * @param x x value multiply with
  3254. * @param y y value multiply with
  3255. * @param z z value multiply with
  3256. * @param w w value multiply with
  3257. * @returns resulting new vector
  3258. */
  3259. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3262. * @param otherVector vector to devide with
  3263. * @returns resulting new vector
  3264. */
  3265. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3268. * @param otherVector vector to devide with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Divides the current Vector3 coordinates by the given ones.
  3275. * @param otherVector vector to devide with
  3276. * @returns the updated Vector3.
  3277. */
  3278. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3281. * @param other defines the second operand
  3282. * @returns the current updated Vector4
  3283. */
  3284. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3287. * @param other defines the second operand
  3288. * @returns the current updated Vector4
  3289. */
  3290. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Gets a new Vector4 from current Vector4 floored values
  3293. * @returns a new Vector4
  3294. */
  3295. floor(): Vector4;
  3296. /**
  3297. * Gets a new Vector4 from current Vector3 floored values
  3298. * @returns a new Vector4
  3299. */
  3300. fract(): Vector4;
  3301. /**
  3302. * Returns the Vector4 length (float).
  3303. * @returns the length
  3304. */
  3305. length(): number;
  3306. /**
  3307. * Returns the Vector4 squared length (float).
  3308. * @returns the length squared
  3309. */
  3310. lengthSquared(): number;
  3311. /**
  3312. * Normalizes in place the Vector4.
  3313. * @returns the updated Vector4.
  3314. */
  3315. normalize(): Vector4;
  3316. /**
  3317. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3318. * @returns this converted to a new vector3
  3319. */
  3320. toVector3(): Vector3;
  3321. /**
  3322. * Returns a new Vector4 copied from the current one.
  3323. * @returns the new cloned vector
  3324. */
  3325. clone(): Vector4;
  3326. /**
  3327. * Updates the current Vector4 with the given one coordinates.
  3328. * @param source the source vector to copy from
  3329. * @returns the updated Vector4.
  3330. */
  3331. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Updates the current Vector4 coordinates with the given floats.
  3334. * @param x float to copy from
  3335. * @param y float to copy from
  3336. * @param z float to copy from
  3337. * @param w float to copy from
  3338. * @returns the updated Vector4.
  3339. */
  3340. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3341. /**
  3342. * Updates the current Vector4 coordinates with the given floats.
  3343. * @param x float to set from
  3344. * @param y float to set from
  3345. * @param z float to set from
  3346. * @param w float to set from
  3347. * @returns the updated Vector4.
  3348. */
  3349. set(x: number, y: number, z: number, w: number): Vector4;
  3350. /**
  3351. * Copies the given float to the current Vector3 coordinates
  3352. * @param v defines the x, y, z and w coordinates of the operand
  3353. * @returns the current updated Vector3
  3354. */
  3355. setAll(v: number): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set from the starting index of the given array.
  3358. * @param array the array to pull values from
  3359. * @param offset the offset into the array to start at
  3360. * @returns the new vector
  3361. */
  3362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3363. /**
  3364. * Updates the given vector "result" from the starting index of the given array.
  3365. * @param array the array to pull values from
  3366. * @param offset the offset into the array to start at
  3367. * @param result the vector to store the result in
  3368. */
  3369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3370. /**
  3371. * Updates the given vector "result" from the starting index of the given Float32Array.
  3372. * @param array the array to pull values from
  3373. * @param offset the offset into the array to start at
  3374. * @param result the vector to store the result in
  3375. */
  3376. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3377. /**
  3378. * Updates the given vector "result" coordinates from the given floats.
  3379. * @param x float to set from
  3380. * @param y float to set from
  3381. * @param z float to set from
  3382. * @param w float to set from
  3383. * @param result the vector to the floats in
  3384. */
  3385. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3386. /**
  3387. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3388. * @returns the new vector
  3389. */
  3390. static Zero(): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3393. * @returns the new vector
  3394. */
  3395. static One(): Vector4;
  3396. /**
  3397. * Returns a new normalized Vector4 from the given one.
  3398. * @param vector the vector to normalize
  3399. * @returns the vector
  3400. */
  3401. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Updates the given vector "result" from the normalization of the given one.
  3404. * @param vector the vector to normalize
  3405. * @param result the vector to store the result in
  3406. */
  3407. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3408. /**
  3409. * Returns a vector with the minimum values from the left and right vectors
  3410. * @param left left vector to minimize
  3411. * @param right right vector to minimize
  3412. * @returns a new vector with the minimum of the left and right vector values
  3413. */
  3414. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Returns a vector with the maximum values from the left and right vectors
  3417. * @param left left vector to maximize
  3418. * @param right right vector to maximize
  3419. * @returns a new vector with the maximum of the left and right vector values
  3420. */
  3421. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns the distance (float) between the vectors "value1" and "value2".
  3424. * @param value1 value to calulate the distance between
  3425. * @param value2 value to calulate the distance between
  3426. * @return the distance between the two vectors
  3427. */
  3428. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3429. /**
  3430. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3431. * @param value1 value to calulate the distance between
  3432. * @param value2 value to calulate the distance between
  3433. * @return the distance between the two vectors squared
  3434. */
  3435. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3436. /**
  3437. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3438. * @param value1 value to calulate the center between
  3439. * @param value2 value to calulate the center between
  3440. * @return the center between the two vectors
  3441. */
  3442. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3445. * This methods computes transformed normalized direction vectors only.
  3446. * @param vector the vector to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @returns the new vector
  3449. */
  3450. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3451. /**
  3452. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3453. * This methods computes transformed normalized direction vectors only.
  3454. * @param vector the vector to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the result in
  3457. */
  3458. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3461. * This methods computes transformed normalized direction vectors only.
  3462. * @param x value to transform
  3463. * @param y value to transform
  3464. * @param z value to transform
  3465. * @param w value to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the results in
  3468. */
  3469. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Creates a new Vector4 from a Vector3
  3472. * @param source defines the source data
  3473. * @param w defines the 4th component (default is 0)
  3474. * @returns a new Vector4
  3475. */
  3476. static FromVector3(source: Vector3, w?: number): Vector4;
  3477. }
  3478. /**
  3479. * Class used to store quaternion data
  3480. * @see https://en.wikipedia.org/wiki/Quaternion
  3481. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3482. */
  3483. export class Quaternion {
  3484. /** defines the first component (0 by default) */
  3485. x: number;
  3486. /** defines the second component (0 by default) */
  3487. y: number;
  3488. /** defines the third component (0 by default) */
  3489. z: number;
  3490. /** defines the fourth component (1.0 by default) */
  3491. w: number;
  3492. /**
  3493. * Creates a new Quaternion from the given floats
  3494. * @param x defines the first component (0 by default)
  3495. * @param y defines the second component (0 by default)
  3496. * @param z defines the third component (0 by default)
  3497. * @param w defines the fourth component (1.0 by default)
  3498. */
  3499. constructor(
  3500. /** defines the first component (0 by default) */
  3501. x?: number,
  3502. /** defines the second component (0 by default) */
  3503. y?: number,
  3504. /** defines the third component (0 by default) */
  3505. z?: number,
  3506. /** defines the fourth component (1.0 by default) */
  3507. w?: number);
  3508. /**
  3509. * Gets a string representation for the current quaternion
  3510. * @returns a string with the Quaternion coordinates
  3511. */
  3512. toString(): string;
  3513. /**
  3514. * Gets the class name of the quaternion
  3515. * @returns the string "Quaternion"
  3516. */
  3517. getClassName(): string;
  3518. /**
  3519. * Gets a hash code for this quaternion
  3520. * @returns the quaternion hash code
  3521. */
  3522. getHashCode(): number;
  3523. /**
  3524. * Copy the quaternion to an array
  3525. * @returns a new array populated with 4 elements from the quaternion coordinates
  3526. */
  3527. asArray(): number[];
  3528. /**
  3529. * Check if two quaternions are equals
  3530. * @param otherQuaternion defines the second operand
  3531. * @return true if the current quaternion and the given one coordinates are strictly equals
  3532. */
  3533. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3534. /**
  3535. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3536. * @param otherQuaternion defines the other quaternion
  3537. * @param epsilon defines the minimal distance to consider equality
  3538. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3539. */
  3540. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3541. /**
  3542. * Clone the current quaternion
  3543. * @returns a new quaternion copied from the current one
  3544. */
  3545. clone(): Quaternion;
  3546. /**
  3547. * Copy a quaternion to the current one
  3548. * @param other defines the other quaternion
  3549. * @returns the updated current quaternion
  3550. */
  3551. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Updates the current quaternion with the given float coordinates
  3554. * @param x defines the x coordinate
  3555. * @param y defines the y coordinate
  3556. * @param z defines the z coordinate
  3557. * @param w defines the w coordinate
  3558. * @returns the updated current quaternion
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3561. /**
  3562. * Updates the current quaternion from the given float coordinates
  3563. * @param x defines the x coordinate
  3564. * @param y defines the y coordinate
  3565. * @param z defines the z coordinate
  3566. * @param w defines the w coordinate
  3567. * @returns the updated current quaternion
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Quaternion;
  3570. /**
  3571. * Adds two quaternions
  3572. * @param other defines the second operand
  3573. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3574. */
  3575. add(other: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Add a quaternion to the current one
  3578. * @param other defines the quaternion to add
  3579. * @returns the current quaternion
  3580. */
  3581. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Subtract two quaternions
  3584. * @param other defines the second operand
  3585. * @returns a new quaternion as the subtraction result of the given one from the current one
  3586. */
  3587. subtract(other: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3592. */
  3593. scale(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies in place the current quaternion by a scale factor
  3603. * @param value defines the scale factor
  3604. * @returns the current modified quaternion
  3605. */
  3606. scaleInPlace(value: number): Quaternion;
  3607. /**
  3608. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3609. * @param scale defines the scale factor
  3610. * @param result defines the Quaternion object where to store the result
  3611. * @returns the unmodified current quaternion
  3612. */
  3613. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3614. /**
  3615. * Multiplies two quaternions
  3616. * @param q1 defines the second operand
  3617. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3618. */
  3619. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3622. * @param q1 defines the second operand
  3623. * @param result defines the target quaternion
  3624. * @returns the current quaternion
  3625. */
  3626. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3627. /**
  3628. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3629. * @param q1 defines the second operand
  3630. * @returns the currentupdated quaternion
  3631. */
  3632. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3633. /**
  3634. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3635. * @param ref defines the target quaternion
  3636. * @returns the current quaternion
  3637. */
  3638. conjugateToRef(ref: Quaternion): Quaternion;
  3639. /**
  3640. * Conjugates in place (1-q) the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. conjugateInPlace(): Quaternion;
  3644. /**
  3645. * Conjugates in place (1-q) the current quaternion
  3646. * @returns a new quaternion
  3647. */
  3648. conjugate(): Quaternion;
  3649. /**
  3650. * Gets length of current quaternion
  3651. * @returns the quaternion length (float)
  3652. */
  3653. length(): number;
  3654. /**
  3655. * Normalize in place the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. normalize(): Quaternion;
  3659. /**
  3660. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3661. * @param order is a reserved parameter and is ignore for now
  3662. * @returns a new Vector3 containing the Euler angles
  3663. */
  3664. toEulerAngles(order?: string): Vector3;
  3665. /**
  3666. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3667. * @param result defines the vector which will be filled with the Euler angles
  3668. * @param order is a reserved parameter and is ignore for now
  3669. * @returns the current unchanged quaternion
  3670. */
  3671. toEulerAnglesToRef(result: Vector3): Quaternion;
  3672. /**
  3673. * Updates the given rotation matrix with the current quaternion values
  3674. * @param result defines the target matrix
  3675. * @returns the current unchanged quaternion
  3676. */
  3677. toRotationMatrix(result: Matrix): Quaternion;
  3678. /**
  3679. * Updates the current quaternion from the given rotation matrix values
  3680. * @param matrix defines the source matrix
  3681. * @returns the current updated quaternion
  3682. */
  3683. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3684. /**
  3685. * Creates a new quaternion from a rotation matrix
  3686. * @param matrix defines the source matrix
  3687. * @returns a new quaternion created from the given rotation matrix values
  3688. */
  3689. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3690. /**
  3691. * Updates the given quaternion with the given rotation matrix values
  3692. * @param matrix defines the source matrix
  3693. * @param result defines the target quaternion
  3694. */
  3695. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3696. /**
  3697. * Returns the dot product (float) between the quaternions "left" and "right"
  3698. * @param left defines the left operand
  3699. * @param right defines the right operand
  3700. * @returns the dot product
  3701. */
  3702. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3703. /**
  3704. * Checks if the two quaternions are close to each other
  3705. * @param quat0 defines the first quaternion to check
  3706. * @param quat1 defines the second quaternion to check
  3707. * @returns true if the two quaternions are close to each other
  3708. */
  3709. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates an empty quaternion
  3712. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3713. */
  3714. static Zero(): Quaternion;
  3715. /**
  3716. * Inverse a given quaternion
  3717. * @param q defines the source quaternion
  3718. * @returns a new quaternion as the inverted current quaternion
  3719. */
  3720. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3721. /**
  3722. * Inverse a given quaternion
  3723. * @param q defines the source quaternion
  3724. * @param result the quaternion the result will be stored in
  3725. * @returns the result quaternion
  3726. */
  3727. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates an identity quaternion
  3730. * @returns the identity quaternion
  3731. */
  3732. static Identity(): Quaternion;
  3733. /**
  3734. * Gets a boolean indicating if the given quaternion is identity
  3735. * @param quaternion defines the quaternion to check
  3736. * @returns true if the quaternion is identity
  3737. */
  3738. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3739. /**
  3740. * Creates a quaternion from a rotation around an axis
  3741. * @param axis defines the axis to use
  3742. * @param angle defines the angle to use
  3743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3744. */
  3745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3746. /**
  3747. * Creates a rotation around an axis and stores it into the given quaternion
  3748. * @param axis defines the axis to use
  3749. * @param angle defines the angle to use
  3750. * @param result defines the target quaternion
  3751. * @returns the target quaternion
  3752. */
  3753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3754. /**
  3755. * Creates a new quaternion from data stored into an array
  3756. * @param array defines the data source
  3757. * @param offset defines the offset in the source array where the data starts
  3758. * @returns a new quaternion
  3759. */
  3760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3761. /**
  3762. * Create a quaternion from Euler rotation angles
  3763. * @param x Pitch
  3764. * @param y Yaw
  3765. * @param z Roll
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation angles
  3771. * @param x Pitch
  3772. * @param y Yaw
  3773. * @param z Roll
  3774. * @param result the quaternion to store the result
  3775. * @returns the updated quaternion
  3776. */
  3777. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3778. /**
  3779. * Create a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @returns the new Quaternion
  3782. */
  3783. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3784. /**
  3785. * Updates a quaternion from Euler rotation vector
  3786. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3787. * @param result the quaternion to store the result
  3788. * @returns the updated quaternion
  3789. */
  3790. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3791. /**
  3792. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3793. * @param yaw defines the rotation around Y axis
  3794. * @param pitch defines the rotation around X axis
  3795. * @param roll defines the rotation around Z axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3799. /**
  3800. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3801. * @param yaw defines the rotation around Y axis
  3802. * @param pitch defines the rotation around X axis
  3803. * @param roll defines the rotation around Z axis
  3804. * @param result defines the target quaternion
  3805. */
  3806. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3807. /**
  3808. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3809. * @param alpha defines the rotation around first axis
  3810. * @param beta defines the rotation around second axis
  3811. * @param gamma defines the rotation around third axis
  3812. * @returns the new quaternion
  3813. */
  3814. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3815. /**
  3816. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3817. * @param alpha defines the rotation around first axis
  3818. * @param beta defines the rotation around second axis
  3819. * @param gamma defines the rotation around third axis
  3820. * @param result defines the target quaternion
  3821. */
  3822. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3823. /**
  3824. * 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)
  3825. * @param axis1 defines the first axis
  3826. * @param axis2 defines the second axis
  3827. * @param axis3 defines the third axis
  3828. * @returns the new quaternion
  3829. */
  3830. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3831. /**
  3832. * 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
  3833. * @param axis1 defines the first axis
  3834. * @param axis2 defines the second axis
  3835. * @param axis3 defines the third axis
  3836. * @param ref defines the target quaternion
  3837. */
  3838. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3839. /**
  3840. * Interpolates between two quaternions
  3841. * @param left defines first quaternion
  3842. * @param right defines second quaternion
  3843. * @param amount defines the gradient to use
  3844. * @returns the new interpolated quaternion
  3845. */
  3846. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3847. /**
  3848. * Interpolates between two quaternions and stores it into a target quaternion
  3849. * @param left defines first quaternion
  3850. * @param right defines second quaternion
  3851. * @param amount defines the gradient to use
  3852. * @param result defines the target quaternion
  3853. */
  3854. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3855. /**
  3856. * Interpolate between two quaternions using Hermite interpolation
  3857. * @param value1 defines first quaternion
  3858. * @param tangent1 defines the incoming tangent
  3859. * @param value2 defines second quaternion
  3860. * @param tangent2 defines the outgoing tangent
  3861. * @param amount defines the target quaternion
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. }
  3866. /**
  3867. * Class used to store matrix data (4x4)
  3868. */
  3869. export class Matrix {
  3870. private static _updateFlagSeed;
  3871. private static _identityReadOnly;
  3872. private _isIdentity;
  3873. private _isIdentityDirty;
  3874. private _isIdentity3x2;
  3875. private _isIdentity3x2Dirty;
  3876. /**
  3877. * Gets the update flag of the matrix which is an unique number for the matrix.
  3878. * It will be incremented every time the matrix data change.
  3879. * You can use it to speed the comparison between two versions of the same matrix.
  3880. */
  3881. updateFlag: number;
  3882. private readonly _m;
  3883. /**
  3884. * Gets the internal data of the matrix
  3885. */
  3886. get m(): DeepImmutable<Float32Array>;
  3887. /** @hidden */
  3888. _markAsUpdated(): void;
  3889. /** @hidden */
  3890. private _updateIdentityStatus;
  3891. /**
  3892. * Creates an empty matrix (filled with zeros)
  3893. */
  3894. constructor();
  3895. /**
  3896. * Check if the current matrix is identity
  3897. * @returns true is the matrix is the identity matrix
  3898. */
  3899. isIdentity(): boolean;
  3900. /**
  3901. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3902. * @returns true is the matrix is the identity matrix
  3903. */
  3904. isIdentityAs3x2(): boolean;
  3905. /**
  3906. * Gets the determinant of the matrix
  3907. * @returns the matrix determinant
  3908. */
  3909. determinant(): number;
  3910. /**
  3911. * Returns the matrix as a Float32Array
  3912. * @returns the matrix underlying array
  3913. */
  3914. toArray(): DeepImmutable<Float32Array>;
  3915. /**
  3916. * Returns the matrix as a Float32Array
  3917. * @returns the matrix underlying array.
  3918. */
  3919. asArray(): DeepImmutable<Float32Array>;
  3920. /**
  3921. * Inverts the current matrix in place
  3922. * @returns the current inverted matrix
  3923. */
  3924. invert(): Matrix;
  3925. /**
  3926. * Sets all the matrix elements to zero
  3927. * @returns the current matrix
  3928. */
  3929. reset(): Matrix;
  3930. /**
  3931. * Adds the current matrix with a second one
  3932. * @param other defines the matrix to add
  3933. * @returns a new matrix as the addition of the current matrix and the given one
  3934. */
  3935. add(other: DeepImmutable<Matrix>): Matrix;
  3936. /**
  3937. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3938. * @param other defines the matrix to add
  3939. * @param result defines the target matrix
  3940. * @returns the current matrix
  3941. */
  3942. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3943. /**
  3944. * Adds in place the given matrix to the current matrix
  3945. * @param other defines the second operand
  3946. * @returns the current updated matrix
  3947. */
  3948. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3949. /**
  3950. * Sets the given matrix to the current inverted Matrix
  3951. * @param other defines the target matrix
  3952. * @returns the unmodified current matrix
  3953. */
  3954. invertToRef(other: Matrix): Matrix;
  3955. /**
  3956. * add a value at the specified position in the current Matrix
  3957. * @param index the index of the value within the matrix. between 0 and 15.
  3958. * @param value the value to be added
  3959. * @returns the current updated matrix
  3960. */
  3961. addAtIndex(index: number, value: number): Matrix;
  3962. /**
  3963. * mutiply the specified position in the current Matrix by a value
  3964. * @param index the index of the value within the matrix. between 0 and 15.
  3965. * @param value the value to be added
  3966. * @returns the current updated matrix
  3967. */
  3968. multiplyAtIndex(index: number, value: number): Matrix;
  3969. /**
  3970. * Inserts the translation vector (using 3 floats) in the current matrix
  3971. * @param x defines the 1st component of the translation
  3972. * @param y defines the 2nd component of the translation
  3973. * @param z defines the 3rd component of the translation
  3974. * @returns the current updated matrix
  3975. */
  3976. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3977. /**
  3978. * Adds the translation vector (using 3 floats) in the current matrix
  3979. * @param x defines the 1st component of the translation
  3980. * @param y defines the 2nd component of the translation
  3981. * @param z defines the 3rd component of the translation
  3982. * @returns the current updated matrix
  3983. */
  3984. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3985. /**
  3986. * Inserts the translation vector in the current matrix
  3987. * @param vector3 defines the translation to insert
  3988. * @returns the current updated matrix
  3989. */
  3990. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3991. /**
  3992. * Gets the translation value of the current matrix
  3993. * @returns a new Vector3 as the extracted translation from the matrix
  3994. */
  3995. getTranslation(): Vector3;
  3996. /**
  3997. * Fill a Vector3 with the extracted translation from the matrix
  3998. * @param result defines the Vector3 where to store the translation
  3999. * @returns the current matrix
  4000. */
  4001. getTranslationToRef(result: Vector3): Matrix;
  4002. /**
  4003. * Remove rotation and scaling part from the matrix
  4004. * @returns the updated matrix
  4005. */
  4006. removeRotationAndScaling(): Matrix;
  4007. /**
  4008. * Multiply two matrices
  4009. * @param other defines the second operand
  4010. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4011. */
  4012. multiply(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Copy the current matrix from the given one
  4015. * @param other defines the source matrix
  4016. * @returns the current updated matrix
  4017. */
  4018. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4019. /**
  4020. * Populates the given array from the starting index with the current matrix values
  4021. * @param array defines the target array
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. copyToArray(array: Float32Array, offset?: number): Matrix;
  4026. /**
  4027. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4028. * @param other defines the second operand
  4029. * @param result defines the matrix where to store the multiplication
  4030. * @returns the current matrix
  4031. */
  4032. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4033. /**
  4034. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4035. * @param other defines the second operand
  4036. * @param result defines the array where to store the multiplication
  4037. * @param offset defines the offset in the target array where to start storing values
  4038. * @returns the current matrix
  4039. */
  4040. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4041. /**
  4042. * Check equality between this matrix and a second one
  4043. * @param value defines the second matrix to compare
  4044. * @returns true is the current matrix and the given one values are strictly equal
  4045. */
  4046. equals(value: DeepImmutable<Matrix>): boolean;
  4047. /**
  4048. * Clone the current matrix
  4049. * @returns a new matrix from the current matrix
  4050. */
  4051. clone(): Matrix;
  4052. /**
  4053. * Returns the name of the current matrix class
  4054. * @returns the string "Matrix"
  4055. */
  4056. getClassName(): string;
  4057. /**
  4058. * Gets the hash code of the current matrix
  4059. * @returns the hash code
  4060. */
  4061. getHashCode(): number;
  4062. /**
  4063. * Decomposes the current Matrix into a translation, rotation and scaling components
  4064. * @param scale defines the scale vector3 given as a reference to update
  4065. * @param rotation defines the rotation quaternion given as a reference to update
  4066. * @param translation defines the translation vector3 given as a reference to update
  4067. * @returns true if operation was successful
  4068. */
  4069. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4070. /**
  4071. * Gets specific row of the matrix
  4072. * @param index defines the number of the row to get
  4073. * @returns the index-th row of the current matrix as a new Vector4
  4074. */
  4075. getRow(index: number): Nullable<Vector4>;
  4076. /**
  4077. * Sets the index-th row of the current matrix to the vector4 values
  4078. * @param index defines the number of the row to set
  4079. * @param row defines the target vector4
  4080. * @returns the updated current matrix
  4081. */
  4082. setRow(index: number, row: Vector4): Matrix;
  4083. /**
  4084. * Compute the transpose of the matrix
  4085. * @returns the new transposed matrix
  4086. */
  4087. transpose(): Matrix;
  4088. /**
  4089. * Compute the transpose of the matrix and store it in a given matrix
  4090. * @param result defines the target matrix
  4091. * @returns the current matrix
  4092. */
  4093. transposeToRef(result: Matrix): Matrix;
  4094. /**
  4095. * Sets the index-th row of the current matrix with the given 4 x float values
  4096. * @param index defines the row index
  4097. * @param x defines the x component to set
  4098. * @param y defines the y component to set
  4099. * @param z defines the z component to set
  4100. * @param w defines the w component to set
  4101. * @returns the updated current matrix
  4102. */
  4103. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4104. /**
  4105. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4106. * @param scale defines the scale factor
  4107. * @returns a new matrix
  4108. */
  4109. scale(scale: number): Matrix;
  4110. /**
  4111. * Scale the current matrix values by a factor to a given result matrix
  4112. * @param scale defines the scale factor
  4113. * @param result defines the matrix to store the result
  4114. * @returns the current matrix
  4115. */
  4116. scaleToRef(scale: number, result: Matrix): Matrix;
  4117. /**
  4118. * Scale the current matrix values by a factor and add the result to a given matrix
  4119. * @param scale defines the scale factor
  4120. * @param result defines the Matrix to store the result
  4121. * @returns the current matrix
  4122. */
  4123. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4124. /**
  4125. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4126. * @param ref matrix to store the result
  4127. */
  4128. toNormalMatrix(ref: Matrix): void;
  4129. /**
  4130. * Gets only rotation part of the current matrix
  4131. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4132. */
  4133. getRotationMatrix(): Matrix;
  4134. /**
  4135. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4136. * @param result defines the target matrix to store data to
  4137. * @returns the current matrix
  4138. */
  4139. getRotationMatrixToRef(result: Matrix): Matrix;
  4140. /**
  4141. * Toggles model matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleModelMatrixHandInPlace(): void;
  4144. /**
  4145. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleProjectionMatrixHandInPlace(): void;
  4148. /**
  4149. * Creates a matrix from an array
  4150. * @param array defines the source array
  4151. * @param offset defines an offset in the source array
  4152. * @returns a new Matrix set from the starting index of the given array
  4153. */
  4154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4155. /**
  4156. * Copy the content of an array into a given matrix
  4157. * @param array defines the source array
  4158. * @param offset defines an offset in the source array
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4162. /**
  4163. * Stores an array into a matrix after having multiplied each component by a given factor
  4164. * @param array defines the source array
  4165. * @param offset defines the offset in the source array
  4166. * @param scale defines the scaling factor
  4167. * @param result defines the target matrix
  4168. */
  4169. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4170. /**
  4171. * Gets an identity matrix that must not be updated
  4172. */
  4173. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4174. /**
  4175. * Stores a list of values (16) inside a given matrix
  4176. * @param initialM11 defines 1st value of 1st row
  4177. * @param initialM12 defines 2nd value of 1st row
  4178. * @param initialM13 defines 3rd value of 1st row
  4179. * @param initialM14 defines 4th value of 1st row
  4180. * @param initialM21 defines 1st value of 2nd row
  4181. * @param initialM22 defines 2nd value of 2nd row
  4182. * @param initialM23 defines 3rd value of 2nd row
  4183. * @param initialM24 defines 4th value of 2nd row
  4184. * @param initialM31 defines 1st value of 3rd row
  4185. * @param initialM32 defines 2nd value of 3rd row
  4186. * @param initialM33 defines 3rd value of 3rd row
  4187. * @param initialM34 defines 4th value of 3rd row
  4188. * @param initialM41 defines 1st value of 4th row
  4189. * @param initialM42 defines 2nd value of 4th row
  4190. * @param initialM43 defines 3rd value of 4th row
  4191. * @param initialM44 defines 4th value of 4th row
  4192. * @param result defines the target matrix
  4193. */
  4194. 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;
  4195. /**
  4196. * Creates new matrix from a list of values (16)
  4197. * @param initialM11 defines 1st value of 1st row
  4198. * @param initialM12 defines 2nd value of 1st row
  4199. * @param initialM13 defines 3rd value of 1st row
  4200. * @param initialM14 defines 4th value of 1st row
  4201. * @param initialM21 defines 1st value of 2nd row
  4202. * @param initialM22 defines 2nd value of 2nd row
  4203. * @param initialM23 defines 3rd value of 2nd row
  4204. * @param initialM24 defines 4th value of 2nd row
  4205. * @param initialM31 defines 1st value of 3rd row
  4206. * @param initialM32 defines 2nd value of 3rd row
  4207. * @param initialM33 defines 3rd value of 3rd row
  4208. * @param initialM34 defines 4th value of 3rd row
  4209. * @param initialM41 defines 1st value of 4th row
  4210. * @param initialM42 defines 2nd value of 4th row
  4211. * @param initialM43 defines 3rd value of 4th row
  4212. * @param initialM44 defines 4th value of 4th row
  4213. * @returns the new matrix
  4214. */
  4215. 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;
  4216. /**
  4217. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4218. * @param scale defines the scale vector3
  4219. * @param rotation defines the rotation quaternion
  4220. * @param translation defines the translation vector3
  4221. * @returns a new matrix
  4222. */
  4223. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4224. /**
  4225. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4226. * @param scale defines the scale vector3
  4227. * @param rotation defines the rotation quaternion
  4228. * @param translation defines the translation vector3
  4229. * @param result defines the target matrix
  4230. */
  4231. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4232. /**
  4233. * Creates a new identity matrix
  4234. * @returns a new identity matrix
  4235. */
  4236. static Identity(): Matrix;
  4237. /**
  4238. * Creates a new identity matrix and stores the result in a given matrix
  4239. * @param result defines the target matrix
  4240. */
  4241. static IdentityToRef(result: Matrix): void;
  4242. /**
  4243. * Creates a new zero matrix
  4244. * @returns a new zero matrix
  4245. */
  4246. static Zero(): Matrix;
  4247. /**
  4248. * Creates a new rotation matrix for "angle" radians around the X axis
  4249. * @param angle defines the angle (in radians) to use
  4250. * @return the new matrix
  4251. */
  4252. static RotationX(angle: number): Matrix;
  4253. /**
  4254. * Creates a new matrix as the invert of a given matrix
  4255. * @param source defines the source matrix
  4256. * @returns the new matrix
  4257. */
  4258. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationXToRef(angle: number, result: Matrix): void;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationY(angle: number): Matrix;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationYToRef(angle: number, result: Matrix): void;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationZ(angle: number): Matrix;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4285. * @param angle defines the angle (in radians) to use
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationZToRef(angle: number, result: Matrix): void;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the given axis
  4291. * @param axis defines the axis to use
  4292. * @param angle defines the angle (in radians) to use
  4293. * @return the new matrix
  4294. */
  4295. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4296. /**
  4297. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4298. * @param axis defines the axis to use
  4299. * @param angle defines the angle (in radians) to use
  4300. * @param result defines the target matrix
  4301. */
  4302. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4303. /**
  4304. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4305. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4306. * @param from defines the vector to align
  4307. * @param to defines the vector to align to
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4311. /**
  4312. * Creates a rotation matrix
  4313. * @param yaw defines the yaw angle in radians (Y axis)
  4314. * @param pitch defines the pitch angle in radians (X axis)
  4315. * @param roll defines the roll angle in radians (X axis)
  4316. * @returns the new rotation matrix
  4317. */
  4318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4319. /**
  4320. * Creates a rotation matrix and stores it in a given matrix
  4321. * @param yaw defines the yaw angle in radians (Y axis)
  4322. * @param pitch defines the pitch angle in radians (X axis)
  4323. * @param roll defines the roll angle in radians (X axis)
  4324. * @param result defines the target matrix
  4325. */
  4326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4327. /**
  4328. * Creates a scaling matrix
  4329. * @param x defines the scale factor on X axis
  4330. * @param y defines the scale factor on Y axis
  4331. * @param z defines the scale factor on Z axis
  4332. * @returns the new matrix
  4333. */
  4334. static Scaling(x: number, y: number, z: number): Matrix;
  4335. /**
  4336. * Creates a scaling matrix and stores it in a given matrix
  4337. * @param x defines the scale factor on X axis
  4338. * @param y defines the scale factor on Y axis
  4339. * @param z defines the scale factor on Z axis
  4340. * @param result defines the target matrix
  4341. */
  4342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4343. /**
  4344. * Creates a translation matrix
  4345. * @param x defines the translation on X axis
  4346. * @param y defines the translation on Y axis
  4347. * @param z defines the translationon Z axis
  4348. * @returns the new matrix
  4349. */
  4350. static Translation(x: number, y: number, z: number): Matrix;
  4351. /**
  4352. * Creates a translation matrix and stores it in a given matrix
  4353. * @param x defines the translation on X axis
  4354. * @param y defines the translation on Y axis
  4355. * @param z defines the translationon Z axis
  4356. * @param result defines the target matrix
  4357. */
  4358. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4359. /**
  4360. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4361. * @param startValue defines the start value
  4362. * @param endValue defines the end value
  4363. * @param gradient defines the gradient factor
  4364. * @returns the new matrix
  4365. */
  4366. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4367. /**
  4368. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4369. * @param startValue defines the start value
  4370. * @param endValue defines the end value
  4371. * @param gradient defines the gradient factor
  4372. * @param result defines the Matrix object where to store data
  4373. */
  4374. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4375. /**
  4376. * Builds a new matrix whose values are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @returns the new matrix
  4384. */
  4385. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4386. /**
  4387. * Update a matrix to values which are computed by:
  4388. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4389. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4390. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4391. * @param startValue defines the first matrix
  4392. * @param endValue defines the second matrix
  4393. * @param gradient defines the gradient between the two matrices
  4394. * @param result defines the target matrix
  4395. */
  4396. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * 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"
  4399. * This function works in left handed mode
  4400. * @param eye defines the final position of the entity
  4401. * @param target defines where the entity should look at
  4402. * @param up defines the up vector for the entity
  4403. * @returns the new matrix
  4404. */
  4405. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * 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".
  4408. * This function works in left handed mode
  4409. * @param eye defines the final position of the entity
  4410. * @param target defines where the entity should look at
  4411. * @param up defines the up vector for the entity
  4412. * @param result defines the target matrix
  4413. */
  4414. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4415. /**
  4416. * 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"
  4417. * This function works in right handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * 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".
  4426. * This function works in right handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Create a left-handed orthographic projection matrix
  4435. * @param width defines the viewport width
  4436. * @param height defines the viewport height
  4437. * @param znear defines the near clip plane
  4438. * @param zfar defines the far clip plane
  4439. * @returns a new matrix as a left-handed orthographic projection matrix
  4440. */
  4441. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4442. /**
  4443. * Store a left-handed orthographic projection to a given matrix
  4444. * @param width defines the viewport width
  4445. * @param height defines the viewport height
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @returns a new matrix as a left-handed orthographic projection matrix
  4460. */
  4461. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4462. /**
  4463. * Stores a left-handed orthographic projection into a given matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Creates a right-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a left-handed perspective projection matrix
  4497. * @param width defines the viewport width
  4498. * @param height defines the viewport height
  4499. * @param znear defines the near clip plane
  4500. * @param zfar defines the far clip plane
  4501. * @returns a new matrix as a left-handed perspective projection matrix
  4502. */
  4503. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4504. /**
  4505. * Creates a left-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a left-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Creates a right-handed perspective projection matrix
  4535. * @param fov defines the horizontal field of view
  4536. * @param aspect defines the aspect ratio
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @returns a new matrix as a right-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a right-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar defines the far clip plane
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a right-handed perspective projection into a given matrix
  4554. * @param fov defines the horizontal field of view
  4555. * @param aspect defines the aspect ratio
  4556. * @param znear defines the near clip plane
  4557. * @param zfar not used as infinity is used as far clip
  4558. * @param result defines the target matrix
  4559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4560. */
  4561. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Stores a perspective projection for WebVR info a given matrix
  4564. * @param fov defines the field of view
  4565. * @param znear defines the near clip plane
  4566. * @param zfar defines the far clip plane
  4567. * @param result defines the target matrix
  4568. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4569. */
  4570. static PerspectiveFovWebVRToRef(fov: {
  4571. upDegrees: number;
  4572. downDegrees: number;
  4573. leftDegrees: number;
  4574. rightDegrees: number;
  4575. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4576. /**
  4577. * Computes a complete transformation matrix
  4578. * @param viewport defines the viewport to use
  4579. * @param world defines the world matrix
  4580. * @param view defines the view matrix
  4581. * @param projection defines the projection matrix
  4582. * @param zmin defines the near clip plane
  4583. * @param zmax defines the far clip plane
  4584. * @returns the transformation matrix
  4585. */
  4586. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4587. /**
  4588. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4595. * @param matrix defines the matrix to use
  4596. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4597. */
  4598. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4599. /**
  4600. * Compute the transpose of a given matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @returns the new matrix
  4603. */
  4604. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4605. /**
  4606. * Compute the transpose of a matrix and store it in a target matrix
  4607. * @param matrix defines the matrix to transpose
  4608. * @param result defines the target matrix
  4609. */
  4610. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @returns a new matrix
  4615. */
  4616. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4617. /**
  4618. * Computes a reflection matrix from a plane
  4619. * @param plane defines the reflection plane
  4620. * @param result defines the target matrix
  4621. */
  4622. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4623. /**
  4624. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4625. * @param xaxis defines the value of the 1st axis
  4626. * @param yaxis defines the value of the 2nd axis
  4627. * @param zaxis defines the value of the 3rd axis
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4631. /**
  4632. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4633. * @param quat defines the quaternion to use
  4634. * @param result defines the target matrix
  4635. */
  4636. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4637. }
  4638. /**
  4639. * @hidden
  4640. */
  4641. export class TmpVectors {
  4642. static Vector2: Vector2[];
  4643. static Vector3: Vector3[];
  4644. static Vector4: Vector4[];
  4645. static Quaternion: Quaternion[];
  4646. static Matrix: Matrix[];
  4647. }
  4648. }
  4649. declare module "babylonjs/Maths/math.path" {
  4650. import { DeepImmutable, Nullable } from "babylonjs/types";
  4651. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4652. /**
  4653. * Defines potential orientation for back face culling
  4654. */
  4655. export enum Orientation {
  4656. /**
  4657. * Clockwise
  4658. */
  4659. CW = 0,
  4660. /** Counter clockwise */
  4661. CCW = 1
  4662. }
  4663. /** Class used to represent a Bezier curve */
  4664. export class BezierCurve {
  4665. /**
  4666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4667. * @param t defines the time
  4668. * @param x1 defines the left coordinate on X axis
  4669. * @param y1 defines the left coordinate on Y axis
  4670. * @param x2 defines the right coordinate on X axis
  4671. * @param y2 defines the right coordinate on Y axis
  4672. * @returns the interpolated value
  4673. */
  4674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4675. }
  4676. /**
  4677. * Defines angle representation
  4678. */
  4679. export class Angle {
  4680. private _radians;
  4681. /**
  4682. * Creates an Angle object of "radians" radians (float).
  4683. * @param radians the angle in radians
  4684. */
  4685. constructor(radians: number);
  4686. /**
  4687. * Get value in degrees
  4688. * @returns the Angle value in degrees (float)
  4689. */
  4690. degrees(): number;
  4691. /**
  4692. * Get value in radians
  4693. * @returns the Angle value in radians (float)
  4694. */
  4695. radians(): number;
  4696. /**
  4697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4698. * @param a defines first vector
  4699. * @param b defines second vector
  4700. * @returns a new Angle
  4701. */
  4702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in radians
  4705. * @param radians defines the angle value in radians
  4706. * @returns a new Angle
  4707. */
  4708. static FromRadians(radians: number): Angle;
  4709. /**
  4710. * Gets a new Angle object from the given float in degrees
  4711. * @param degrees defines the angle value in degrees
  4712. * @returns a new Angle
  4713. */
  4714. static FromDegrees(degrees: number): Angle;
  4715. }
  4716. /**
  4717. * This represents an arc in a 2d space.
  4718. */
  4719. export class Arc2 {
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2;
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2;
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2;
  4726. /**
  4727. * Defines the center point of the arc.
  4728. */
  4729. centerPoint: Vector2;
  4730. /**
  4731. * Defines the radius of the arc.
  4732. */
  4733. radius: number;
  4734. /**
  4735. * Defines the angle of the arc (from mid point to end point).
  4736. */
  4737. angle: Angle;
  4738. /**
  4739. * Defines the start angle of the arc (from start point to middle point).
  4740. */
  4741. startAngle: Angle;
  4742. /**
  4743. * Defines the orientation of the arc (clock wise/counter clock wise).
  4744. */
  4745. orientation: Orientation;
  4746. /**
  4747. * Creates an Arc object from the three given points : start, middle and end.
  4748. * @param startPoint Defines the start point of the arc
  4749. * @param midPoint Defines the midlle point of the arc
  4750. * @param endPoint Defines the end point of the arc
  4751. */
  4752. constructor(
  4753. /** Defines the start point of the arc */
  4754. startPoint: Vector2,
  4755. /** Defines the mid point of the arc */
  4756. midPoint: Vector2,
  4757. /** Defines the end point of the arc */
  4758. endPoint: Vector2);
  4759. }
  4760. /**
  4761. * Represents a 2D path made up of multiple 2D points
  4762. */
  4763. export class Path2 {
  4764. private _points;
  4765. private _length;
  4766. /**
  4767. * If the path start and end point are the same
  4768. */
  4769. closed: boolean;
  4770. /**
  4771. * Creates a Path2 object from the starting 2D coordinates x and y.
  4772. * @param x the starting points x value
  4773. * @param y the starting points y value
  4774. */
  4775. constructor(x: number, y: number);
  4776. /**
  4777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4778. * @param x the added points x value
  4779. * @param y the added points y value
  4780. * @returns the updated Path2.
  4781. */
  4782. addLineTo(x: number, y: number): Path2;
  4783. /**
  4784. * 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.
  4785. * @param midX middle point x value
  4786. * @param midY middle point y value
  4787. * @param endX end point x value
  4788. * @param endY end point y value
  4789. * @param numberOfSegments (default: 36)
  4790. * @returns the updated Path2.
  4791. */
  4792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4793. /**
  4794. * Closes the Path2.
  4795. * @returns the Path2.
  4796. */
  4797. close(): Path2;
  4798. /**
  4799. * Gets the sum of the distance between each sequential point in the path
  4800. * @returns the Path2 total length (float).
  4801. */
  4802. length(): number;
  4803. /**
  4804. * Gets the points which construct the path
  4805. * @returns the Path2 internal array of points.
  4806. */
  4807. getPoints(): Vector2[];
  4808. /**
  4809. * Retreives the point at the distance aways from the starting point
  4810. * @param normalizedLengthPosition the length along the path to retreive the point from
  4811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4812. */
  4813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4814. /**
  4815. * Creates a new path starting from an x and y position
  4816. * @param x starting x value
  4817. * @param y starting y value
  4818. * @returns a new Path2 starting at the coordinates (x, y).
  4819. */
  4820. static StartingAt(x: number, y: number): Path2;
  4821. }
  4822. /**
  4823. * Represents a 3D path made up of multiple 3D points
  4824. */
  4825. export class Path3D {
  4826. /**
  4827. * an array of Vector3, the curve axis of the Path3D
  4828. */
  4829. path: Vector3[];
  4830. private _curve;
  4831. private _distances;
  4832. private _tangents;
  4833. private _normals;
  4834. private _binormals;
  4835. private _raw;
  4836. private _alignTangentsWithPath;
  4837. private readonly _pointAtData;
  4838. /**
  4839. * new Path3D(path, normal, raw)
  4840. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4841. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4842. * @param path an array of Vector3, the curve axis of the Path3D
  4843. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4844. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4846. */
  4847. constructor(
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4852. /**
  4853. * Returns the Path3D array of successive Vector3 designing its curve.
  4854. * @returns the Path3D array of successive Vector3 designing its curve.
  4855. */
  4856. getCurve(): Vector3[];
  4857. /**
  4858. * Returns the Path3D array of successive Vector3 designing its curve.
  4859. * @returns the Path3D array of successive Vector3 designing its curve.
  4860. */
  4861. getPoints(): Vector3[];
  4862. /**
  4863. * @returns the computed length (float) of the path.
  4864. */
  4865. length(): number;
  4866. /**
  4867. * Returns an array populated with tangent vectors on each Path3D curve point.
  4868. * @returns an array populated with tangent vectors on each Path3D curve point.
  4869. */
  4870. getTangents(): Vector3[];
  4871. /**
  4872. * Returns an array populated with normal vectors on each Path3D curve point.
  4873. * @returns an array populated with normal vectors on each Path3D curve point.
  4874. */
  4875. getNormals(): Vector3[];
  4876. /**
  4877. * Returns an array populated with binormal vectors on each Path3D curve point.
  4878. * @returns an array populated with binormal vectors on each Path3D curve point.
  4879. */
  4880. getBinormals(): Vector3[];
  4881. /**
  4882. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4883. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4884. */
  4885. getDistances(): number[];
  4886. /**
  4887. * Returns an interpolated point along this path
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @returns a new Vector3 as the point
  4890. */
  4891. getPointAt(position: number): Vector3;
  4892. /**
  4893. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4894. * @param position the position of the point along this path, from 0.0 to 1.0
  4895. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4896. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4897. */
  4898. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4899. /**
  4900. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4901. * @param position the position of the point along this path, from 0.0 to 1.0
  4902. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4903. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4904. */
  4905. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4906. /**
  4907. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4908. * @param position the position of the point along this path, from 0.0 to 1.0
  4909. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4910. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4911. */
  4912. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4913. /**
  4914. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4917. */
  4918. getDistanceAt(position: number): number;
  4919. /**
  4920. * Returns the array index of the previous point of an interpolated point along this path
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the array index
  4923. */
  4924. getPreviousPointIndexAt(position: number): number;
  4925. /**
  4926. * 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)
  4927. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4928. * @returns the sub position
  4929. */
  4930. getSubPositionAt(position: number): number;
  4931. /**
  4932. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4933. * @param target the vector of which to get the closest position to
  4934. * @returns the position of the closest virtual point on this path to the target vector
  4935. */
  4936. getClosestPositionTo(target: Vector3): number;
  4937. /**
  4938. * Returns a sub path (slice) of this path
  4939. * @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
  4940. * @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
  4941. * @returns a sub path (slice) of this path
  4942. */
  4943. slice(start?: number, end?: number): Path3D;
  4944. /**
  4945. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4946. * @param path path which all values are copied into the curves points
  4947. * @param firstNormal which should be projected onto the curve
  4948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4949. * @returns the same object updated.
  4950. */
  4951. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4952. private _compute;
  4953. private _getFirstNonNullVector;
  4954. private _getLastNonNullVector;
  4955. private _normalVector;
  4956. /**
  4957. * Updates the point at data for an interpolated point along this curve
  4958. * @param position the position of the point along this curve, from 0.0 to 1.0
  4959. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4960. * @returns the (updated) point at data
  4961. */
  4962. private _updatePointAtData;
  4963. /**
  4964. * Updates the point at data from the specified parameters
  4965. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4966. * @param point the interpolated point
  4967. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4968. */
  4969. private _setPointAtData;
  4970. /**
  4971. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4972. */
  4973. private _updateInterpolationMatrix;
  4974. }
  4975. /**
  4976. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4977. * A Curve3 is designed from a series of successive Vector3.
  4978. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4979. */
  4980. export class Curve3 {
  4981. private _points;
  4982. private _length;
  4983. /**
  4984. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4985. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4986. * @param v1 (Vector3) the control point
  4987. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4994. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4995. * @param v1 (Vector3) the first control point
  4996. * @param v2 (Vector3) the second control point
  4997. * @param v3 (Vector3) the end point of the Cubic Bezier
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5004. * @param p1 (Vector3) the origin point of the Hermite Spline
  5005. * @param t1 (Vector3) the tangent vector at the origin point
  5006. * @param p2 (Vector3) the end point of the Hermite Spline
  5007. * @param t2 (Vector3) the tangent vector at the end point
  5008. * @param nbPoints (integer) the wanted number of points in the curve
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5012. /**
  5013. * Returns a Curve3 object along a CatmullRom Spline curve :
  5014. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5015. * @param nbPoints (integer) the wanted number of points between each curve control points
  5016. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5020. /**
  5021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5022. * A Curve3 is designed from a series of successive Vector3.
  5023. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5024. * @param points points which make up the curve
  5025. */
  5026. constructor(points: Vector3[]);
  5027. /**
  5028. * @returns the Curve3 stored array of successive Vector3
  5029. */
  5030. getPoints(): Vector3[];
  5031. /**
  5032. * @returns the computed length (float) of the curve.
  5033. */
  5034. length(): number;
  5035. /**
  5036. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5037. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5038. * curveA and curveB keep unchanged.
  5039. * @param curve the curve to continue from this curve
  5040. * @returns the newly constructed curve
  5041. */
  5042. continue(curve: DeepImmutable<Curve3>): Curve3;
  5043. private _computeLength;
  5044. }
  5045. }
  5046. declare module "babylonjs/Animations/easing" {
  5047. /**
  5048. * This represents the main contract an easing function should follow.
  5049. * Easing functions are used throughout the animation system.
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export interface IEasingFunction {
  5053. /**
  5054. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5055. * of the easing function.
  5056. * The link below provides some of the most common examples of easing functions.
  5057. * @see https://easings.net/
  5058. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5059. * @returns the corresponding value on the curve defined by the easing function
  5060. */
  5061. ease(gradient: number): number;
  5062. }
  5063. /**
  5064. * Base class used for every default easing function.
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class EasingFunction implements IEasingFunction {
  5068. /**
  5069. * Interpolation follows the mathematical formula associated with the easing function.
  5070. */
  5071. static readonly EASINGMODE_EASEIN: number;
  5072. /**
  5073. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEOUT: number;
  5076. /**
  5077. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5078. */
  5079. static readonly EASINGMODE_EASEINOUT: number;
  5080. private _easingMode;
  5081. /**
  5082. * Sets the easing mode of the current function.
  5083. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5084. */
  5085. setEasingMode(easingMode: number): void;
  5086. /**
  5087. * Gets the current easing mode.
  5088. * @returns the easing mode
  5089. */
  5090. getEasingMode(): number;
  5091. /**
  5092. * @hidden
  5093. */
  5094. easeInCore(gradient: number): number;
  5095. /**
  5096. * Given an input gradient between 0 and 1, this returns the corresponding value
  5097. * of the easing function.
  5098. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5099. * @returns the corresponding value on the curve defined by the easing function
  5100. */
  5101. ease(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a circle shape (see link below).
  5105. * @see https://easings.net/#easeInCirc
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class CircleEase extends EasingFunction implements IEasingFunction {
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. /**
  5113. * Easing function with a ease back shape (see link below).
  5114. * @see https://easings.net/#easeInBack
  5115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5116. */
  5117. export class BackEase extends EasingFunction implements IEasingFunction {
  5118. /** Defines the amplitude of the function */
  5119. amplitude: number;
  5120. /**
  5121. * Instantiates a back ease easing
  5122. * @see https://easings.net/#easeInBack
  5123. * @param amplitude Defines the amplitude of the function
  5124. */
  5125. constructor(
  5126. /** Defines the amplitude of the function */
  5127. amplitude?: number);
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with a bouncing shape (see link below).
  5133. * @see https://easings.net/#easeInBounce
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class BounceEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of bounces */
  5138. bounces: number;
  5139. /** Defines the amplitude of the bounce */
  5140. bounciness: number;
  5141. /**
  5142. * Instantiates a bounce easing
  5143. * @see https://easings.net/#easeInBounce
  5144. * @param bounces Defines the number of bounces
  5145. * @param bounciness Defines the amplitude of the bounce
  5146. */
  5147. constructor(
  5148. /** Defines the number of bounces */
  5149. bounces?: number,
  5150. /** Defines the amplitude of the bounce */
  5151. bounciness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with a power of 3 shape (see link below).
  5157. * @see https://easings.net/#easeInCubic
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class CubicEase extends EasingFunction implements IEasingFunction {
  5161. /** @hidden */
  5162. easeInCore(gradient: number): number;
  5163. }
  5164. /**
  5165. * Easing function with an elastic shape (see link below).
  5166. * @see https://easings.net/#easeInElastic
  5167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5168. */
  5169. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5170. /** Defines the number of oscillations*/
  5171. oscillations: number;
  5172. /** Defines the amplitude of the oscillations*/
  5173. springiness: number;
  5174. /**
  5175. * Instantiates an elastic easing function
  5176. * @see https://easings.net/#easeInElastic
  5177. * @param oscillations Defines the number of oscillations
  5178. * @param springiness Defines the amplitude of the oscillations
  5179. */
  5180. constructor(
  5181. /** Defines the number of oscillations*/
  5182. oscillations?: number,
  5183. /** Defines the amplitude of the oscillations*/
  5184. springiness?: number);
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with an exponential shape (see link below).
  5190. * @see https://easings.net/#easeInExpo
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5194. /** Defines the exponent of the function */
  5195. exponent: number;
  5196. /**
  5197. * Instantiates an exponential easing function
  5198. * @see https://easings.net/#easeInExpo
  5199. * @param exponent Defines the exponent of the function
  5200. */
  5201. constructor(
  5202. /** Defines the exponent of the function */
  5203. exponent?: number);
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power shape (see link below).
  5209. * @see https://easings.net/#easeInQuad
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class PowerEase extends EasingFunction implements IEasingFunction {
  5213. /** Defines the power of the function */
  5214. power: number;
  5215. /**
  5216. * Instantiates an power base easing function
  5217. * @see https://easings.net/#easeInQuad
  5218. * @param power Defines the power of the function
  5219. */
  5220. constructor(
  5221. /** Defines the power of the function */
  5222. power?: number);
  5223. /** @hidden */
  5224. easeInCore(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a power of 2 shape (see link below).
  5228. * @see https://easings.net/#easeInQuad
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a power of 4 shape (see link below).
  5237. * @see https://easings.net/#easeInQuart
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 5 shape (see link below).
  5246. * @see https://easings.net/#easeInQuint
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a sin shape (see link below).
  5255. * @see https://easings.net/#easeInSine
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class SineEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a bezier shape (see link below).
  5264. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1: number;
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1: number;
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2: number;
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2: number;
  5276. /**
  5277. * Instantiates a bezier function
  5278. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5279. * @param x1 Defines the x component of the start tangent in the bezier curve
  5280. * @param y1 Defines the y component of the start tangent in the bezier curve
  5281. * @param x2 Defines the x component of the end tangent in the bezier curve
  5282. * @param y2 Defines the y component of the end tangent in the bezier curve
  5283. */
  5284. constructor(
  5285. /** Defines the x component of the start tangent in the bezier curve */
  5286. x1?: number,
  5287. /** Defines the y component of the start tangent in the bezier curve */
  5288. y1?: number,
  5289. /** Defines the x component of the end tangent in the bezier curve */
  5290. x2?: number,
  5291. /** Defines the y component of the end tangent in the bezier curve */
  5292. y2?: number);
  5293. /** @hidden */
  5294. easeInCore(gradient: number): number;
  5295. }
  5296. }
  5297. declare module "babylonjs/Maths/math.color" {
  5298. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5299. /**
  5300. * Class used to hold a RBG color
  5301. */
  5302. export class Color3 {
  5303. /**
  5304. * Defines the red component (between 0 and 1, default is 0)
  5305. */
  5306. r: number;
  5307. /**
  5308. * Defines the green component (between 0 and 1, default is 0)
  5309. */
  5310. g: number;
  5311. /**
  5312. * Defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. b: number;
  5315. /**
  5316. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5317. * @param r defines the red component (between 0 and 1, default is 0)
  5318. * @param g defines the green component (between 0 and 1, default is 0)
  5319. * @param b defines the blue component (between 0 and 1, default is 0)
  5320. */
  5321. constructor(
  5322. /**
  5323. * Defines the red component (between 0 and 1, default is 0)
  5324. */
  5325. r?: number,
  5326. /**
  5327. * Defines the green component (between 0 and 1, default is 0)
  5328. */
  5329. g?: number,
  5330. /**
  5331. * Defines the blue component (between 0 and 1, default is 0)
  5332. */
  5333. b?: number);
  5334. /**
  5335. * Creates a string with the Color3 current values
  5336. * @returns the string representation of the Color3 object
  5337. */
  5338. toString(): string;
  5339. /**
  5340. * Returns the string "Color3"
  5341. * @returns "Color3"
  5342. */
  5343. getClassName(): string;
  5344. /**
  5345. * Compute the Color3 hash code
  5346. * @returns an unique number that can be used to hash Color3 objects
  5347. */
  5348. getHashCode(): number;
  5349. /**
  5350. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5351. * @param array defines the array where to store the r,g,b components
  5352. * @param index defines an optional index in the target array to define where to start storing values
  5353. * @returns the current Color3 object
  5354. */
  5355. toArray(array: FloatArray, index?: number): Color3;
  5356. /**
  5357. * Returns a new Color4 object from the current Color3 and the given alpha
  5358. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5359. * @returns a new Color4 object
  5360. */
  5361. toColor4(alpha?: number): Color4;
  5362. /**
  5363. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5364. * @returns the new array
  5365. */
  5366. asArray(): number[];
  5367. /**
  5368. * Returns the luminance value
  5369. * @returns a float value
  5370. */
  5371. toLuminance(): number;
  5372. /**
  5373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5374. * @param otherColor defines the second operand
  5375. * @returns the new Color3 object
  5376. */
  5377. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5380. * @param otherColor defines the second operand
  5381. * @param result defines the Color3 object where to store the result
  5382. * @returns the current Color3
  5383. */
  5384. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5385. /**
  5386. * Determines equality between Color3 objects
  5387. * @param otherColor defines the second operand
  5388. * @returns true if the rgb values are equal to the given ones
  5389. */
  5390. equals(otherColor: DeepImmutable<Color3>): boolean;
  5391. /**
  5392. * Determines equality between the current Color3 object and a set of r,b,g values
  5393. * @param r defines the red component to check
  5394. * @param g defines the green component to check
  5395. * @param b defines the blue component to check
  5396. * @returns true if the rgb values are equal to the given ones
  5397. */
  5398. equalsFloats(r: number, g: number, b: number): boolean;
  5399. /**
  5400. * Multiplies in place each rgb value by scale
  5401. * @param scale defines the scaling factor
  5402. * @returns the updated Color3
  5403. */
  5404. scale(scale: number): Color3;
  5405. /**
  5406. * Multiplies the rgb values by scale and stores the result into "result"
  5407. * @param scale defines the scaling factor
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Scale the current Color3 values by a factor and add the result to a given Color3
  5414. * @param scale defines the scale factor
  5415. * @param result defines color to store the result into
  5416. * @returns the unmodified current Color3
  5417. */
  5418. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5419. /**
  5420. * Clamps the rgb values by the min and max values and stores the result into "result"
  5421. * @param min defines minimum clamping value (default is 0)
  5422. * @param max defines maximum clamping value (default is 1)
  5423. * @param result defines color to store the result into
  5424. * @returns the original Color3
  5425. */
  5426. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5427. /**
  5428. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5429. * @param otherColor defines the second operand
  5430. * @returns the new Color3
  5431. */
  5432. add(otherColor: DeepImmutable<Color3>): Color3;
  5433. /**
  5434. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5435. * @param otherColor defines the second operand
  5436. * @param result defines Color3 object to store the result into
  5437. * @returns the unmodified current Color3
  5438. */
  5439. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5440. /**
  5441. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5442. * @param otherColor defines the second operand
  5443. * @returns the new Color3
  5444. */
  5445. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5448. * @param otherColor defines the second operand
  5449. * @param result defines Color3 object to store the result into
  5450. * @returns the unmodified current Color3
  5451. */
  5452. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5453. /**
  5454. * Copy the current object
  5455. * @returns a new Color3 copied the current one
  5456. */
  5457. clone(): Color3;
  5458. /**
  5459. * Copies the rgb values from the source in the current Color3
  5460. * @param source defines the source Color3 object
  5461. * @returns the updated Color3 object
  5462. */
  5463. copyFrom(source: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Updates the Color3 rgb values from the given floats
  5466. * @param r defines the red component to read from
  5467. * @param g defines the green component to read from
  5468. * @param b defines the blue component to read from
  5469. * @returns the current Color3 object
  5470. */
  5471. copyFromFloats(r: number, g: number, b: number): Color3;
  5472. /**
  5473. * Updates the Color3 rgb values from the given floats
  5474. * @param r defines the red component to read from
  5475. * @param g defines the green component to read from
  5476. * @param b defines the blue component to read from
  5477. * @returns the current Color3 object
  5478. */
  5479. set(r: number, g: number, b: number): Color3;
  5480. /**
  5481. * Compute the Color3 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color3 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color3 converted from the current one to linear space
  5487. * @returns a new Color3 object
  5488. */
  5489. toLinearSpace(): Color3;
  5490. /**
  5491. * Converts current color in rgb space to HSV values
  5492. * @returns a new color3 representing the HSV values
  5493. */
  5494. toHSV(): Color3;
  5495. /**
  5496. * Converts current color in rgb space to HSV values
  5497. * @param result defines the Color3 where to store the HSV values
  5498. */
  5499. toHSVToRef(result: Color3): void;
  5500. /**
  5501. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5502. * @param convertedColor defines the Color3 object where to store the linear space version
  5503. * @returns the unmodified Color3
  5504. */
  5505. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5506. /**
  5507. * Computes a new Color3 converted from the current one to gamma space
  5508. * @returns a new Color3 object
  5509. */
  5510. toGammaSpace(): Color3;
  5511. /**
  5512. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5513. * @param convertedColor defines the Color3 object where to store the gamma space version
  5514. * @returns the unmodified Color3
  5515. */
  5516. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5517. private static _BlackReadOnly;
  5518. /**
  5519. * Convert Hue, saturation and value to a Color3 (RGB)
  5520. * @param hue defines the hue
  5521. * @param saturation defines the saturation
  5522. * @param value defines the value
  5523. * @param result defines the Color3 where to store the RGB values
  5524. */
  5525. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5526. /**
  5527. * Creates a new Color3 from the string containing valid hexadecimal values
  5528. * @param hex defines a string containing valid hexadecimal values
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromHexString(hex: string): Color3;
  5532. /**
  5533. * Creates a new Color3 from the starting index of the given array
  5534. * @param array defines the source array
  5535. * @param offset defines an offset in the source array
  5536. * @returns a new Color3 object
  5537. */
  5538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5539. /**
  5540. * Creates a new Color3 from integer values (< 256)
  5541. * @param r defines the red component to read from (value between 0 and 255)
  5542. * @param g defines the green component to read from (value between 0 and 255)
  5543. * @param b defines the blue component to read from (value between 0 and 255)
  5544. * @returns a new Color3 object
  5545. */
  5546. static FromInts(r: number, g: number, b: number): Color3;
  5547. /**
  5548. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5549. * @param start defines the start Color3 value
  5550. * @param end defines the end Color3 value
  5551. * @param amount defines the gradient value between start and end
  5552. * @returns a new Color3 object
  5553. */
  5554. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5555. /**
  5556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5557. * @param left defines the start value
  5558. * @param right defines the end value
  5559. * @param amount defines the gradient factor
  5560. * @param result defines the Color3 object where to store the result
  5561. */
  5562. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5563. /**
  5564. * Returns a Color3 value containing a red color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Red(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a green color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Green(): Color3;
  5573. /**
  5574. * Returns a Color3 value containing a blue color
  5575. * @returns a new Color3 object
  5576. */
  5577. static Blue(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a black color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Black(): Color3;
  5583. /**
  5584. * Gets a Color3 value containing a black color that must not be updated
  5585. */
  5586. static get BlackReadOnly(): DeepImmutable<Color3>;
  5587. /**
  5588. * Returns a Color3 value containing a white color
  5589. * @returns a new Color3 object
  5590. */
  5591. static White(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a purple color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Purple(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a magenta color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Magenta(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a yellow color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Yellow(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a gray color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Gray(): Color3;
  5612. /**
  5613. * Returns a Color3 value containing a teal color
  5614. * @returns a new Color3 object
  5615. */
  5616. static Teal(): Color3;
  5617. /**
  5618. * Returns a Color3 value containing a random color
  5619. * @returns a new Color3 object
  5620. */
  5621. static Random(): Color3;
  5622. }
  5623. /**
  5624. * Class used to hold a RBGA color
  5625. */
  5626. export class Color4 {
  5627. /**
  5628. * Defines the red component (between 0 and 1, default is 0)
  5629. */
  5630. r: number;
  5631. /**
  5632. * Defines the green component (between 0 and 1, default is 0)
  5633. */
  5634. g: number;
  5635. /**
  5636. * Defines the blue component (between 0 and 1, default is 0)
  5637. */
  5638. b: number;
  5639. /**
  5640. * Defines the alpha component (between 0 and 1, default is 1)
  5641. */
  5642. a: number;
  5643. /**
  5644. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5645. * @param r defines the red component (between 0 and 1, default is 0)
  5646. * @param g defines the green component (between 0 and 1, default is 0)
  5647. * @param b defines the blue component (between 0 and 1, default is 0)
  5648. * @param a defines the alpha component (between 0 and 1, default is 1)
  5649. */
  5650. constructor(
  5651. /**
  5652. * Defines the red component (between 0 and 1, default is 0)
  5653. */
  5654. r?: number,
  5655. /**
  5656. * Defines the green component (between 0 and 1, default is 0)
  5657. */
  5658. g?: number,
  5659. /**
  5660. * Defines the blue component (between 0 and 1, default is 0)
  5661. */
  5662. b?: number,
  5663. /**
  5664. * Defines the alpha component (between 0 and 1, default is 1)
  5665. */
  5666. a?: number);
  5667. /**
  5668. * Adds in place the given Color4 values to the current Color4 object
  5669. * @param right defines the second operand
  5670. * @returns the current updated Color4 object
  5671. */
  5672. addInPlace(right: DeepImmutable<Color4>): Color4;
  5673. /**
  5674. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5675. * @returns the new array
  5676. */
  5677. asArray(): number[];
  5678. /**
  5679. * Stores from the starting index in the given array the Color4 successive values
  5680. * @param array defines the array where to store the r,g,b components
  5681. * @param index defines an optional index in the target array to define where to start storing values
  5682. * @returns the current Color4 object
  5683. */
  5684. toArray(array: number[], index?: number): Color4;
  5685. /**
  5686. * Determines equality between Color4 objects
  5687. * @param otherColor defines the second operand
  5688. * @returns true if the rgba values are equal to the given ones
  5689. */
  5690. equals(otherColor: DeepImmutable<Color4>): boolean;
  5691. /**
  5692. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5693. * @param right defines the second operand
  5694. * @returns a new Color4 object
  5695. */
  5696. add(right: DeepImmutable<Color4>): Color4;
  5697. /**
  5698. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5699. * @param right defines the second operand
  5700. * @returns a new Color4 object
  5701. */
  5702. subtract(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5705. * @param right defines the second operand
  5706. * @param result defines the Color4 object where to store the result
  5707. * @returns the current Color4 object
  5708. */
  5709. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5710. /**
  5711. * Creates a new Color4 with the current Color4 values multiplied by scale
  5712. * @param scale defines the scaling factor to apply
  5713. * @returns a new Color4 object
  5714. */
  5715. scale(scale: number): Color4;
  5716. /**
  5717. * Multiplies the current Color4 values by scale and stores the result in "result"
  5718. * @param scale defines the scaling factor to apply
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the current unmodified Color4
  5721. */
  5722. scaleToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Scale the current Color4 values by a factor and add the result to a given Color4
  5725. * @param scale defines the scale factor
  5726. * @param result defines the Color4 object where to store the result
  5727. * @returns the unmodified current Color4
  5728. */
  5729. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5730. /**
  5731. * Clamps the rgb values by the min and max values and stores the result into "result"
  5732. * @param min defines minimum clamping value (default is 0)
  5733. * @param max defines maximum clamping value (default is 1)
  5734. * @param result defines color to store the result into.
  5735. * @returns the cuurent Color4
  5736. */
  5737. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5738. /**
  5739. * Multipy an Color4 value by another and return a new Color4 object
  5740. * @param color defines the Color4 value to multiply by
  5741. * @returns a new Color4 object
  5742. */
  5743. multiply(color: Color4): Color4;
  5744. /**
  5745. * Multipy a Color4 value by another and push the result in a reference value
  5746. * @param color defines the Color4 value to multiply by
  5747. * @param result defines the Color4 to fill the result in
  5748. * @returns the result Color4
  5749. */
  5750. multiplyToRef(color: Color4, result: Color4): Color4;
  5751. /**
  5752. * Creates a string with the Color4 current values
  5753. * @returns the string representation of the Color4 object
  5754. */
  5755. toString(): string;
  5756. /**
  5757. * Returns the string "Color4"
  5758. * @returns "Color4"
  5759. */
  5760. getClassName(): string;
  5761. /**
  5762. * Compute the Color4 hash code
  5763. * @returns an unique number that can be used to hash Color4 objects
  5764. */
  5765. getHashCode(): number;
  5766. /**
  5767. * Creates a new Color4 copied from the current one
  5768. * @returns a new Color4 object
  5769. */
  5770. clone(): Color4;
  5771. /**
  5772. * Copies the given Color4 values into the current one
  5773. * @param source defines the source Color4 object
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFrom(source: Color4): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Copies the given float values into the current one
  5788. * @param r defines the red component to read from
  5789. * @param g defines the green component to read from
  5790. * @param b defines the blue component to read from
  5791. * @param a defines the alpha component to read from
  5792. * @returns the current updated Color4 object
  5793. */
  5794. set(r: number, g: number, b: number, a: number): Color4;
  5795. /**
  5796. * Compute the Color4 hexadecimal code as a string
  5797. * @returns a string containing the hexadecimal representation of the Color4 object
  5798. */
  5799. toHexString(): string;
  5800. /**
  5801. * Computes a new Color4 converted from the current one to linear space
  5802. * @returns a new Color4 object
  5803. */
  5804. toLinearSpace(): Color4;
  5805. /**
  5806. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5807. * @param convertedColor defines the Color4 object where to store the linear space version
  5808. * @returns the unmodified Color4
  5809. */
  5810. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5811. /**
  5812. * Computes a new Color4 converted from the current one to gamma space
  5813. * @returns a new Color4 object
  5814. */
  5815. toGammaSpace(): Color4;
  5816. /**
  5817. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5818. * @param convertedColor defines the Color4 object where to store the gamma space version
  5819. * @returns the unmodified Color4
  5820. */
  5821. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5822. /**
  5823. * Creates a new Color4 from the string containing valid hexadecimal values
  5824. * @param hex defines a string containing valid hexadecimal values
  5825. * @returns a new Color4 object
  5826. */
  5827. static FromHexString(hex: string): Color4;
  5828. /**
  5829. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @returns a new Color4 object
  5834. */
  5835. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5836. /**
  5837. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5838. * @param left defines the start value
  5839. * @param right defines the end value
  5840. * @param amount defines the gradient factor
  5841. * @param result defines the Color4 object where to store data
  5842. */
  5843. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5844. /**
  5845. * Creates a new Color4 from a Color3 and an alpha value
  5846. * @param color3 defines the source Color3 to read from
  5847. * @param alpha defines the alpha component (1.0 by default)
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5851. /**
  5852. * Creates a new Color4 from the starting index element of the given array
  5853. * @param array defines the source array to read from
  5854. * @param offset defines the offset in the source array
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5858. /**
  5859. * Creates a new Color3 from integer values (< 256)
  5860. * @param r defines the red component to read from (value between 0 and 255)
  5861. * @param g defines the green component to read from (value between 0 and 255)
  5862. * @param b defines the blue component to read from (value between 0 and 255)
  5863. * @param a defines the alpha component to read from (value between 0 and 255)
  5864. * @returns a new Color3 object
  5865. */
  5866. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5867. /**
  5868. * Check the content of a given array and convert it to an array containing RGBA data
  5869. * If the original array was already containing count * 4 values then it is returned directly
  5870. * @param colors defines the array to check
  5871. * @param count defines the number of RGBA data to expect
  5872. * @returns an array containing count * 4 values (RGBA)
  5873. */
  5874. static CheckColors4(colors: number[], count: number): number[];
  5875. }
  5876. /**
  5877. * @hidden
  5878. */
  5879. export class TmpColors {
  5880. static Color3: Color3[];
  5881. static Color4: Color4[];
  5882. }
  5883. }
  5884. declare module "babylonjs/Animations/animationKey" {
  5885. /**
  5886. * Defines an interface which represents an animation key frame
  5887. */
  5888. export interface IAnimationKey {
  5889. /**
  5890. * Frame of the key frame
  5891. */
  5892. frame: number;
  5893. /**
  5894. * Value at the specifies key frame
  5895. */
  5896. value: any;
  5897. /**
  5898. * The input tangent for the cubic hermite spline
  5899. */
  5900. inTangent?: any;
  5901. /**
  5902. * The output tangent for the cubic hermite spline
  5903. */
  5904. outTangent?: any;
  5905. /**
  5906. * The animation interpolation type
  5907. */
  5908. interpolation?: AnimationKeyInterpolation;
  5909. }
  5910. /**
  5911. * Enum for the animation key frame interpolation type
  5912. */
  5913. export enum AnimationKeyInterpolation {
  5914. /**
  5915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5916. */
  5917. STEP = 1
  5918. }
  5919. }
  5920. declare module "babylonjs/Animations/animationRange" {
  5921. /**
  5922. * Represents the range of an animation
  5923. */
  5924. export class AnimationRange {
  5925. /**The name of the animation range**/
  5926. name: string;
  5927. /**The starting frame of the animation */
  5928. from: number;
  5929. /**The ending frame of the animation*/
  5930. to: number;
  5931. /**
  5932. * Initializes the range of an animation
  5933. * @param name The name of the animation range
  5934. * @param from The starting frame of the animation
  5935. * @param to The ending frame of the animation
  5936. */
  5937. constructor(
  5938. /**The name of the animation range**/
  5939. name: string,
  5940. /**The starting frame of the animation */
  5941. from: number,
  5942. /**The ending frame of the animation*/
  5943. to: number);
  5944. /**
  5945. * Makes a copy of the animation range
  5946. * @returns A copy of the animation range
  5947. */
  5948. clone(): AnimationRange;
  5949. }
  5950. }
  5951. declare module "babylonjs/Animations/animationEvent" {
  5952. /**
  5953. * Composed of a frame, and an action function
  5954. */
  5955. export class AnimationEvent {
  5956. /** The frame for which the event is triggered **/
  5957. frame: number;
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void;
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined;
  5962. /**
  5963. * Specifies if the animation event is done
  5964. */
  5965. isDone: boolean;
  5966. /**
  5967. * Initializes the animation event
  5968. * @param frame The frame for which the event is triggered
  5969. * @param action The event to perform when triggered
  5970. * @param onlyOnce Specifies if the event should be triggered only once
  5971. */
  5972. constructor(
  5973. /** The frame for which the event is triggered **/
  5974. frame: number,
  5975. /** The event to perform when triggered **/
  5976. action: (currentFrame: number) => void,
  5977. /** Specifies if the event should be triggered only once**/
  5978. onlyOnce?: boolean | undefined);
  5979. /** @hidden */
  5980. _clone(): AnimationEvent;
  5981. }
  5982. }
  5983. declare module "babylonjs/Behaviors/behavior" {
  5984. import { Nullable } from "babylonjs/types";
  5985. /**
  5986. * Interface used to define a behavior
  5987. */
  5988. export interface Behavior<T> {
  5989. /** gets or sets behavior's name */
  5990. name: string;
  5991. /**
  5992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5993. */
  5994. init(): void;
  5995. /**
  5996. * Called when the behavior is attached to a target
  5997. * @param target defines the target where the behavior is attached to
  5998. */
  5999. attach(target: T): void;
  6000. /**
  6001. * Called when the behavior is detached from its target
  6002. */
  6003. detach(): void;
  6004. }
  6005. /**
  6006. * Interface implemented by classes supporting behaviors
  6007. */
  6008. export interface IBehaviorAware<T> {
  6009. /**
  6010. * Attach a behavior
  6011. * @param behavior defines the behavior to attach
  6012. * @returns the current host
  6013. */
  6014. addBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Remove a behavior from the current object
  6017. * @param behavior defines the behavior to detach
  6018. * @returns the current host
  6019. */
  6020. removeBehavior(behavior: Behavior<T>): T;
  6021. /**
  6022. * Gets a behavior using its name to search
  6023. * @param name defines the name to search
  6024. * @returns the behavior or null if not found
  6025. */
  6026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6027. }
  6028. }
  6029. declare module "babylonjs/Misc/smartArray" {
  6030. /**
  6031. * Defines an array and its length.
  6032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6033. */
  6034. export interface ISmartArrayLike<T> {
  6035. /**
  6036. * The data of the array.
  6037. */
  6038. data: Array<T>;
  6039. /**
  6040. * The active length of the array.
  6041. */
  6042. length: number;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. */
  6047. export class SmartArray<T> implements ISmartArrayLike<T> {
  6048. /**
  6049. * The full set of data from the array.
  6050. */
  6051. data: Array<T>;
  6052. /**
  6053. * The active length of the array.
  6054. */
  6055. length: number;
  6056. protected _id: number;
  6057. /**
  6058. * Instantiates a Smart Array.
  6059. * @param capacity defines the default capacity of the array.
  6060. */
  6061. constructor(capacity: number);
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * @param value defines the object to push in the array.
  6065. */
  6066. push(value: T): void;
  6067. /**
  6068. * Iterates over the active data and apply the lambda to them.
  6069. * @param func defines the action to apply on each value.
  6070. */
  6071. forEach(func: (content: T) => void): void;
  6072. /**
  6073. * Sorts the full sets of data.
  6074. * @param compareFn defines the comparison function to apply.
  6075. */
  6076. sort(compareFn: (a: T, b: T) => number): void;
  6077. /**
  6078. * Resets the active data to an empty array.
  6079. */
  6080. reset(): void;
  6081. /**
  6082. * Releases all the data from the array as well as the array.
  6083. */
  6084. dispose(): void;
  6085. /**
  6086. * Concats the active data with a given array.
  6087. * @param array defines the data to concatenate with.
  6088. */
  6089. concat(array: any): void;
  6090. /**
  6091. * Returns the position of a value in the active data.
  6092. * @param value defines the value to find the index for
  6093. * @returns the index if found in the active data otherwise -1
  6094. */
  6095. indexOf(value: T): number;
  6096. /**
  6097. * Returns whether an element is part of the active data.
  6098. * @param value defines the value to look for
  6099. * @returns true if found in the active data otherwise false
  6100. */
  6101. contains(value: T): boolean;
  6102. private static _GlobalId;
  6103. }
  6104. /**
  6105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6106. * The data in this array can only be present once
  6107. */
  6108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6109. private _duplicateId;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6113. * @param value defines the object to push in the array.
  6114. */
  6115. push(value: T): void;
  6116. /**
  6117. * Pushes a value at the end of the active data.
  6118. * If the data is already present, it won t be added again
  6119. * @param value defines the object to push in the array.
  6120. * @returns true if added false if it was already present
  6121. */
  6122. pushNoDuplicate(value: T): boolean;
  6123. /**
  6124. * Resets the active data to an empty array.
  6125. */
  6126. reset(): void;
  6127. /**
  6128. * Concats the active data with a given array.
  6129. * This ensures no dupplicate will be present in the result.
  6130. * @param array defines the data to concatenate with.
  6131. */
  6132. concatWithNoDuplicate(array: any): void;
  6133. }
  6134. }
  6135. declare module "babylonjs/Cameras/cameraInputsManager" {
  6136. import { Nullable } from "babylonjs/types";
  6137. import { Camera } from "babylonjs/Cameras/camera";
  6138. /**
  6139. * @ignore
  6140. * This is a list of all the different input types that are available in the application.
  6141. * Fo instance: ArcRotateCameraGamepadInput...
  6142. */
  6143. export var CameraInputTypes: {};
  6144. /**
  6145. * This is the contract to implement in order to create a new input class.
  6146. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6147. */
  6148. export interface ICameraInput<TCamera extends Camera> {
  6149. /**
  6150. * Defines the camera the input is attached to.
  6151. */
  6152. camera: Nullable<TCamera>;
  6153. /**
  6154. * Gets the class name of the current intput.
  6155. * @returns the class name
  6156. */
  6157. getClassName(): string;
  6158. /**
  6159. * Get the friendly name associated with the input class.
  6160. * @returns the input friendly name
  6161. */
  6162. getSimpleName(): string;
  6163. /**
  6164. * Attach the input controls to a specific dom element to get the input from.
  6165. * @param element Defines the element the controls should be listened from
  6166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6167. */
  6168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6169. /**
  6170. * Detach the current controls from the specified dom element.
  6171. * @param element Defines the element to stop listening the inputs from
  6172. */
  6173. detachControl(element: Nullable<HTMLElement>): void;
  6174. /**
  6175. * Update the current camera state depending on the inputs that have been used this frame.
  6176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6177. */
  6178. checkInputs?: () => void;
  6179. }
  6180. /**
  6181. * Represents a map of input types to input instance or input index to input instance.
  6182. */
  6183. export interface CameraInputsMap<TCamera extends Camera> {
  6184. /**
  6185. * Accessor to the input by input type.
  6186. */
  6187. [name: string]: ICameraInput<TCamera>;
  6188. /**
  6189. * Accessor to the input by input index.
  6190. */
  6191. [idx: number]: ICameraInput<TCamera>;
  6192. }
  6193. /**
  6194. * This represents the input manager used within a camera.
  6195. * It helps dealing with all the different kind of input attached to a camera.
  6196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6197. */
  6198. export class CameraInputsManager<TCamera extends Camera> {
  6199. /**
  6200. * Defines the list of inputs attahed to the camera.
  6201. */
  6202. attached: CameraInputsMap<TCamera>;
  6203. /**
  6204. * Defines the dom element the camera is collecting inputs from.
  6205. * This is null if the controls have not been attached.
  6206. */
  6207. attachedElement: Nullable<HTMLElement>;
  6208. /**
  6209. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6210. */
  6211. noPreventDefault: boolean;
  6212. /**
  6213. * Defined the camera the input manager belongs to.
  6214. */
  6215. camera: TCamera;
  6216. /**
  6217. * Update the current camera state depending on the inputs that have been used this frame.
  6218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6219. */
  6220. checkInputs: () => void;
  6221. /**
  6222. * Instantiate a new Camera Input Manager.
  6223. * @param camera Defines the camera the input manager blongs to
  6224. */
  6225. constructor(camera: TCamera);
  6226. /**
  6227. * Add an input method to a camera
  6228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6229. * @param input camera input method
  6230. */
  6231. add(input: ICameraInput<TCamera>): void;
  6232. /**
  6233. * Remove a specific input method from a camera
  6234. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6235. * @param inputToRemove camera input method
  6236. */
  6237. remove(inputToRemove: ICameraInput<TCamera>): void;
  6238. /**
  6239. * Remove a specific input type from a camera
  6240. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6241. * @param inputType the type of the input to remove
  6242. */
  6243. removeByType(inputType: string): void;
  6244. private _addCheckInputs;
  6245. /**
  6246. * Attach the input controls to the currently attached dom element to listen the events from.
  6247. * @param input Defines the input to attach
  6248. */
  6249. attachInput(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6252. * @param element Defines the dom element to collect the events from
  6253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6254. */
  6255. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6256. /**
  6257. * Detach the current manager inputs controls from a specific dom element.
  6258. * @param element Defines the dom element to collect the events from
  6259. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6260. */
  6261. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6262. /**
  6263. * Rebuild the dynamic inputCheck function from the current list of
  6264. * defined inputs in the manager.
  6265. */
  6266. rebuildInputCheck(): void;
  6267. /**
  6268. * Remove all attached input methods from a camera
  6269. */
  6270. clear(): void;
  6271. /**
  6272. * Serialize the current input manager attached to a camera.
  6273. * This ensures than once parsed,
  6274. * the input associated to the camera will be identical to the current ones
  6275. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6276. */
  6277. serialize(serializedCamera: any): void;
  6278. /**
  6279. * Parses an input manager serialized JSON to restore the previous list of inputs
  6280. * and states associated to a camera.
  6281. * @param parsedCamera Defines the JSON to parse
  6282. */
  6283. parse(parsedCamera: any): void;
  6284. }
  6285. }
  6286. declare module "babylonjs/Meshes/buffer" {
  6287. import { Nullable, DataArray } from "babylonjs/types";
  6288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6289. /**
  6290. * Class used to store data that will be store in GPU memory
  6291. */
  6292. export class Buffer {
  6293. private _engine;
  6294. private _buffer;
  6295. /** @hidden */
  6296. _data: Nullable<DataArray>;
  6297. private _updatable;
  6298. private _instanced;
  6299. private _divisor;
  6300. /**
  6301. * Gets the byte stride.
  6302. */
  6303. readonly byteStride: number;
  6304. /**
  6305. * Constructor
  6306. * @param engine the engine
  6307. * @param data the data to use for this buffer
  6308. * @param updatable whether the data is updatable
  6309. * @param stride the stride (optional)
  6310. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6311. * @param instanced whether the buffer is instanced (optional)
  6312. * @param useBytes set to true if the stride in in bytes (optional)
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. */
  6315. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6316. /**
  6317. * Create a new VertexBuffer based on the current buffer
  6318. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6319. * @param offset defines offset in the buffer (0 by default)
  6320. * @param size defines the size in floats of attributes (position is 3 for instance)
  6321. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6322. * @param instanced defines if the vertex buffer contains indexed data
  6323. * @param useBytes defines if the offset and stride are in bytes *
  6324. * @param divisor sets an optional divisor for instances (1 by default)
  6325. * @returns the new vertex buffer
  6326. */
  6327. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6328. /**
  6329. * Gets a boolean indicating if the Buffer is updatable?
  6330. * @returns true if the buffer is updatable
  6331. */
  6332. isUpdatable(): boolean;
  6333. /**
  6334. * Gets current buffer's data
  6335. * @returns a DataArray or null
  6336. */
  6337. getData(): Nullable<DataArray>;
  6338. /**
  6339. * Gets underlying native buffer
  6340. * @returns underlying native buffer
  6341. */
  6342. getBuffer(): Nullable<DataBuffer>;
  6343. /**
  6344. * Gets the stride in float32 units (i.e. byte stride / 4).
  6345. * May not be an integer if the byte stride is not divisible by 4.
  6346. * @returns the stride in float32 units
  6347. * @deprecated Please use byteStride instead.
  6348. */
  6349. getStrideSize(): number;
  6350. /**
  6351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6352. * @param data defines the data to store
  6353. */
  6354. create(data?: Nullable<DataArray>): void;
  6355. /** @hidden */
  6356. _rebuild(): void;
  6357. /**
  6358. * Update current buffer data
  6359. * @param data defines the data to store
  6360. */
  6361. update(data: DataArray): void;
  6362. /**
  6363. * Updates the data directly.
  6364. * @param data the new data
  6365. * @param offset the new offset
  6366. * @param vertexCount the vertex count (optional)
  6367. * @param useBytes set to true if the offset is in bytes
  6368. */
  6369. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6370. /**
  6371. * Release all resources
  6372. */
  6373. dispose(): void;
  6374. }
  6375. /**
  6376. * Specialized buffer used to store vertex data
  6377. */
  6378. export class VertexBuffer {
  6379. /** @hidden */
  6380. _buffer: Buffer;
  6381. private _kind;
  6382. private _size;
  6383. private _ownsBuffer;
  6384. private _instanced;
  6385. private _instanceDivisor;
  6386. /**
  6387. * The byte type.
  6388. */
  6389. static readonly BYTE: number;
  6390. /**
  6391. * The unsigned byte type.
  6392. */
  6393. static readonly UNSIGNED_BYTE: number;
  6394. /**
  6395. * The short type.
  6396. */
  6397. static readonly SHORT: number;
  6398. /**
  6399. * The unsigned short type.
  6400. */
  6401. static readonly UNSIGNED_SHORT: number;
  6402. /**
  6403. * The integer type.
  6404. */
  6405. static readonly INT: number;
  6406. /**
  6407. * The unsigned integer type.
  6408. */
  6409. static readonly UNSIGNED_INT: number;
  6410. /**
  6411. * The float type.
  6412. */
  6413. static readonly FLOAT: number;
  6414. /**
  6415. * Gets or sets the instance divisor when in instanced mode
  6416. */
  6417. get instanceDivisor(): number;
  6418. set instanceDivisor(value: number);
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Gets the byte offset.
  6425. */
  6426. readonly byteOffset: number;
  6427. /**
  6428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6429. */
  6430. readonly normalized: boolean;
  6431. /**
  6432. * Gets the data type of each component in the array.
  6433. */
  6434. readonly type: number;
  6435. /**
  6436. * Constructor
  6437. * @param engine the engine
  6438. * @param data the data to use for this vertex buffer
  6439. * @param kind the vertex buffer kind
  6440. * @param updatable whether the data is updatable
  6441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6442. * @param stride the stride (optional)
  6443. * @param instanced whether the buffer is instanced (optional)
  6444. * @param offset the offset of the data (optional)
  6445. * @param size the number of components (optional)
  6446. * @param type the type of the component (optional)
  6447. * @param normalized whether the data contains normalized data (optional)
  6448. * @param useBytes set to true if stride and offset are in bytes (optional)
  6449. * @param divisor defines the instance divisor to use (1 by default)
  6450. */
  6451. 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);
  6452. /** @hidden */
  6453. _rebuild(): void;
  6454. /**
  6455. * Returns the kind of the VertexBuffer (string)
  6456. * @returns a string
  6457. */
  6458. getKind(): string;
  6459. /**
  6460. * Gets a boolean indicating if the VertexBuffer is updatable?
  6461. * @returns true if the buffer is updatable
  6462. */
  6463. isUpdatable(): boolean;
  6464. /**
  6465. * Gets current buffer's data
  6466. * @returns a DataArray or null
  6467. */
  6468. getData(): Nullable<DataArray>;
  6469. /**
  6470. * Gets underlying native buffer
  6471. * @returns underlying native buffer
  6472. */
  6473. getBuffer(): Nullable<DataBuffer>;
  6474. /**
  6475. * Gets the stride in float32 units (i.e. byte stride / 4).
  6476. * May not be an integer if the byte stride is not divisible by 4.
  6477. * @returns the stride in float32 units
  6478. * @deprecated Please use byteStride instead.
  6479. */
  6480. getStrideSize(): number;
  6481. /**
  6482. * Returns the offset as a multiple of the type byte length.
  6483. * @returns the offset in bytes
  6484. * @deprecated Please use byteOffset instead.
  6485. */
  6486. getOffset(): number;
  6487. /**
  6488. * Returns the number of components per vertex attribute (integer)
  6489. * @returns the size in float
  6490. */
  6491. getSize(): number;
  6492. /**
  6493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6494. * @returns true if this buffer is instanced
  6495. */
  6496. getIsInstanced(): boolean;
  6497. /**
  6498. * Returns the instancing divisor, zero for non-instanced (integer).
  6499. * @returns a number
  6500. */
  6501. getInstanceDivisor(): number;
  6502. /**
  6503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6504. * @param data defines the data to store
  6505. */
  6506. create(data?: DataArray): void;
  6507. /**
  6508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6509. * This function will create a new buffer if the current one is not updatable
  6510. * @param data defines the data to store
  6511. */
  6512. update(data: DataArray): void;
  6513. /**
  6514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6515. * Returns the directly updated WebGLBuffer.
  6516. * @param data the new data
  6517. * @param offset the new offset
  6518. * @param useBytes set to true if the offset is in bytes
  6519. */
  6520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6521. /**
  6522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6523. */
  6524. dispose(): void;
  6525. /**
  6526. * Enumerates each value of this vertex buffer as numbers.
  6527. * @param count the number of values to enumerate
  6528. * @param callback the callback function called for each value
  6529. */
  6530. forEach(count: number, callback: (value: number, index: number) => void): void;
  6531. /**
  6532. * Positions
  6533. */
  6534. static readonly PositionKind: string;
  6535. /**
  6536. * Normals
  6537. */
  6538. static readonly NormalKind: string;
  6539. /**
  6540. * Tangents
  6541. */
  6542. static readonly TangentKind: string;
  6543. /**
  6544. * Texture coordinates
  6545. */
  6546. static readonly UVKind: string;
  6547. /**
  6548. * Texture coordinates 2
  6549. */
  6550. static readonly UV2Kind: string;
  6551. /**
  6552. * Texture coordinates 3
  6553. */
  6554. static readonly UV3Kind: string;
  6555. /**
  6556. * Texture coordinates 4
  6557. */
  6558. static readonly UV4Kind: string;
  6559. /**
  6560. * Texture coordinates 5
  6561. */
  6562. static readonly UV5Kind: string;
  6563. /**
  6564. * Texture coordinates 6
  6565. */
  6566. static readonly UV6Kind: string;
  6567. /**
  6568. * Colors
  6569. */
  6570. static readonly ColorKind: string;
  6571. /**
  6572. * Matrix indices (for bones)
  6573. */
  6574. static readonly MatricesIndicesKind: string;
  6575. /**
  6576. * Matrix weights (for bones)
  6577. */
  6578. static readonly MatricesWeightsKind: string;
  6579. /**
  6580. * Additional matrix indices (for bones)
  6581. */
  6582. static readonly MatricesIndicesExtraKind: string;
  6583. /**
  6584. * Additional matrix weights (for bones)
  6585. */
  6586. static readonly MatricesWeightsExtraKind: string;
  6587. /**
  6588. * Deduces the stride given a kind.
  6589. * @param kind The kind string to deduce
  6590. * @returns The deduced stride
  6591. */
  6592. static DeduceStride(kind: string): number;
  6593. /**
  6594. * Gets the byte length of the given type.
  6595. * @param type the type
  6596. * @returns the number of bytes
  6597. */
  6598. static GetTypeByteLength(type: number): number;
  6599. /**
  6600. * Enumerates each value of the given parameters as numbers.
  6601. * @param data the data to enumerate
  6602. * @param byteOffset the byte offset of the data
  6603. * @param byteStride the byte stride of the data
  6604. * @param componentCount the number of components per element
  6605. * @param componentType the type of the component
  6606. * @param count the number of values to enumerate
  6607. * @param normalized whether the data is normalized
  6608. * @param callback the callback function called for each value
  6609. */
  6610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6611. private static _GetFloatValue;
  6612. }
  6613. }
  6614. declare module "babylonjs/Collisions/intersectionInfo" {
  6615. import { Nullable } from "babylonjs/types";
  6616. /**
  6617. * @hidden
  6618. */
  6619. export class IntersectionInfo {
  6620. bu: Nullable<number>;
  6621. bv: Nullable<number>;
  6622. distance: number;
  6623. faceId: number;
  6624. subMeshId: number;
  6625. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6626. }
  6627. }
  6628. declare module "babylonjs/Maths/math.plane" {
  6629. import { DeepImmutable } from "babylonjs/types";
  6630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6631. /**
  6632. * Represens a plane by the equation ax + by + cz + d = 0
  6633. */
  6634. export class Plane {
  6635. private static _TmpMatrix;
  6636. /**
  6637. * Normal of the plane (a,b,c)
  6638. */
  6639. normal: Vector3;
  6640. /**
  6641. * d component of the plane
  6642. */
  6643. d: number;
  6644. /**
  6645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6646. * @param a a component of the plane
  6647. * @param b b component of the plane
  6648. * @param c c component of the plane
  6649. * @param d d component of the plane
  6650. */
  6651. constructor(a: number, b: number, c: number, d: number);
  6652. /**
  6653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6654. */
  6655. asArray(): number[];
  6656. /**
  6657. * @returns a new plane copied from the current Plane.
  6658. */
  6659. clone(): Plane;
  6660. /**
  6661. * @returns the string "Plane".
  6662. */
  6663. getClassName(): string;
  6664. /**
  6665. * @returns the Plane hash code.
  6666. */
  6667. getHashCode(): number;
  6668. /**
  6669. * Normalize the current Plane in place.
  6670. * @returns the updated Plane.
  6671. */
  6672. normalize(): Plane;
  6673. /**
  6674. * Applies a transformation the plane and returns the result
  6675. * @param transformation the transformation matrix to be applied to the plane
  6676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6677. */
  6678. transform(transformation: DeepImmutable<Matrix>): Plane;
  6679. /**
  6680. * Calcualtte the dot product between the point and the plane normal
  6681. * @param point point to calculate the dot product with
  6682. * @returns the dot product (float) of the point coordinates and the plane normal.
  6683. */
  6684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Updates the current Plane from the plane defined by the three given points.
  6687. * @param point1 one of the points used to contruct the plane
  6688. * @param point2 one of the points used to contruct the plane
  6689. * @param point3 one of the points used to contruct the plane
  6690. * @returns the updated Plane.
  6691. */
  6692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6693. /**
  6694. * Checks if the plane is facing a given direction
  6695. * @param direction the direction to check if the plane is facing
  6696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6697. * @returns True is the vector "direction" is the same side than the plane normal.
  6698. */
  6699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6700. /**
  6701. * Calculates the distance to a point
  6702. * @param point point to calculate distance to
  6703. * @returns the signed distance (float) from the given point to the Plane.
  6704. */
  6705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6706. /**
  6707. * Creates a plane from an array
  6708. * @param array the array to create a plane from
  6709. * @returns a new Plane from the given array.
  6710. */
  6711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6712. /**
  6713. * Creates a plane from three points
  6714. * @param point1 point used to create the plane
  6715. * @param point2 point used to create the plane
  6716. * @param point3 point used to create the plane
  6717. * @returns a new Plane defined by the three given points.
  6718. */
  6719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6720. /**
  6721. * Creates a plane from an origin point and a normal
  6722. * @param origin origin of the plane to be constructed
  6723. * @param normal normal of the plane to be constructed
  6724. * @returns a new Plane the normal vector to this plane at the given origin point.
  6725. * Note : the vector "normal" is updated because normalized.
  6726. */
  6727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6728. /**
  6729. * Calculates the distance from a plane and a point
  6730. * @param origin origin of the plane to be constructed
  6731. * @param normal normal of the plane to be constructed
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6734. */
  6735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6736. }
  6737. }
  6738. declare module "babylonjs/Culling/boundingSphere" {
  6739. import { DeepImmutable } from "babylonjs/types";
  6740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6741. import { Plane } from "babylonjs/Maths/math.plane";
  6742. /**
  6743. * Class used to store bounding sphere information
  6744. */
  6745. export class BoundingSphere {
  6746. /**
  6747. * Gets the center of the bounding sphere in local space
  6748. */
  6749. readonly center: Vector3;
  6750. /**
  6751. * Radius of the bounding sphere in local space
  6752. */
  6753. radius: number;
  6754. /**
  6755. * Gets the center of the bounding sphere in world space
  6756. */
  6757. readonly centerWorld: Vector3;
  6758. /**
  6759. * Radius of the bounding sphere in world space
  6760. */
  6761. radiusWorld: number;
  6762. /**
  6763. * Gets the minimum vector in local space
  6764. */
  6765. readonly minimum: Vector3;
  6766. /**
  6767. * Gets the maximum vector in local space
  6768. */
  6769. readonly maximum: Vector3;
  6770. private _worldMatrix;
  6771. private static readonly TmpVector3;
  6772. /**
  6773. * Creates a new bounding sphere
  6774. * @param min defines the minimum vector (in local space)
  6775. * @param max defines the maximum vector (in local space)
  6776. * @param worldMatrix defines the new world matrix
  6777. */
  6778. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6779. /**
  6780. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6781. * @param min defines the new minimum vector (in local space)
  6782. * @param max defines the new maximum vector (in local space)
  6783. * @param worldMatrix defines the new world matrix
  6784. */
  6785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6786. /**
  6787. * Scale the current bounding sphere by applying a scale factor
  6788. * @param factor defines the scale factor to apply
  6789. * @returns the current bounding box
  6790. */
  6791. scale(factor: number): BoundingSphere;
  6792. /**
  6793. * Gets the world matrix of the bounding box
  6794. * @returns a matrix
  6795. */
  6796. getWorldMatrix(): DeepImmutable<Matrix>;
  6797. /** @hidden */
  6798. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6799. /**
  6800. * Tests if the bounding sphere is intersecting the frustum planes
  6801. * @param frustumPlanes defines the frustum planes to test
  6802. * @returns true if there is an intersection
  6803. */
  6804. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6805. /**
  6806. * Tests if the bounding sphere center is in between the frustum planes.
  6807. * Used for optimistic fast inclusion.
  6808. * @param frustumPlanes defines the frustum planes to test
  6809. * @returns true if the sphere center is in between the frustum planes
  6810. */
  6811. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6812. /**
  6813. * Tests if a point is inside the bounding sphere
  6814. * @param point defines the point to test
  6815. * @returns true if the point is inside the bounding sphere
  6816. */
  6817. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6818. /**
  6819. * Checks if two sphere intersct
  6820. * @param sphere0 sphere 0
  6821. * @param sphere1 sphere 1
  6822. * @returns true if the speres intersect
  6823. */
  6824. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6825. }
  6826. }
  6827. declare module "babylonjs/Culling/boundingBox" {
  6828. import { DeepImmutable } from "babylonjs/types";
  6829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6830. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6831. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6832. import { Plane } from "babylonjs/Maths/math.plane";
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module "babylonjs/Collisions/collider" {
  6978. import { Nullable, IndicesArray } from "babylonjs/types";
  6979. import { Vector3 } from "babylonjs/Maths/math.vector";
  6980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6981. import { Plane } from "babylonjs/Maths/math.plane";
  6982. /** @hidden */
  6983. export class Collider {
  6984. /** Define if a collision was found */
  6985. collisionFound: boolean;
  6986. /**
  6987. * Define last intersection point in local space
  6988. */
  6989. intersectionPoint: Vector3;
  6990. /**
  6991. * Define last collided mesh
  6992. */
  6993. collidedMesh: Nullable<AbstractMesh>;
  6994. private _collisionPoint;
  6995. private _planeIntersectionPoint;
  6996. private _tempVector;
  6997. private _tempVector2;
  6998. private _tempVector3;
  6999. private _tempVector4;
  7000. private _edge;
  7001. private _baseToVertex;
  7002. private _destinationPoint;
  7003. private _slidePlaneNormal;
  7004. private _displacementVector;
  7005. /** @hidden */
  7006. _radius: Vector3;
  7007. /** @hidden */
  7008. _retry: number;
  7009. private _velocity;
  7010. private _basePoint;
  7011. private _epsilon;
  7012. /** @hidden */
  7013. _velocityWorldLength: number;
  7014. /** @hidden */
  7015. _basePointWorld: Vector3;
  7016. private _velocityWorld;
  7017. private _normalizedVelocity;
  7018. /** @hidden */
  7019. _initialVelocity: Vector3;
  7020. /** @hidden */
  7021. _initialPosition: Vector3;
  7022. private _nearestDistance;
  7023. private _collisionMask;
  7024. get collisionMask(): number;
  7025. set collisionMask(mask: number);
  7026. /**
  7027. * Gets the plane normal used to compute the sliding response (in local space)
  7028. */
  7029. get slidePlaneNormal(): Vector3;
  7030. /** @hidden */
  7031. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7032. /** @hidden */
  7033. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7034. /** @hidden */
  7035. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */
  7037. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7038. /** @hidden */
  7039. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _getResponse(pos: Vector3, vel: Vector3): void;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingInfo" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7048. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. import { Collider } from "babylonjs/Collisions/collider";
  7051. /**
  7052. * Interface for cullable objects
  7053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7054. */
  7055. export interface ICullable {
  7056. /**
  7057. * Checks if the object or part of the object is in the frustum
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isInFrustum(frustumPlanes: Plane[]): boolean;
  7062. /**
  7063. * Checks if a cullable object (mesh...) is in the camera frustum
  7064. * Unlike isInFrustum this cheks the full bounding box
  7065. * @param frustumPlanes Camera near/planes
  7066. * @returns true if the object is in frustum otherwise false
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7069. }
  7070. /**
  7071. * Info for a bounding data of a mesh
  7072. */
  7073. export class BoundingInfo implements ICullable {
  7074. /**
  7075. * Bounding box for the mesh
  7076. */
  7077. readonly boundingBox: BoundingBox;
  7078. /**
  7079. * Bounding sphere for the mesh
  7080. */
  7081. readonly boundingSphere: BoundingSphere;
  7082. private _isLocked;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * Constructs bounding info
  7086. * @param minimum min vector of the bounding box/sphere
  7087. * @param maximum max vector of the bounding box/sphere
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * min vector of the bounding box/sphere
  7100. */
  7101. get minimum(): Vector3;
  7102. /**
  7103. * max vector of the bounding box/sphere
  7104. */
  7105. get maximum(): Vector3;
  7106. /**
  7107. * If the info is locked and won't be updated to avoid perf overhead
  7108. */
  7109. get isLocked(): boolean;
  7110. set isLocked(value: boolean);
  7111. /**
  7112. * Updates the bounding sphere and box
  7113. * @param world world matrix to be used to update
  7114. */
  7115. update(world: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7118. * @param center New center of the bounding info
  7119. * @param extend New extend of the bounding info
  7120. * @returns the current bounding info
  7121. */
  7122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7123. /**
  7124. * Scale the current bounding info by applying a scale factor
  7125. * @param factor defines the scale factor to apply
  7126. * @returns the current bounding info
  7127. */
  7128. scale(factor: number): BoundingInfo;
  7129. /**
  7130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7131. * @param frustumPlanes defines the frustum to test
  7132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7133. * @returns true if the bounding info is in the frustum planes
  7134. */
  7135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7136. /**
  7137. * Gets the world distance between the min and max points of the bounding box
  7138. */
  7139. get diagonalLength(): number;
  7140. /**
  7141. * Checks if a cullable object (mesh...) is in the camera frustum
  7142. * Unlike isInFrustum this cheks the full bounding box
  7143. * @param frustumPlanes Camera near/planes
  7144. * @returns true if the object is in frustum otherwise false
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /** @hidden */
  7148. _checkCollision(collider: Collider): boolean;
  7149. /**
  7150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7152. * @param point the point to check intersection with
  7153. * @returns if the point intersects
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7159. * @param boundingInfo the bounding info to check intersection with
  7160. * @param precise if the intersection should be done using OBB
  7161. * @returns if the bounding info intersects
  7162. */
  7163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7164. }
  7165. }
  7166. declare module "babylonjs/Maths/math.functions" {
  7167. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7168. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7169. /**
  7170. * Extracts minimum and maximum values from a list of indexed positions
  7171. * @param positions defines the positions to use
  7172. * @param indices defines the indices to the positions
  7173. * @param indexStart defines the start index
  7174. * @param indexCount defines the end index
  7175. * @param bias defines bias value to add to the result
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. /**
  7183. * Extracts minimum and maximum values from a list of positions
  7184. * @param positions defines the positions to use
  7185. * @param start defines the start index in the positions array
  7186. * @param count defines the number of positions to handle
  7187. * @param bias defines bias value to add to the result
  7188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7189. * @return minimum and maximum values
  7190. */
  7191. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7192. minimum: Vector3;
  7193. maximum: Vector3;
  7194. };
  7195. }
  7196. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7198. /** @hidden */
  7199. export class WebGLDataBuffer extends DataBuffer {
  7200. private _buffer;
  7201. constructor(resource: WebGLBuffer);
  7202. get underlyingResource(): any;
  7203. }
  7204. }
  7205. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7206. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7207. import { Nullable } from "babylonjs/types";
  7208. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7229. import { FloatArray, Nullable } from "babylonjs/types";
  7230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7232. module "babylonjs/Engines/thinEngine" {
  7233. interface ThinEngine {
  7234. /**
  7235. * Create an uniform buffer
  7236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7237. * @param elements defines the content of the uniform buffer
  7238. * @returns the webGL uniform buffer
  7239. */
  7240. createUniformBuffer(elements: FloatArray): DataBuffer;
  7241. /**
  7242. * Create a dynamic uniform buffer
  7243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7244. * @param elements defines the content of the uniform buffer
  7245. * @returns the webGL uniform buffer
  7246. */
  7247. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7248. /**
  7249. * Update an existing uniform buffer
  7250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7251. * @param uniformBuffer defines the target uniform buffer
  7252. * @param elements defines the content to update
  7253. * @param offset defines the offset in the uniform buffer where update should start
  7254. * @param count defines the size of the data to update
  7255. */
  7256. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7257. /**
  7258. * Bind an uniform buffer to the current webGL context
  7259. * @param buffer defines the buffer to bind
  7260. */
  7261. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7262. /**
  7263. * Bind a buffer to the current webGL context at a given location
  7264. * @param buffer defines the buffer to bind
  7265. * @param location defines the index where to bind the buffer
  7266. */
  7267. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7268. /**
  7269. * Bind a specific block at a given index in a specific shader program
  7270. * @param pipelineContext defines the pipeline context to use
  7271. * @param blockName defines the block name
  7272. * @param index defines the index where to bind the block
  7273. */
  7274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7275. }
  7276. }
  7277. }
  7278. declare module "babylonjs/Materials/uniformBuffer" {
  7279. import { Nullable, FloatArray } from "babylonjs/types";
  7280. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7281. import { Engine } from "babylonjs/Engines/engine";
  7282. import { Effect } from "babylonjs/Materials/effect";
  7283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { Color3 } from "babylonjs/Maths/math.color";
  7286. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7287. /**
  7288. * Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. */
  7297. export class UniformBuffer {
  7298. private _engine;
  7299. private _buffer;
  7300. private _data;
  7301. private _bufferData;
  7302. private _dynamic?;
  7303. private _uniformLocations;
  7304. private _uniformSizes;
  7305. private _uniformLocationPointer;
  7306. private _needSync;
  7307. private _noUBO;
  7308. private _currentEffect;
  7309. /** @hidden */
  7310. _alreadyBound: boolean;
  7311. private static _MAX_UNIFORM_SIZE;
  7312. private static _tempBuffer;
  7313. /**
  7314. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7319. /**
  7320. * Lambda to Update a 2x2 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  7331. /**
  7332. * Lambda to Update a vec2 of 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7337. /**
  7338. * Lambda to Update a vec3 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec4 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7355. /**
  7356. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7361. /**
  7362. * Lambda to Update vec4 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. updateVector4: (name: string, vector: Vector4) => void;
  7367. /**
  7368. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update vec4 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7379. /**
  7380. * Instantiates a new Uniform buffer objects.
  7381. *
  7382. * Handles blocks of uniform on the GPU.
  7383. *
  7384. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7385. *
  7386. * For more information, please refer to :
  7387. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7388. * @param engine Define the engine the buffer is associated with
  7389. * @param data Define the data contained in the buffer
  7390. * @param dynamic Define if the buffer is updatable
  7391. */
  7392. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7393. /**
  7394. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7395. * or just falling back on setUniformXXX calls.
  7396. */
  7397. get useUbo(): boolean;
  7398. /**
  7399. * Indicates if the WebGL underlying uniform buffer is in sync
  7400. * with the javascript cache data.
  7401. */
  7402. get isSync(): boolean;
  7403. /**
  7404. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7405. * Also, a dynamic UniformBuffer will disable cache verification and always
  7406. * update the underlying WebGL uniform buffer to the GPU.
  7407. * @returns if Dynamic, otherwise false
  7408. */
  7409. isDynamic(): boolean;
  7410. /**
  7411. * The data cache on JS side.
  7412. * @returns the underlying data as a float array
  7413. */
  7414. getData(): Float32Array;
  7415. /**
  7416. * The underlying WebGL Uniform buffer.
  7417. * @returns the webgl buffer
  7418. */
  7419. getBuffer(): Nullable<DataBuffer>;
  7420. /**
  7421. * std140 layout specifies how to align data within an UBO structure.
  7422. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7423. * for specs.
  7424. */
  7425. private _fillAlignment;
  7426. /**
  7427. * Adds an uniform in the buffer.
  7428. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7429. * for the layout to be correct !
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param size Data size, or data directly.
  7432. */
  7433. addUniform(name: string, size: number | number[]): void;
  7434. /**
  7435. * Adds a Matrix 4x4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param mat A 4x4 matrix.
  7438. */
  7439. addMatrix(name: string, mat: Matrix): void;
  7440. /**
  7441. * Adds a vec2 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param x Define the x component value of the vec2
  7444. * @param y Define the y component value of the vec2
  7445. */
  7446. addFloat2(name: string, x: number, y: number): void;
  7447. /**
  7448. * Adds a vec3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. * @param x Define the x component value of the vec3
  7451. * @param y Define the y component value of the vec3
  7452. * @param z Define the z component value of the vec3
  7453. */
  7454. addFloat3(name: string, x: number, y: number, z: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param color Define the vec3 from a Color
  7459. */
  7460. addColor3(name: string, color: Color3): void;
  7461. /**
  7462. * Adds a vec4 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 rgb components from a Color
  7465. * @param alpha Define the a component of the vec4
  7466. */
  7467. addColor4(name: string, color: Color3, alpha: number): void;
  7468. /**
  7469. * Adds a vec3 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. * @param vector Define the vec3 components from a Vector
  7472. */
  7473. addVector3(name: string, vector: Vector3): void;
  7474. /**
  7475. * Adds a Matrix 3x3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. */
  7478. addMatrix3x3(name: string): void;
  7479. /**
  7480. * Adds a Matrix 2x2 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. */
  7483. addMatrix2x2(name: string): void;
  7484. /**
  7485. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7486. */
  7487. create(): void;
  7488. /** @hidden */
  7489. _rebuild(): void;
  7490. /**
  7491. * Updates the WebGL Uniform Buffer on the GPU.
  7492. * If the `dynamic` flag is set to true, no cache comparison is done.
  7493. * Otherwise, the buffer will be updated only if the cache differs.
  7494. */
  7495. update(): void;
  7496. /**
  7497. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7498. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7499. * @param data Define the flattened data
  7500. * @param size Define the size of the data.
  7501. */
  7502. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7503. private _valueCache;
  7504. private _cacheMatrix;
  7505. private _updateMatrix3x3ForUniform;
  7506. private _updateMatrix3x3ForEffect;
  7507. private _updateMatrix2x2ForEffect;
  7508. private _updateMatrix2x2ForUniform;
  7509. private _updateFloatForEffect;
  7510. private _updateFloatForUniform;
  7511. private _updateFloat2ForEffect;
  7512. private _updateFloat2ForUniform;
  7513. private _updateFloat3ForEffect;
  7514. private _updateFloat3ForUniform;
  7515. private _updateFloat4ForEffect;
  7516. private _updateFloat4ForUniform;
  7517. private _updateMatrixForEffect;
  7518. private _updateMatrixForUniform;
  7519. private _updateVector3ForEffect;
  7520. private _updateVector3ForUniform;
  7521. private _updateVector4ForEffect;
  7522. private _updateVector4ForUniform;
  7523. private _updateColor3ForEffect;
  7524. private _updateColor3ForUniform;
  7525. private _updateColor4ForEffect;
  7526. private _updateColor4ForUniform;
  7527. /**
  7528. * Sets a sampler uniform on the effect.
  7529. * @param name Define the name of the sampler.
  7530. * @param texture Define the texture to set in the sampler
  7531. */
  7532. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7533. /**
  7534. * Directly updates the value of the uniform in the cache AND on the GPU.
  7535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7536. * @param data Define the flattened data
  7537. */
  7538. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7539. /**
  7540. * Binds this uniform buffer to an effect.
  7541. * @param effect Define the effect to bind the buffer to
  7542. * @param name Name of the uniform block in the shader.
  7543. */
  7544. bindToEffect(effect: Effect, name: string): void;
  7545. /**
  7546. * Disposes the uniform buffer.
  7547. */
  7548. dispose(): void;
  7549. }
  7550. }
  7551. declare module "babylonjs/Misc/iInspectable" {
  7552. /**
  7553. * Enum that determines the text-wrapping mode to use.
  7554. */
  7555. export enum InspectableType {
  7556. /**
  7557. * Checkbox for booleans
  7558. */
  7559. Checkbox = 0,
  7560. /**
  7561. * Sliders for numbers
  7562. */
  7563. Slider = 1,
  7564. /**
  7565. * Vector3
  7566. */
  7567. Vector3 = 2,
  7568. /**
  7569. * Quaternions
  7570. */
  7571. Quaternion = 3,
  7572. /**
  7573. * Color3
  7574. */
  7575. Color3 = 4,
  7576. /**
  7577. * String
  7578. */
  7579. String = 5
  7580. }
  7581. /**
  7582. * Interface used to define custom inspectable properties.
  7583. * This interface is used by the inspector to display custom property grids
  7584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7585. */
  7586. export interface IInspectable {
  7587. /**
  7588. * Gets the label to display
  7589. */
  7590. label: string;
  7591. /**
  7592. * Gets the name of the property to edit
  7593. */
  7594. propertyName: string;
  7595. /**
  7596. * Gets the type of the editor to use
  7597. */
  7598. type: InspectableType;
  7599. /**
  7600. * Gets the minimum value of the property when using in "slider" mode
  7601. */
  7602. min?: number;
  7603. /**
  7604. * Gets the maximum value of the property when using in "slider" mode
  7605. */
  7606. max?: number;
  7607. /**
  7608. * Gets the setp to use when using in "slider" mode
  7609. */
  7610. step?: number;
  7611. }
  7612. }
  7613. declare module "babylonjs/Misc/timingTools" {
  7614. /**
  7615. * Class used to provide helper for timing
  7616. */
  7617. export class TimingTools {
  7618. /**
  7619. * Polyfill for setImmediate
  7620. * @param action defines the action to execute after the current execution block
  7621. */
  7622. static SetImmediate(action: () => void): void;
  7623. }
  7624. }
  7625. declare module "babylonjs/Misc/instantiationTools" {
  7626. /**
  7627. * Class used to enable instatition of objects by class name
  7628. */
  7629. export class InstantiationTools {
  7630. /**
  7631. * Use this object to register external classes like custom textures or material
  7632. * to allow the laoders to instantiate them
  7633. */
  7634. static RegisteredExternalClasses: {
  7635. [key: string]: Object;
  7636. };
  7637. /**
  7638. * Tries to instantiate a new object from a given class name
  7639. * @param className defines the class name to instantiate
  7640. * @returns the new object or null if the system was not able to do the instantiation
  7641. */
  7642. static Instantiate(className: string): any;
  7643. }
  7644. }
  7645. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7646. /**
  7647. * Define options used to create a depth texture
  7648. */
  7649. export class DepthTextureCreationOptions {
  7650. /** Specifies whether or not a stencil should be allocated in the texture */
  7651. generateStencil?: boolean;
  7652. /** Specifies whether or not bilinear filtering is enable on the texture */
  7653. bilinearFiltering?: boolean;
  7654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7655. comparisonFunction?: number;
  7656. /** Specifies if the created texture is a cube texture */
  7657. isCube?: boolean;
  7658. }
  7659. }
  7660. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7662. import { Nullable } from "babylonjs/types";
  7663. import { Scene } from "babylonjs/scene";
  7664. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7665. module "babylonjs/Engines/thinEngine" {
  7666. interface ThinEngine {
  7667. /**
  7668. * Creates a depth stencil cube texture.
  7669. * This is only available in WebGL 2.
  7670. * @param size The size of face edge in the cube texture.
  7671. * @param options The options defining the cube texture.
  7672. * @returns The cube texture
  7673. */
  7674. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7675. /**
  7676. * Creates a cube texture
  7677. * @param rootUrl defines the url where the files to load is located
  7678. * @param scene defines the current scene
  7679. * @param files defines the list of files to load (1 per face)
  7680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7681. * @param onLoad defines an optional callback raised when the texture is loaded
  7682. * @param onError defines an optional callback raised if there is an issue to load the texture
  7683. * @param format defines the format of the data
  7684. * @param forcedExtension defines the extension to use to pick the right loader
  7685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. 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;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. 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;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @returns the cube texture as an InternalTexture
  7719. */
  7720. 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;
  7721. /** @hidden */
  7722. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7723. /** @hidden */
  7724. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7725. /** @hidden */
  7726. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7727. /** @hidden */
  7728. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7729. /**
  7730. * @hidden
  7731. */
  7732. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7733. }
  7734. }
  7735. }
  7736. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7737. import { Nullable } from "babylonjs/types";
  7738. import { Scene } from "babylonjs/scene";
  7739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7741. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7742. import { Observable } from "babylonjs/Misc/observable";
  7743. /**
  7744. * Class for creating a cube texture
  7745. */
  7746. export class CubeTexture extends BaseTexture {
  7747. private _delayedOnLoad;
  7748. /**
  7749. * Observable triggered once the texture has been loaded.
  7750. */
  7751. onLoadObservable: Observable<CubeTexture>;
  7752. /**
  7753. * The url of the texture
  7754. */
  7755. url: string;
  7756. /**
  7757. * Gets or sets the center of the bounding box associated with the cube texture.
  7758. * It must define where the camera used to render the texture was set
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. boundingBoxPosition: Vector3;
  7762. private _boundingBoxSize;
  7763. /**
  7764. * Gets or sets the size of the bounding box associated with the cube texture
  7765. * When defined, the cubemap will switch to local mode
  7766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7767. * @example https://www.babylonjs-playground.com/#RNASML
  7768. */
  7769. set boundingBoxSize(value: Vector3);
  7770. /**
  7771. * Returns the bounding box size
  7772. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7773. */
  7774. get boundingBoxSize(): Vector3;
  7775. protected _rotationY: number;
  7776. /**
  7777. * Sets texture matrix rotation angle around Y axis in radians.
  7778. */
  7779. set rotationY(value: number);
  7780. /**
  7781. * Gets texture matrix rotation angle around Y axis radians.
  7782. */
  7783. get rotationY(): number;
  7784. /**
  7785. * Are mip maps generated for this texture or not.
  7786. */
  7787. get noMipmap(): boolean;
  7788. private _noMipmap;
  7789. private _files;
  7790. protected _forcedExtension: Nullable<string>;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. 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);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. get isPrefiltered(): boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7848. */
  7849. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7850. /**
  7851. * Delays loading of the cube texture
  7852. * @param forcedExtension defines the extension to use
  7853. */
  7854. delayLoad(forcedExtension?: string): void;
  7855. /**
  7856. * Returns the reflection texture matrix
  7857. * @returns the reflection texture matrix
  7858. */
  7859. getReflectionTextureMatrix(): Matrix;
  7860. /**
  7861. * Sets the reflection texture matrix
  7862. * @param value Reflection texture matrix
  7863. */
  7864. setReflectionTextureMatrix(value: Matrix): void;
  7865. /**
  7866. * Parses text to create a cube texture
  7867. * @param parsedTexture define the serialized text to read from
  7868. * @param scene defines the hosting scene
  7869. * @param rootUrl defines the root url of the cube texture
  7870. * @returns a cube texture
  7871. */
  7872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7873. /**
  7874. * Makes a clone, or deep copy, of the cube texture
  7875. * @returns a new cube texture
  7876. */
  7877. clone(): CubeTexture;
  7878. }
  7879. }
  7880. declare module "babylonjs/Materials/materialDefines" {
  7881. /**
  7882. * Manages the defines for the Material
  7883. */
  7884. export class MaterialDefines {
  7885. /** @hidden */
  7886. protected _keys: string[];
  7887. private _isDirty;
  7888. /** @hidden */
  7889. _renderId: number;
  7890. /** @hidden */
  7891. _areLightsDirty: boolean;
  7892. /** @hidden */
  7893. _areLightsDisposed: boolean;
  7894. /** @hidden */
  7895. _areAttributesDirty: boolean;
  7896. /** @hidden */
  7897. _areTexturesDirty: boolean;
  7898. /** @hidden */
  7899. _areFresnelDirty: boolean;
  7900. /** @hidden */
  7901. _areMiscDirty: boolean;
  7902. /** @hidden */
  7903. _areImageProcessingDirty: boolean;
  7904. /** @hidden */
  7905. _normals: boolean;
  7906. /** @hidden */
  7907. _uvs: boolean;
  7908. /** @hidden */
  7909. _needNormals: boolean;
  7910. /** @hidden */
  7911. _needUVs: boolean;
  7912. [id: string]: any;
  7913. /**
  7914. * Specifies if the material needs to be re-calculated
  7915. */
  7916. get isDirty(): boolean;
  7917. /**
  7918. * Marks the material to indicate that it has been re-calculated
  7919. */
  7920. markAsProcessed(): void;
  7921. /**
  7922. * Marks the material to indicate that it needs to be re-calculated
  7923. */
  7924. markAsUnprocessed(): void;
  7925. /**
  7926. * Marks the material to indicate all of its defines need to be re-calculated
  7927. */
  7928. markAllAsDirty(): void;
  7929. /**
  7930. * Marks the material to indicate that image processing needs to be re-calculated
  7931. */
  7932. markAsImageProcessingDirty(): void;
  7933. /**
  7934. * Marks the material to indicate the lights need to be re-calculated
  7935. * @param disposed Defines whether the light is dirty due to dispose or not
  7936. */
  7937. markAsLightDirty(disposed?: boolean): void;
  7938. /**
  7939. * Marks the attribute state as changed
  7940. */
  7941. markAsAttributesDirty(): void;
  7942. /**
  7943. * Marks the texture state as changed
  7944. */
  7945. markAsTexturesDirty(): void;
  7946. /**
  7947. * Marks the fresnel state as changed
  7948. */
  7949. markAsFresnelDirty(): void;
  7950. /**
  7951. * Marks the misc state as changed
  7952. */
  7953. markAsMiscDirty(): void;
  7954. /**
  7955. * Rebuilds the material defines
  7956. */
  7957. rebuild(): void;
  7958. /**
  7959. * Specifies if two material defines are equal
  7960. * @param other - A material define instance to compare to
  7961. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7962. */
  7963. isEqual(other: MaterialDefines): boolean;
  7964. /**
  7965. * Clones this instance's defines to another instance
  7966. * @param other - material defines to clone values to
  7967. */
  7968. cloneTo(other: MaterialDefines): void;
  7969. /**
  7970. * Resets the material define values
  7971. */
  7972. reset(): void;
  7973. /**
  7974. * Converts the material define values to a string
  7975. * @returns - String of material define information
  7976. */
  7977. toString(): string;
  7978. }
  7979. }
  7980. declare module "babylonjs/Materials/colorCurves" {
  7981. import { Effect } from "babylonjs/Materials/effect";
  7982. /**
  7983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7985. * 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;
  7986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7987. */
  7988. export class ColorCurves {
  7989. private _dirty;
  7990. private _tempColor;
  7991. private _globalCurve;
  7992. private _highlightsCurve;
  7993. private _midtonesCurve;
  7994. private _shadowsCurve;
  7995. private _positiveCurve;
  7996. private _negativeCurve;
  7997. private _globalHue;
  7998. private _globalDensity;
  7999. private _globalSaturation;
  8000. private _globalExposure;
  8001. /**
  8002. * Gets the global Hue value.
  8003. * 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).
  8004. */
  8005. get globalHue(): number;
  8006. /**
  8007. * Sets the global Hue value.
  8008. * 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).
  8009. */
  8010. set globalHue(value: number);
  8011. /**
  8012. * Gets the global Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get globalDensity(): number;
  8017. /**
  8018. * Sets 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. set globalDensity(value: number);
  8023. /**
  8024. * Gets the global Saturation value.
  8025. * 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.
  8026. */
  8027. get globalSaturation(): number;
  8028. /**
  8029. * Sets the global Saturation value.
  8030. * 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.
  8031. */
  8032. set globalSaturation(value: number);
  8033. /**
  8034. * Gets the global Exposure value.
  8035. * 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.
  8036. */
  8037. get globalExposure(): number;
  8038. /**
  8039. * Sets the global Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set globalExposure(value: number);
  8043. private _highlightsHue;
  8044. private _highlightsDensity;
  8045. private _highlightsSaturation;
  8046. private _highlightsExposure;
  8047. /**
  8048. * Gets the highlights Hue value.
  8049. * 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).
  8050. */
  8051. get highlightsHue(): number;
  8052. /**
  8053. * Sets the highlights Hue value.
  8054. * 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).
  8055. */
  8056. set highlightsHue(value: number);
  8057. /**
  8058. * Gets the highlights Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get highlightsDensity(): number;
  8063. /**
  8064. * Sets 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. set highlightsDensity(value: number);
  8069. /**
  8070. * Gets the highlights Saturation value.
  8071. * 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.
  8072. */
  8073. get highlightsSaturation(): number;
  8074. /**
  8075. * Sets the highlights Saturation value.
  8076. * 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.
  8077. */
  8078. set highlightsSaturation(value: number);
  8079. /**
  8080. * Gets the highlights Exposure value.
  8081. * 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.
  8082. */
  8083. get highlightsExposure(): number;
  8084. /**
  8085. * Sets the highlights Exposure value.
  8086. * 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.
  8087. */
  8088. set highlightsExposure(value: number);
  8089. private _midtonesHue;
  8090. private _midtonesDensity;
  8091. private _midtonesSaturation;
  8092. private _midtonesExposure;
  8093. /**
  8094. * Gets the midtones Hue value.
  8095. * 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).
  8096. */
  8097. get midtonesHue(): number;
  8098. /**
  8099. * Sets the midtones Hue value.
  8100. * 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).
  8101. */
  8102. set midtonesHue(value: number);
  8103. /**
  8104. * Gets the midtones Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get midtonesDensity(): number;
  8109. /**
  8110. * Sets 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. set midtonesDensity(value: number);
  8115. /**
  8116. * Gets the midtones Saturation value.
  8117. * 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.
  8118. */
  8119. get midtonesSaturation(): number;
  8120. /**
  8121. * Sets the midtones Saturation value.
  8122. * 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.
  8123. */
  8124. set midtonesSaturation(value: number);
  8125. /**
  8126. * Gets the midtones Exposure value.
  8127. * 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.
  8128. */
  8129. get midtonesExposure(): number;
  8130. /**
  8131. * Sets the midtones Exposure value.
  8132. * 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.
  8133. */
  8134. set midtonesExposure(value: number);
  8135. private _shadowsHue;
  8136. private _shadowsDensity;
  8137. private _shadowsSaturation;
  8138. private _shadowsExposure;
  8139. /**
  8140. * Gets the shadows Hue value.
  8141. * 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).
  8142. */
  8143. get shadowsHue(): number;
  8144. /**
  8145. * Sets the shadows Hue value.
  8146. * 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).
  8147. */
  8148. set shadowsHue(value: number);
  8149. /**
  8150. * Gets the shadows Density value.
  8151. * 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.
  8152. * Values less than zero provide a filter of opposite hue.
  8153. */
  8154. get shadowsDensity(): number;
  8155. /**
  8156. * Sets 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. set shadowsDensity(value: number);
  8161. /**
  8162. * Gets the shadows Saturation value.
  8163. * 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.
  8164. */
  8165. get shadowsSaturation(): number;
  8166. /**
  8167. * Sets the shadows Saturation value.
  8168. * 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.
  8169. */
  8170. set shadowsSaturation(value: number);
  8171. /**
  8172. * Gets the shadows Exposure value.
  8173. * 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.
  8174. */
  8175. get shadowsExposure(): number;
  8176. /**
  8177. * Sets the shadows Exposure value.
  8178. * 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.
  8179. */
  8180. set shadowsExposure(value: number);
  8181. /**
  8182. * Returns the class name
  8183. * @returns The class name
  8184. */
  8185. getClassName(): string;
  8186. /**
  8187. * Binds the color curves to the shader.
  8188. * @param colorCurves The color curve to bind
  8189. * @param effect The effect to bind to
  8190. * @param positiveUniform The positive uniform shader parameter
  8191. * @param neutralUniform The neutral uniform shader parameter
  8192. * @param negativeUniform The negative uniform shader parameter
  8193. */
  8194. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8195. /**
  8196. * Prepare the list of uniforms associated with the ColorCurves effects.
  8197. * @param uniformsList The list of uniforms used in the effect
  8198. */
  8199. static PrepareUniforms(uniformsList: string[]): void;
  8200. /**
  8201. * Returns color grading data based on a hue, density, saturation and exposure value.
  8202. * @param filterHue The hue of the color filter.
  8203. * @param filterDensity The density of the color filter.
  8204. * @param saturation The saturation.
  8205. * @param exposure The exposure.
  8206. * @param result The result data container.
  8207. */
  8208. private getColorGradingDataToRef;
  8209. /**
  8210. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8211. * @param value The input slider value in range [-100,100].
  8212. * @returns Adjusted value.
  8213. */
  8214. private static applyColorGradingSliderNonlinear;
  8215. /**
  8216. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8217. * @param hue The hue (H) input.
  8218. * @param saturation The saturation (S) input.
  8219. * @param brightness The brightness (B) input.
  8220. * @result An RGBA color represented as Vector4.
  8221. */
  8222. private static fromHSBToRef;
  8223. /**
  8224. * Returns a value clamped between min and max
  8225. * @param value The value to clamp
  8226. * @param min The minimum of value
  8227. * @param max The maximum of value
  8228. * @returns The clamped value.
  8229. */
  8230. private static clamp;
  8231. /**
  8232. * Clones the current color curve instance.
  8233. * @return The cloned curves
  8234. */
  8235. clone(): ColorCurves;
  8236. /**
  8237. * Serializes the current color curve instance to a json representation.
  8238. * @return a JSON representation
  8239. */
  8240. serialize(): any;
  8241. /**
  8242. * Parses the color curve from a json representation.
  8243. * @param source the JSON source to parse
  8244. * @return The parsed curves
  8245. */
  8246. static Parse(source: any): ColorCurves;
  8247. }
  8248. }
  8249. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8250. import { Observable } from "babylonjs/Misc/observable";
  8251. import { Nullable } from "babylonjs/types";
  8252. import { Color4 } from "babylonjs/Maths/math.color";
  8253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8254. import { Effect } from "babylonjs/Materials/effect";
  8255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8256. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8257. /**
  8258. * Interface to follow in your material defines to integrate easily the
  8259. * Image proccessing functions.
  8260. * @hidden
  8261. */
  8262. export interface IImageProcessingConfigurationDefines {
  8263. IMAGEPROCESSING: boolean;
  8264. VIGNETTE: boolean;
  8265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8266. VIGNETTEBLENDMODEOPAQUE: boolean;
  8267. TONEMAPPING: boolean;
  8268. TONEMAPPING_ACES: boolean;
  8269. CONTRAST: boolean;
  8270. EXPOSURE: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. }
  8278. /**
  8279. * @hidden
  8280. */
  8281. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8282. IMAGEPROCESSING: boolean;
  8283. VIGNETTE: boolean;
  8284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8285. VIGNETTEBLENDMODEOPAQUE: boolean;
  8286. TONEMAPPING: boolean;
  8287. TONEMAPPING_ACES: boolean;
  8288. CONTRAST: boolean;
  8289. COLORCURVES: boolean;
  8290. COLORGRADING: boolean;
  8291. COLORGRADING3D: boolean;
  8292. SAMPLER3DGREENDEPTH: boolean;
  8293. SAMPLER3DBGRMAP: boolean;
  8294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8295. EXPOSURE: boolean;
  8296. constructor();
  8297. }
  8298. /**
  8299. * This groups together the common properties used for image processing either in direct forward pass
  8300. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8301. * or not.
  8302. */
  8303. export class ImageProcessingConfiguration {
  8304. /**
  8305. * Default tone mapping applied in BabylonJS.
  8306. */
  8307. static readonly TONEMAPPING_STANDARD: number;
  8308. /**
  8309. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8310. * to other engines rendering to increase portability.
  8311. */
  8312. static readonly TONEMAPPING_ACES: number;
  8313. /**
  8314. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8315. */
  8316. colorCurves: Nullable<ColorCurves>;
  8317. private _colorCurvesEnabled;
  8318. /**
  8319. * Gets wether the color curves effect is enabled.
  8320. */
  8321. get colorCurvesEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color curves effect is enabled.
  8324. */
  8325. set colorCurvesEnabled(value: boolean);
  8326. private _colorGradingTexture;
  8327. /**
  8328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8329. */
  8330. get colorGradingTexture(): Nullable<BaseTexture>;
  8331. /**
  8332. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8333. */
  8334. set colorGradingTexture(value: Nullable<BaseTexture>);
  8335. private _colorGradingEnabled;
  8336. /**
  8337. * Gets wether the color grading effect is enabled.
  8338. */
  8339. get colorGradingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the color grading effect is enabled.
  8342. */
  8343. set colorGradingEnabled(value: boolean);
  8344. private _colorGradingWithGreenDepth;
  8345. /**
  8346. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8347. */
  8348. get colorGradingWithGreenDepth(): boolean;
  8349. /**
  8350. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8351. */
  8352. set colorGradingWithGreenDepth(value: boolean);
  8353. private _colorGradingBGR;
  8354. /**
  8355. * Gets wether the color grading texture contains BGR values.
  8356. */
  8357. get colorGradingBGR(): boolean;
  8358. /**
  8359. * Sets wether the color grading texture contains BGR values.
  8360. */
  8361. set colorGradingBGR(value: boolean);
  8362. /** @hidden */
  8363. _exposure: number;
  8364. /**
  8365. * Gets the Exposure used in the effect.
  8366. */
  8367. get exposure(): number;
  8368. /**
  8369. * Sets the Exposure used in the effect.
  8370. */
  8371. set exposure(value: number);
  8372. private _toneMappingEnabled;
  8373. /**
  8374. * Gets wether the tone mapping effect is enabled.
  8375. */
  8376. get toneMappingEnabled(): boolean;
  8377. /**
  8378. * Sets wether the tone mapping effect is enabled.
  8379. */
  8380. set toneMappingEnabled(value: boolean);
  8381. private _toneMappingType;
  8382. /**
  8383. * Gets the type of tone mapping effect.
  8384. */
  8385. get toneMappingType(): number;
  8386. /**
  8387. * Sets the type of tone mapping effect used in BabylonJS.
  8388. */
  8389. set toneMappingType(value: number);
  8390. protected _contrast: number;
  8391. /**
  8392. * Gets the contrast used in the effect.
  8393. */
  8394. get contrast(): number;
  8395. /**
  8396. * Sets the contrast used in the effect.
  8397. */
  8398. set contrast(value: number);
  8399. /**
  8400. * Vignette stretch size.
  8401. */
  8402. vignetteStretch: number;
  8403. /**
  8404. * Vignette centre X Offset.
  8405. */
  8406. vignetteCentreX: number;
  8407. /**
  8408. * Vignette centre Y Offset.
  8409. */
  8410. vignetteCentreY: number;
  8411. /**
  8412. * Vignette weight or intensity of the vignette effect.
  8413. */
  8414. vignetteWeight: number;
  8415. /**
  8416. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8417. * if vignetteEnabled is set to true.
  8418. */
  8419. vignetteColor: Color4;
  8420. /**
  8421. * Camera field of view used by the Vignette effect.
  8422. */
  8423. vignetteCameraFov: number;
  8424. private _vignetteBlendMode;
  8425. /**
  8426. * Gets the vignette blend mode allowing different kind of effect.
  8427. */
  8428. get vignetteBlendMode(): number;
  8429. /**
  8430. * Sets the vignette blend mode allowing different kind of effect.
  8431. */
  8432. set vignetteBlendMode(value: number);
  8433. private _vignetteEnabled;
  8434. /**
  8435. * Gets wether the vignette effect is enabled.
  8436. */
  8437. get vignetteEnabled(): boolean;
  8438. /**
  8439. * Sets wether the vignette effect is enabled.
  8440. */
  8441. set vignetteEnabled(value: boolean);
  8442. private _applyByPostProcess;
  8443. /**
  8444. * Gets wether the image processing is applied through a post process or not.
  8445. */
  8446. get applyByPostProcess(): boolean;
  8447. /**
  8448. * Sets wether the image processing is applied through a post process or not.
  8449. */
  8450. set applyByPostProcess(value: boolean);
  8451. private _isEnabled;
  8452. /**
  8453. * Gets wether the image processing is enabled or not.
  8454. */
  8455. get isEnabled(): boolean;
  8456. /**
  8457. * Sets wether the image processing is enabled or not.
  8458. */
  8459. set isEnabled(value: boolean);
  8460. /**
  8461. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8462. */
  8463. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8464. /**
  8465. * Method called each time the image processing information changes requires to recompile the effect.
  8466. */
  8467. protected _updateParameters(): void;
  8468. /**
  8469. * Gets the current class name.
  8470. * @return "ImageProcessingConfiguration"
  8471. */
  8472. getClassName(): string;
  8473. /**
  8474. * Prepare the list of uniforms associated with the Image Processing effects.
  8475. * @param uniforms The list of uniforms used in the effect
  8476. * @param defines the list of defines currently in use
  8477. */
  8478. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8479. /**
  8480. * Prepare the list of samplers associated with the Image Processing effects.
  8481. * @param samplersList The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of defines associated to the shader.
  8487. * @param defines the list of defines to complete
  8488. * @param forPostProcess Define if we are currently in post process mode or not
  8489. */
  8490. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8491. /**
  8492. * Returns true if all the image processing information are ready.
  8493. * @returns True if ready, otherwise, false
  8494. */
  8495. isReady(): boolean;
  8496. /**
  8497. * Binds the image processing to the shader.
  8498. * @param effect The effect to bind to
  8499. * @param overrideAspectRatio Override the aspect ratio of the effect
  8500. */
  8501. bind(effect: Effect, overrideAspectRatio?: number): void;
  8502. /**
  8503. * Clones the current image processing instance.
  8504. * @return The cloned image processing
  8505. */
  8506. clone(): ImageProcessingConfiguration;
  8507. /**
  8508. * Serializes the current image processing instance to a json representation.
  8509. * @return a JSON representation
  8510. */
  8511. serialize(): any;
  8512. /**
  8513. * Parses the image processing from a json representation.
  8514. * @param source the JSON source to parse
  8515. * @return The parsed image processing
  8516. */
  8517. static Parse(source: any): ImageProcessingConfiguration;
  8518. private static _VIGNETTEMODE_MULTIPLY;
  8519. private static _VIGNETTEMODE_OPAQUE;
  8520. /**
  8521. * Used to apply the vignette as a mix with the pixel color.
  8522. */
  8523. static get VIGNETTEMODE_MULTIPLY(): number;
  8524. /**
  8525. * Used to apply the vignette as a replacement of the pixel color.
  8526. */
  8527. static get VIGNETTEMODE_OPAQUE(): number;
  8528. }
  8529. }
  8530. declare module "babylonjs/Shaders/postprocess.vertex" {
  8531. /** @hidden */
  8532. export var postprocessVertexShader: {
  8533. name: string;
  8534. shader: string;
  8535. };
  8536. }
  8537. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8540. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8541. module "babylonjs/Engines/thinEngine" {
  8542. interface ThinEngine {
  8543. /**
  8544. * Creates a new render target texture
  8545. * @param size defines the size of the texture
  8546. * @param options defines the options used to create the texture
  8547. * @returns a new render target texture stored in an InternalTexture
  8548. */
  8549. createRenderTargetTexture(size: number | {
  8550. width: number;
  8551. height: number;
  8552. layers?: number;
  8553. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8554. /**
  8555. * Creates a depth stencil texture.
  8556. * This is only available in WebGL 2 or with the depth texture extension available.
  8557. * @param size The size of face edge in the texture.
  8558. * @param options The options defining the texture.
  8559. * @returns The texture
  8560. */
  8561. createDepthStencilTexture(size: number | {
  8562. width: number;
  8563. height: number;
  8564. layers?: number;
  8565. }, options: DepthTextureCreationOptions): InternalTexture;
  8566. /** @hidden */
  8567. _createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. }
  8573. }
  8574. }
  8575. declare module "babylonjs/Maths/math.axis" {
  8576. import { Vector3 } from "babylonjs/Maths/math.vector";
  8577. /** Defines supported spaces */
  8578. export enum Space {
  8579. /** Local (object) space */
  8580. LOCAL = 0,
  8581. /** World space */
  8582. WORLD = 1,
  8583. /** Bone space */
  8584. BONE = 2
  8585. }
  8586. /** Defines the 3 main axes */
  8587. export class Axis {
  8588. /** X axis */
  8589. static X: Vector3;
  8590. /** Y axis */
  8591. static Y: Vector3;
  8592. /** Z axis */
  8593. static Z: Vector3;
  8594. }
  8595. }
  8596. declare module "babylonjs/Cameras/targetCamera" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Camera } from "babylonjs/Cameras/camera";
  8599. import { Scene } from "babylonjs/scene";
  8600. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8601. /**
  8602. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8603. * This is the base of the follow, arc rotate cameras and Free camera
  8604. * @see http://doc.babylonjs.com/features/cameras
  8605. */
  8606. export class TargetCamera extends Camera {
  8607. private static _RigCamTransformMatrix;
  8608. private static _TargetTransformMatrix;
  8609. private static _TargetFocalPoint;
  8610. /**
  8611. * Define the current direction the camera is moving to
  8612. */
  8613. cameraDirection: Vector3;
  8614. /**
  8615. * Define the current rotation the camera is rotating to
  8616. */
  8617. cameraRotation: Vector2;
  8618. /**
  8619. * When set, the up vector of the camera will be updated by the rotation of the camera
  8620. */
  8621. updateUpVectorFromRotation: boolean;
  8622. private _tmpQuaternion;
  8623. /**
  8624. * Define the current rotation of the camera
  8625. */
  8626. rotation: Vector3;
  8627. /**
  8628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8629. */
  8630. rotationQuaternion: Quaternion;
  8631. /**
  8632. * Define the current speed of the camera
  8633. */
  8634. speed: number;
  8635. /**
  8636. * Add constraint to the camera to prevent it to move freely in all directions and
  8637. * around all axis.
  8638. */
  8639. noRotationConstraint: boolean;
  8640. /**
  8641. * Define the current target of the camera as an object or a position.
  8642. */
  8643. lockedTarget: any;
  8644. /** @hidden */
  8645. _currentTarget: Vector3;
  8646. /** @hidden */
  8647. _initialFocalDistance: number;
  8648. /** @hidden */
  8649. _viewMatrix: Matrix;
  8650. /** @hidden */
  8651. _camMatrix: Matrix;
  8652. /** @hidden */
  8653. _cameraTransformMatrix: Matrix;
  8654. /** @hidden */
  8655. _cameraRotationMatrix: Matrix;
  8656. /** @hidden */
  8657. _referencePoint: Vector3;
  8658. /** @hidden */
  8659. _transformedReferencePoint: Vector3;
  8660. protected _globalCurrentTarget: Vector3;
  8661. protected _globalCurrentUpVector: Vector3;
  8662. /** @hidden */
  8663. _reset: () => void;
  8664. private _defaultUp;
  8665. /**
  8666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8667. * This is the base of the follow, arc rotate cameras and Free camera
  8668. * @see http://doc.babylonjs.com/features/cameras
  8669. * @param name Defines the name of the camera in the scene
  8670. * @param position Defines the start position of the camera in the scene
  8671. * @param scene Defines the scene the camera belongs to
  8672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8675. /**
  8676. * Gets the position in front of the camera at a given distance.
  8677. * @param distance The distance from the camera we want the position to be
  8678. * @returns the position
  8679. */
  8680. getFrontPosition(distance: number): Vector3;
  8681. /** @hidden */
  8682. _getLockedTargetPosition(): Nullable<Vector3>;
  8683. private _storedPosition;
  8684. private _storedRotation;
  8685. private _storedRotationQuaternion;
  8686. /**
  8687. * Store current camera state of the camera (fov, position, rotation, etc..)
  8688. * @returns the camera
  8689. */
  8690. storeState(): Camera;
  8691. /**
  8692. * Restored camera state. You must call storeState() first
  8693. * @returns whether it was successful or not
  8694. * @hidden
  8695. */
  8696. _restoreStateValues(): boolean;
  8697. /** @hidden */
  8698. _initCache(): void;
  8699. /** @hidden */
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. /** @hidden */
  8702. _isSynchronizedViewMatrix(): boolean;
  8703. /** @hidden */
  8704. _computeLocalCameraSpeed(): number;
  8705. /**
  8706. * Defines the target the camera should look at.
  8707. * @param target Defines the new target as a Vector or a mesh
  8708. */
  8709. setTarget(target: Vector3): void;
  8710. /**
  8711. * Return the current target position of the camera. This value is expressed in local space.
  8712. * @returns the target position
  8713. */
  8714. getTarget(): Vector3;
  8715. /** @hidden */
  8716. _decideIfNeedsToMove(): boolean;
  8717. /** @hidden */
  8718. _updatePosition(): void;
  8719. /** @hidden */
  8720. _checkInputs(): void;
  8721. protected _updateCameraRotationMatrix(): void;
  8722. /**
  8723. * 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)
  8724. * @returns the current camera
  8725. */
  8726. private _rotateUpVectorWithCameraRotationMatrix;
  8727. private _cachedRotationZ;
  8728. private _cachedQuaternionRotationZ;
  8729. /** @hidden */
  8730. _getViewMatrix(): Matrix;
  8731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8732. /**
  8733. * @hidden
  8734. */
  8735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8736. /**
  8737. * @hidden
  8738. */
  8739. _updateRigCameras(): void;
  8740. private _getRigCamPositionAndTarget;
  8741. /**
  8742. * Gets the current object class name.
  8743. * @return the class name
  8744. */
  8745. getClassName(): string;
  8746. }
  8747. }
  8748. declare module "babylonjs/Events/keyboardEvents" {
  8749. /**
  8750. * Gather the list of keyboard event types as constants.
  8751. */
  8752. export class KeyboardEventTypes {
  8753. /**
  8754. * The keydown event is fired when a key becomes active (pressed).
  8755. */
  8756. static readonly KEYDOWN: number;
  8757. /**
  8758. * The keyup event is fired when a key has been released.
  8759. */
  8760. static readonly KEYUP: number;
  8761. }
  8762. /**
  8763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8764. */
  8765. export class KeyboardInfo {
  8766. /**
  8767. * Defines the type of event (KeyboardEventTypes)
  8768. */
  8769. type: number;
  8770. /**
  8771. * Defines the related dom event
  8772. */
  8773. event: KeyboardEvent;
  8774. /**
  8775. * Instantiates a new keyboard info.
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. /**
  8791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8793. */
  8794. export class KeyboardInfoPre extends KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8805. */
  8806. skipOnPointerObservable: boolean;
  8807. /**
  8808. * Instantiates a new keyboard pre info.
  8809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8810. * @param type Defines the type of event (KeyboardEventTypes)
  8811. * @param event Defines the related dom event
  8812. */
  8813. constructor(
  8814. /**
  8815. * Defines the type of event (KeyboardEventTypes)
  8816. */
  8817. type: number,
  8818. /**
  8819. * Defines the related dom event
  8820. */
  8821. event: KeyboardEvent);
  8822. }
  8823. }
  8824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8825. import { Nullable } from "babylonjs/types";
  8826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8828. /**
  8829. * Manage the keyboard inputs to control the movement of a free camera.
  8830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8831. */
  8832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8833. /**
  8834. * Defines the camera the input is attached to.
  8835. */
  8836. camera: FreeCamera;
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8839. */
  8840. keysUp: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8843. */
  8844. keysDown: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8847. */
  8848. keysLeft: number[];
  8849. /**
  8850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8851. */
  8852. keysRight: number[];
  8853. private _keys;
  8854. private _onCanvasBlurObserver;
  8855. private _onKeyboardObserver;
  8856. private _engine;
  8857. private _scene;
  8858. /**
  8859. * Attach the input controls to a specific dom element to get the input from.
  8860. * @param element Defines the element the controls should be listened from
  8861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8862. */
  8863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8864. /**
  8865. * Detach the current controls from the specified dom element.
  8866. * @param element Defines the element to stop listening the inputs from
  8867. */
  8868. detachControl(element: Nullable<HTMLElement>): void;
  8869. /**
  8870. * Update the current camera state depending on the inputs that have been used this frame.
  8871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8872. */
  8873. checkInputs(): void;
  8874. /**
  8875. * Gets the class name of the current intput.
  8876. * @returns the class name
  8877. */
  8878. getClassName(): string;
  8879. /** @hidden */
  8880. _onLostFocus(): void;
  8881. /**
  8882. * Get the friendly name associated with the input class.
  8883. * @returns the input friendly name
  8884. */
  8885. getSimpleName(): string;
  8886. }
  8887. }
  8888. declare module "babylonjs/Lights/shadowLight" {
  8889. import { Camera } from "babylonjs/Cameras/camera";
  8890. import { Scene } from "babylonjs/scene";
  8891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8893. import { Light } from "babylonjs/Lights/light";
  8894. /**
  8895. * Interface describing all the common properties and methods a shadow light needs to implement.
  8896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8897. * as well as binding the different shadow properties to the effects.
  8898. */
  8899. export interface IShadowLight extends Light {
  8900. /**
  8901. * The light id in the scene (used in scene.findLighById for instance)
  8902. */
  8903. id: string;
  8904. /**
  8905. * The position the shdow will be casted from.
  8906. */
  8907. position: Vector3;
  8908. /**
  8909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8910. */
  8911. direction: Vector3;
  8912. /**
  8913. * The transformed position. Position of the light in world space taking parenting in account.
  8914. */
  8915. transformedPosition: Vector3;
  8916. /**
  8917. * The transformed direction. Direction of the light in world space taking parenting in account.
  8918. */
  8919. transformedDirection: Vector3;
  8920. /**
  8921. * The friendly name of the light in the scene.
  8922. */
  8923. name: string;
  8924. /**
  8925. * Defines the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. /**
  8929. * Defines the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Gets the scene the light belongs to.
  8939. * @returns The scene
  8940. */
  8941. getScene(): Scene;
  8942. /**
  8943. * Callback defining a custom Projection Matrix Builder.
  8944. * This can be used to override the default projection matrix computation.
  8945. */
  8946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8947. /**
  8948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8949. * @param matrix The materix to updated with the projection information
  8950. * @param viewMatrix The transform matrix of the light
  8951. * @param renderList The list of mesh to render in the map
  8952. * @returns The current light
  8953. */
  8954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8955. /**
  8956. * Gets the current depth scale used in ESM.
  8957. * @returns The scale
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8962. * @returns true if a cube texture needs to be use
  8963. */
  8964. needCube(): boolean;
  8965. /**
  8966. * Detects if the projection matrix requires to be recomputed this frame.
  8967. * @returns true if it requires to be recomputed otherwise, false.
  8968. */
  8969. needProjectionMatrixCompute(): boolean;
  8970. /**
  8971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8972. */
  8973. forceProjectionMatrixCompute(): void;
  8974. /**
  8975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8978. */
  8979. getShadowDirection(faceIndex?: number): Vector3;
  8980. /**
  8981. * Gets the minZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the min for
  8983. * @returns the depth min z
  8984. */
  8985. getDepthMinZ(activeCamera: Camera): number;
  8986. /**
  8987. * Gets the maxZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the max for
  8989. * @returns the depth max z
  8990. */
  8991. getDepthMaxZ(activeCamera: Camera): number;
  8992. }
  8993. /**
  8994. * Base implementation IShadowLight
  8995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8996. */
  8997. export abstract class ShadowLight extends Light implements IShadowLight {
  8998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8999. protected _position: Vector3;
  9000. protected _setPosition(value: Vector3): void;
  9001. /**
  9002. * Sets the position the shadow will be casted from. Also use as the light position for both
  9003. * point and spot lights.
  9004. */
  9005. get position(): Vector3;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. set position(value: Vector3);
  9011. protected _direction: Vector3;
  9012. protected _setDirection(value: Vector3): void;
  9013. /**
  9014. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. get direction(): Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9020. * Also use as the light direction on spot and directional lights.
  9021. */
  9022. set direction(value: Vector3);
  9023. protected _shadowMinZ: number;
  9024. /**
  9025. * Gets the shadow projection clipping minimum z value.
  9026. */
  9027. get shadowMinZ(): number;
  9028. /**
  9029. * Sets the shadow projection clipping minimum z value.
  9030. */
  9031. set shadowMinZ(value: number);
  9032. protected _shadowMaxZ: number;
  9033. /**
  9034. * Sets the shadow projection clipping maximum z value.
  9035. */
  9036. get shadowMaxZ(): number;
  9037. /**
  9038. * Gets the shadow projection clipping maximum z value.
  9039. */
  9040. set shadowMaxZ(value: number);
  9041. /**
  9042. * Callback defining a custom Projection Matrix Builder.
  9043. * This can be used to override the default projection matrix computation.
  9044. */
  9045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9046. /**
  9047. * The transformed position. Position of the light in world space taking parenting in account.
  9048. */
  9049. transformedPosition: Vector3;
  9050. /**
  9051. * The transformed direction. Direction of the light in world space taking parenting in account.
  9052. */
  9053. transformedDirection: Vector3;
  9054. private _needProjectionMatrixCompute;
  9055. /**
  9056. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9057. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9058. */
  9059. computeTransformedInformation(): boolean;
  9060. /**
  9061. * Return the depth scale used for the shadow map.
  9062. * @returns the depth scale.
  9063. */
  9064. getDepthScale(): number;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Returns the ShadowLight absolute position in the World.
  9073. * @returns the position vector in world space
  9074. */
  9075. getAbsolutePosition(): Vector3;
  9076. /**
  9077. * Sets the ShadowLight direction toward the passed target.
  9078. * @param target The point to target in local space
  9079. * @returns the updated ShadowLight direction
  9080. */
  9081. setDirectionToTarget(target: Vector3): Vector3;
  9082. /**
  9083. * Returns the light rotation in euler definition.
  9084. * @returns the x y z rotation in local space.
  9085. */
  9086. getRotation(): Vector3;
  9087. /**
  9088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9089. * @returns true if a cube texture needs to be use
  9090. */
  9091. needCube(): boolean;
  9092. /**
  9093. * Detects if the projection matrix requires to be recomputed this frame.
  9094. * @returns true if it requires to be recomputed otherwise, false.
  9095. */
  9096. needProjectionMatrixCompute(): boolean;
  9097. /**
  9098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9099. */
  9100. forceProjectionMatrixCompute(): void;
  9101. /** @hidden */
  9102. _initCache(): void;
  9103. /** @hidden */
  9104. _isSynchronized(): boolean;
  9105. /**
  9106. * Computes the world matrix of the node
  9107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9108. * @returns the world matrix
  9109. */
  9110. computeWorldMatrix(force?: boolean): Matrix;
  9111. /**
  9112. * Gets the minZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the min for
  9114. * @returns the depth min z
  9115. */
  9116. getDepthMinZ(activeCamera: Camera): number;
  9117. /**
  9118. * Gets the maxZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the max for
  9120. * @returns the depth max z
  9121. */
  9122. getDepthMaxZ(activeCamera: Camera): number;
  9123. /**
  9124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9125. * @param matrix The materix to updated with the projection information
  9126. * @param viewMatrix The transform matrix of the light
  9127. * @param renderList The list of mesh to render in the map
  9128. * @returns The current light
  9129. */
  9130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9131. }
  9132. }
  9133. declare module "babylonjs/Materials/effectFallbacks" {
  9134. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9135. import { Effect } from "babylonjs/Materials/effect";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. /**
  9138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9140. */
  9141. export class EffectFallbacks implements IEffectFallbacks {
  9142. private _defines;
  9143. private _currentRank;
  9144. private _maxRank;
  9145. private _mesh;
  9146. /**
  9147. * Removes the fallback from the bound mesh.
  9148. */
  9149. unBindMesh(): void;
  9150. /**
  9151. * Adds a fallback on the specified property.
  9152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9153. * @param define The name of the define in the shader
  9154. */
  9155. addFallback(rank: number, define: string): void;
  9156. /**
  9157. * Sets the mesh to use CPU skinning when needing to fallback.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param mesh The mesh to use the fallbacks.
  9160. */
  9161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9162. /**
  9163. * Checks to see if more fallbacks are still availible.
  9164. */
  9165. get hasMoreFallbacks(): boolean;
  9166. /**
  9167. * Removes the defines that should be removed when falling back.
  9168. * @param currentDefines defines the current define statements for the shader.
  9169. * @param effect defines the current effect we try to compile
  9170. * @returns The resulting defines with defines of the current rank removed.
  9171. */
  9172. reduce(currentDefines: string, effect: Effect): string;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/materialHelper" {
  9176. import { Nullable } from "babylonjs/types";
  9177. import { Scene } from "babylonjs/scene";
  9178. import { Engine } from "babylonjs/Engines/engine";
  9179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9180. import { Light } from "babylonjs/Lights/light";
  9181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9185. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9186. /**
  9187. * "Static Class" containing the most commonly used helper while dealing with material for
  9188. * rendering purpose.
  9189. *
  9190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9191. *
  9192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9193. */
  9194. export class MaterialHelper {
  9195. /**
  9196. * Bind the current view position to an effect.
  9197. * @param effect The effect to be bound
  9198. * @param scene The scene the eyes position is used from
  9199. */
  9200. static BindEyePosition(effect: Effect, scene: Scene): void;
  9201. /**
  9202. * Helps preparing the defines values about the UVs in used in the effect.
  9203. * UVs are shared as much as we can accross channels in the shaders.
  9204. * @param texture The texture we are preparing the UVs for
  9205. * @param defines The defines to update
  9206. * @param key The channel key "diffuse", "specular"... used in the shader
  9207. */
  9208. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9209. /**
  9210. * Binds a texture matrix value to its corrsponding uniform
  9211. * @param texture The texture to bind the matrix for
  9212. * @param uniformBuffer The uniform buffer receivin the data
  9213. * @param key The channel key "diffuse", "specular"... used in the shader
  9214. */
  9215. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9216. /**
  9217. * Gets the current status of the fog (should it be enabled?)
  9218. * @param mesh defines the mesh to evaluate for fog support
  9219. * @param scene defines the hosting scene
  9220. * @returns true if fog must be enabled
  9221. */
  9222. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9223. /**
  9224. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9225. * @param mesh defines the current mesh
  9226. * @param scene defines the current scene
  9227. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9228. * @param pointsCloud defines if point cloud rendering has to be turned on
  9229. * @param fogEnabled defines if fog has to be turned on
  9230. * @param alphaTest defines if alpha testing has to be turned on
  9231. * @param defines defines the current list of defines
  9232. */
  9233. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9234. /**
  9235. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9236. * @param scene defines the current scene
  9237. * @param engine defines the current engine
  9238. * @param defines specifies the list of active defines
  9239. * @param useInstances defines if instances have to be turned on
  9240. * @param useClipPlane defines if clip plane have to be turned on
  9241. */
  9242. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9243. /**
  9244. * Prepares the defines for bones
  9245. * @param mesh The mesh containing the geometry data we will draw
  9246. * @param defines The defines to update
  9247. */
  9248. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9249. /**
  9250. * Prepares the defines for morph targets
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9260. * @param useBones Precise whether bones should be used or not (override mesh info)
  9261. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9262. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9263. * @returns false if defines are considered not dirty and have not been checked
  9264. */
  9265. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9266. /**
  9267. * Prepares the defines related to multiview
  9268. * @param scene The scene we are intending to draw
  9269. * @param defines The defines to update
  9270. */
  9271. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param light The light the effect is compiling for
  9277. * @param lightIndex The index of the light
  9278. * @param defines The defines to update
  9279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9280. * @param state Defines the current state regarding what is needed (normals, etc...)
  9281. */
  9282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9283. needNormals: boolean;
  9284. needRebuild: boolean;
  9285. shadowEnabled: boolean;
  9286. specularEnabled: boolean;
  9287. lightmapMode: boolean;
  9288. }): void;
  9289. /**
  9290. * Prepares the defines related to the light information passed in parameter
  9291. * @param scene The scene we are intending to draw
  9292. * @param mesh The mesh the effect is compiling for
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9297. * @returns true if normals will be required for the rest of the effect
  9298. */
  9299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9300. /**
  9301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9302. * @param lightIndex defines the light index
  9303. * @param uniformsList The uniform list
  9304. * @param samplersList The sampler list
  9305. * @param projectedLightTexture defines if projected texture must be used
  9306. * @param uniformBuffersList defines an optional list of uniform buffers
  9307. */
  9308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9309. /**
  9310. * Prepares the uniforms and samplers list to be used in the effect
  9311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9312. * @param samplersList The sampler list
  9313. * @param defines The defines helping in the list generation
  9314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9315. */
  9316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9317. /**
  9318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9319. * @param defines The defines to update while falling back
  9320. * @param fallbacks The authorized effect fallbacks
  9321. * @param maxSimultaneousLights The maximum number of lights allowed
  9322. * @param rank the current rank of the Effect
  9323. * @returns The newly affected rank
  9324. */
  9325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9326. private static _TmpMorphInfluencers;
  9327. /**
  9328. * Prepares the list of attributes required for morph targets according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the morph targets attributes for
  9331. * @param influencers The number of influencers
  9332. */
  9333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9334. /**
  9335. * Prepares the list of attributes required for morph targets according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param mesh The mesh to prepare the morph targets attributes for
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9341. /**
  9342. * Prepares the list of attributes required for bones according to the effect defines.
  9343. * @param attribs The current list of supported attribs
  9344. * @param mesh The mesh to prepare the bones attributes for
  9345. * @param defines The current Defines of the effect
  9346. * @param fallbacks The current efffect fallback strategy
  9347. */
  9348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9349. /**
  9350. * Check and prepare the list of attributes required for instances according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param defines The current MaterialDefines of the effect
  9353. */
  9354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9355. /**
  9356. * Add the list of attributes required for instances to the attribs array.
  9357. * @param attribs The current list of supported attribs
  9358. */
  9359. static PushAttributesForInstances(attribs: string[]): void;
  9360. /**
  9361. * Binds the light information to the effect.
  9362. * @param light The light containing the generator
  9363. * @param effect The effect we are binding the data to
  9364. * @param lightIndex The light index in the effect used to render
  9365. */
  9366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9367. /**
  9368. * Binds the lights information from the scene to the effect for the given mesh.
  9369. * @param light Light to bind
  9370. * @param lightIndex Light index
  9371. * @param scene The scene where the light belongs to
  9372. * @param effect The effect we are binding the data to
  9373. * @param useSpecular Defines if specular is supported
  9374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9375. */
  9376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9377. /**
  9378. * Binds the lights information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param defines The generated defines for the effect
  9383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9385. */
  9386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9387. private static _tempFogColor;
  9388. /**
  9389. * Binds the fog information from the scene to the effect for the given mesh.
  9390. * @param scene The scene the lights belongs to
  9391. * @param mesh The mesh we are binding the information to render
  9392. * @param effect The effect we are binding the data to
  9393. * @param linearSpace Defines if the fog effect is applied in linear space
  9394. */
  9395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9396. /**
  9397. * Binds the bones information from the mesh to the effect.
  9398. * @param mesh The mesh we are binding the information to render
  9399. * @param effect The effect we are binding the data to
  9400. */
  9401. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9402. /**
  9403. * Binds the morph targets information from the mesh to the effect.
  9404. * @param abstractMesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9408. /**
  9409. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9410. * @param defines The generated defines used in the effect
  9411. * @param effect The effect we are binding the data to
  9412. * @param scene The scene we are willing to render with logarithmic scale for
  9413. */
  9414. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9415. /**
  9416. * Binds the clip plane information from the scene to the effect.
  9417. * @param scene The scene the clip plane information are extracted from
  9418. * @param effect The effect we are binding the data to
  9419. */
  9420. static BindClipPlane(effect: Effect, scene: Scene): void;
  9421. }
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9424. /** @hidden */
  9425. export var packingFunctions: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9431. /** @hidden */
  9432. export var clipPlaneFragmentDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9438. /** @hidden */
  9439. export var clipPlaneFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. /** @hidden */
  9449. export var shadowMapPixelShader: {
  9450. name: string;
  9451. shader: string;
  9452. };
  9453. }
  9454. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9455. /** @hidden */
  9456. export var bonesDeclaration: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9462. /** @hidden */
  9463. export var morphTargetsVertexGlobalDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9476. /** @hidden */
  9477. export var instancesDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9483. /** @hidden */
  9484. export var helperFunctions: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9490. /** @hidden */
  9491. export var clipPlaneVertexDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9518. /** @hidden */
  9519. export var clipPlaneVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9535. /** @hidden */
  9536. export var shadowMapVertexShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9542. /** @hidden */
  9543. export var depthBoxBlurPixelShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Culling/ray" {
  9549. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9550. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9553. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9554. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9555. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9556. import { Plane } from "babylonjs/Maths/math.plane";
  9557. /**
  9558. * Class representing a ray with position and direction
  9559. */
  9560. export class Ray {
  9561. /** origin point */
  9562. origin: Vector3;
  9563. /** direction */
  9564. direction: Vector3;
  9565. /** length of the ray */
  9566. length: number;
  9567. private static readonly TmpVector3;
  9568. private _tmpRay;
  9569. /**
  9570. * Creates a new ray
  9571. * @param origin origin point
  9572. * @param direction direction
  9573. * @param length length of the ray
  9574. */
  9575. constructor(
  9576. /** origin point */
  9577. origin: Vector3,
  9578. /** direction */
  9579. direction: Vector3,
  9580. /** length of the ray */
  9581. length?: number);
  9582. /**
  9583. * Checks if the ray intersects a box
  9584. * @param minimum bound of the box
  9585. * @param maximum bound of the box
  9586. * @param intersectionTreshold extra extend to be added to the box in all direction
  9587. * @returns if the box was hit
  9588. */
  9589. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9590. /**
  9591. * Checks if the ray intersects a box
  9592. * @param box the bounding box to check
  9593. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9594. * @returns if the box was hit
  9595. */
  9596. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9597. /**
  9598. * If the ray hits a sphere
  9599. * @param sphere the bounding sphere to check
  9600. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9601. * @returns true if it hits the sphere
  9602. */
  9603. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9604. /**
  9605. * If the ray hits a triange
  9606. * @param vertex0 triangle vertex
  9607. * @param vertex1 triangle vertex
  9608. * @param vertex2 triangle vertex
  9609. * @returns intersection information if hit
  9610. */
  9611. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9612. /**
  9613. * Checks if ray intersects a plane
  9614. * @param plane the plane to check
  9615. * @returns the distance away it was hit
  9616. */
  9617. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9618. /**
  9619. * Calculate the intercept of a ray on a given axis
  9620. * @param axis to check 'x' | 'y' | 'z'
  9621. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9622. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9623. */
  9624. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9625. /**
  9626. * Checks if ray intersects a mesh
  9627. * @param mesh the mesh to check
  9628. * @param fastCheck if only the bounding box should checked
  9629. * @returns picking info of the intersecton
  9630. */
  9631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9632. /**
  9633. * Checks if ray intersects a mesh
  9634. * @param meshes the meshes to check
  9635. * @param fastCheck if only the bounding box should checked
  9636. * @param results array to store result in
  9637. * @returns Array of picking infos
  9638. */
  9639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9640. private _comparePickingInfo;
  9641. private static smallnum;
  9642. private static rayl;
  9643. /**
  9644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9645. * @param sega the first point of the segment to test the intersection against
  9646. * @param segb the second point of the segment to test the intersection against
  9647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9649. */
  9650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9651. /**
  9652. * Update the ray from viewport position
  9653. * @param x position
  9654. * @param y y position
  9655. * @param viewportWidth viewport width
  9656. * @param viewportHeight viewport height
  9657. * @param world world matrix
  9658. * @param view view matrix
  9659. * @param projection projection matrix
  9660. * @returns this ray updated
  9661. */
  9662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9663. /**
  9664. * Creates a ray with origin and direction of 0,0,0
  9665. * @returns the new ray
  9666. */
  9667. static Zero(): Ray;
  9668. /**
  9669. * Creates a new ray from screen space and viewport
  9670. * @param x position
  9671. * @param y y position
  9672. * @param viewportWidth viewport width
  9673. * @param viewportHeight viewport height
  9674. * @param world world matrix
  9675. * @param view view matrix
  9676. * @param projection projection matrix
  9677. * @returns new ray
  9678. */
  9679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9680. /**
  9681. * 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
  9682. * transformed to the given world matrix.
  9683. * @param origin The origin point
  9684. * @param end The end point
  9685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9686. * @returns the new ray
  9687. */
  9688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9689. /**
  9690. * Transforms a ray by a matrix
  9691. * @param ray ray to transform
  9692. * @param matrix matrix to apply
  9693. * @returns the resulting new ray
  9694. */
  9695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9696. /**
  9697. * Transforms a ray by a matrix
  9698. * @param ray ray to transform
  9699. * @param matrix matrix to apply
  9700. * @param result ray to store result in
  9701. */
  9702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9703. /**
  9704. * Unproject a ray from screen space to object space
  9705. * @param sourceX defines the screen space x coordinate to use
  9706. * @param sourceY defines the screen space y coordinate to use
  9707. * @param viewportWidth defines the current width of the viewport
  9708. * @param viewportHeight defines the current height of the viewport
  9709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9710. * @param view defines the view matrix to use
  9711. * @param projection defines the projection matrix to use
  9712. */
  9713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9714. }
  9715. /**
  9716. * Type used to define predicate used to select faces when a mesh intersection is detected
  9717. */
  9718. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9719. module "babylonjs/scene" {
  9720. interface Scene {
  9721. /** @hidden */
  9722. _tempPickingRay: Nullable<Ray>;
  9723. /** @hidden */
  9724. _cachedRayForTransform: Ray;
  9725. /** @hidden */
  9726. _pickWithRayInverseMatrix: Matrix;
  9727. /** @hidden */
  9728. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9729. /** @hidden */
  9730. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9731. }
  9732. }
  9733. }
  9734. declare module "babylonjs/sceneComponent" {
  9735. import { Scene } from "babylonjs/scene";
  9736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9738. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9740. import { Nullable } from "babylonjs/types";
  9741. import { Camera } from "babylonjs/Cameras/camera";
  9742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9744. import { AbstractScene } from "babylonjs/abstractScene";
  9745. import { Mesh } from "babylonjs/Meshes/mesh";
  9746. /**
  9747. * Groups all the scene component constants in one place to ease maintenance.
  9748. * @hidden
  9749. */
  9750. export class SceneComponentConstants {
  9751. static readonly NAME_EFFECTLAYER: string;
  9752. static readonly NAME_LAYER: string;
  9753. static readonly NAME_LENSFLARESYSTEM: string;
  9754. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9755. static readonly NAME_PARTICLESYSTEM: string;
  9756. static readonly NAME_GAMEPAD: string;
  9757. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9758. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9759. static readonly NAME_DEPTHRENDERER: string;
  9760. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9761. static readonly NAME_SPRITE: string;
  9762. static readonly NAME_OUTLINERENDERER: string;
  9763. static readonly NAME_PROCEDURALTEXTURE: string;
  9764. static readonly NAME_SHADOWGENERATOR: string;
  9765. static readonly NAME_OCTREE: string;
  9766. static readonly NAME_PHYSICSENGINE: string;
  9767. static readonly NAME_AUDIO: string;
  9768. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9769. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9770. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9771. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9772. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9773. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9774. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9788. static readonly STEP_AFTERRENDER_AUDIO: number;
  9789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9794. static readonly STEP_POINTERMOVE_SPRITE: number;
  9795. static readonly STEP_POINTERDOWN_SPRITE: number;
  9796. static readonly STEP_POINTERUP_SPRITE: number;
  9797. }
  9798. /**
  9799. * This represents a scene component.
  9800. *
  9801. * This is used to decouple the dependency the scene is having on the different workloads like
  9802. * layers, post processes...
  9803. */
  9804. export interface ISceneComponent {
  9805. /**
  9806. * The name of the component. Each component must have a unique name.
  9807. */
  9808. name: string;
  9809. /**
  9810. * The scene the component belongs to.
  9811. */
  9812. scene: Scene;
  9813. /**
  9814. * Register the component to one instance of a scene.
  9815. */
  9816. register(): void;
  9817. /**
  9818. * Rebuilds the elements related to this component in case of
  9819. * context lost for instance.
  9820. */
  9821. rebuild(): void;
  9822. /**
  9823. * Disposes the component and the associated ressources.
  9824. */
  9825. dispose(): void;
  9826. }
  9827. /**
  9828. * This represents a SERIALIZABLE scene component.
  9829. *
  9830. * This extends Scene Component to add Serialization methods on top.
  9831. */
  9832. export interface ISceneSerializableComponent extends ISceneComponent {
  9833. /**
  9834. * Adds all the elements from the container to the scene
  9835. * @param container the container holding the elements
  9836. */
  9837. addFromContainer(container: AbstractScene): void;
  9838. /**
  9839. * Removes all the elements in the container from the scene
  9840. * @param container contains the elements to remove
  9841. * @param dispose if the removed element should be disposed (default: false)
  9842. */
  9843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9844. /**
  9845. * Serializes the component data to the specified json object
  9846. * @param serializationObject The object to serialize to
  9847. */
  9848. serialize(serializationObject: any): void;
  9849. }
  9850. /**
  9851. * Strong typing of a Mesh related stage step action
  9852. */
  9853. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9854. /**
  9855. * Strong typing of a Evaluate Sub Mesh related stage step action
  9856. */
  9857. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9858. /**
  9859. * Strong typing of a Active Mesh related stage step action
  9860. */
  9861. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9862. /**
  9863. * Strong typing of a Camera related stage step action
  9864. */
  9865. export type CameraStageAction = (camera: Camera) => void;
  9866. /**
  9867. * Strong typing of a Camera Frame buffer related stage step action
  9868. */
  9869. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9870. /**
  9871. * Strong typing of a Render Target related stage step action
  9872. */
  9873. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9874. /**
  9875. * Strong typing of a RenderingGroup related stage step action
  9876. */
  9877. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9878. /**
  9879. * Strong typing of a Mesh Render related stage step action
  9880. */
  9881. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9882. /**
  9883. * Strong typing of a simple stage step action
  9884. */
  9885. export type SimpleStageAction = () => void;
  9886. /**
  9887. * Strong typing of a render target action.
  9888. */
  9889. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9890. /**
  9891. * Strong typing of a pointer move action.
  9892. */
  9893. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9894. /**
  9895. * Strong typing of a pointer up/down action.
  9896. */
  9897. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9898. /**
  9899. * Representation of a stage in the scene (Basically a list of ordered steps)
  9900. * @hidden
  9901. */
  9902. export class Stage<T extends Function> extends Array<{
  9903. index: number;
  9904. component: ISceneComponent;
  9905. action: T;
  9906. }> {
  9907. /**
  9908. * Hide ctor from the rest of the world.
  9909. * @param items The items to add.
  9910. */
  9911. private constructor();
  9912. /**
  9913. * Creates a new Stage.
  9914. * @returns A new instance of a Stage
  9915. */
  9916. static Create<T extends Function>(): Stage<T>;
  9917. /**
  9918. * Registers a step in an ordered way in the targeted stage.
  9919. * @param index Defines the position to register the step in
  9920. * @param component Defines the component attached to the step
  9921. * @param action Defines the action to launch during the step
  9922. */
  9923. registerStep(index: number, component: ISceneComponent, action: T): void;
  9924. /**
  9925. * Clears all the steps from the stage.
  9926. */
  9927. clear(): void;
  9928. }
  9929. }
  9930. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Observable } from "babylonjs/Misc/observable";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Sprite } from "babylonjs/Sprites/sprite";
  9935. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9936. import { Ray } from "babylonjs/Culling/ray";
  9937. import { Camera } from "babylonjs/Cameras/camera";
  9938. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9939. import { ISceneComponent } from "babylonjs/sceneComponent";
  9940. module "babylonjs/scene" {
  9941. interface Scene {
  9942. /** @hidden */
  9943. _pointerOverSprite: Nullable<Sprite>;
  9944. /** @hidden */
  9945. _pickedDownSprite: Nullable<Sprite>;
  9946. /** @hidden */
  9947. _tempSpritePickingRay: Nullable<Ray>;
  9948. /**
  9949. * All of the sprite managers added to this scene
  9950. * @see http://doc.babylonjs.com/babylon101/sprites
  9951. */
  9952. spriteManagers: Array<ISpriteManager>;
  9953. /**
  9954. * An event triggered when sprites rendering is about to start
  9955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9956. */
  9957. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9958. /**
  9959. * An event triggered when sprites rendering is done
  9960. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9961. */
  9962. onAfterSpritesRenderingObservable: Observable<Scene>;
  9963. /** @hidden */
  9964. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9965. /** Launch a ray to try to pick a sprite in the scene
  9966. * @param x position on screen
  9967. * @param y position on screen
  9968. * @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
  9969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9970. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9971. * @returns a PickingInfo
  9972. */
  9973. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9974. /** Use the given ray to pick a sprite in the scene
  9975. * @param ray The ray (in world space) to use to pick meshes
  9976. * @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
  9977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9979. * @returns a PickingInfo
  9980. */
  9981. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9982. /** @hidden */
  9983. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9984. /** Launch a ray to try to pick sprites in the scene
  9985. * @param x position on screen
  9986. * @param y position on screen
  9987. * @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
  9988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9989. * @returns a PickingInfo array
  9990. */
  9991. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9992. /** Use the given ray to pick sprites in the scene
  9993. * @param ray The ray (in world space) to use to pick meshes
  9994. * @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
  9995. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9996. * @returns a PickingInfo array
  9997. */
  9998. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9999. /**
  10000. * Force the sprite under the pointer
  10001. * @param sprite defines the sprite to use
  10002. */
  10003. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10004. /**
  10005. * Gets the sprite under the pointer
  10006. * @returns a Sprite or null if no sprite is under the pointer
  10007. */
  10008. getPointerOverSprite(): Nullable<Sprite>;
  10009. }
  10010. }
  10011. /**
  10012. * Defines the sprite scene component responsible to manage sprites
  10013. * in a given scene.
  10014. */
  10015. export class SpriteSceneComponent implements ISceneComponent {
  10016. /**
  10017. * The component name helpfull to identify the component in the list of scene components.
  10018. */
  10019. readonly name: string;
  10020. /**
  10021. * The scene the component belongs to.
  10022. */
  10023. scene: Scene;
  10024. /** @hidden */
  10025. private _spritePredicate;
  10026. /**
  10027. * Creates a new instance of the component for the given scene
  10028. * @param scene Defines the scene to register the component in
  10029. */
  10030. constructor(scene: Scene);
  10031. /**
  10032. * Registers the component in a given scene
  10033. */
  10034. register(): void;
  10035. /**
  10036. * Rebuilds the elements related to this component in case of
  10037. * context lost for instance.
  10038. */
  10039. rebuild(): void;
  10040. /**
  10041. * Disposes the component and the associated ressources.
  10042. */
  10043. dispose(): void;
  10044. private _pickSpriteButKeepRay;
  10045. private _pointerMove;
  10046. private _pointerDown;
  10047. private _pointerUp;
  10048. }
  10049. }
  10050. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10051. /** @hidden */
  10052. export var fogFragmentDeclaration: {
  10053. name: string;
  10054. shader: string;
  10055. };
  10056. }
  10057. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10058. /** @hidden */
  10059. export var fogFragment: {
  10060. name: string;
  10061. shader: string;
  10062. };
  10063. }
  10064. declare module "babylonjs/Shaders/sprites.fragment" {
  10065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10066. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10067. /** @hidden */
  10068. export var spritesPixelShader: {
  10069. name: string;
  10070. shader: string;
  10071. };
  10072. }
  10073. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10074. /** @hidden */
  10075. export var fogVertexDeclaration: {
  10076. name: string;
  10077. shader: string;
  10078. };
  10079. }
  10080. declare module "babylonjs/Shaders/sprites.vertex" {
  10081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10082. /** @hidden */
  10083. export var spritesVertexShader: {
  10084. name: string;
  10085. shader: string;
  10086. };
  10087. }
  10088. declare module "babylonjs/Sprites/spriteManager" {
  10089. import { IDisposable, Scene } from "babylonjs/scene";
  10090. import { Nullable } from "babylonjs/types";
  10091. import { Observable } from "babylonjs/Misc/observable";
  10092. import { Sprite } from "babylonjs/Sprites/sprite";
  10093. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10094. import { Camera } from "babylonjs/Cameras/camera";
  10095. import { Texture } from "babylonjs/Materials/Textures/texture";
  10096. import "babylonjs/Shaders/sprites.fragment";
  10097. import "babylonjs/Shaders/sprites.vertex";
  10098. import { Ray } from "babylonjs/Culling/ray";
  10099. /**
  10100. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10101. */
  10102. export interface ISpriteManager extends IDisposable {
  10103. /**
  10104. * Restricts the camera to viewing objects with the same layerMask.
  10105. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10106. */
  10107. layerMask: number;
  10108. /**
  10109. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10110. */
  10111. isPickable: boolean;
  10112. /**
  10113. * Specifies the rendering group id for this mesh (0 by default)
  10114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10115. */
  10116. renderingGroupId: number;
  10117. /**
  10118. * Defines the list of sprites managed by the manager.
  10119. */
  10120. sprites: Array<Sprite>;
  10121. /**
  10122. * Tests the intersection of a sprite with a specific ray.
  10123. * @param ray The ray we are sending to test the collision
  10124. * @param camera The camera space we are sending rays in
  10125. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10126. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10127. * @returns picking info or null.
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Renders the list of sprites on screen.
  10140. */
  10141. render(): void;
  10142. }
  10143. /**
  10144. * Class used to manage multiple sprites on the same spritesheet
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class SpriteManager implements ISpriteManager {
  10148. /** defines the manager's name */
  10149. name: string;
  10150. /** Gets the list of sprites */
  10151. sprites: Sprite[];
  10152. /** Gets or sets the rendering group id (0 by default) */
  10153. renderingGroupId: number;
  10154. /** Gets or sets camera layer mask */
  10155. layerMask: number;
  10156. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10157. fogEnabled: boolean;
  10158. /** Gets or sets a boolean indicating if the sprites are pickable */
  10159. isPickable: boolean;
  10160. /** Defines the default width of a cell in the spritesheet */
  10161. cellWidth: number;
  10162. /** Defines the default height of a cell in the spritesheet */
  10163. cellHeight: number;
  10164. /** Associative array from JSON sprite data file */
  10165. private _cellData;
  10166. /** Array of sprite names from JSON sprite data file */
  10167. private _spriteMap;
  10168. /** True when packed cell data from JSON file is ready*/
  10169. private _packedAndReady;
  10170. /**
  10171. * An event triggered when the manager is disposed.
  10172. */
  10173. onDisposeObservable: Observable<SpriteManager>;
  10174. private _onDisposeObserver;
  10175. /**
  10176. * Callback called when the manager is disposed
  10177. */
  10178. set onDispose(callback: () => void);
  10179. private _capacity;
  10180. private _fromPacked;
  10181. private _spriteTexture;
  10182. private _epsilon;
  10183. private _scene;
  10184. private _vertexData;
  10185. private _buffer;
  10186. private _vertexBuffers;
  10187. private _indexBuffer;
  10188. private _effectBase;
  10189. private _effectFog;
  10190. /**
  10191. * Gets or sets the spritesheet texture
  10192. */
  10193. get texture(): Texture;
  10194. set texture(value: Texture);
  10195. private _blendMode;
  10196. /**
  10197. * Blend mode use to render the particle, it can be any of
  10198. * the static Constants.ALPHA_x properties provided in this class.
  10199. * Default value is Constants.ALPHA_COMBINE
  10200. */
  10201. get blendMode(): number;
  10202. set blendMode(blendMode: number);
  10203. /** Disables writing to the depth buffer when rendering the sprites.
  10204. * It can be handy to disable depth writing when using textures without alpha channel
  10205. * and setting some specific blend modes.
  10206. */
  10207. disableDepthWrite: boolean;
  10208. /**
  10209. * Creates a new sprite manager
  10210. * @param name defines the manager's name
  10211. * @param imgUrl defines the sprite sheet url
  10212. * @param capacity defines the maximum allowed number of sprites
  10213. * @param cellSize defines the size of a sprite cell
  10214. * @param scene defines the hosting scene
  10215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10216. * @param samplingMode defines the smapling mode to use with spritesheet
  10217. * @param fromPacked set to false; do not alter
  10218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10219. */
  10220. constructor(
  10221. /** defines the manager's name */
  10222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10223. private _makePacked;
  10224. private _appendSpriteVertex;
  10225. /**
  10226. * Intersects the sprites with a ray
  10227. * @param ray defines the ray to intersect with
  10228. * @param camera defines the current active camera
  10229. * @param predicate defines a predicate used to select candidate sprites
  10230. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10231. * @returns null if no hit or a PickingInfo
  10232. */
  10233. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10234. /**
  10235. * Intersects the sprites with a ray
  10236. * @param ray defines the ray to intersect with
  10237. * @param camera defines the current active camera
  10238. * @param predicate defines a predicate used to select candidate sprites
  10239. * @returns null if no hit or a PickingInfo array
  10240. */
  10241. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10242. /**
  10243. * Render all child sprites
  10244. */
  10245. render(): void;
  10246. /**
  10247. * Release associated resources
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Misc/gradients" {
  10253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10254. /** Interface used by value gradients (color, factor, ...) */
  10255. export interface IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. }
  10261. /** Class used to store color4 gradient */
  10262. export class ColorGradient implements IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. /**
  10268. * Gets or sets first associated color
  10269. */
  10270. color1: Color4;
  10271. /**
  10272. * Gets or sets second associated color
  10273. */
  10274. color2?: Color4;
  10275. /**
  10276. * Will get a color picked randomly between color1 and color2.
  10277. * If color2 is undefined then color1 will be used
  10278. * @param result defines the target Color4 to store the result in
  10279. */
  10280. getColorToRef(result: Color4): void;
  10281. }
  10282. /** Class used to store color 3 gradient */
  10283. export class Color3Gradient implements IValueGradient {
  10284. /**
  10285. * Gets or sets the gradient value (between 0 and 1)
  10286. */
  10287. gradient: number;
  10288. /**
  10289. * Gets or sets the associated color
  10290. */
  10291. color: Color3;
  10292. }
  10293. /** Class used to store factor gradient */
  10294. export class FactorGradient implements IValueGradient {
  10295. /**
  10296. * Gets or sets the gradient value (between 0 and 1)
  10297. */
  10298. gradient: number;
  10299. /**
  10300. * Gets or sets first associated factor
  10301. */
  10302. factor1: number;
  10303. /**
  10304. * Gets or sets second associated factor
  10305. */
  10306. factor2?: number;
  10307. /**
  10308. * Will get a number picked randomly between factor1 and factor2.
  10309. * If factor2 is undefined then factor1 will be used
  10310. * @returns the picked number
  10311. */
  10312. getFactor(): number;
  10313. }
  10314. /**
  10315. * Helper used to simplify some generic gradient tasks
  10316. */
  10317. export class GradientHelper {
  10318. /**
  10319. * Gets the current gradient from an array of IValueGradient
  10320. * @param ratio defines the current ratio to get
  10321. * @param gradients defines the array of IValueGradient
  10322. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10323. */
  10324. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Maths/math.size" {
  10328. /**
  10329. * Interface for the size containing width and height
  10330. */
  10331. export interface ISize {
  10332. /**
  10333. * Width
  10334. */
  10335. width: number;
  10336. /**
  10337. * Heighht
  10338. */
  10339. height: number;
  10340. }
  10341. /**
  10342. * Size containing widht and height
  10343. */
  10344. export class Size implements ISize {
  10345. /**
  10346. * Width
  10347. */
  10348. width: number;
  10349. /**
  10350. * Height
  10351. */
  10352. height: number;
  10353. /**
  10354. * Creates a Size object from the given width and height (floats).
  10355. * @param width width of the new size
  10356. * @param height height of the new size
  10357. */
  10358. constructor(width: number, height: number);
  10359. /**
  10360. * Returns a string with the Size width and height
  10361. * @returns a string with the Size width and height
  10362. */
  10363. toString(): string;
  10364. /**
  10365. * "Size"
  10366. * @returns the string "Size"
  10367. */
  10368. getClassName(): string;
  10369. /**
  10370. * Returns the Size hash code.
  10371. * @returns a hash code for a unique width and height
  10372. */
  10373. getHashCode(): number;
  10374. /**
  10375. * Updates the current size from the given one.
  10376. * @param src the given size
  10377. */
  10378. copyFrom(src: Size): void;
  10379. /**
  10380. * Updates in place the current Size from the given floats.
  10381. * @param width width of the new size
  10382. * @param height height of the new size
  10383. * @returns the updated Size.
  10384. */
  10385. copyFromFloats(width: number, height: number): Size;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width to set
  10389. * @param height height to set
  10390. * @returns the updated Size.
  10391. */
  10392. set(width: number, height: number): Size;
  10393. /**
  10394. * Multiplies the width and height by numbers
  10395. * @param w factor to multiple the width by
  10396. * @param h factor to multiple the height by
  10397. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10398. */
  10399. multiplyByFloats(w: number, h: number): Size;
  10400. /**
  10401. * Clones the size
  10402. * @returns a new Size copied from the given one.
  10403. */
  10404. clone(): Size;
  10405. /**
  10406. * True if the current Size and the given one width and height are strictly equal.
  10407. * @param other the other size to compare against
  10408. * @returns True if the current Size and the given one width and height are strictly equal.
  10409. */
  10410. equals(other: Size): boolean;
  10411. /**
  10412. * The surface of the Size : width * height (float).
  10413. */
  10414. get surface(): number;
  10415. /**
  10416. * Create a new size of zero
  10417. * @returns a new Size set to (0.0, 0.0)
  10418. */
  10419. static Zero(): Size;
  10420. /**
  10421. * Sums the width and height of two sizes
  10422. * @param otherSize size to add to this size
  10423. * @returns a new Size set as the addition result of the current Size and the given one.
  10424. */
  10425. add(otherSize: Size): Size;
  10426. /**
  10427. * Subtracts the width and height of two
  10428. * @param otherSize size to subtract to this size
  10429. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10430. */
  10431. subtract(otherSize: Size): Size;
  10432. /**
  10433. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10434. * @param start starting size to lerp between
  10435. * @param end end size to lerp between
  10436. * @param amount amount to lerp between the start and end values
  10437. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10438. */
  10439. static Lerp(start: Size, end: Size, amount: number): Size;
  10440. }
  10441. }
  10442. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10444. import { Nullable } from "babylonjs/types";
  10445. module "babylonjs/Engines/thinEngine" {
  10446. interface ThinEngine {
  10447. /**
  10448. * Creates a dynamic texture
  10449. * @param width defines the width of the texture
  10450. * @param height defines the height of the texture
  10451. * @param generateMipMaps defines if the engine should generate the mip levels
  10452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10453. * @returns the dynamic texture inside an InternalTexture
  10454. */
  10455. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10456. /**
  10457. * Update the content of a dynamic texture
  10458. * @param texture defines the texture to update
  10459. * @param canvas defines the canvas containing the source
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. * @param premulAlpha defines if alpha is stored as premultiplied
  10462. * @param format defines the format of the data
  10463. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10464. */
  10465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10466. }
  10467. }
  10468. }
  10469. declare module "babylonjs/Misc/canvasGenerator" {
  10470. /**
  10471. * Helper class used to generate a canvas to manipulate images
  10472. */
  10473. export class CanvasGenerator {
  10474. /**
  10475. * Create a new canvas (or offscreen canvas depending on the context)
  10476. * @param width defines the expected width
  10477. * @param height defines the expected height
  10478. * @return a new canvas or offscreen canvas
  10479. */
  10480. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10481. }
  10482. }
  10483. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10484. import { Scene } from "babylonjs/scene";
  10485. import { Texture } from "babylonjs/Materials/Textures/texture";
  10486. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10487. /**
  10488. * A class extending Texture allowing drawing on a texture
  10489. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10490. */
  10491. export class DynamicTexture extends Texture {
  10492. private _generateMipMaps;
  10493. private _canvas;
  10494. private _context;
  10495. private _engine;
  10496. /**
  10497. * Creates a DynamicTexture
  10498. * @param name defines the name of the texture
  10499. * @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
  10500. * @param scene defines the scene where you want the texture
  10501. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10502. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10503. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10504. */
  10505. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10506. /**
  10507. * Get the current class name of the texture useful for serialization or dynamic coding.
  10508. * @returns "DynamicTexture"
  10509. */
  10510. getClassName(): string;
  10511. /**
  10512. * Gets the current state of canRescale
  10513. */
  10514. get canRescale(): boolean;
  10515. private _recreate;
  10516. /**
  10517. * Scales the texture
  10518. * @param ratio the scale factor to apply to both width and height
  10519. */
  10520. scale(ratio: number): void;
  10521. /**
  10522. * Resizes the texture
  10523. * @param width the new width
  10524. * @param height the new height
  10525. */
  10526. scaleTo(width: number, height: number): void;
  10527. /**
  10528. * Gets the context of the canvas used by the texture
  10529. * @returns the canvas context of the dynamic texture
  10530. */
  10531. getContext(): CanvasRenderingContext2D;
  10532. /**
  10533. * Clears the texture
  10534. */
  10535. clear(): void;
  10536. /**
  10537. * Updates the texture
  10538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10539. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10540. */
  10541. update(invertY?: boolean, premulAlpha?: boolean): void;
  10542. /**
  10543. * Draws text onto the texture
  10544. * @param text defines the text to be drawn
  10545. * @param x defines the placement of the text from the left
  10546. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10547. * @param font defines the font to be used with font-style, font-size, font-name
  10548. * @param color defines the color used for the text
  10549. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10551. * @param update defines whether texture is immediately update (default is true)
  10552. */
  10553. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10554. /**
  10555. * Clones the texture
  10556. * @returns the clone of the texture.
  10557. */
  10558. clone(): DynamicTexture;
  10559. /**
  10560. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10561. * @returns a serialized dynamic texture object
  10562. */
  10563. serialize(): any;
  10564. /** @hidden */
  10565. _rebuild(): void;
  10566. }
  10567. }
  10568. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10569. import { Nullable } from "babylonjs/types";
  10570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10571. import { Scene } from "babylonjs/scene";
  10572. module "babylonjs/Engines/engine" {
  10573. interface Engine {
  10574. /**
  10575. * Creates a raw texture
  10576. * @param data defines the data to store in the texture
  10577. * @param width defines the width of the texture
  10578. * @param height defines the height of the texture
  10579. * @param format defines the format of the data
  10580. * @param generateMipMaps defines if the engine should generate the mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10583. * @param compression defines the compression used (null by default)
  10584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10585. * @returns the raw texture inside an InternalTexture
  10586. */
  10587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10588. /**
  10589. * Update a raw texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store in the texture
  10592. * @param format defines the format of the data
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store in the texture
  10600. * @param format defines the format of the data
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the compression used (null by default)
  10603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10604. */
  10605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10606. /**
  10607. * Creates a new raw cube texture
  10608. * @param data defines the array of data to use to create each face
  10609. * @param size defines the size of the textures
  10610. * @param format defines the format of the data
  10611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param compression defines the compression used (null by default)
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10619. /**
  10620. * Update a raw cube texture
  10621. * @param texture defines the texture to udpdate
  10622. * @param data defines the data to store
  10623. * @param format defines the data format
  10624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. */
  10627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10628. /**
  10629. * Update a raw cube texture
  10630. * @param texture defines the texture to udpdate
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the compression used (null by default)
  10636. */
  10637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10638. /**
  10639. * Update a raw cube texture
  10640. * @param texture defines the texture to udpdate
  10641. * @param data defines the data to store
  10642. * @param format defines the data format
  10643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10644. * @param invertY defines if data must be stored with Y axis inverted
  10645. * @param compression defines the compression used (null by default)
  10646. * @param level defines which level of the texture to update
  10647. */
  10648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10649. /**
  10650. * Creates a new raw cube texture from a specified url
  10651. * @param url defines the url where the data is located
  10652. * @param scene defines the current scene
  10653. * @param size defines the size of the textures
  10654. * @param format defines the format of the data
  10655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10656. * @param noMipmap defines if the engine should avoid generating the mip levels
  10657. * @param callback defines a callback used to extract texture data from loaded data
  10658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10659. * @param onLoad defines a callback called when texture is loaded
  10660. * @param onError defines a callback called if there is an error
  10661. * @returns the cube texture as an InternalTexture
  10662. */
  10663. 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;
  10664. /**
  10665. * Creates a new raw cube texture from a specified url
  10666. * @param url defines the url where the data is located
  10667. * @param scene defines the current scene
  10668. * @param size defines the size of the textures
  10669. * @param format defines the format of the data
  10670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10671. * @param noMipmap defines if the engine should avoid generating the mip levels
  10672. * @param callback defines a callback used to extract texture data from loaded data
  10673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10674. * @param onLoad defines a callback called when texture is loaded
  10675. * @param onError defines a callback called if there is an error
  10676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param invertY defines if data must be stored with Y axis inverted
  10678. * @returns the cube texture as an InternalTexture
  10679. */
  10680. 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;
  10681. /**
  10682. * Creates a new raw 3D texture
  10683. * @param data defines the data used to create the texture
  10684. * @param width defines the width of the texture
  10685. * @param height defines the height of the texture
  10686. * @param depth defines the depth of the texture
  10687. * @param format defines the format of the texture
  10688. * @param generateMipMaps defines if the engine must generate mip levels
  10689. * @param invertY defines if data must be stored with Y axis inverted
  10690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10691. * @param compression defines the compressed used (can be null)
  10692. * @param textureType defines the compressed used (can be null)
  10693. * @returns a new raw 3D texture (stored in an InternalTexture)
  10694. */
  10695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10696. /**
  10697. * Update a raw 3D texture
  10698. * @param texture defines the texture to update
  10699. * @param data defines the data to store
  10700. * @param format defines the data format
  10701. * @param invertY defines if data must be stored with Y axis inverted
  10702. */
  10703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10704. /**
  10705. * Update a raw 3D texture
  10706. * @param texture defines the texture to update
  10707. * @param data defines the data to store
  10708. * @param format defines the data format
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param compression defines the used compression (can be null)
  10711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10712. */
  10713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10714. /**
  10715. * Creates a new raw 2D array texture
  10716. * @param data defines the data used to create the texture
  10717. * @param width defines the width of the texture
  10718. * @param height defines the height of the texture
  10719. * @param depth defines the number of layers of the texture
  10720. * @param format defines the format of the texture
  10721. * @param generateMipMaps defines if the engine must generate mip levels
  10722. * @param invertY defines if data must be stored with Y axis inverted
  10723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10724. * @param compression defines the compressed used (can be null)
  10725. * @param textureType defines the compressed used (can be null)
  10726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10727. */
  10728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10729. /**
  10730. * Update a raw 2D array texture
  10731. * @param texture defines the texture to update
  10732. * @param data defines the data to store
  10733. * @param format defines the data format
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. */
  10736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10737. /**
  10738. * Update a raw 2D array texture
  10739. * @param texture defines the texture to update
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param compression defines the used compression (can be null)
  10744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10745. */
  10746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10747. }
  10748. }
  10749. }
  10750. declare module "babylonjs/Materials/Textures/rawTexture" {
  10751. import { Scene } from "babylonjs/scene";
  10752. import { Texture } from "babylonjs/Materials/Textures/texture";
  10753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. private _engine;
  10765. /**
  10766. * Instantiates a new RawTexture.
  10767. * Raw texture can help creating a texture directly from an array of data.
  10768. * This can be super useful if you either get the data from an uncompressed source or
  10769. * if you wish to create your texture pixel by pixel.
  10770. * @param data define the array of data to use to create the texture
  10771. * @param width define the width of the texture
  10772. * @param height define the height of the texture
  10773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10774. * @param scene define the scene the texture belongs to
  10775. * @param generateMipMaps define whether mip maps should be generated or not
  10776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10779. */
  10780. constructor(data: ArrayBufferView, width: number, height: number,
  10781. /**
  10782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10783. */
  10784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10785. /**
  10786. * Updates the texture underlying data.
  10787. * @param data Define the new data of the texture
  10788. */
  10789. update(data: ArrayBufferView): void;
  10790. /**
  10791. * Creates a luminance texture from some data.
  10792. * @param data Define the texture data
  10793. * @param width Define the width of the texture
  10794. * @param height Define the height of the texture
  10795. * @param scene Define the scene the texture belongs to
  10796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10799. * @returns the luminance texture
  10800. */
  10801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10802. /**
  10803. * Creates a luminance alpha texture from some data.
  10804. * @param data Define the texture data
  10805. * @param width Define the width of the texture
  10806. * @param height Define the height of the texture
  10807. * @param scene Define the scene the texture belongs to
  10808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10811. * @returns the luminance alpha texture
  10812. */
  10813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10814. /**
  10815. * Creates an alpha texture from some data.
  10816. * @param data Define the texture data
  10817. * @param width Define the width of the texture
  10818. * @param height Define the height of the texture
  10819. * @param scene Define the scene the texture belongs to
  10820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10823. * @returns the alpha texture
  10824. */
  10825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10826. /**
  10827. * Creates a RGB texture from some data.
  10828. * @param data Define the texture data
  10829. * @param width Define the width of the texture
  10830. * @param height Define the height of the texture
  10831. * @param scene Define the scene the texture belongs to
  10832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10836. * @returns the RGB alpha texture
  10837. */
  10838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10839. /**
  10840. * Creates a RGBA texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10849. * @returns the RGBA texture
  10850. */
  10851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10852. /**
  10853. * Creates a R texture from some data.
  10854. * @param data Define the texture data
  10855. * @param width Define the width of the texture
  10856. * @param height Define the height of the texture
  10857. * @param scene Define the scene the texture belongs to
  10858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10862. * @returns the R texture
  10863. */
  10864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10865. }
  10866. }
  10867. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10868. import { Scene } from "babylonjs/scene";
  10869. import { ISceneComponent } from "babylonjs/sceneComponent";
  10870. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10871. module "babylonjs/abstractScene" {
  10872. interface AbstractScene {
  10873. /**
  10874. * The list of procedural textures added to the scene
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. */
  10877. proceduralTextures: Array<ProceduralTexture>;
  10878. }
  10879. }
  10880. /**
  10881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10882. * in a given scene.
  10883. */
  10884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10885. /**
  10886. * The component name helpfull to identify the component in the list of scene components.
  10887. */
  10888. readonly name: string;
  10889. /**
  10890. * The scene the component belongs to.
  10891. */
  10892. scene: Scene;
  10893. /**
  10894. * Creates a new instance of the component for the given scene
  10895. * @param scene Defines the scene to register the component in
  10896. */
  10897. constructor(scene: Scene);
  10898. /**
  10899. * Registers the component in a given scene
  10900. */
  10901. register(): void;
  10902. /**
  10903. * Rebuilds the elements related to this component in case of
  10904. * context lost for instance.
  10905. */
  10906. rebuild(): void;
  10907. /**
  10908. * Disposes the component and the associated ressources.
  10909. */
  10910. dispose(): void;
  10911. private _beforeClear;
  10912. }
  10913. }
  10914. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10916. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10917. module "babylonjs/Engines/thinEngine" {
  10918. interface ThinEngine {
  10919. /**
  10920. * Creates a new render target cube texture
  10921. * @param size defines the size of the texture
  10922. * @param options defines the options used to create the texture
  10923. * @returns a new render target cube texture stored in an InternalTexture
  10924. */
  10925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10926. }
  10927. }
  10928. }
  10929. declare module "babylonjs/Shaders/procedural.vertex" {
  10930. /** @hidden */
  10931. export var proceduralVertexShader: {
  10932. name: string;
  10933. shader: string;
  10934. };
  10935. }
  10936. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { Nullable } from "babylonjs/types";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10941. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10942. import { Effect } from "babylonjs/Materials/effect";
  10943. import { Texture } from "babylonjs/Materials/Textures/texture";
  10944. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10945. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10946. import "babylonjs/Shaders/procedural.vertex";
  10947. /**
  10948. * 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.
  10949. * This is the base class of any Procedural texture and contains most of the shareable code.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10951. */
  10952. export class ProceduralTexture extends Texture {
  10953. isCube: boolean;
  10954. /**
  10955. * Define if the texture is enabled or not (disabled texture will not render)
  10956. */
  10957. isEnabled: boolean;
  10958. /**
  10959. * Define if the texture must be cleared before rendering (default is true)
  10960. */
  10961. autoClear: boolean;
  10962. /**
  10963. * Callback called when the texture is generated
  10964. */
  10965. onGenerated: () => void;
  10966. /**
  10967. * Event raised when the texture is generated
  10968. */
  10969. onGeneratedObservable: Observable<ProceduralTexture>;
  10970. /** @hidden */
  10971. _generateMipMaps: boolean;
  10972. /** @hidden **/
  10973. _effect: Effect;
  10974. /** @hidden */
  10975. _textures: {
  10976. [key: string]: Texture;
  10977. };
  10978. private _size;
  10979. private _currentRefreshId;
  10980. private _frameId;
  10981. private _refreshRate;
  10982. private _vertexBuffers;
  10983. private _indexBuffer;
  10984. private _uniforms;
  10985. private _samplers;
  10986. private _fragment;
  10987. private _floats;
  10988. private _ints;
  10989. private _floatsArrays;
  10990. private _colors3;
  10991. private _colors4;
  10992. private _vectors2;
  10993. private _vectors3;
  10994. private _matrices;
  10995. private _fallbackTexture;
  10996. private _fallbackTextureUsed;
  10997. private _engine;
  10998. private _cachedDefines;
  10999. private _contentUpdateId;
  11000. private _contentData;
  11001. /**
  11002. * Instantiates a new procedural texture.
  11003. * 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.
  11004. * This is the base class of any Procedural texture and contains most of the shareable code.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11006. * @param name Define the name of the texture
  11007. * @param size Define the size of the texture to create
  11008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11009. * @param scene Define the scene the texture belongs to
  11010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11011. * @param generateMipMaps Define if the texture should creates mip maps or not
  11012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11013. */
  11014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11015. /**
  11016. * The effect that is created when initializing the post process.
  11017. * @returns The created effect corresponding the the postprocess.
  11018. */
  11019. getEffect(): Effect;
  11020. /**
  11021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11023. */
  11024. getContent(): Nullable<ArrayBufferView>;
  11025. private _createIndexBuffer;
  11026. /** @hidden */
  11027. _rebuild(): void;
  11028. /**
  11029. * Resets the texture in order to recreate its associated resources.
  11030. * This can be called in case of context loss
  11031. */
  11032. reset(): void;
  11033. protected _getDefines(): string;
  11034. /**
  11035. * Is the texture ready to be used ? (rendered at least once)
  11036. * @returns true if ready, otherwise, false.
  11037. */
  11038. isReady(): boolean;
  11039. /**
  11040. * Resets the refresh counter of the texture and start bak from scratch.
  11041. * Could be useful to regenerate the texture if it is setup to render only once.
  11042. */
  11043. resetRefreshCounter(): void;
  11044. /**
  11045. * Set the fragment shader to use in order to render the texture.
  11046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11047. */
  11048. setFragment(fragment: any): void;
  11049. /**
  11050. * Define the refresh rate of the texture or the rendering frequency.
  11051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11052. */
  11053. get refreshRate(): number;
  11054. set refreshRate(value: number);
  11055. /** @hidden */
  11056. _shouldRender(): boolean;
  11057. /**
  11058. * Get the size the texture is rendering at.
  11059. * @returns the size (texture is always squared)
  11060. */
  11061. getRenderSize(): number;
  11062. /**
  11063. * Resize the texture to new value.
  11064. * @param size Define the new size the texture should have
  11065. * @param generateMipMaps Define whether the new texture should create mip maps
  11066. */
  11067. resize(size: number, generateMipMaps: boolean): void;
  11068. private _checkUniform;
  11069. /**
  11070. * Set a texture in the shader program used to render.
  11071. * @param name Define the name of the uniform samplers as defined in the shader
  11072. * @param texture Define the texture to bind to this sampler
  11073. * @return the texture itself allowing "fluent" like uniform updates
  11074. */
  11075. setTexture(name: string, texture: Texture): ProceduralTexture;
  11076. /**
  11077. * Set a float in the shader.
  11078. * @param name Define the name of the uniform as defined in the shader
  11079. * @param value Define the value to give to the uniform
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setFloat(name: string, value: number): ProceduralTexture;
  11083. /**
  11084. * Set a int in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setInt(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set an array of floats in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setFloats(name: string, value: number[]): ProceduralTexture;
  11097. /**
  11098. * Set a vec3 in the shader from a Color3.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setColor3(name: string, value: Color3): ProceduralTexture;
  11104. /**
  11105. * Set a vec4 in the shader from a Color4.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor4(name: string, value: Color4): ProceduralTexture;
  11111. /**
  11112. * Set a vec2 in the shader from a Vector2.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setVector2(name: string, value: Vector2): ProceduralTexture;
  11118. /**
  11119. * Set a vec3 in the shader from a Vector3.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector3(name: string, value: Vector3): ProceduralTexture;
  11125. /**
  11126. * Set a mat4 in the shader from a MAtrix.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11132. /**
  11133. * Render the texture to its associated render target.
  11134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11135. */
  11136. render(useCameraPostProcess?: boolean): void;
  11137. /**
  11138. * Clone the texture.
  11139. * @returns the cloned texture
  11140. */
  11141. clone(): ProceduralTexture;
  11142. /**
  11143. * Dispose the texture and release its asoociated resources.
  11144. */
  11145. dispose(): void;
  11146. }
  11147. }
  11148. declare module "babylonjs/Particles/baseParticleSystem" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11154. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11155. import { Scene } from "babylonjs/scene";
  11156. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11157. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import { Color4 } from "babylonjs/Maths/math.color";
  11160. import { Animation } from "babylonjs/Animations/animation";
  11161. /**
  11162. * This represents the base class for particle system in Babylon.
  11163. * 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.
  11164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11165. * @example https://doc.babylonjs.com/babylon101/particles
  11166. */
  11167. export class BaseParticleSystem {
  11168. /**
  11169. * Source color is added to the destination color without alpha affecting the result
  11170. */
  11171. static BLENDMODE_ONEONE: number;
  11172. /**
  11173. * Blend current color and particle color using particle’s alpha
  11174. */
  11175. static BLENDMODE_STANDARD: number;
  11176. /**
  11177. * Add current color and particle color multiplied by particle’s alpha
  11178. */
  11179. static BLENDMODE_ADD: number;
  11180. /**
  11181. * Multiply current color with particle color
  11182. */
  11183. static BLENDMODE_MULTIPLY: number;
  11184. /**
  11185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11186. */
  11187. static BLENDMODE_MULTIPLYADD: number;
  11188. /**
  11189. * List of animations used by the particle system.
  11190. */
  11191. animations: Animation[];
  11192. /**
  11193. * The id of the Particle system.
  11194. */
  11195. id: string;
  11196. /**
  11197. * The friendly name of the Particle system.
  11198. */
  11199. name: string;
  11200. /**
  11201. * The rendering group used by the Particle system to chose when to render.
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * The emitter represents the Mesh or position we are attaching the particle system to.
  11206. */
  11207. emitter: Nullable<AbstractMesh | Vector3>;
  11208. /**
  11209. * The maximum number of particles to emit per frame
  11210. */
  11211. emitRate: number;
  11212. /**
  11213. * If you want to launch only a few particles at once, that can be done, as well.
  11214. */
  11215. manualEmitCount: number;
  11216. /**
  11217. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11218. */
  11219. updateSpeed: number;
  11220. /**
  11221. * The amount of time the particle system is running (depends of the overall update speed).
  11222. */
  11223. targetStopDuration: number;
  11224. /**
  11225. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11226. */
  11227. disposeOnStop: boolean;
  11228. /**
  11229. * Minimum power of emitting particles.
  11230. */
  11231. minEmitPower: number;
  11232. /**
  11233. * Maximum power of emitting particles.
  11234. */
  11235. maxEmitPower: number;
  11236. /**
  11237. * Minimum life time of emitting particles.
  11238. */
  11239. minLifeTime: number;
  11240. /**
  11241. * Maximum life time of emitting particles.
  11242. */
  11243. maxLifeTime: number;
  11244. /**
  11245. * Minimum Size of emitting particles.
  11246. */
  11247. minSize: number;
  11248. /**
  11249. * Maximum Size of emitting particles.
  11250. */
  11251. maxSize: number;
  11252. /**
  11253. * Minimum scale of emitting particles on X axis.
  11254. */
  11255. minScaleX: number;
  11256. /**
  11257. * Maximum scale of emitting particles on X axis.
  11258. */
  11259. maxScaleX: number;
  11260. /**
  11261. * Minimum scale of emitting particles on Y axis.
  11262. */
  11263. minScaleY: number;
  11264. /**
  11265. * Maximum scale of emitting particles on Y axis.
  11266. */
  11267. maxScaleY: number;
  11268. /**
  11269. * Gets or sets the minimal initial rotation in radians.
  11270. */
  11271. minInitialRotation: number;
  11272. /**
  11273. * Gets or sets the maximal initial rotation in radians.
  11274. */
  11275. maxInitialRotation: number;
  11276. /**
  11277. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11278. */
  11279. minAngularSpeed: number;
  11280. /**
  11281. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11282. */
  11283. maxAngularSpeed: number;
  11284. /**
  11285. * The texture used to render each particle. (this can be a spritesheet)
  11286. */
  11287. particleTexture: Nullable<Texture>;
  11288. /**
  11289. * The layer mask we are rendering the particles through.
  11290. */
  11291. layerMask: number;
  11292. /**
  11293. * This can help using your own shader to render the particle system.
  11294. * The according effect will be created
  11295. */
  11296. customShader: any;
  11297. /**
  11298. * By default particle system starts as soon as they are created. This prevents the
  11299. * automatic start to happen and let you decide when to start emitting particles.
  11300. */
  11301. preventAutoStart: boolean;
  11302. private _noiseTexture;
  11303. /**
  11304. * Gets or sets a texture used to add random noise to particle positions
  11305. */
  11306. get noiseTexture(): Nullable<ProceduralTexture>;
  11307. set noiseTexture(value: Nullable<ProceduralTexture>);
  11308. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11309. noiseStrength: Vector3;
  11310. /**
  11311. * Callback triggered when the particle animation is ending.
  11312. */
  11313. onAnimationEnd: Nullable<() => void>;
  11314. /**
  11315. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11316. */
  11317. blendMode: number;
  11318. /**
  11319. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11320. * to override the particles.
  11321. */
  11322. forceDepthWrite: boolean;
  11323. /** 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 */
  11324. preWarmCycles: number;
  11325. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11326. preWarmStepOffset: number;
  11327. /**
  11328. * 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)
  11329. */
  11330. spriteCellChangeSpeed: number;
  11331. /**
  11332. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11333. */
  11334. startSpriteCellID: number;
  11335. /**
  11336. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11337. */
  11338. endSpriteCellID: number;
  11339. /**
  11340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11341. */
  11342. spriteCellWidth: number;
  11343. /**
  11344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11345. */
  11346. spriteCellHeight: number;
  11347. /**
  11348. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11349. */
  11350. spriteRandomStartCell: boolean;
  11351. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11352. translationPivot: Vector2;
  11353. /** @hidden */
  11354. protected _isAnimationSheetEnabled: boolean;
  11355. /**
  11356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11357. */
  11358. beginAnimationOnStart: boolean;
  11359. /**
  11360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11361. */
  11362. beginAnimationFrom: number;
  11363. /**
  11364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11365. */
  11366. beginAnimationTo: number;
  11367. /**
  11368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11369. */
  11370. beginAnimationLoop: boolean;
  11371. /**
  11372. * Gets or sets a world offset applied to all particles
  11373. */
  11374. worldOffset: Vector3;
  11375. /**
  11376. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11377. */
  11378. get isAnimationSheetEnabled(): boolean;
  11379. set isAnimationSheetEnabled(value: boolean);
  11380. /**
  11381. * Get hosting scene
  11382. * @returns the scene
  11383. */
  11384. getScene(): Scene;
  11385. /**
  11386. * You can use gravity if you want to give an orientation to your particles.
  11387. */
  11388. gravity: Vector3;
  11389. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11390. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11391. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11392. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11393. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11394. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11395. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11396. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11397. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11399. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11400. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11401. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11402. /**
  11403. * Defines the delay in milliseconds before starting the system (0 by default)
  11404. */
  11405. startDelay: number;
  11406. /**
  11407. * Gets the current list of drag gradients.
  11408. * You must use addDragGradient and removeDragGradient to udpate this list
  11409. * @returns the list of drag gradients
  11410. */
  11411. getDragGradients(): Nullable<Array<FactorGradient>>;
  11412. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11413. limitVelocityDamping: number;
  11414. /**
  11415. * Gets the current list of limit velocity gradients.
  11416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11417. * @returns the list of limit velocity gradients
  11418. */
  11419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11420. /**
  11421. * Gets the current list of color gradients.
  11422. * You must use addColorGradient and removeColorGradient to udpate this list
  11423. * @returns the list of color gradients
  11424. */
  11425. getColorGradients(): Nullable<Array<ColorGradient>>;
  11426. /**
  11427. * Gets the current list of size gradients.
  11428. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11429. * @returns the list of size gradients
  11430. */
  11431. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11432. /**
  11433. * Gets the current list of color remap gradients.
  11434. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11435. * @returns the list of color remap gradients
  11436. */
  11437. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of alpha remap gradients.
  11440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11441. * @returns the list of alpha remap gradients
  11442. */
  11443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of life time gradients.
  11446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11447. * @returns the list of life time gradients
  11448. */
  11449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of angular speed gradients.
  11452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11453. * @returns the list of angular speed gradients
  11454. */
  11455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of velocity gradients.
  11458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11459. * @returns the list of velocity gradients
  11460. */
  11461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of start size gradients.
  11464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11465. * @returns the list of start size gradients
  11466. */
  11467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of emit rate gradients.
  11470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11471. * @returns the list of emit rate gradients
  11472. */
  11473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11477. */
  11478. get direction1(): Vector3;
  11479. set direction1(value: Vector3);
  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 direction2(): Vector3;
  11485. set direction2(value: Vector3);
  11486. /**
  11487. * 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.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get minEmitBox(): Vector3;
  11491. set minEmitBox(value: Vector3);
  11492. /**
  11493. * 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.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get maxEmitBox(): Vector3;
  11497. set maxEmitBox(value: Vector3);
  11498. /**
  11499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11504. */
  11505. color2: Color4;
  11506. /**
  11507. * Color the particle will have at the end of its lifetime
  11508. */
  11509. colorDead: Color4;
  11510. /**
  11511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11512. */
  11513. textureMask: Color4;
  11514. /**
  11515. * The particle emitter type defines the emitter used by the particle system.
  11516. * It can be for example box, sphere, or cone...
  11517. */
  11518. particleEmitterType: IParticleEmitterType;
  11519. /** @hidden */
  11520. _isSubEmitter: boolean;
  11521. /**
  11522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11524. */
  11525. billboardMode: number;
  11526. protected _isBillboardBased: boolean;
  11527. /**
  11528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11529. */
  11530. get isBillboardBased(): boolean;
  11531. set isBillboardBased(value: boolean);
  11532. /**
  11533. * The scene the particle system belongs to.
  11534. */
  11535. protected _scene: Scene;
  11536. /**
  11537. * Local cache of defines for image processing.
  11538. */
  11539. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11540. /**
  11541. * Default configuration related to image processing available in the standard Material.
  11542. */
  11543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11544. /**
  11545. * Gets the image processing configuration used either in this material.
  11546. */
  11547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11548. /**
  11549. * Sets the Default image processing configuration used either in the this material.
  11550. *
  11551. * If sets to null, the scene one is in use.
  11552. */
  11553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11554. /**
  11555. * Attaches a new image processing configuration to the Standard Material.
  11556. * @param configuration
  11557. */
  11558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11559. /** @hidden */
  11560. protected _reset(): void;
  11561. /** @hidden */
  11562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11563. /**
  11564. * Instantiates a particle system.
  11565. * 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.
  11566. * @param name The name of the particle system
  11567. */
  11568. constructor(name: string);
  11569. /**
  11570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11573. * @returns the emitter
  11574. */
  11575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11576. /**
  11577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11578. * @param radius The radius of the hemisphere to emit from
  11579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11580. * @returns the emitter
  11581. */
  11582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11583. /**
  11584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11585. * @param radius The radius of the sphere to emit from
  11586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11590. /**
  11591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11595. * @returns the emitter
  11596. */
  11597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11598. /**
  11599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11600. * @param radius The radius of the emission cylinder
  11601. * @param height The height of the emission cylinder
  11602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11604. * @returns the emitter
  11605. */
  11606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11607. /**
  11608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11609. * @param radius The radius of the cylinder to emit from
  11610. * @param height The height of the emission cylinder
  11611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11614. * @returns the emitter
  11615. */
  11616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11617. /**
  11618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11619. * @param radius The radius of the cone to emit from
  11620. * @param angle The base angle of the cone
  11621. * @returns the emitter
  11622. */
  11623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11624. /**
  11625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11630. * @returns the emitter
  11631. */
  11632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11633. }
  11634. }
  11635. declare module "babylonjs/Particles/subEmitter" {
  11636. import { Scene } from "babylonjs/scene";
  11637. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11638. /**
  11639. * Type of sub emitter
  11640. */
  11641. export enum SubEmitterType {
  11642. /**
  11643. * Attached to the particle over it's lifetime
  11644. */
  11645. ATTACHED = 0,
  11646. /**
  11647. * Created when the particle dies
  11648. */
  11649. END = 1
  11650. }
  11651. /**
  11652. * Sub emitter class used to emit particles from an existing particle
  11653. */
  11654. export class SubEmitter {
  11655. /**
  11656. * the particle system to be used by the sub emitter
  11657. */
  11658. particleSystem: ParticleSystem;
  11659. /**
  11660. * Type of the submitter (Default: END)
  11661. */
  11662. type: SubEmitterType;
  11663. /**
  11664. * 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)
  11665. * Note: This only is supported when using an emitter of type Mesh
  11666. */
  11667. inheritDirection: boolean;
  11668. /**
  11669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11670. */
  11671. inheritedVelocityAmount: number;
  11672. /**
  11673. * Creates a sub emitter
  11674. * @param particleSystem the particle system to be used by the sub emitter
  11675. */
  11676. constructor(
  11677. /**
  11678. * the particle system to be used by the sub emitter
  11679. */
  11680. particleSystem: ParticleSystem);
  11681. /**
  11682. * Clones the sub emitter
  11683. * @returns the cloned sub emitter
  11684. */
  11685. clone(): SubEmitter;
  11686. /**
  11687. * Serialize current object to a JSON object
  11688. * @returns the serialized object
  11689. */
  11690. serialize(): any;
  11691. /** @hidden */
  11692. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11693. /**
  11694. * Creates a new SubEmitter from a serialized JSON version
  11695. * @param serializationObject defines the JSON object to read from
  11696. * @param scene defines the hosting scene
  11697. * @param rootUrl defines the rootUrl for data loading
  11698. * @returns a new SubEmitter
  11699. */
  11700. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11701. /** Release associated resources */
  11702. dispose(): void;
  11703. }
  11704. }
  11705. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11706. /** @hidden */
  11707. export var imageProcessingDeclaration: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11713. /** @hidden */
  11714. export var imageProcessingFunctions: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/particles.fragment" {
  11720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11721. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11723. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11725. /** @hidden */
  11726. export var particlesPixelShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module "babylonjs/Shaders/particles.vertex" {
  11732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11734. /** @hidden */
  11735. export var particlesVertexShader: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Particles/particleSystem" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11743. import { Observable } from "babylonjs/Misc/observable";
  11744. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11745. import { Effect } from "babylonjs/Materials/effect";
  11746. import { Scene, IDisposable } from "babylonjs/scene";
  11747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11748. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11749. import { Particle } from "babylonjs/Particles/particle";
  11750. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11752. import "babylonjs/Shaders/particles.fragment";
  11753. import "babylonjs/Shaders/particles.vertex";
  11754. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11755. /**
  11756. * This represents a particle system in Babylon.
  11757. * 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.
  11758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11759. * @example https://doc.babylonjs.com/babylon101/particles
  11760. */
  11761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11762. /**
  11763. * Billboard mode will only apply to Y axis
  11764. */
  11765. static readonly BILLBOARDMODE_Y: number;
  11766. /**
  11767. * Billboard mode will apply to all axes
  11768. */
  11769. static readonly BILLBOARDMODE_ALL: number;
  11770. /**
  11771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11772. */
  11773. static readonly BILLBOARDMODE_STRETCHED: number;
  11774. /**
  11775. * This function can be defined to provide custom update for active particles.
  11776. * This function will be called instead of regular update (age, position, color, etc.).
  11777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11778. */
  11779. updateFunction: (particles: Particle[]) => void;
  11780. private _emitterWorldMatrix;
  11781. /**
  11782. * This function can be defined to specify initial direction for every new particle.
  11783. * It by default use the emitterType defined function
  11784. */
  11785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11786. /**
  11787. * This function can be defined to specify initial position for every new particle.
  11788. * It by default use the emitterType defined function
  11789. */
  11790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11791. /**
  11792. * @hidden
  11793. */
  11794. _inheritedVelocityOffset: Vector3;
  11795. /**
  11796. * An event triggered when the system is disposed
  11797. */
  11798. onDisposeObservable: Observable<ParticleSystem>;
  11799. private _onDisposeObserver;
  11800. /**
  11801. * Sets a callback that will be triggered when the system is disposed
  11802. */
  11803. set onDispose(callback: () => void);
  11804. private _particles;
  11805. private _epsilon;
  11806. private _capacity;
  11807. private _stockParticles;
  11808. private _newPartsExcess;
  11809. private _vertexData;
  11810. private _vertexBuffer;
  11811. private _vertexBuffers;
  11812. private _spriteBuffer;
  11813. private _indexBuffer;
  11814. private _effect;
  11815. private _customEffect;
  11816. private _cachedDefines;
  11817. private _scaledColorStep;
  11818. private _colorDiff;
  11819. private _scaledDirection;
  11820. private _scaledGravity;
  11821. private _currentRenderId;
  11822. private _alive;
  11823. private _useInstancing;
  11824. private _started;
  11825. private _stopped;
  11826. private _actualFrame;
  11827. private _scaledUpdateSpeed;
  11828. private _vertexBufferSize;
  11829. /** @hidden */
  11830. _currentEmitRateGradient: Nullable<FactorGradient>;
  11831. /** @hidden */
  11832. _currentEmitRate1: number;
  11833. /** @hidden */
  11834. _currentEmitRate2: number;
  11835. /** @hidden */
  11836. _currentStartSizeGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentStartSize1: number;
  11839. /** @hidden */
  11840. _currentStartSize2: number;
  11841. private readonly _rawTextureWidth;
  11842. private _rampGradientsTexture;
  11843. private _useRampGradients;
  11844. /** Gets or sets a boolean indicating that ramp gradients must be used
  11845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11846. */
  11847. get useRampGradients(): boolean;
  11848. set useRampGradients(value: boolean);
  11849. /**
  11850. * 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.
  11851. * 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: [])
  11852. */
  11853. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11854. private _subEmitters;
  11855. /**
  11856. * @hidden
  11857. * If the particle systems emitter should be disposed when the particle system is disposed
  11858. */
  11859. _disposeEmitterOnDispose: boolean;
  11860. /**
  11861. * The current active Sub-systems, this property is used by the root particle system only.
  11862. */
  11863. activeSubSystems: Array<ParticleSystem>;
  11864. /**
  11865. * Specifies if the particles are updated in emitter local space or world space
  11866. */
  11867. isLocal: boolean;
  11868. private _rootParticleSystem;
  11869. /**
  11870. * Gets the current list of active particles
  11871. */
  11872. get particles(): Particle[];
  11873. /**
  11874. * Returns the string "ParticleSystem"
  11875. * @returns a string containing the class name
  11876. */
  11877. getClassName(): string;
  11878. /**
  11879. * Instantiates a particle system.
  11880. * 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.
  11881. * @param name The name of the particle system
  11882. * @param capacity The max number of particles alive at the same time
  11883. * @param scene The scene the particle system belongs to
  11884. * @param customEffect a custom effect used to change the way particles are rendered by default
  11885. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11886. * @param epsilon Offset used to render the particles
  11887. */
  11888. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11889. private _addFactorGradient;
  11890. private _removeFactorGradient;
  11891. /**
  11892. * Adds a new life time gradient
  11893. * @param gradient defines the gradient to use (between 0 and 1)
  11894. * @param factor defines the life time factor to affect to the specified gradient
  11895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11896. * @returns the current particle system
  11897. */
  11898. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11899. /**
  11900. * Remove a specific life time gradient
  11901. * @param gradient defines the gradient to remove
  11902. * @returns the current particle system
  11903. */
  11904. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11905. /**
  11906. * Adds a new size gradient
  11907. * @param gradient defines the gradient to use (between 0 and 1)
  11908. * @param factor defines the size factor to affect to the specified gradient
  11909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11910. * @returns the current particle system
  11911. */
  11912. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11913. /**
  11914. * Remove a specific size gradient
  11915. * @param gradient defines the gradient to remove
  11916. * @returns the current particle system
  11917. */
  11918. removeSizeGradient(gradient: number): IParticleSystem;
  11919. /**
  11920. * Adds a new color remap gradient
  11921. * @param gradient defines the gradient to use (between 0 and 1)
  11922. * @param min defines the color remap minimal range
  11923. * @param max defines the color remap maximal range
  11924. * @returns the current particle system
  11925. */
  11926. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11927. /**
  11928. * Remove a specific color remap gradient
  11929. * @param gradient defines the gradient to remove
  11930. * @returns the current particle system
  11931. */
  11932. removeColorRemapGradient(gradient: number): IParticleSystem;
  11933. /**
  11934. * Adds a new alpha remap gradient
  11935. * @param gradient defines the gradient to use (between 0 and 1)
  11936. * @param min defines the alpha remap minimal range
  11937. * @param max defines the alpha remap maximal range
  11938. * @returns the current particle system
  11939. */
  11940. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11941. /**
  11942. * Remove a specific alpha remap gradient
  11943. * @param gradient defines the gradient to remove
  11944. * @returns the current particle system
  11945. */
  11946. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11947. /**
  11948. * Adds a new angular speed gradient
  11949. * @param gradient defines the gradient to use (between 0 and 1)
  11950. * @param factor defines the angular speed to affect to the specified gradient
  11951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11952. * @returns the current particle system
  11953. */
  11954. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11955. /**
  11956. * Remove a specific angular speed gradient
  11957. * @param gradient defines the gradient to remove
  11958. * @returns the current particle system
  11959. */
  11960. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11961. /**
  11962. * Adds a new velocity gradient
  11963. * @param gradient defines the gradient to use (between 0 and 1)
  11964. * @param factor defines the velocity to affect to the specified gradient
  11965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11966. * @returns the current particle system
  11967. */
  11968. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11969. /**
  11970. * Remove a specific velocity gradient
  11971. * @param gradient defines the gradient to remove
  11972. * @returns the current particle system
  11973. */
  11974. removeVelocityGradient(gradient: number): IParticleSystem;
  11975. /**
  11976. * Adds a new limit velocity gradient
  11977. * @param gradient defines the gradient to use (between 0 and 1)
  11978. * @param factor defines the limit velocity value to affect to the specified gradient
  11979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11980. * @returns the current particle system
  11981. */
  11982. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11983. /**
  11984. * Remove a specific limit velocity gradient
  11985. * @param gradient defines the gradient to remove
  11986. * @returns the current particle system
  11987. */
  11988. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11989. /**
  11990. * Adds a new drag gradient
  11991. * @param gradient defines the gradient to use (between 0 and 1)
  11992. * @param factor defines the drag value to affect to the specified gradient
  11993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11994. * @returns the current particle system
  11995. */
  11996. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11997. /**
  11998. * Remove a specific drag gradient
  11999. * @param gradient defines the gradient to remove
  12000. * @returns the current particle system
  12001. */
  12002. removeDragGradient(gradient: number): IParticleSystem;
  12003. /**
  12004. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12005. * @param gradient defines the gradient to use (between 0 and 1)
  12006. * @param factor defines the emit rate value to affect to the specified gradient
  12007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12008. * @returns the current particle system
  12009. */
  12010. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12011. /**
  12012. * Remove a specific emit rate gradient
  12013. * @param gradient defines the gradient to remove
  12014. * @returns the current particle system
  12015. */
  12016. removeEmitRateGradient(gradient: number): IParticleSystem;
  12017. /**
  12018. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12019. * @param gradient defines the gradient to use (between 0 and 1)
  12020. * @param factor defines the start size value to affect to the specified gradient
  12021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12022. * @returns the current particle system
  12023. */
  12024. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12025. /**
  12026. * Remove a specific start size gradient
  12027. * @param gradient defines the gradient to remove
  12028. * @returns the current particle system
  12029. */
  12030. removeStartSizeGradient(gradient: number): IParticleSystem;
  12031. private _createRampGradientTexture;
  12032. /**
  12033. * Gets the current list of ramp gradients.
  12034. * You must use addRampGradient and removeRampGradient to udpate this list
  12035. * @returns the list of ramp gradients
  12036. */
  12037. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12038. /**
  12039. * Adds a new ramp gradient used to remap particle colors
  12040. * @param gradient defines the gradient to use (between 0 and 1)
  12041. * @param color defines the color to affect to the specified gradient
  12042. * @returns the current particle system
  12043. */
  12044. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12045. /**
  12046. * Remove a specific ramp gradient
  12047. * @param gradient defines the gradient to remove
  12048. * @returns the current particle system
  12049. */
  12050. removeRampGradient(gradient: number): ParticleSystem;
  12051. /**
  12052. * Adds a new color gradient
  12053. * @param gradient defines the gradient to use (between 0 and 1)
  12054. * @param color1 defines the color to affect to the specified gradient
  12055. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12056. * @returns this particle system
  12057. */
  12058. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12059. /**
  12060. * Remove a specific color gradient
  12061. * @param gradient defines the gradient to remove
  12062. * @returns this particle system
  12063. */
  12064. removeColorGradient(gradient: number): IParticleSystem;
  12065. private _fetchR;
  12066. protected _reset(): void;
  12067. private _resetEffect;
  12068. private _createVertexBuffers;
  12069. private _createIndexBuffer;
  12070. /**
  12071. * Gets the maximum number of particles active at the same time.
  12072. * @returns The max number of active particles.
  12073. */
  12074. getCapacity(): number;
  12075. /**
  12076. * Gets whether there are still active particles in the system.
  12077. * @returns True if it is alive, otherwise false.
  12078. */
  12079. isAlive(): boolean;
  12080. /**
  12081. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12082. * @returns True if it has been started, otherwise false.
  12083. */
  12084. isStarted(): boolean;
  12085. private _prepareSubEmitterInternalArray;
  12086. /**
  12087. * Starts the particle system and begins to emit
  12088. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12089. */
  12090. start(delay?: number): void;
  12091. /**
  12092. * Stops the particle system.
  12093. * @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.
  12094. */
  12095. stop(stopSubEmitters?: boolean): void;
  12096. /**
  12097. * Remove all active particles
  12098. */
  12099. reset(): void;
  12100. /**
  12101. * @hidden (for internal use only)
  12102. */
  12103. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12104. /**
  12105. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12106. * Its lifetime will start back at 0.
  12107. */
  12108. recycleParticle: (particle: Particle) => void;
  12109. private _stopSubEmitters;
  12110. private _createParticle;
  12111. private _removeFromRoot;
  12112. private _emitFromParticle;
  12113. private _update;
  12114. /** @hidden */
  12115. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12116. /** @hidden */
  12117. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12118. /** @hidden */
  12119. private _getEffect;
  12120. /**
  12121. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12122. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12123. */
  12124. animate(preWarmOnly?: boolean): void;
  12125. private _appendParticleVertices;
  12126. /**
  12127. * Rebuilds the particle system.
  12128. */
  12129. rebuild(): void;
  12130. /**
  12131. * Is this system ready to be used/rendered
  12132. * @return true if the system is ready
  12133. */
  12134. isReady(): boolean;
  12135. private _render;
  12136. /**
  12137. * Renders the particle system in its current state.
  12138. * @returns the current number of particles
  12139. */
  12140. render(): number;
  12141. /**
  12142. * Disposes the particle system and free the associated resources
  12143. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12144. */
  12145. dispose(disposeTexture?: boolean): void;
  12146. /**
  12147. * Clones the particle system.
  12148. * @param name The name of the cloned object
  12149. * @param newEmitter The new emitter to use
  12150. * @returns the cloned particle system
  12151. */
  12152. clone(name: string, newEmitter: any): ParticleSystem;
  12153. /**
  12154. * Serializes the particle system to a JSON object.
  12155. * @returns the JSON object
  12156. */
  12157. serialize(): any;
  12158. /** @hidden */
  12159. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12160. /** @hidden */
  12161. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12162. /**
  12163. * Parses a JSON object to create a particle system.
  12164. * @param parsedParticleSystem The JSON object to parse
  12165. * @param scene The scene to create the particle system in
  12166. * @param rootUrl The root url to use to load external dependencies like texture
  12167. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12168. * @returns the Parsed particle system
  12169. */
  12170. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12171. }
  12172. }
  12173. declare module "babylonjs/Particles/particle" {
  12174. import { Nullable } from "babylonjs/types";
  12175. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12176. import { Color4 } from "babylonjs/Maths/math.color";
  12177. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12178. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12179. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12180. /**
  12181. * A particle represents one of the element emitted by a particle system.
  12182. * This is mainly define by its coordinates, direction, velocity and age.
  12183. */
  12184. export class Particle {
  12185. /**
  12186. * The particle system the particle belongs to.
  12187. */
  12188. particleSystem: ParticleSystem;
  12189. private static _Count;
  12190. /**
  12191. * Unique ID of the particle
  12192. */
  12193. id: number;
  12194. /**
  12195. * The world position of the particle in the scene.
  12196. */
  12197. position: Vector3;
  12198. /**
  12199. * The world direction of the particle in the scene.
  12200. */
  12201. direction: Vector3;
  12202. /**
  12203. * The color of the particle.
  12204. */
  12205. color: Color4;
  12206. /**
  12207. * The color change of the particle per step.
  12208. */
  12209. colorStep: Color4;
  12210. /**
  12211. * Defines how long will the life of the particle be.
  12212. */
  12213. lifeTime: number;
  12214. /**
  12215. * The current age of the particle.
  12216. */
  12217. age: number;
  12218. /**
  12219. * The current size of the particle.
  12220. */
  12221. size: number;
  12222. /**
  12223. * The current scale of the particle.
  12224. */
  12225. scale: Vector2;
  12226. /**
  12227. * The current angle of the particle.
  12228. */
  12229. angle: number;
  12230. /**
  12231. * Defines how fast is the angle changing.
  12232. */
  12233. angularSpeed: number;
  12234. /**
  12235. * Defines the cell index used by the particle to be rendered from a sprite.
  12236. */
  12237. cellIndex: number;
  12238. /**
  12239. * The information required to support color remapping
  12240. */
  12241. remapData: Vector4;
  12242. /** @hidden */
  12243. _randomCellOffset?: number;
  12244. /** @hidden */
  12245. _initialDirection: Nullable<Vector3>;
  12246. /** @hidden */
  12247. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12248. /** @hidden */
  12249. _initialStartSpriteCellID: number;
  12250. /** @hidden */
  12251. _initialEndSpriteCellID: number;
  12252. /** @hidden */
  12253. _currentColorGradient: Nullable<ColorGradient>;
  12254. /** @hidden */
  12255. _currentColor1: Color4;
  12256. /** @hidden */
  12257. _currentColor2: Color4;
  12258. /** @hidden */
  12259. _currentSizeGradient: Nullable<FactorGradient>;
  12260. /** @hidden */
  12261. _currentSize1: number;
  12262. /** @hidden */
  12263. _currentSize2: number;
  12264. /** @hidden */
  12265. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12266. /** @hidden */
  12267. _currentAngularSpeed1: number;
  12268. /** @hidden */
  12269. _currentAngularSpeed2: number;
  12270. /** @hidden */
  12271. _currentVelocityGradient: Nullable<FactorGradient>;
  12272. /** @hidden */
  12273. _currentVelocity1: number;
  12274. /** @hidden */
  12275. _currentVelocity2: number;
  12276. /** @hidden */
  12277. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12278. /** @hidden */
  12279. _currentLimitVelocity1: number;
  12280. /** @hidden */
  12281. _currentLimitVelocity2: number;
  12282. /** @hidden */
  12283. _currentDragGradient: Nullable<FactorGradient>;
  12284. /** @hidden */
  12285. _currentDrag1: number;
  12286. /** @hidden */
  12287. _currentDrag2: number;
  12288. /** @hidden */
  12289. _randomNoiseCoordinates1: Vector3;
  12290. /** @hidden */
  12291. _randomNoiseCoordinates2: Vector3;
  12292. /** @hidden */
  12293. _localPosition?: Vector3;
  12294. /**
  12295. * Creates a new instance Particle
  12296. * @param particleSystem the particle system the particle belongs to
  12297. */
  12298. constructor(
  12299. /**
  12300. * The particle system the particle belongs to.
  12301. */
  12302. particleSystem: ParticleSystem);
  12303. private updateCellInfoFromSystem;
  12304. /**
  12305. * Defines how the sprite cell index is updated for the particle
  12306. */
  12307. updateCellIndex(): void;
  12308. /** @hidden */
  12309. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12310. /** @hidden */
  12311. _inheritParticleInfoToSubEmitters(): void;
  12312. /** @hidden */
  12313. _reset(): void;
  12314. /**
  12315. * Copy the properties of particle to another one.
  12316. * @param other the particle to copy the information to.
  12317. */
  12318. copyTo(other: Particle): void;
  12319. }
  12320. }
  12321. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12322. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12323. import { Effect } from "babylonjs/Materials/effect";
  12324. import { Particle } from "babylonjs/Particles/particle";
  12325. import { Scene } from "babylonjs/scene";
  12326. /**
  12327. * Particle emitter represents a volume emitting particles.
  12328. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12329. */
  12330. export interface IParticleEmitterType {
  12331. /**
  12332. * Called by the particle System when the direction is computed for the created particle.
  12333. * @param worldMatrix is the world matrix of the particle system
  12334. * @param directionToUpdate is the direction vector to update with the result
  12335. * @param particle is the particle we are computed the direction for
  12336. * @param isLocal defines if the direction should be set in local space
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. * @param isLocal defines if the position should be set in local space
  12345. */
  12346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12347. /**
  12348. * Clones the current emitter and returns a copy of it
  12349. * @returns the new emitter
  12350. */
  12351. clone(): IParticleEmitterType;
  12352. /**
  12353. * Called by the GPUParticleSystem to setup the update shader
  12354. * @param effect defines the update shader
  12355. */
  12356. applyToShader(effect: Effect): void;
  12357. /**
  12358. * Returns a string to use to update the GPU particles update shader
  12359. * @returns the effect defines string
  12360. */
  12361. getEffectDefines(): string;
  12362. /**
  12363. * Returns a string representing the class name
  12364. * @returns a string containing the class name
  12365. */
  12366. getClassName(): string;
  12367. /**
  12368. * Serializes the particle system to a JSON object.
  12369. * @returns the JSON object
  12370. */
  12371. serialize(): any;
  12372. /**
  12373. * Parse properties from a JSON object
  12374. * @param serializationObject defines the JSON object
  12375. * @param scene defines the hosting scene
  12376. */
  12377. parse(serializationObject: any, scene: Scene): void;
  12378. }
  12379. }
  12380. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12382. import { Effect } from "babylonjs/Materials/effect";
  12383. import { Particle } from "babylonjs/Particles/particle";
  12384. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12385. /**
  12386. * Particle emitter emitting particles from the inside of a box.
  12387. * It emits the particles randomly between 2 given directions.
  12388. */
  12389. export class BoxParticleEmitter implements IParticleEmitterType {
  12390. /**
  12391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12392. */
  12393. direction1: Vector3;
  12394. /**
  12395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12396. */
  12397. direction2: Vector3;
  12398. /**
  12399. * 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.
  12400. */
  12401. minEmitBox: Vector3;
  12402. /**
  12403. * 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.
  12404. */
  12405. maxEmitBox: Vector3;
  12406. /**
  12407. * Creates a new instance BoxParticleEmitter
  12408. */
  12409. constructor();
  12410. /**
  12411. * Called by the particle System when the direction is computed for the created particle.
  12412. * @param worldMatrix is the world matrix of the particle system
  12413. * @param directionToUpdate is the direction vector to update with the result
  12414. * @param particle is the particle we are computed the direction for
  12415. * @param isLocal defines if the direction should be set in local space
  12416. */
  12417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12418. /**
  12419. * Called by the particle System when the position is computed for the created particle.
  12420. * @param worldMatrix is the world matrix of the particle system
  12421. * @param positionToUpdate is the position vector to update with the result
  12422. * @param particle is the particle we are computed the position for
  12423. * @param isLocal defines if the position should be set in local space
  12424. */
  12425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12426. /**
  12427. * Clones the current emitter and returns a copy of it
  12428. * @returns the new emitter
  12429. */
  12430. clone(): BoxParticleEmitter;
  12431. /**
  12432. * Called by the GPUParticleSystem to setup the update shader
  12433. * @param effect defines the update shader
  12434. */
  12435. applyToShader(effect: Effect): void;
  12436. /**
  12437. * Returns a string to use to update the GPU particles update shader
  12438. * @returns a string containng the defines string
  12439. */
  12440. getEffectDefines(): string;
  12441. /**
  12442. * Returns the string "BoxParticleEmitter"
  12443. * @returns a string containing the class name
  12444. */
  12445. getClassName(): string;
  12446. /**
  12447. * Serializes the particle system to a JSON object.
  12448. * @returns the JSON object
  12449. */
  12450. serialize(): any;
  12451. /**
  12452. * Parse properties from a JSON object
  12453. * @param serializationObject defines the JSON object
  12454. */
  12455. parse(serializationObject: any): void;
  12456. }
  12457. }
  12458. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12460. import { Effect } from "babylonjs/Materials/effect";
  12461. import { Particle } from "babylonjs/Particles/particle";
  12462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12463. /**
  12464. * Particle emitter emitting particles from the inside of a cone.
  12465. * It emits the particles alongside the cone volume from the base to the particle.
  12466. * The emission direction might be randomized.
  12467. */
  12468. export class ConeParticleEmitter implements IParticleEmitterType {
  12469. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12470. directionRandomizer: number;
  12471. private _radius;
  12472. private _angle;
  12473. private _height;
  12474. /**
  12475. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12476. */
  12477. radiusRange: number;
  12478. /**
  12479. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12480. */
  12481. heightRange: number;
  12482. /**
  12483. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12484. */
  12485. emitFromSpawnPointOnly: boolean;
  12486. /**
  12487. * Gets or sets the radius of the emission cone
  12488. */
  12489. get radius(): number;
  12490. set radius(value: number);
  12491. /**
  12492. * Gets or sets the angle of the emission cone
  12493. */
  12494. get angle(): number;
  12495. set angle(value: number);
  12496. private _buildHeight;
  12497. /**
  12498. * Creates a new instance ConeParticleEmitter
  12499. * @param radius the radius of the emission cone (1 by default)
  12500. * @param angle the cone base angle (PI by default)
  12501. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12502. */
  12503. constructor(radius?: number, angle?: number,
  12504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12505. directionRandomizer?: number);
  12506. /**
  12507. * Called by the particle System when the direction is computed for the created particle.
  12508. * @param worldMatrix is the world matrix of the particle system
  12509. * @param directionToUpdate is the direction vector to update with the result
  12510. * @param particle is the particle we are computed the direction for
  12511. * @param isLocal defines if the direction should be set in local space
  12512. */
  12513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12514. /**
  12515. * Called by the particle System when the position is computed for the created particle.
  12516. * @param worldMatrix is the world matrix of the particle system
  12517. * @param positionToUpdate is the position vector to update with the result
  12518. * @param particle is the particle we are computed the position for
  12519. * @param isLocal defines if the position should be set in local space
  12520. */
  12521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12522. /**
  12523. * Clones the current emitter and returns a copy of it
  12524. * @returns the new emitter
  12525. */
  12526. clone(): ConeParticleEmitter;
  12527. /**
  12528. * Called by the GPUParticleSystem to setup the update shader
  12529. * @param effect defines the update shader
  12530. */
  12531. applyToShader(effect: Effect): void;
  12532. /**
  12533. * Returns a string to use to update the GPU particles update shader
  12534. * @returns a string containng the defines string
  12535. */
  12536. getEffectDefines(): string;
  12537. /**
  12538. * Returns the string "ConeParticleEmitter"
  12539. * @returns a string containing the class name
  12540. */
  12541. getClassName(): string;
  12542. /**
  12543. * Serializes the particle system to a JSON object.
  12544. * @returns the JSON object
  12545. */
  12546. serialize(): any;
  12547. /**
  12548. * Parse properties from a JSON object
  12549. * @param serializationObject defines the JSON object
  12550. */
  12551. parse(serializationObject: any): void;
  12552. }
  12553. }
  12554. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12555. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12556. import { Effect } from "babylonjs/Materials/effect";
  12557. import { Particle } from "babylonjs/Particles/particle";
  12558. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12559. /**
  12560. * Particle emitter emitting particles from the inside of a cylinder.
  12561. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12562. */
  12563. export class CylinderParticleEmitter implements IParticleEmitterType {
  12564. /**
  12565. * The radius of the emission cylinder.
  12566. */
  12567. radius: number;
  12568. /**
  12569. * The height of the emission cylinder.
  12570. */
  12571. height: number;
  12572. /**
  12573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12574. */
  12575. radiusRange: number;
  12576. /**
  12577. * How much to randomize the particle direction [0-1].
  12578. */
  12579. directionRandomizer: number;
  12580. /**
  12581. * Creates a new instance CylinderParticleEmitter
  12582. * @param radius the radius of the emission cylinder (1 by default)
  12583. * @param height the height of the emission cylinder (1 by default)
  12584. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12585. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12586. */
  12587. constructor(
  12588. /**
  12589. * The radius of the emission cylinder.
  12590. */
  12591. radius?: number,
  12592. /**
  12593. * The height of the emission cylinder.
  12594. */
  12595. height?: number,
  12596. /**
  12597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12598. */
  12599. radiusRange?: number,
  12600. /**
  12601. * How much to randomize the particle direction [0-1].
  12602. */
  12603. directionRandomizer?: number);
  12604. /**
  12605. * Called by the particle System when the direction is computed for the created particle.
  12606. * @param worldMatrix is the world matrix of the particle system
  12607. * @param directionToUpdate is the direction vector to update with the result
  12608. * @param particle is the particle we are computed the direction for
  12609. * @param isLocal defines if the direction should be set in local space
  12610. */
  12611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12612. /**
  12613. * Called by the particle System when the position is computed for the created particle.
  12614. * @param worldMatrix is the world matrix of the particle system
  12615. * @param positionToUpdate is the position vector to update with the result
  12616. * @param particle is the particle we are computed the position for
  12617. * @param isLocal defines if the position should be set in local space
  12618. */
  12619. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12620. /**
  12621. * Clones the current emitter and returns a copy of it
  12622. * @returns the new emitter
  12623. */
  12624. clone(): CylinderParticleEmitter;
  12625. /**
  12626. * Called by the GPUParticleSystem to setup the update shader
  12627. * @param effect defines the update shader
  12628. */
  12629. applyToShader(effect: Effect): void;
  12630. /**
  12631. * Returns a string to use to update the GPU particles update shader
  12632. * @returns a string containng the defines string
  12633. */
  12634. getEffectDefines(): string;
  12635. /**
  12636. * Returns the string "CylinderParticleEmitter"
  12637. * @returns a string containing the class name
  12638. */
  12639. getClassName(): string;
  12640. /**
  12641. * Serializes the particle system to a JSON object.
  12642. * @returns the JSON object
  12643. */
  12644. serialize(): any;
  12645. /**
  12646. * Parse properties from a JSON object
  12647. * @param serializationObject defines the JSON object
  12648. */
  12649. parse(serializationObject: any): void;
  12650. }
  12651. /**
  12652. * Particle emitter emitting particles from the inside of a cylinder.
  12653. * It emits the particles randomly between two vectors.
  12654. */
  12655. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12656. /**
  12657. * The min limit of the emission direction.
  12658. */
  12659. direction1: Vector3;
  12660. /**
  12661. * The max limit of the emission direction.
  12662. */
  12663. direction2: Vector3;
  12664. /**
  12665. * Creates a new instance CylinderDirectedParticleEmitter
  12666. * @param radius the radius of the emission cylinder (1 by default)
  12667. * @param height the height of the emission cylinder (1 by default)
  12668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12669. * @param direction1 the min limit of the emission direction (up vector by default)
  12670. * @param direction2 the max limit of the emission direction (up vector by default)
  12671. */
  12672. constructor(radius?: number, height?: number, radiusRange?: number,
  12673. /**
  12674. * The min limit of the emission direction.
  12675. */
  12676. direction1?: Vector3,
  12677. /**
  12678. * The max limit of the emission direction.
  12679. */
  12680. direction2?: Vector3);
  12681. /**
  12682. * Called by the particle System when the direction is computed for the created particle.
  12683. * @param worldMatrix is the world matrix of the particle system
  12684. * @param directionToUpdate is the direction vector to update with the result
  12685. * @param particle is the particle we are computed the direction for
  12686. */
  12687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12688. /**
  12689. * Clones the current emitter and returns a copy of it
  12690. * @returns the new emitter
  12691. */
  12692. clone(): CylinderDirectedParticleEmitter;
  12693. /**
  12694. * Called by the GPUParticleSystem to setup the update shader
  12695. * @param effect defines the update shader
  12696. */
  12697. applyToShader(effect: Effect): void;
  12698. /**
  12699. * Returns a string to use to update the GPU particles update shader
  12700. * @returns a string containng the defines string
  12701. */
  12702. getEffectDefines(): string;
  12703. /**
  12704. * Returns the string "CylinderDirectedParticleEmitter"
  12705. * @returns a string containing the class name
  12706. */
  12707. getClassName(): string;
  12708. /**
  12709. * Serializes the particle system to a JSON object.
  12710. * @returns the JSON object
  12711. */
  12712. serialize(): any;
  12713. /**
  12714. * Parse properties from a JSON object
  12715. * @param serializationObject defines the JSON object
  12716. */
  12717. parse(serializationObject: any): void;
  12718. }
  12719. }
  12720. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12721. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12722. import { Effect } from "babylonjs/Materials/effect";
  12723. import { Particle } from "babylonjs/Particles/particle";
  12724. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12725. /**
  12726. * Particle emitter emitting particles from the inside of a hemisphere.
  12727. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12728. */
  12729. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12730. /**
  12731. * The radius of the emission hemisphere.
  12732. */
  12733. radius: number;
  12734. /**
  12735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12736. */
  12737. radiusRange: number;
  12738. /**
  12739. * How much to randomize the particle direction [0-1].
  12740. */
  12741. directionRandomizer: number;
  12742. /**
  12743. * Creates a new instance HemisphericParticleEmitter
  12744. * @param radius the radius of the emission hemisphere (1 by default)
  12745. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12747. */
  12748. constructor(
  12749. /**
  12750. * The radius of the emission hemisphere.
  12751. */
  12752. radius?: number,
  12753. /**
  12754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12755. */
  12756. radiusRange?: number,
  12757. /**
  12758. * How much to randomize the particle direction [0-1].
  12759. */
  12760. directionRandomizer?: number);
  12761. /**
  12762. * Called by the particle System when the direction is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param directionToUpdate is the direction vector to update with the result
  12765. * @param particle is the particle we are computed the direction for
  12766. * @param isLocal defines if the direction should be set in local space
  12767. */
  12768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12769. /**
  12770. * Called by the particle System when the position is computed for the created particle.
  12771. * @param worldMatrix is the world matrix of the particle system
  12772. * @param positionToUpdate is the position vector to update with the result
  12773. * @param particle is the particle we are computed the position for
  12774. * @param isLocal defines if the position should be set in local space
  12775. */
  12776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12777. /**
  12778. * Clones the current emitter and returns a copy of it
  12779. * @returns the new emitter
  12780. */
  12781. clone(): HemisphericParticleEmitter;
  12782. /**
  12783. * Called by the GPUParticleSystem to setup the update shader
  12784. * @param effect defines the update shader
  12785. */
  12786. applyToShader(effect: Effect): void;
  12787. /**
  12788. * Returns a string to use to update the GPU particles update shader
  12789. * @returns a string containng the defines string
  12790. */
  12791. getEffectDefines(): string;
  12792. /**
  12793. * Returns the string "HemisphericParticleEmitter"
  12794. * @returns a string containing the class name
  12795. */
  12796. getClassName(): string;
  12797. /**
  12798. * Serializes the particle system to a JSON object.
  12799. * @returns the JSON object
  12800. */
  12801. serialize(): any;
  12802. /**
  12803. * Parse properties from a JSON object
  12804. * @param serializationObject defines the JSON object
  12805. */
  12806. parse(serializationObject: any): void;
  12807. }
  12808. }
  12809. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12811. import { Effect } from "babylonjs/Materials/effect";
  12812. import { Particle } from "babylonjs/Particles/particle";
  12813. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12814. /**
  12815. * Particle emitter emitting particles from a point.
  12816. * It emits the particles randomly between 2 given directions.
  12817. */
  12818. export class PointParticleEmitter implements IParticleEmitterType {
  12819. /**
  12820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12821. */
  12822. direction1: Vector3;
  12823. /**
  12824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12825. */
  12826. direction2: Vector3;
  12827. /**
  12828. * Creates a new instance PointParticleEmitter
  12829. */
  12830. constructor();
  12831. /**
  12832. * Called by the particle System when the direction is computed for the created particle.
  12833. * @param worldMatrix is the world matrix of the particle system
  12834. * @param directionToUpdate is the direction vector to update with the result
  12835. * @param particle is the particle we are computed the direction for
  12836. * @param isLocal defines if the direction should be set in local space
  12837. */
  12838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12839. /**
  12840. * Called by the particle System when the position is computed for the created particle.
  12841. * @param worldMatrix is the world matrix of the particle system
  12842. * @param positionToUpdate is the position vector to update with the result
  12843. * @param particle is the particle we are computed the position for
  12844. * @param isLocal defines if the position should be set in local space
  12845. */
  12846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12847. /**
  12848. * Clones the current emitter and returns a copy of it
  12849. * @returns the new emitter
  12850. */
  12851. clone(): PointParticleEmitter;
  12852. /**
  12853. * Called by the GPUParticleSystem to setup the update shader
  12854. * @param effect defines the update shader
  12855. */
  12856. applyToShader(effect: Effect): void;
  12857. /**
  12858. * Returns a string to use to update the GPU particles update shader
  12859. * @returns a string containng the defines string
  12860. */
  12861. getEffectDefines(): string;
  12862. /**
  12863. * Returns the string "PointParticleEmitter"
  12864. * @returns a string containing the class name
  12865. */
  12866. getClassName(): string;
  12867. /**
  12868. * Serializes the particle system to a JSON object.
  12869. * @returns the JSON object
  12870. */
  12871. serialize(): any;
  12872. /**
  12873. * Parse properties from a JSON object
  12874. * @param serializationObject defines the JSON object
  12875. */
  12876. parse(serializationObject: any): void;
  12877. }
  12878. }
  12879. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12880. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12881. import { Effect } from "babylonjs/Materials/effect";
  12882. import { Particle } from "babylonjs/Particles/particle";
  12883. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12884. /**
  12885. * Particle emitter emitting particles from the inside of a sphere.
  12886. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12887. */
  12888. export class SphereParticleEmitter implements IParticleEmitterType {
  12889. /**
  12890. * The radius of the emission sphere.
  12891. */
  12892. radius: number;
  12893. /**
  12894. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12895. */
  12896. radiusRange: number;
  12897. /**
  12898. * How much to randomize the particle direction [0-1].
  12899. */
  12900. directionRandomizer: number;
  12901. /**
  12902. * Creates a new instance SphereParticleEmitter
  12903. * @param radius the radius of the emission sphere (1 by default)
  12904. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12905. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12906. */
  12907. constructor(
  12908. /**
  12909. * The radius of the emission sphere.
  12910. */
  12911. radius?: number,
  12912. /**
  12913. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12914. */
  12915. radiusRange?: number,
  12916. /**
  12917. * How much to randomize the particle direction [0-1].
  12918. */
  12919. directionRandomizer?: number);
  12920. /**
  12921. * Called by the particle System when the direction is computed for the created particle.
  12922. * @param worldMatrix is the world matrix of the particle system
  12923. * @param directionToUpdate is the direction vector to update with the result
  12924. * @param particle is the particle we are computed the direction for
  12925. * @param isLocal defines if the direction should be set in local space
  12926. */
  12927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12928. /**
  12929. * Called by the particle System when the position is computed for the created particle.
  12930. * @param worldMatrix is the world matrix of the particle system
  12931. * @param positionToUpdate is the position vector to update with the result
  12932. * @param particle is the particle we are computed the position for
  12933. * @param isLocal defines if the position should be set in local space
  12934. */
  12935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12936. /**
  12937. * Clones the current emitter and returns a copy of it
  12938. * @returns the new emitter
  12939. */
  12940. clone(): SphereParticleEmitter;
  12941. /**
  12942. * Called by the GPUParticleSystem to setup the update shader
  12943. * @param effect defines the update shader
  12944. */
  12945. applyToShader(effect: Effect): void;
  12946. /**
  12947. * Returns a string to use to update the GPU particles update shader
  12948. * @returns a string containng the defines string
  12949. */
  12950. getEffectDefines(): string;
  12951. /**
  12952. * Returns the string "SphereParticleEmitter"
  12953. * @returns a string containing the class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Serializes the particle system to a JSON object.
  12958. * @returns the JSON object
  12959. */
  12960. serialize(): any;
  12961. /**
  12962. * Parse properties from a JSON object
  12963. * @param serializationObject defines the JSON object
  12964. */
  12965. parse(serializationObject: any): void;
  12966. }
  12967. /**
  12968. * Particle emitter emitting particles from the inside of a sphere.
  12969. * It emits the particles randomly between two vectors.
  12970. */
  12971. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12972. /**
  12973. * The min limit of the emission direction.
  12974. */
  12975. direction1: Vector3;
  12976. /**
  12977. * The max limit of the emission direction.
  12978. */
  12979. direction2: Vector3;
  12980. /**
  12981. * Creates a new instance SphereDirectedParticleEmitter
  12982. * @param radius the radius of the emission sphere (1 by default)
  12983. * @param direction1 the min limit of the emission direction (up vector by default)
  12984. * @param direction2 the max limit of the emission direction (up vector by default)
  12985. */
  12986. constructor(radius?: number,
  12987. /**
  12988. * The min limit of the emission direction.
  12989. */
  12990. direction1?: Vector3,
  12991. /**
  12992. * The max limit of the emission direction.
  12993. */
  12994. direction2?: Vector3);
  12995. /**
  12996. * Called by the particle System when the direction is computed for the created particle.
  12997. * @param worldMatrix is the world matrix of the particle system
  12998. * @param directionToUpdate is the direction vector to update with the result
  12999. * @param particle is the particle we are computed the direction for
  13000. */
  13001. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13002. /**
  13003. * Clones the current emitter and returns a copy of it
  13004. * @returns the new emitter
  13005. */
  13006. clone(): SphereDirectedParticleEmitter;
  13007. /**
  13008. * Called by the GPUParticleSystem to setup the update shader
  13009. * @param effect defines the update shader
  13010. */
  13011. applyToShader(effect: Effect): void;
  13012. /**
  13013. * Returns a string to use to update the GPU particles update shader
  13014. * @returns a string containng the defines string
  13015. */
  13016. getEffectDefines(): string;
  13017. /**
  13018. * Returns the string "SphereDirectedParticleEmitter"
  13019. * @returns a string containing the class name
  13020. */
  13021. getClassName(): string;
  13022. /**
  13023. * Serializes the particle system to a JSON object.
  13024. * @returns the JSON object
  13025. */
  13026. serialize(): any;
  13027. /**
  13028. * Parse properties from a JSON object
  13029. * @param serializationObject defines the JSON object
  13030. */
  13031. parse(serializationObject: any): void;
  13032. }
  13033. }
  13034. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13035. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13036. import { Effect } from "babylonjs/Materials/effect";
  13037. import { Particle } from "babylonjs/Particles/particle";
  13038. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13039. import { Nullable } from "babylonjs/types";
  13040. /**
  13041. * Particle emitter emitting particles from a custom list of positions.
  13042. */
  13043. export class CustomParticleEmitter implements IParticleEmitterType {
  13044. /**
  13045. * Gets or sets the position generator that will create the inital position of each particle.
  13046. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13047. */
  13048. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13049. /**
  13050. * Gets or sets the destination generator that will create the final destination of each particle.
  13051. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13052. */
  13053. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13054. /**
  13055. * Creates a new instance CustomParticleEmitter
  13056. */
  13057. constructor();
  13058. /**
  13059. * Called by the particle System when the direction is computed for the created particle.
  13060. * @param worldMatrix is the world matrix of the particle system
  13061. * @param directionToUpdate is the direction vector to update with the result
  13062. * @param particle is the particle we are computed the direction for
  13063. * @param isLocal defines if the direction should be set in local space
  13064. */
  13065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13066. /**
  13067. * Called by the particle System when the position is computed for the created particle.
  13068. * @param worldMatrix is the world matrix of the particle system
  13069. * @param positionToUpdate is the position vector to update with the result
  13070. * @param particle is the particle we are computed the position for
  13071. * @param isLocal defines if the position should be set in local space
  13072. */
  13073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13074. /**
  13075. * Clones the current emitter and returns a copy of it
  13076. * @returns the new emitter
  13077. */
  13078. clone(): CustomParticleEmitter;
  13079. /**
  13080. * Called by the GPUParticleSystem to setup the update shader
  13081. * @param effect defines the update shader
  13082. */
  13083. applyToShader(effect: Effect): void;
  13084. /**
  13085. * Returns a string to use to update the GPU particles update shader
  13086. * @returns a string containng the defines string
  13087. */
  13088. getEffectDefines(): string;
  13089. /**
  13090. * Returns the string "PointParticleEmitter"
  13091. * @returns a string containing the class name
  13092. */
  13093. getClassName(): string;
  13094. /**
  13095. * Serializes the particle system to a JSON object.
  13096. * @returns the JSON object
  13097. */
  13098. serialize(): any;
  13099. /**
  13100. * Parse properties from a JSON object
  13101. * @param serializationObject defines the JSON object
  13102. */
  13103. parse(serializationObject: any): void;
  13104. }
  13105. }
  13106. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13107. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13108. import { Effect } from "babylonjs/Materials/effect";
  13109. import { Particle } from "babylonjs/Particles/particle";
  13110. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13111. import { Scene } from "babylonjs/scene";
  13112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13113. /**
  13114. * Particle emitter emitting particles from the inside of a box.
  13115. * It emits the particles randomly between 2 given directions.
  13116. */
  13117. export class MeshParticleEmitter implements IParticleEmitterType {
  13118. /** Defines the mesh to use as source */
  13119. mesh?: AbstractMesh | undefined;
  13120. private _indices;
  13121. private _positions;
  13122. private _normals;
  13123. private _storedNormal;
  13124. /**
  13125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13126. */
  13127. direction1: Vector3;
  13128. /**
  13129. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13130. */
  13131. direction2: Vector3;
  13132. /**
  13133. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13134. */
  13135. useMeshNormalsForDirection: boolean;
  13136. /**
  13137. * Creates a new instance MeshParticleEmitter
  13138. * @param mesh defines the mesh to use as source
  13139. */
  13140. constructor(
  13141. /** Defines the mesh to use as source */
  13142. mesh?: AbstractMesh | undefined);
  13143. /**
  13144. * Called by the particle System when the direction is computed for the created particle.
  13145. * @param worldMatrix is the world matrix of the particle system
  13146. * @param directionToUpdate is the direction vector to update with the result
  13147. * @param particle is the particle we are computed the direction for
  13148. * @param isLocal defines if the direction should be set in local space
  13149. */
  13150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13151. /**
  13152. * Called by the particle System when the position is computed for the created particle.
  13153. * @param worldMatrix is the world matrix of the particle system
  13154. * @param positionToUpdate is the position vector to update with the result
  13155. * @param particle is the particle we are computed the position for
  13156. * @param isLocal defines if the position should be set in local space
  13157. */
  13158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13159. /**
  13160. * Clones the current emitter and returns a copy of it
  13161. * @returns the new emitter
  13162. */
  13163. clone(): MeshParticleEmitter;
  13164. /**
  13165. * Called by the GPUParticleSystem to setup the update shader
  13166. * @param effect defines the update shader
  13167. */
  13168. applyToShader(effect: Effect): void;
  13169. /**
  13170. * Returns a string to use to update the GPU particles update shader
  13171. * @returns a string containng the defines string
  13172. */
  13173. getEffectDefines(): string;
  13174. /**
  13175. * Returns the string "BoxParticleEmitter"
  13176. * @returns a string containing the class name
  13177. */
  13178. getClassName(): string;
  13179. /**
  13180. * Serializes the particle system to a JSON object.
  13181. * @returns the JSON object
  13182. */
  13183. serialize(): any;
  13184. /**
  13185. * Parse properties from a JSON object
  13186. * @param serializationObject defines the JSON object
  13187. * @param scene defines the hosting scene
  13188. */
  13189. parse(serializationObject: any, scene: Scene): void;
  13190. }
  13191. }
  13192. declare module "babylonjs/Particles/EmitterTypes/index" {
  13193. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13194. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13195. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13196. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13197. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13198. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13199. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13200. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13201. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13202. }
  13203. declare module "babylonjs/Particles/IParticleSystem" {
  13204. import { Nullable } from "babylonjs/types";
  13205. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13206. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13209. import { Texture } from "babylonjs/Materials/Textures/texture";
  13210. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13211. import { Scene } from "babylonjs/scene";
  13212. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13213. import { Animation } from "babylonjs/Animations/animation";
  13214. /**
  13215. * Interface representing a particle system in Babylon.js.
  13216. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13217. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13218. */
  13219. export interface IParticleSystem {
  13220. /**
  13221. * List of animations used by the particle system.
  13222. */
  13223. animations: Animation[];
  13224. /**
  13225. * The id of the Particle system.
  13226. */
  13227. id: string;
  13228. /**
  13229. * The name of the Particle system.
  13230. */
  13231. name: string;
  13232. /**
  13233. * The emitter represents the Mesh or position we are attaching the particle system to.
  13234. */
  13235. emitter: Nullable<AbstractMesh | Vector3>;
  13236. /**
  13237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13238. */
  13239. isBillboardBased: boolean;
  13240. /**
  13241. * The rendering group used by the Particle system to chose when to render.
  13242. */
  13243. renderingGroupId: number;
  13244. /**
  13245. * The layer mask we are rendering the particles through.
  13246. */
  13247. layerMask: number;
  13248. /**
  13249. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13250. */
  13251. updateSpeed: number;
  13252. /**
  13253. * The amount of time the particle system is running (depends of the overall update speed).
  13254. */
  13255. targetStopDuration: number;
  13256. /**
  13257. * The texture used to render each particle. (this can be a spritesheet)
  13258. */
  13259. particleTexture: Nullable<Texture>;
  13260. /**
  13261. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13262. */
  13263. blendMode: number;
  13264. /**
  13265. * Minimum life time of emitting particles.
  13266. */
  13267. minLifeTime: number;
  13268. /**
  13269. * Maximum life time of emitting particles.
  13270. */
  13271. maxLifeTime: number;
  13272. /**
  13273. * Minimum Size of emitting particles.
  13274. */
  13275. minSize: number;
  13276. /**
  13277. * Maximum Size of emitting particles.
  13278. */
  13279. maxSize: number;
  13280. /**
  13281. * Minimum scale of emitting particles on X axis.
  13282. */
  13283. minScaleX: number;
  13284. /**
  13285. * Maximum scale of emitting particles on X axis.
  13286. */
  13287. maxScaleX: number;
  13288. /**
  13289. * Minimum scale of emitting particles on Y axis.
  13290. */
  13291. minScaleY: number;
  13292. /**
  13293. * Maximum scale of emitting particles on Y axis.
  13294. */
  13295. maxScaleY: number;
  13296. /**
  13297. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13298. */
  13299. color1: Color4;
  13300. /**
  13301. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13302. */
  13303. color2: Color4;
  13304. /**
  13305. * Color the particle will have at the end of its lifetime.
  13306. */
  13307. colorDead: Color4;
  13308. /**
  13309. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13310. */
  13311. emitRate: number;
  13312. /**
  13313. * You can use gravity if you want to give an orientation to your particles.
  13314. */
  13315. gravity: Vector3;
  13316. /**
  13317. * Minimum power of emitting particles.
  13318. */
  13319. minEmitPower: number;
  13320. /**
  13321. * Maximum power of emitting particles.
  13322. */
  13323. maxEmitPower: number;
  13324. /**
  13325. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13326. */
  13327. minAngularSpeed: number;
  13328. /**
  13329. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13330. */
  13331. maxAngularSpeed: number;
  13332. /**
  13333. * Gets or sets the minimal initial rotation in radians.
  13334. */
  13335. minInitialRotation: number;
  13336. /**
  13337. * Gets or sets the maximal initial rotation in radians.
  13338. */
  13339. maxInitialRotation: number;
  13340. /**
  13341. * The particle emitter type defines the emitter used by the particle system.
  13342. * It can be for example box, sphere, or cone...
  13343. */
  13344. particleEmitterType: Nullable<IParticleEmitterType>;
  13345. /**
  13346. * Defines the delay in milliseconds before starting the system (0 by default)
  13347. */
  13348. startDelay: number;
  13349. /**
  13350. * 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
  13351. */
  13352. preWarmCycles: number;
  13353. /**
  13354. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13355. */
  13356. preWarmStepOffset: number;
  13357. /**
  13358. * 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)
  13359. */
  13360. spriteCellChangeSpeed: number;
  13361. /**
  13362. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13363. */
  13364. startSpriteCellID: number;
  13365. /**
  13366. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13367. */
  13368. endSpriteCellID: number;
  13369. /**
  13370. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13371. */
  13372. spriteCellWidth: number;
  13373. /**
  13374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13375. */
  13376. spriteCellHeight: number;
  13377. /**
  13378. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13379. */
  13380. spriteRandomStartCell: boolean;
  13381. /**
  13382. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13383. */
  13384. isAnimationSheetEnabled: boolean;
  13385. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13386. translationPivot: Vector2;
  13387. /**
  13388. * Gets or sets a texture used to add random noise to particle positions
  13389. */
  13390. noiseTexture: Nullable<BaseTexture>;
  13391. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13392. noiseStrength: Vector3;
  13393. /**
  13394. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13395. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13396. */
  13397. billboardMode: number;
  13398. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13399. limitVelocityDamping: number;
  13400. /**
  13401. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13402. */
  13403. beginAnimationOnStart: boolean;
  13404. /**
  13405. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13406. */
  13407. beginAnimationFrom: number;
  13408. /**
  13409. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13410. */
  13411. beginAnimationTo: number;
  13412. /**
  13413. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13414. */
  13415. beginAnimationLoop: boolean;
  13416. /**
  13417. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13418. */
  13419. disposeOnStop: boolean;
  13420. /**
  13421. * Specifies if the particles are updated in emitter local space or world space
  13422. */
  13423. isLocal: boolean;
  13424. /**
  13425. * Gets the maximum number of particles active at the same time.
  13426. * @returns The max number of active particles.
  13427. */
  13428. getCapacity(): number;
  13429. /**
  13430. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13431. * @returns True if it has been started, otherwise false.
  13432. */
  13433. isStarted(): boolean;
  13434. /**
  13435. * Animates the particle system for this frame.
  13436. */
  13437. animate(): void;
  13438. /**
  13439. * Renders the particle system in its current state.
  13440. * @returns the current number of particles
  13441. */
  13442. render(): number;
  13443. /**
  13444. * Dispose the particle system and frees its associated resources.
  13445. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13446. */
  13447. dispose(disposeTexture?: boolean): void;
  13448. /**
  13449. * Clones the particle system.
  13450. * @param name The name of the cloned object
  13451. * @param newEmitter The new emitter to use
  13452. * @returns the cloned particle system
  13453. */
  13454. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13455. /**
  13456. * Serializes the particle system to a JSON object.
  13457. * @returns the JSON object
  13458. */
  13459. serialize(): any;
  13460. /**
  13461. * Rebuild the particle system
  13462. */
  13463. rebuild(): void;
  13464. /**
  13465. * Starts the particle system and begins to emit
  13466. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13467. */
  13468. start(delay?: number): void;
  13469. /**
  13470. * Stops the particle system.
  13471. */
  13472. stop(): void;
  13473. /**
  13474. * Remove all active particles
  13475. */
  13476. reset(): void;
  13477. /**
  13478. * Is this system ready to be used/rendered
  13479. * @return true if the system is ready
  13480. */
  13481. isReady(): boolean;
  13482. /**
  13483. * Adds a new color gradient
  13484. * @param gradient defines the gradient to use (between 0 and 1)
  13485. * @param color1 defines the color to affect to the specified gradient
  13486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13487. * @returns the current particle system
  13488. */
  13489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13490. /**
  13491. * Remove a specific color gradient
  13492. * @param gradient defines the gradient to remove
  13493. * @returns the current particle system
  13494. */
  13495. removeColorGradient(gradient: number): IParticleSystem;
  13496. /**
  13497. * Adds a new size gradient
  13498. * @param gradient defines the gradient to use (between 0 and 1)
  13499. * @param factor defines the size factor to affect to the specified gradient
  13500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13501. * @returns the current particle system
  13502. */
  13503. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13504. /**
  13505. * Remove a specific size gradient
  13506. * @param gradient defines the gradient to remove
  13507. * @returns the current particle system
  13508. */
  13509. removeSizeGradient(gradient: number): IParticleSystem;
  13510. /**
  13511. * Gets the current list of color gradients.
  13512. * You must use addColorGradient and removeColorGradient to udpate this list
  13513. * @returns the list of color gradients
  13514. */
  13515. getColorGradients(): Nullable<Array<ColorGradient>>;
  13516. /**
  13517. * Gets the current list of size gradients.
  13518. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13519. * @returns the list of size gradients
  13520. */
  13521. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13522. /**
  13523. * Gets the current list of angular speed gradients.
  13524. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13525. * @returns the list of angular speed gradients
  13526. */
  13527. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13528. /**
  13529. * Adds a new angular speed gradient
  13530. * @param gradient defines the gradient to use (between 0 and 1)
  13531. * @param factor defines the angular speed to affect to the specified gradient
  13532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13533. * @returns the current particle system
  13534. */
  13535. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13536. /**
  13537. * Remove a specific angular speed gradient
  13538. * @param gradient defines the gradient to remove
  13539. * @returns the current particle system
  13540. */
  13541. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13542. /**
  13543. * Gets the current list of velocity gradients.
  13544. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13545. * @returns the list of velocity gradients
  13546. */
  13547. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13548. /**
  13549. * Adds a new velocity gradient
  13550. * @param gradient defines the gradient to use (between 0 and 1)
  13551. * @param factor defines the velocity to affect to the specified gradient
  13552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13553. * @returns the current particle system
  13554. */
  13555. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13556. /**
  13557. * Remove a specific velocity gradient
  13558. * @param gradient defines the gradient to remove
  13559. * @returns the current particle system
  13560. */
  13561. removeVelocityGradient(gradient: number): IParticleSystem;
  13562. /**
  13563. * Gets the current list of limit velocity gradients.
  13564. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13565. * @returns the list of limit velocity gradients
  13566. */
  13567. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13568. /**
  13569. * Adds a new limit velocity gradient
  13570. * @param gradient defines the gradient to use (between 0 and 1)
  13571. * @param factor defines the limit velocity to affect to the specified gradient
  13572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13573. * @returns the current particle system
  13574. */
  13575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13576. /**
  13577. * Remove a specific limit velocity gradient
  13578. * @param gradient defines the gradient to remove
  13579. * @returns the current particle system
  13580. */
  13581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13582. /**
  13583. * Adds a new drag gradient
  13584. * @param gradient defines the gradient to use (between 0 and 1)
  13585. * @param factor defines the drag to affect to the specified gradient
  13586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13587. * @returns the current particle system
  13588. */
  13589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13590. /**
  13591. * Remove a specific drag gradient
  13592. * @param gradient defines the gradient to remove
  13593. * @returns the current particle system
  13594. */
  13595. removeDragGradient(gradient: number): IParticleSystem;
  13596. /**
  13597. * Gets the current list of drag gradients.
  13598. * You must use addDragGradient and removeDragGradient to udpate this list
  13599. * @returns the list of drag gradients
  13600. */
  13601. getDragGradients(): Nullable<Array<FactorGradient>>;
  13602. /**
  13603. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13604. * @param gradient defines the gradient to use (between 0 and 1)
  13605. * @param factor defines the emit rate to affect to the specified gradient
  13606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13607. * @returns the current particle system
  13608. */
  13609. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13610. /**
  13611. * Remove a specific emit rate gradient
  13612. * @param gradient defines the gradient to remove
  13613. * @returns the current particle system
  13614. */
  13615. removeEmitRateGradient(gradient: number): IParticleSystem;
  13616. /**
  13617. * Gets the current list of emit rate gradients.
  13618. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13619. * @returns the list of emit rate gradients
  13620. */
  13621. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13622. /**
  13623. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13624. * @param gradient defines the gradient to use (between 0 and 1)
  13625. * @param factor defines the start size to affect to the specified gradient
  13626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13627. * @returns the current particle system
  13628. */
  13629. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13630. /**
  13631. * Remove a specific start size gradient
  13632. * @param gradient defines the gradient to remove
  13633. * @returns the current particle system
  13634. */
  13635. removeStartSizeGradient(gradient: number): IParticleSystem;
  13636. /**
  13637. * Gets the current list of start size gradients.
  13638. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13639. * @returns the list of start size gradients
  13640. */
  13641. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13642. /**
  13643. * Adds a new life time gradient
  13644. * @param gradient defines the gradient to use (between 0 and 1)
  13645. * @param factor defines the life time factor to affect to the specified gradient
  13646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13647. * @returns the current particle system
  13648. */
  13649. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13650. /**
  13651. * Remove a specific life time gradient
  13652. * @param gradient defines the gradient to remove
  13653. * @returns the current particle system
  13654. */
  13655. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13656. /**
  13657. * Gets the current list of life time gradients.
  13658. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13659. * @returns the list of life time gradients
  13660. */
  13661. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13662. /**
  13663. * Gets the current list of color gradients.
  13664. * You must use addColorGradient and removeColorGradient to udpate this list
  13665. * @returns the list of color gradients
  13666. */
  13667. getColorGradients(): Nullable<Array<ColorGradient>>;
  13668. /**
  13669. * Adds a new ramp gradient used to remap particle colors
  13670. * @param gradient defines the gradient to use (between 0 and 1)
  13671. * @param color defines the color to affect to the specified gradient
  13672. * @returns the current particle system
  13673. */
  13674. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13675. /**
  13676. * Gets the current list of ramp gradients.
  13677. * You must use addRampGradient and removeRampGradient to udpate this list
  13678. * @returns the list of ramp gradients
  13679. */
  13680. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13681. /** Gets or sets a boolean indicating that ramp gradients must be used
  13682. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13683. */
  13684. useRampGradients: boolean;
  13685. /**
  13686. * Adds a new color remap gradient
  13687. * @param gradient defines the gradient to use (between 0 and 1)
  13688. * @param min defines the color remap minimal range
  13689. * @param max defines the color remap maximal range
  13690. * @returns the current particle system
  13691. */
  13692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13693. /**
  13694. * Gets the current list of color remap gradients.
  13695. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13696. * @returns the list of color remap gradients
  13697. */
  13698. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13699. /**
  13700. * Adds a new alpha remap gradient
  13701. * @param gradient defines the gradient to use (between 0 and 1)
  13702. * @param min defines the alpha remap minimal range
  13703. * @param max defines the alpha remap maximal range
  13704. * @returns the current particle system
  13705. */
  13706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13707. /**
  13708. * Gets the current list of alpha remap gradients.
  13709. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13710. * @returns the list of alpha remap gradients
  13711. */
  13712. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13713. /**
  13714. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13717. * @returns the emitter
  13718. */
  13719. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13720. /**
  13721. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13722. * @param radius The radius of the hemisphere to emit from
  13723. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13724. * @returns the emitter
  13725. */
  13726. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13727. /**
  13728. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13729. * @param radius The radius of the sphere to emit from
  13730. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13731. * @returns the emitter
  13732. */
  13733. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13734. /**
  13735. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13736. * @param radius The radius of the sphere to emit from
  13737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13739. * @returns the emitter
  13740. */
  13741. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13742. /**
  13743. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13744. * @param radius The radius of the emission cylinder
  13745. * @param height The height of the emission cylinder
  13746. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13747. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13748. * @returns the emitter
  13749. */
  13750. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13751. /**
  13752. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13753. * @param radius The radius of the cylinder to emit from
  13754. * @param height The height of the emission cylinder
  13755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13758. * @returns the emitter
  13759. */
  13760. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13761. /**
  13762. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13763. * @param radius The radius of the cone to emit from
  13764. * @param angle The base angle of the cone
  13765. * @returns the emitter
  13766. */
  13767. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13768. /**
  13769. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13772. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13773. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13774. * @returns the emitter
  13775. */
  13776. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13777. /**
  13778. * Get hosting scene
  13779. * @returns the scene
  13780. */
  13781. getScene(): Scene;
  13782. }
  13783. }
  13784. declare module "babylonjs/Meshes/transformNode" {
  13785. import { DeepImmutable } from "babylonjs/types";
  13786. import { Observable } from "babylonjs/Misc/observable";
  13787. import { Nullable } from "babylonjs/types";
  13788. import { Camera } from "babylonjs/Cameras/camera";
  13789. import { Scene } from "babylonjs/scene";
  13790. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13791. import { Node } from "babylonjs/node";
  13792. import { Bone } from "babylonjs/Bones/bone";
  13793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13794. import { Space } from "babylonjs/Maths/math.axis";
  13795. /**
  13796. * 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.
  13797. * @see https://doc.babylonjs.com/how_to/transformnode
  13798. */
  13799. export class TransformNode extends Node {
  13800. /**
  13801. * Object will not rotate to face the camera
  13802. */
  13803. static BILLBOARDMODE_NONE: number;
  13804. /**
  13805. * Object will rotate to face the camera but only on the x axis
  13806. */
  13807. static BILLBOARDMODE_X: number;
  13808. /**
  13809. * Object will rotate to face the camera but only on the y axis
  13810. */
  13811. static BILLBOARDMODE_Y: number;
  13812. /**
  13813. * Object will rotate to face the camera but only on the z axis
  13814. */
  13815. static BILLBOARDMODE_Z: number;
  13816. /**
  13817. * Object will rotate to face the camera
  13818. */
  13819. static BILLBOARDMODE_ALL: number;
  13820. /**
  13821. * Object will rotate to face the camera's position instead of orientation
  13822. */
  13823. static BILLBOARDMODE_USE_POSITION: number;
  13824. private _forward;
  13825. private _forwardInverted;
  13826. private _up;
  13827. private _right;
  13828. private _rightInverted;
  13829. private _position;
  13830. private _rotation;
  13831. private _rotationQuaternion;
  13832. protected _scaling: Vector3;
  13833. protected _isDirty: boolean;
  13834. private _transformToBoneReferal;
  13835. private _isAbsoluteSynced;
  13836. private _billboardMode;
  13837. /**
  13838. * Gets or sets the billboard mode. Default is 0.
  13839. *
  13840. * | Value | Type | Description |
  13841. * | --- | --- | --- |
  13842. * | 0 | BILLBOARDMODE_NONE | |
  13843. * | 1 | BILLBOARDMODE_X | |
  13844. * | 2 | BILLBOARDMODE_Y | |
  13845. * | 4 | BILLBOARDMODE_Z | |
  13846. * | 7 | BILLBOARDMODE_ALL | |
  13847. *
  13848. */
  13849. get billboardMode(): number;
  13850. set billboardMode(value: number);
  13851. private _preserveParentRotationForBillboard;
  13852. /**
  13853. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13854. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13855. */
  13856. get preserveParentRotationForBillboard(): boolean;
  13857. set preserveParentRotationForBillboard(value: boolean);
  13858. /**
  13859. * 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
  13860. */
  13861. scalingDeterminant: number;
  13862. private _infiniteDistance;
  13863. /**
  13864. * Gets or sets the distance of the object to max, often used by skybox
  13865. */
  13866. get infiniteDistance(): boolean;
  13867. set infiniteDistance(value: boolean);
  13868. /**
  13869. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13870. * By default the system will update normals to compensate
  13871. */
  13872. ignoreNonUniformScaling: boolean;
  13873. /**
  13874. * 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
  13875. */
  13876. reIntegrateRotationIntoRotationQuaternion: boolean;
  13877. /** @hidden */
  13878. _poseMatrix: Nullable<Matrix>;
  13879. /** @hidden */
  13880. _localMatrix: Matrix;
  13881. private _usePivotMatrix;
  13882. private _absolutePosition;
  13883. private _absoluteScaling;
  13884. private _absoluteRotationQuaternion;
  13885. private _pivotMatrix;
  13886. private _pivotMatrixInverse;
  13887. protected _postMultiplyPivotMatrix: boolean;
  13888. protected _isWorldMatrixFrozen: boolean;
  13889. /** @hidden */
  13890. _indexInSceneTransformNodesArray: number;
  13891. /**
  13892. * An event triggered after the world matrix is updated
  13893. */
  13894. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13895. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13896. /**
  13897. * Gets a string identifying the name of the class
  13898. * @returns "TransformNode" string
  13899. */
  13900. getClassName(): string;
  13901. /**
  13902. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13903. */
  13904. get position(): Vector3;
  13905. set position(newPosition: Vector3);
  13906. /**
  13907. * 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)).
  13908. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13909. */
  13910. get rotation(): Vector3;
  13911. set rotation(newRotation: Vector3);
  13912. /**
  13913. * 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)).
  13914. */
  13915. get scaling(): Vector3;
  13916. set scaling(newScaling: Vector3);
  13917. /**
  13918. * 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).
  13919. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13920. */
  13921. get rotationQuaternion(): Nullable<Quaternion>;
  13922. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13923. /**
  13924. * The forward direction of that transform in world space.
  13925. */
  13926. get forward(): Vector3;
  13927. /**
  13928. * The up direction of that transform in world space.
  13929. */
  13930. get up(): Vector3;
  13931. /**
  13932. * The right direction of that transform in world space.
  13933. */
  13934. get right(): Vector3;
  13935. /**
  13936. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13937. * @param matrix the matrix to copy the pose from
  13938. * @returns this TransformNode.
  13939. */
  13940. updatePoseMatrix(matrix: Matrix): TransformNode;
  13941. /**
  13942. * Returns the mesh Pose matrix.
  13943. * @returns the pose matrix
  13944. */
  13945. getPoseMatrix(): Matrix;
  13946. /** @hidden */
  13947. _isSynchronized(): boolean;
  13948. /** @hidden */
  13949. _initCache(): void;
  13950. /**
  13951. * Flag the transform node as dirty (Forcing it to update everything)
  13952. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13953. * @returns this transform node
  13954. */
  13955. markAsDirty(property: string): TransformNode;
  13956. /**
  13957. * Returns the current mesh absolute position.
  13958. * Returns a Vector3.
  13959. */
  13960. get absolutePosition(): Vector3;
  13961. /**
  13962. * Returns the current mesh absolute scaling.
  13963. * Returns a Vector3.
  13964. */
  13965. get absoluteScaling(): Vector3;
  13966. /**
  13967. * Returns the current mesh absolute rotation.
  13968. * Returns a Quaternion.
  13969. */
  13970. get absoluteRotationQuaternion(): Quaternion;
  13971. /**
  13972. * Sets a new matrix to apply before all other transformation
  13973. * @param matrix defines the transform matrix
  13974. * @returns the current TransformNode
  13975. */
  13976. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13977. /**
  13978. * Sets a new pivot matrix to the current node
  13979. * @param matrix defines the new pivot matrix to use
  13980. * @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
  13981. * @returns the current TransformNode
  13982. */
  13983. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13984. /**
  13985. * Returns the mesh pivot matrix.
  13986. * Default : Identity.
  13987. * @returns the matrix
  13988. */
  13989. getPivotMatrix(): Matrix;
  13990. /**
  13991. * Instantiate (when possible) or clone that node with its hierarchy
  13992. * @param newParent defines the new parent to use for the instance (or clone)
  13993. * @param options defines options to configure how copy is done
  13994. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13995. * @returns an instance (or a clone) of the current node with its hiearchy
  13996. */
  13997. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13998. doNotInstantiate: boolean;
  13999. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14000. /**
  14001. * Prevents the World matrix to be computed any longer
  14002. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14003. * @returns the TransformNode.
  14004. */
  14005. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14006. /**
  14007. * Allows back the World matrix computation.
  14008. * @returns the TransformNode.
  14009. */
  14010. unfreezeWorldMatrix(): this;
  14011. /**
  14012. * True if the World matrix has been frozen.
  14013. */
  14014. get isWorldMatrixFrozen(): boolean;
  14015. /**
  14016. * Retuns the mesh absolute position in the World.
  14017. * @returns a Vector3.
  14018. */
  14019. getAbsolutePosition(): Vector3;
  14020. /**
  14021. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14022. * @param absolutePosition the absolute position to set
  14023. * @returns the TransformNode.
  14024. */
  14025. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14026. /**
  14027. * Sets the mesh position in its local space.
  14028. * @param vector3 the position to set in localspace
  14029. * @returns the TransformNode.
  14030. */
  14031. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14032. /**
  14033. * Returns the mesh position in the local space from the current World matrix values.
  14034. * @returns a new Vector3.
  14035. */
  14036. getPositionExpressedInLocalSpace(): Vector3;
  14037. /**
  14038. * Translates the mesh along the passed Vector3 in its local space.
  14039. * @param vector3 the distance to translate in localspace
  14040. * @returns the TransformNode.
  14041. */
  14042. locallyTranslate(vector3: Vector3): TransformNode;
  14043. private static _lookAtVectorCache;
  14044. /**
  14045. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14046. * @param targetPoint the position (must be in same space as current mesh) to look at
  14047. * @param yawCor optional yaw (y-axis) correction in radians
  14048. * @param pitchCor optional pitch (x-axis) correction in radians
  14049. * @param rollCor optional roll (z-axis) correction in radians
  14050. * @param space the choosen space of the target
  14051. * @returns the TransformNode.
  14052. */
  14053. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14054. /**
  14055. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14056. * This Vector3 is expressed in the World space.
  14057. * @param localAxis axis to rotate
  14058. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14059. */
  14060. getDirection(localAxis: Vector3): Vector3;
  14061. /**
  14062. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14063. * localAxis is expressed in the mesh local space.
  14064. * result is computed in the Wordl space from the mesh World matrix.
  14065. * @param localAxis axis to rotate
  14066. * @param result the resulting transformnode
  14067. * @returns this TransformNode.
  14068. */
  14069. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14070. /**
  14071. * Sets this transform node rotation to the given local axis.
  14072. * @param localAxis the axis in local space
  14073. * @param yawCor optional yaw (y-axis) correction in radians
  14074. * @param pitchCor optional pitch (x-axis) correction in radians
  14075. * @param rollCor optional roll (z-axis) correction in radians
  14076. * @returns this TransformNode
  14077. */
  14078. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14079. /**
  14080. * Sets a new pivot point to the current node
  14081. * @param point defines the new pivot point to use
  14082. * @param space defines if the point is in world or local space (local by default)
  14083. * @returns the current TransformNode
  14084. */
  14085. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14086. /**
  14087. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14088. * @returns the pivot point
  14089. */
  14090. getPivotPoint(): Vector3;
  14091. /**
  14092. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14093. * @param result the vector3 to store the result
  14094. * @returns this TransformNode.
  14095. */
  14096. getPivotPointToRef(result: Vector3): TransformNode;
  14097. /**
  14098. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14099. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14100. */
  14101. getAbsolutePivotPoint(): Vector3;
  14102. /**
  14103. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14104. * @param result vector3 to store the result
  14105. * @returns this TransformNode.
  14106. */
  14107. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14108. /**
  14109. * Defines the passed node as the parent of the current node.
  14110. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14111. * @see https://doc.babylonjs.com/how_to/parenting
  14112. * @param node the node ot set as the parent
  14113. * @returns this TransformNode.
  14114. */
  14115. setParent(node: Nullable<Node>): TransformNode;
  14116. private _nonUniformScaling;
  14117. /**
  14118. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14119. */
  14120. get nonUniformScaling(): boolean;
  14121. /** @hidden */
  14122. _updateNonUniformScalingState(value: boolean): boolean;
  14123. /**
  14124. * Attach the current TransformNode to another TransformNode associated with a bone
  14125. * @param bone Bone affecting the TransformNode
  14126. * @param affectedTransformNode TransformNode associated with the bone
  14127. * @returns this object
  14128. */
  14129. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14130. /**
  14131. * Detach the transform node if its associated with a bone
  14132. * @returns this object
  14133. */
  14134. detachFromBone(): TransformNode;
  14135. private static _rotationAxisCache;
  14136. /**
  14137. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14138. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14139. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14140. * The passed axis is also normalized.
  14141. * @param axis the axis to rotate around
  14142. * @param amount the amount to rotate in radians
  14143. * @param space Space to rotate in (Default: local)
  14144. * @returns the TransformNode.
  14145. */
  14146. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14147. /**
  14148. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14149. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14150. * The passed axis is also normalized. .
  14151. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14152. * @param point the point to rotate around
  14153. * @param axis the axis to rotate around
  14154. * @param amount the amount to rotate in radians
  14155. * @returns the TransformNode
  14156. */
  14157. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14158. /**
  14159. * Translates the mesh along the axis vector for the passed distance in the given space.
  14160. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14161. * @param axis the axis to translate in
  14162. * @param distance the distance to translate
  14163. * @param space Space to rotate in (Default: local)
  14164. * @returns the TransformNode.
  14165. */
  14166. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14167. /**
  14168. * Adds a rotation step to the mesh current rotation.
  14169. * x, y, z are Euler angles expressed in radians.
  14170. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14171. * This means this rotation is made in the mesh local space only.
  14172. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14173. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14174. * ```javascript
  14175. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14176. * ```
  14177. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14178. * 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.
  14179. * @param x Rotation to add
  14180. * @param y Rotation to add
  14181. * @param z Rotation to add
  14182. * @returns the TransformNode.
  14183. */
  14184. addRotation(x: number, y: number, z: number): TransformNode;
  14185. /**
  14186. * @hidden
  14187. */
  14188. protected _getEffectiveParent(): Nullable<Node>;
  14189. /**
  14190. * Computes the world matrix of the node
  14191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14192. * @returns the world matrix
  14193. */
  14194. computeWorldMatrix(force?: boolean): Matrix;
  14195. /**
  14196. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14197. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14198. */
  14199. resetLocalMatrix(independentOfChildren?: boolean): void;
  14200. protected _afterComputeWorldMatrix(): void;
  14201. /**
  14202. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14203. * @param func callback function to add
  14204. *
  14205. * @returns the TransformNode.
  14206. */
  14207. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14208. /**
  14209. * Removes a registered callback function.
  14210. * @param func callback function to remove
  14211. * @returns the TransformNode.
  14212. */
  14213. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14214. /**
  14215. * Gets the position of the current mesh in camera space
  14216. * @param camera defines the camera to use
  14217. * @returns a position
  14218. */
  14219. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14220. /**
  14221. * Returns the distance from the mesh to the active camera
  14222. * @param camera defines the camera to use
  14223. * @returns the distance
  14224. */
  14225. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14226. /**
  14227. * Clone the current transform node
  14228. * @param name Name of the new clone
  14229. * @param newParent New parent for the clone
  14230. * @param doNotCloneChildren Do not clone children hierarchy
  14231. * @returns the new transform node
  14232. */
  14233. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14234. /**
  14235. * Serializes the objects information.
  14236. * @param currentSerializationObject defines the object to serialize in
  14237. * @returns the serialized object
  14238. */
  14239. serialize(currentSerializationObject?: any): any;
  14240. /**
  14241. * Returns a new TransformNode object parsed from the source provided.
  14242. * @param parsedTransformNode is the source.
  14243. * @param scene the scne the object belongs to
  14244. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14245. * @returns a new TransformNode object parsed from the source provided.
  14246. */
  14247. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14248. /**
  14249. * Get all child-transformNodes of this node
  14250. * @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
  14251. * @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
  14252. * @returns an array of TransformNode
  14253. */
  14254. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14255. /**
  14256. * Releases resources associated with this transform node.
  14257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14259. */
  14260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14261. /**
  14262. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14263. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14264. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14265. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14266. * @returns the current mesh
  14267. */
  14268. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14269. private _syncAbsoluteScalingAndRotation;
  14270. }
  14271. }
  14272. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14273. /**
  14274. * Class used to override all child animations of a given target
  14275. */
  14276. export class AnimationPropertiesOverride {
  14277. /**
  14278. * Gets or sets a value indicating if animation blending must be used
  14279. */
  14280. enableBlending: boolean;
  14281. /**
  14282. * Gets or sets the blending speed to use when enableBlending is true
  14283. */
  14284. blendingSpeed: number;
  14285. /**
  14286. * Gets or sets the default loop mode to use
  14287. */
  14288. loopMode: number;
  14289. }
  14290. }
  14291. declare module "babylonjs/Bones/bone" {
  14292. import { Skeleton } from "babylonjs/Bones/skeleton";
  14293. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14294. import { Nullable } from "babylonjs/types";
  14295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14297. import { Node } from "babylonjs/node";
  14298. import { Space } from "babylonjs/Maths/math.axis";
  14299. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14300. /**
  14301. * Class used to store bone information
  14302. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14303. */
  14304. export class Bone extends Node {
  14305. /**
  14306. * defines the bone name
  14307. */
  14308. name: string;
  14309. private static _tmpVecs;
  14310. private static _tmpQuat;
  14311. private static _tmpMats;
  14312. /**
  14313. * Gets the list of child bones
  14314. */
  14315. children: Bone[];
  14316. /** Gets the animations associated with this bone */
  14317. animations: import("babylonjs/Animations/animation").Animation[];
  14318. /**
  14319. * Gets or sets bone length
  14320. */
  14321. length: number;
  14322. /**
  14323. * @hidden Internal only
  14324. * Set this value to map this bone to a different index in the transform matrices
  14325. * Set this value to -1 to exclude the bone from the transform matrices
  14326. */
  14327. _index: Nullable<number>;
  14328. private _skeleton;
  14329. private _localMatrix;
  14330. private _restPose;
  14331. private _baseMatrix;
  14332. private _absoluteTransform;
  14333. private _invertedAbsoluteTransform;
  14334. private _parent;
  14335. private _scalingDeterminant;
  14336. private _worldTransform;
  14337. private _localScaling;
  14338. private _localRotation;
  14339. private _localPosition;
  14340. private _needToDecompose;
  14341. private _needToCompose;
  14342. /** @hidden */
  14343. _linkedTransformNode: Nullable<TransformNode>;
  14344. /** @hidden */
  14345. _waitingTransformNodeId: Nullable<string>;
  14346. /** @hidden */
  14347. get _matrix(): Matrix;
  14348. /** @hidden */
  14349. set _matrix(value: Matrix);
  14350. /**
  14351. * Create a new bone
  14352. * @param name defines the bone name
  14353. * @param skeleton defines the parent skeleton
  14354. * @param parentBone defines the parent (can be null if the bone is the root)
  14355. * @param localMatrix defines the local matrix
  14356. * @param restPose defines the rest pose matrix
  14357. * @param baseMatrix defines the base matrix
  14358. * @param index defines index of the bone in the hiearchy
  14359. */
  14360. constructor(
  14361. /**
  14362. * defines the bone name
  14363. */
  14364. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14365. /**
  14366. * Gets the current object class name.
  14367. * @return the class name
  14368. */
  14369. getClassName(): string;
  14370. /**
  14371. * Gets the parent skeleton
  14372. * @returns a skeleton
  14373. */
  14374. getSkeleton(): Skeleton;
  14375. /**
  14376. * Gets parent bone
  14377. * @returns a bone or null if the bone is the root of the bone hierarchy
  14378. */
  14379. getParent(): Nullable<Bone>;
  14380. /**
  14381. * Returns an array containing the root bones
  14382. * @returns an array containing the root bones
  14383. */
  14384. getChildren(): Array<Bone>;
  14385. /**
  14386. * Gets the node index in matrix array generated for rendering
  14387. * @returns the node index
  14388. */
  14389. getIndex(): number;
  14390. /**
  14391. * Sets the parent bone
  14392. * @param parent defines the parent (can be null if the bone is the root)
  14393. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14394. */
  14395. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14396. /**
  14397. * Gets the local matrix
  14398. * @returns a matrix
  14399. */
  14400. getLocalMatrix(): Matrix;
  14401. /**
  14402. * Gets the base matrix (initial matrix which remains unchanged)
  14403. * @returns a matrix
  14404. */
  14405. getBaseMatrix(): Matrix;
  14406. /**
  14407. * Gets the rest pose matrix
  14408. * @returns a matrix
  14409. */
  14410. getRestPose(): Matrix;
  14411. /**
  14412. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14413. */
  14414. getWorldMatrix(): Matrix;
  14415. /**
  14416. * Sets the local matrix to rest pose matrix
  14417. */
  14418. returnToRest(): void;
  14419. /**
  14420. * Gets the inverse of the absolute transform matrix.
  14421. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14422. * @returns a matrix
  14423. */
  14424. getInvertedAbsoluteTransform(): Matrix;
  14425. /**
  14426. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14427. * @returns a matrix
  14428. */
  14429. getAbsoluteTransform(): Matrix;
  14430. /**
  14431. * Links with the given transform node.
  14432. * The local matrix of this bone is copied from the transform node every frame.
  14433. * @param transformNode defines the transform node to link to
  14434. */
  14435. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14436. /**
  14437. * Gets the node used to drive the bone's transformation
  14438. * @returns a transform node or null
  14439. */
  14440. getTransformNode(): Nullable<TransformNode>;
  14441. /** Gets or sets current position (in local space) */
  14442. get position(): Vector3;
  14443. set position(newPosition: Vector3);
  14444. /** Gets or sets current rotation (in local space) */
  14445. get rotation(): Vector3;
  14446. set rotation(newRotation: Vector3);
  14447. /** Gets or sets current rotation quaternion (in local space) */
  14448. get rotationQuaternion(): Quaternion;
  14449. set rotationQuaternion(newRotation: Quaternion);
  14450. /** Gets or sets current scaling (in local space) */
  14451. get scaling(): Vector3;
  14452. set scaling(newScaling: Vector3);
  14453. /**
  14454. * Gets the animation properties override
  14455. */
  14456. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14457. private _decompose;
  14458. private _compose;
  14459. /**
  14460. * Update the base and local matrices
  14461. * @param matrix defines the new base or local matrix
  14462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14463. * @param updateLocalMatrix defines if the local matrix should be updated
  14464. */
  14465. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14466. /** @hidden */
  14467. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14468. /**
  14469. * Flag the bone as dirty (Forcing it to update everything)
  14470. */
  14471. markAsDirty(): void;
  14472. /** @hidden */
  14473. _markAsDirtyAndCompose(): void;
  14474. private _markAsDirtyAndDecompose;
  14475. /**
  14476. * Translate the bone in local or world space
  14477. * @param vec The amount to translate the bone
  14478. * @param space The space that the translation is in
  14479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14480. */
  14481. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14482. /**
  14483. * Set the postion of the bone in local or world space
  14484. * @param position The position to set the bone
  14485. * @param space The space that the position is in
  14486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14487. */
  14488. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14489. /**
  14490. * Set the absolute position of the bone (world space)
  14491. * @param position The position to set the bone
  14492. * @param mesh The mesh that this bone is attached to
  14493. */
  14494. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14495. /**
  14496. * Scale the bone on the x, y and z axes (in local space)
  14497. * @param x The amount to scale the bone on the x axis
  14498. * @param y The amount to scale the bone on the y axis
  14499. * @param z The amount to scale the bone on the z axis
  14500. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14501. */
  14502. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14503. /**
  14504. * Set the bone scaling in local space
  14505. * @param scale defines the scaling vector
  14506. */
  14507. setScale(scale: Vector3): void;
  14508. /**
  14509. * Gets the current scaling in local space
  14510. * @returns the current scaling vector
  14511. */
  14512. getScale(): Vector3;
  14513. /**
  14514. * Gets the current scaling in local space and stores it in a target vector
  14515. * @param result defines the target vector
  14516. */
  14517. getScaleToRef(result: Vector3): void;
  14518. /**
  14519. * Set the yaw, pitch, and roll of the bone in local or world space
  14520. * @param yaw The rotation of the bone on the y axis
  14521. * @param pitch The rotation of the bone on the x axis
  14522. * @param roll The rotation of the bone on the z axis
  14523. * @param space The space that the axes of rotation are in
  14524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14525. */
  14526. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14527. /**
  14528. * Add a rotation to the bone on an axis in local or world space
  14529. * @param axis The axis to rotate the bone on
  14530. * @param amount The amount to rotate the bone
  14531. * @param space The space that the axis is in
  14532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14533. */
  14534. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14535. /**
  14536. * Set the rotation of the bone to a particular axis angle in local or world space
  14537. * @param axis The axis to rotate the bone on
  14538. * @param angle The angle that the bone should be rotated to
  14539. * @param space The space that the axis is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14543. /**
  14544. * Set the euler rotation of the bone in local of world space
  14545. * @param rotation The euler rotation that the bone should be set to
  14546. * @param space The space that the rotation is in
  14547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14548. */
  14549. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14550. /**
  14551. * Set the quaternion rotation of the bone in local of world space
  14552. * @param quat The quaternion rotation that the bone should be set to
  14553. * @param space The space that the rotation is in
  14554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14555. */
  14556. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14557. /**
  14558. * Set the rotation matrix of the bone in local of world space
  14559. * @param rotMat The rotation matrix that the bone should be set to
  14560. * @param space The space that the rotation is in
  14561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14562. */
  14563. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14564. private _rotateWithMatrix;
  14565. private _getNegativeRotationToRef;
  14566. /**
  14567. * Get the position of the bone in local or world space
  14568. * @param space The space that the returned position is in
  14569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14570. * @returns The position of the bone
  14571. */
  14572. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14573. /**
  14574. * Copy the position of the bone to a vector3 in local or world space
  14575. * @param space The space that the returned position is in
  14576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14577. * @param result The vector3 to copy the position to
  14578. */
  14579. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14580. /**
  14581. * Get the absolute position of the bone (world space)
  14582. * @param mesh The mesh that this bone is attached to
  14583. * @returns The absolute position of the bone
  14584. */
  14585. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14586. /**
  14587. * Copy the absolute position of the bone (world space) to the result param
  14588. * @param mesh The mesh that this bone is attached to
  14589. * @param result The vector3 to copy the absolute position to
  14590. */
  14591. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14592. /**
  14593. * Compute the absolute transforms of this bone and its children
  14594. */
  14595. computeAbsoluteTransforms(): void;
  14596. /**
  14597. * Get the world direction from an axis that is in the local space of the bone
  14598. * @param localAxis The local direction that is used to compute the world direction
  14599. * @param mesh The mesh that this bone is attached to
  14600. * @returns The world direction
  14601. */
  14602. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14603. /**
  14604. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14605. * @param localAxis The local direction that is used to compute the world direction
  14606. * @param mesh The mesh that this bone is attached to
  14607. * @param result The vector3 that the world direction will be copied to
  14608. */
  14609. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14610. /**
  14611. * Get the euler rotation of the bone in local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @returns The euler rotation
  14615. */
  14616. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14617. /**
  14618. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @param result The vector3 that the rotation should be copied to
  14622. */
  14623. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14624. /**
  14625. * Get the quaternion rotation of the bone in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @returns The quaternion rotation
  14629. */
  14630. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14631. /**
  14632. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14633. * @param space The space that the rotation should be in
  14634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14635. * @param result The quaternion that the rotation should be copied to
  14636. */
  14637. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14638. /**
  14639. * Get the rotation matrix of the bone in local or world space
  14640. * @param space The space that the rotation should be in
  14641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14642. * @returns The rotation matrix
  14643. */
  14644. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14645. /**
  14646. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14647. * @param space The space that the rotation should be in
  14648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14649. * @param result The quaternion that the rotation should be copied to
  14650. */
  14651. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14652. /**
  14653. * Get the world position of a point that is in the local space of the bone
  14654. * @param position The local position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @returns The world position
  14657. */
  14658. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14659. /**
  14660. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14661. * @param position The local position
  14662. * @param mesh The mesh that this bone is attached to
  14663. * @param result The vector3 that the world position should be copied to
  14664. */
  14665. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14666. /**
  14667. * Get the local position of a point that is in world space
  14668. * @param position The world position
  14669. * @param mesh The mesh that this bone is attached to
  14670. * @returns The local position
  14671. */
  14672. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14673. /**
  14674. * Get the local position of a point that is in world space and copy it to the result param
  14675. * @param position The world position
  14676. * @param mesh The mesh that this bone is attached to
  14677. * @param result The vector3 that the local position should be copied to
  14678. */
  14679. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14680. }
  14681. }
  14682. declare module "babylonjs/Animations/runtimeAnimation" {
  14683. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14684. import { Animatable } from "babylonjs/Animations/animatable";
  14685. import { Scene } from "babylonjs/scene";
  14686. /**
  14687. * Defines a runtime animation
  14688. */
  14689. export class RuntimeAnimation {
  14690. private _events;
  14691. /**
  14692. * The current frame of the runtime animation
  14693. */
  14694. private _currentFrame;
  14695. /**
  14696. * The animation used by the runtime animation
  14697. */
  14698. private _animation;
  14699. /**
  14700. * The target of the runtime animation
  14701. */
  14702. private _target;
  14703. /**
  14704. * The initiating animatable
  14705. */
  14706. private _host;
  14707. /**
  14708. * The original value of the runtime animation
  14709. */
  14710. private _originalValue;
  14711. /**
  14712. * The original blend value of the runtime animation
  14713. */
  14714. private _originalBlendValue;
  14715. /**
  14716. * The offsets cache of the runtime animation
  14717. */
  14718. private _offsetsCache;
  14719. /**
  14720. * The high limits cache of the runtime animation
  14721. */
  14722. private _highLimitsCache;
  14723. /**
  14724. * Specifies if the runtime animation has been stopped
  14725. */
  14726. private _stopped;
  14727. /**
  14728. * The blending factor of the runtime animation
  14729. */
  14730. private _blendingFactor;
  14731. /**
  14732. * The BabylonJS scene
  14733. */
  14734. private _scene;
  14735. /**
  14736. * The current value of the runtime animation
  14737. */
  14738. private _currentValue;
  14739. /** @hidden */
  14740. _animationState: _IAnimationState;
  14741. /**
  14742. * The active target of the runtime animation
  14743. */
  14744. private _activeTargets;
  14745. private _currentActiveTarget;
  14746. private _directTarget;
  14747. /**
  14748. * The target path of the runtime animation
  14749. */
  14750. private _targetPath;
  14751. /**
  14752. * The weight of the runtime animation
  14753. */
  14754. private _weight;
  14755. /**
  14756. * The ratio offset of the runtime animation
  14757. */
  14758. private _ratioOffset;
  14759. /**
  14760. * The previous delay of the runtime animation
  14761. */
  14762. private _previousDelay;
  14763. /**
  14764. * The previous ratio of the runtime animation
  14765. */
  14766. private _previousRatio;
  14767. private _enableBlending;
  14768. private _keys;
  14769. private _minFrame;
  14770. private _maxFrame;
  14771. private _minValue;
  14772. private _maxValue;
  14773. private _targetIsArray;
  14774. /**
  14775. * Gets the current frame of the runtime animation
  14776. */
  14777. get currentFrame(): number;
  14778. /**
  14779. * Gets the weight of the runtime animation
  14780. */
  14781. get weight(): number;
  14782. /**
  14783. * Gets the current value of the runtime animation
  14784. */
  14785. get currentValue(): any;
  14786. /**
  14787. * Gets the target path of the runtime animation
  14788. */
  14789. get targetPath(): string;
  14790. /**
  14791. * Gets the actual target of the runtime animation
  14792. */
  14793. get target(): any;
  14794. /** @hidden */
  14795. _onLoop: () => void;
  14796. /**
  14797. * Create a new RuntimeAnimation object
  14798. * @param target defines the target of the animation
  14799. * @param animation defines the source animation object
  14800. * @param scene defines the hosting scene
  14801. * @param host defines the initiating Animatable
  14802. */
  14803. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14804. private _preparePath;
  14805. /**
  14806. * Gets the animation from the runtime animation
  14807. */
  14808. get animation(): Animation;
  14809. /**
  14810. * Resets the runtime animation to the beginning
  14811. * @param restoreOriginal defines whether to restore the target property to the original value
  14812. */
  14813. reset(restoreOriginal?: boolean): void;
  14814. /**
  14815. * Specifies if the runtime animation is stopped
  14816. * @returns Boolean specifying if the runtime animation is stopped
  14817. */
  14818. isStopped(): boolean;
  14819. /**
  14820. * Disposes of the runtime animation
  14821. */
  14822. dispose(): void;
  14823. /**
  14824. * Apply the interpolated value to the target
  14825. * @param currentValue defines the value computed by the animation
  14826. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14827. */
  14828. setValue(currentValue: any, weight: number): void;
  14829. private _getOriginalValues;
  14830. private _setValue;
  14831. /**
  14832. * Gets the loop pmode of the runtime animation
  14833. * @returns Loop Mode
  14834. */
  14835. private _getCorrectLoopMode;
  14836. /**
  14837. * Move the current animation to a given frame
  14838. * @param frame defines the frame to move to
  14839. */
  14840. goToFrame(frame: number): void;
  14841. /**
  14842. * @hidden Internal use only
  14843. */
  14844. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14845. /**
  14846. * Execute the current animation
  14847. * @param delay defines the delay to add to the current frame
  14848. * @param from defines the lower bound of the animation range
  14849. * @param to defines the upper bound of the animation range
  14850. * @param loop defines if the current animation must loop
  14851. * @param speedRatio defines the current speed ratio
  14852. * @param weight defines the weight of the animation (default is -1 so no weight)
  14853. * @param onLoop optional callback called when animation loops
  14854. * @returns a boolean indicating if the animation is running
  14855. */
  14856. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14857. }
  14858. }
  14859. declare module "babylonjs/Animations/animatable" {
  14860. import { Animation } from "babylonjs/Animations/animation";
  14861. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14862. import { Nullable } from "babylonjs/types";
  14863. import { Observable } from "babylonjs/Misc/observable";
  14864. import { Scene } from "babylonjs/scene";
  14865. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14866. import { Node } from "babylonjs/node";
  14867. /**
  14868. * Class used to store an actual running animation
  14869. */
  14870. export class Animatable {
  14871. /** defines the target object */
  14872. target: any;
  14873. /** defines the starting frame number (default is 0) */
  14874. fromFrame: number;
  14875. /** defines the ending frame number (default is 100) */
  14876. toFrame: number;
  14877. /** defines if the animation must loop (default is false) */
  14878. loopAnimation: boolean;
  14879. /** defines a callback to call when animation ends if it is not looping */
  14880. onAnimationEnd?: (() => void) | null | undefined;
  14881. /** defines a callback to call when animation loops */
  14882. onAnimationLoop?: (() => void) | null | undefined;
  14883. private _localDelayOffset;
  14884. private _pausedDelay;
  14885. private _runtimeAnimations;
  14886. private _paused;
  14887. private _scene;
  14888. private _speedRatio;
  14889. private _weight;
  14890. private _syncRoot;
  14891. /**
  14892. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14893. * This will only apply for non looping animation (default is true)
  14894. */
  14895. disposeOnEnd: boolean;
  14896. /**
  14897. * Gets a boolean indicating if the animation has started
  14898. */
  14899. animationStarted: boolean;
  14900. /**
  14901. * Observer raised when the animation ends
  14902. */
  14903. onAnimationEndObservable: Observable<Animatable>;
  14904. /**
  14905. * Observer raised when the animation loops
  14906. */
  14907. onAnimationLoopObservable: Observable<Animatable>;
  14908. /**
  14909. * Gets the root Animatable used to synchronize and normalize animations
  14910. */
  14911. get syncRoot(): Nullable<Animatable>;
  14912. /**
  14913. * Gets the current frame of the first RuntimeAnimation
  14914. * Used to synchronize Animatables
  14915. */
  14916. get masterFrame(): number;
  14917. /**
  14918. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14919. */
  14920. get weight(): number;
  14921. set weight(value: number);
  14922. /**
  14923. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14924. */
  14925. get speedRatio(): number;
  14926. set speedRatio(value: number);
  14927. /**
  14928. * Creates a new Animatable
  14929. * @param scene defines the hosting scene
  14930. * @param target defines the target object
  14931. * @param fromFrame defines the starting frame number (default is 0)
  14932. * @param toFrame defines the ending frame number (default is 100)
  14933. * @param loopAnimation defines if the animation must loop (default is false)
  14934. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14935. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14936. * @param animations defines a group of animation to add to the new Animatable
  14937. * @param onAnimationLoop defines a callback to call when animation loops
  14938. */
  14939. constructor(scene: Scene,
  14940. /** defines the target object */
  14941. target: any,
  14942. /** defines the starting frame number (default is 0) */
  14943. fromFrame?: number,
  14944. /** defines the ending frame number (default is 100) */
  14945. toFrame?: number,
  14946. /** defines if the animation must loop (default is false) */
  14947. loopAnimation?: boolean, speedRatio?: number,
  14948. /** defines a callback to call when animation ends if it is not looping */
  14949. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14950. /** defines a callback to call when animation loops */
  14951. onAnimationLoop?: (() => void) | null | undefined);
  14952. /**
  14953. * Synchronize and normalize current Animatable with a source Animatable
  14954. * This is useful when using animation weights and when animations are not of the same length
  14955. * @param root defines the root Animatable to synchronize with
  14956. * @returns the current Animatable
  14957. */
  14958. syncWith(root: Animatable): Animatable;
  14959. /**
  14960. * Gets the list of runtime animations
  14961. * @returns an array of RuntimeAnimation
  14962. */
  14963. getAnimations(): RuntimeAnimation[];
  14964. /**
  14965. * Adds more animations to the current animatable
  14966. * @param target defines the target of the animations
  14967. * @param animations defines the new animations to add
  14968. */
  14969. appendAnimations(target: any, animations: Animation[]): void;
  14970. /**
  14971. * Gets the source animation for a specific property
  14972. * @param property defines the propertyu to look for
  14973. * @returns null or the source animation for the given property
  14974. */
  14975. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14976. /**
  14977. * Gets the runtime animation for a specific property
  14978. * @param property defines the propertyu to look for
  14979. * @returns null or the runtime animation for the given property
  14980. */
  14981. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14982. /**
  14983. * Resets the animatable to its original state
  14984. */
  14985. reset(): void;
  14986. /**
  14987. * Allows the animatable to blend with current running animations
  14988. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14989. * @param blendingSpeed defines the blending speed to use
  14990. */
  14991. enableBlending(blendingSpeed: number): void;
  14992. /**
  14993. * Disable animation blending
  14994. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14995. */
  14996. disableBlending(): void;
  14997. /**
  14998. * Jump directly to a given frame
  14999. * @param frame defines the frame to jump to
  15000. */
  15001. goToFrame(frame: number): void;
  15002. /**
  15003. * Pause the animation
  15004. */
  15005. pause(): void;
  15006. /**
  15007. * Restart the animation
  15008. */
  15009. restart(): void;
  15010. private _raiseOnAnimationEnd;
  15011. /**
  15012. * Stop and delete the current animation
  15013. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15014. * @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)
  15015. */
  15016. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15017. /**
  15018. * Wait asynchronously for the animation to end
  15019. * @returns a promise which will be fullfilled when the animation ends
  15020. */
  15021. waitAsync(): Promise<Animatable>;
  15022. /** @hidden */
  15023. _animate(delay: number): boolean;
  15024. }
  15025. module "babylonjs/scene" {
  15026. interface Scene {
  15027. /** @hidden */
  15028. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15029. /** @hidden */
  15030. _processLateAnimationBindingsForMatrices(holder: {
  15031. totalWeight: number;
  15032. animations: RuntimeAnimation[];
  15033. originalValue: Matrix;
  15034. }): any;
  15035. /** @hidden */
  15036. _processLateAnimationBindingsForQuaternions(holder: {
  15037. totalWeight: number;
  15038. animations: RuntimeAnimation[];
  15039. originalValue: Quaternion;
  15040. }, refQuaternion: Quaternion): Quaternion;
  15041. /** @hidden */
  15042. _processLateAnimationBindings(): void;
  15043. /**
  15044. * Will start the animation sequence of a given target
  15045. * @param target defines the target
  15046. * @param from defines from which frame should animation start
  15047. * @param to defines until which frame should animation run.
  15048. * @param weight defines the weight to apply to the animation (1.0 by default)
  15049. * @param loop defines if the animation loops
  15050. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15051. * @param onAnimationEnd defines the function to be executed when the animation ends
  15052. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15053. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15054. * @param onAnimationLoop defines the callback to call when an animation loops
  15055. * @returns the animatable object created for this animation
  15056. */
  15057. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15058. /**
  15059. * Will start the animation sequence of a given target
  15060. * @param target defines the target
  15061. * @param from defines from which frame should animation start
  15062. * @param to defines until which frame should animation run.
  15063. * @param loop defines if the animation loops
  15064. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15065. * @param onAnimationEnd defines the function to be executed when the animation ends
  15066. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15067. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15068. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15069. * @param onAnimationLoop defines the callback to call when an animation loops
  15070. * @returns the animatable object created for this animation
  15071. */
  15072. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15073. /**
  15074. * Will start the animation sequence of a given target and its hierarchy
  15075. * @param target defines the target
  15076. * @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.
  15077. * @param from defines from which frame should animation start
  15078. * @param to defines until which frame should animation run.
  15079. * @param loop defines if the animation loops
  15080. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15081. * @param onAnimationEnd defines the function to be executed when the animation ends
  15082. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15083. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15084. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15085. * @param onAnimationLoop defines the callback to call when an animation loops
  15086. * @returns the list of created animatables
  15087. */
  15088. 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[];
  15089. /**
  15090. * Begin a new animation on a given node
  15091. * @param target defines the target where the animation will take place
  15092. * @param animations defines the list of animations to start
  15093. * @param from defines the initial value
  15094. * @param to defines the final value
  15095. * @param loop defines if you want animation to loop (off by default)
  15096. * @param speedRatio defines the speed ratio to apply to all animations
  15097. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15098. * @param onAnimationLoop defines the callback to call when an animation loops
  15099. * @returns the list of created animatables
  15100. */
  15101. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15102. /**
  15103. * Begin a new animation on a given node and its hierarchy
  15104. * @param target defines the root node where the animation will take place
  15105. * @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.
  15106. * @param animations defines the list of animations to start
  15107. * @param from defines the initial value
  15108. * @param to defines the final value
  15109. * @param loop defines if you want animation to loop (off by default)
  15110. * @param speedRatio defines the speed ratio to apply to all animations
  15111. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15112. * @param onAnimationLoop defines the callback to call when an animation loops
  15113. * @returns the list of animatables created for all nodes
  15114. */
  15115. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15116. /**
  15117. * Gets the animatable associated with a specific target
  15118. * @param target defines the target of the animatable
  15119. * @returns the required animatable if found
  15120. */
  15121. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15122. /**
  15123. * Gets all animatables associated with a given target
  15124. * @param target defines the target to look animatables for
  15125. * @returns an array of Animatables
  15126. */
  15127. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15128. /**
  15129. * Stops and removes all animations that have been applied to the scene
  15130. */
  15131. stopAllAnimations(): void;
  15132. /**
  15133. * Gets the current delta time used by animation engine
  15134. */
  15135. deltaTime: number;
  15136. }
  15137. }
  15138. module "babylonjs/Bones/bone" {
  15139. interface Bone {
  15140. /**
  15141. * Copy an animation range from another bone
  15142. * @param source defines the source bone
  15143. * @param rangeName defines the range name to copy
  15144. * @param frameOffset defines the frame offset
  15145. * @param rescaleAsRequired defines if rescaling must be applied if required
  15146. * @param skelDimensionsRatio defines the scaling ratio
  15147. * @returns true if operation was successful
  15148. */
  15149. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15150. }
  15151. }
  15152. }
  15153. declare module "babylonjs/Bones/skeleton" {
  15154. import { Bone } from "babylonjs/Bones/bone";
  15155. import { Observable } from "babylonjs/Misc/observable";
  15156. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15157. import { Scene } from "babylonjs/scene";
  15158. import { Nullable } from "babylonjs/types";
  15159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15160. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15161. import { Animatable } from "babylonjs/Animations/animatable";
  15162. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15163. import { Animation } from "babylonjs/Animations/animation";
  15164. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15165. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15166. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15167. /**
  15168. * Class used to handle skinning animations
  15169. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15170. */
  15171. export class Skeleton implements IAnimatable {
  15172. /** defines the skeleton name */
  15173. name: string;
  15174. /** defines the skeleton Id */
  15175. id: string;
  15176. /**
  15177. * Defines the list of child bones
  15178. */
  15179. bones: Bone[];
  15180. /**
  15181. * Defines an estimate of the dimension of the skeleton at rest
  15182. */
  15183. dimensionsAtRest: Vector3;
  15184. /**
  15185. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15186. */
  15187. needInitialSkinMatrix: boolean;
  15188. /**
  15189. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15190. */
  15191. overrideMesh: Nullable<AbstractMesh>;
  15192. /**
  15193. * Gets the list of animations attached to this skeleton
  15194. */
  15195. animations: Array<Animation>;
  15196. private _scene;
  15197. private _isDirty;
  15198. private _transformMatrices;
  15199. private _transformMatrixTexture;
  15200. private _meshesWithPoseMatrix;
  15201. private _animatables;
  15202. private _identity;
  15203. private _synchronizedWithMesh;
  15204. private _ranges;
  15205. private _lastAbsoluteTransformsUpdateId;
  15206. private _canUseTextureForBones;
  15207. private _uniqueId;
  15208. /** @hidden */
  15209. _numBonesWithLinkedTransformNode: number;
  15210. /** @hidden */
  15211. _hasWaitingData: Nullable<boolean>;
  15212. /**
  15213. * Specifies if the skeleton should be serialized
  15214. */
  15215. doNotSerialize: boolean;
  15216. private _useTextureToStoreBoneMatrices;
  15217. /**
  15218. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15219. * Please note that this option is not available if the hardware does not support it
  15220. */
  15221. get useTextureToStoreBoneMatrices(): boolean;
  15222. set useTextureToStoreBoneMatrices(value: boolean);
  15223. private _animationPropertiesOverride;
  15224. /**
  15225. * Gets or sets the animation properties override
  15226. */
  15227. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15228. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15229. /**
  15230. * List of inspectable custom properties (used by the Inspector)
  15231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15232. */
  15233. inspectableCustomProperties: IInspectable[];
  15234. /**
  15235. * An observable triggered before computing the skeleton's matrices
  15236. */
  15237. onBeforeComputeObservable: Observable<Skeleton>;
  15238. /**
  15239. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15240. */
  15241. get isUsingTextureForMatrices(): boolean;
  15242. /**
  15243. * Gets the unique ID of this skeleton
  15244. */
  15245. get uniqueId(): number;
  15246. /**
  15247. * Creates a new skeleton
  15248. * @param name defines the skeleton name
  15249. * @param id defines the skeleton Id
  15250. * @param scene defines the hosting scene
  15251. */
  15252. constructor(
  15253. /** defines the skeleton name */
  15254. name: string,
  15255. /** defines the skeleton Id */
  15256. id: string, scene: Scene);
  15257. /**
  15258. * Gets the current object class name.
  15259. * @return the class name
  15260. */
  15261. getClassName(): string;
  15262. /**
  15263. * Returns an array containing the root bones
  15264. * @returns an array containing the root bones
  15265. */
  15266. getChildren(): Array<Bone>;
  15267. /**
  15268. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15269. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15270. * @returns a Float32Array containing matrices data
  15271. */
  15272. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15273. /**
  15274. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15275. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15276. * @returns a raw texture containing the data
  15277. */
  15278. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15279. /**
  15280. * Gets the current hosting scene
  15281. * @returns a scene object
  15282. */
  15283. getScene(): Scene;
  15284. /**
  15285. * Gets a string representing the current skeleton data
  15286. * @param fullDetails defines a boolean indicating if we want a verbose version
  15287. * @returns a string representing the current skeleton data
  15288. */
  15289. toString(fullDetails?: boolean): string;
  15290. /**
  15291. * Get bone's index searching by name
  15292. * @param name defines bone's name to search for
  15293. * @return the indice of the bone. Returns -1 if not found
  15294. */
  15295. getBoneIndexByName(name: string): number;
  15296. /**
  15297. * Creater a new animation range
  15298. * @param name defines the name of the range
  15299. * @param from defines the start key
  15300. * @param to defines the end key
  15301. */
  15302. createAnimationRange(name: string, from: number, to: number): void;
  15303. /**
  15304. * Delete a specific animation range
  15305. * @param name defines the name of the range
  15306. * @param deleteFrames defines if frames must be removed as well
  15307. */
  15308. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15309. /**
  15310. * Gets a specific animation range
  15311. * @param name defines the name of the range to look for
  15312. * @returns the requested animation range or null if not found
  15313. */
  15314. getAnimationRange(name: string): Nullable<AnimationRange>;
  15315. /**
  15316. * Gets the list of all animation ranges defined on this skeleton
  15317. * @returns an array
  15318. */
  15319. getAnimationRanges(): Nullable<AnimationRange>[];
  15320. /**
  15321. * Copy animation range from a source skeleton.
  15322. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15323. * @param source defines the source skeleton
  15324. * @param name defines the name of the range to copy
  15325. * @param rescaleAsRequired defines if rescaling must be applied if required
  15326. * @returns true if operation was successful
  15327. */
  15328. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15329. /**
  15330. * Forces the skeleton to go to rest pose
  15331. */
  15332. returnToRest(): void;
  15333. private _getHighestAnimationFrame;
  15334. /**
  15335. * Begin a specific animation range
  15336. * @param name defines the name of the range to start
  15337. * @param loop defines if looping must be turned on (false by default)
  15338. * @param speedRatio defines the speed ratio to apply (1 by default)
  15339. * @param onAnimationEnd defines a callback which will be called when animation will end
  15340. * @returns a new animatable
  15341. */
  15342. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15343. /** @hidden */
  15344. _markAsDirty(): void;
  15345. /** @hidden */
  15346. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15347. /** @hidden */
  15348. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15349. private _computeTransformMatrices;
  15350. /**
  15351. * Build all resources required to render a skeleton
  15352. */
  15353. prepare(): void;
  15354. /**
  15355. * Gets the list of animatables currently running for this skeleton
  15356. * @returns an array of animatables
  15357. */
  15358. getAnimatables(): IAnimatable[];
  15359. /**
  15360. * Clone the current skeleton
  15361. * @param name defines the name of the new skeleton
  15362. * @param id defines the id of the new skeleton
  15363. * @returns the new skeleton
  15364. */
  15365. clone(name: string, id?: string): Skeleton;
  15366. /**
  15367. * Enable animation blending for this skeleton
  15368. * @param blendingSpeed defines the blending speed to apply
  15369. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15370. */
  15371. enableBlending(blendingSpeed?: number): void;
  15372. /**
  15373. * Releases all resources associated with the current skeleton
  15374. */
  15375. dispose(): void;
  15376. /**
  15377. * Serialize the skeleton in a JSON object
  15378. * @returns a JSON object
  15379. */
  15380. serialize(): any;
  15381. /**
  15382. * Creates a new skeleton from serialized data
  15383. * @param parsedSkeleton defines the serialized data
  15384. * @param scene defines the hosting scene
  15385. * @returns a new skeleton
  15386. */
  15387. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15388. /**
  15389. * Compute all node absolute transforms
  15390. * @param forceUpdate defines if computation must be done even if cache is up to date
  15391. */
  15392. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15393. /**
  15394. * Gets the root pose matrix
  15395. * @returns a matrix
  15396. */
  15397. getPoseMatrix(): Nullable<Matrix>;
  15398. /**
  15399. * Sorts bones per internal index
  15400. */
  15401. sortBones(): void;
  15402. private _sortBones;
  15403. }
  15404. }
  15405. declare module "babylonjs/Meshes/instancedMesh" {
  15406. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15407. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15408. import { Camera } from "babylonjs/Cameras/camera";
  15409. import { Node } from "babylonjs/node";
  15410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15411. import { Mesh } from "babylonjs/Meshes/mesh";
  15412. import { Material } from "babylonjs/Materials/material";
  15413. import { Skeleton } from "babylonjs/Bones/skeleton";
  15414. import { Light } from "babylonjs/Lights/light";
  15415. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15416. /**
  15417. * Creates an instance based on a source mesh.
  15418. */
  15419. export class InstancedMesh extends AbstractMesh {
  15420. private _sourceMesh;
  15421. private _currentLOD;
  15422. /** @hidden */
  15423. _indexInSourceMeshInstanceArray: number;
  15424. constructor(name: string, source: Mesh);
  15425. /**
  15426. * Returns the string "InstancedMesh".
  15427. */
  15428. getClassName(): string;
  15429. /** Gets the list of lights affecting that mesh */
  15430. get lightSources(): Light[];
  15431. _resyncLightSources(): void;
  15432. _resyncLightSource(light: Light): void;
  15433. _removeLightSource(light: Light, dispose: boolean): void;
  15434. /**
  15435. * If the source mesh receives shadows
  15436. */
  15437. get receiveShadows(): boolean;
  15438. /**
  15439. * The material of the source mesh
  15440. */
  15441. get material(): Nullable<Material>;
  15442. /**
  15443. * Visibility of the source mesh
  15444. */
  15445. get visibility(): number;
  15446. /**
  15447. * Skeleton of the source mesh
  15448. */
  15449. get skeleton(): Nullable<Skeleton>;
  15450. /**
  15451. * Rendering ground id of the source mesh
  15452. */
  15453. get renderingGroupId(): number;
  15454. set renderingGroupId(value: number);
  15455. /**
  15456. * Returns the total number of vertices (integer).
  15457. */
  15458. getTotalVertices(): number;
  15459. /**
  15460. * Returns a positive integer : the total number of indices in this mesh geometry.
  15461. * @returns the numner of indices or zero if the mesh has no geometry.
  15462. */
  15463. getTotalIndices(): number;
  15464. /**
  15465. * The source mesh of the instance
  15466. */
  15467. get sourceMesh(): Mesh;
  15468. /**
  15469. * Is this node ready to be used/rendered
  15470. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15471. * @return {boolean} is it ready
  15472. */
  15473. isReady(completeCheck?: boolean): boolean;
  15474. /**
  15475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15476. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15477. * @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.
  15478. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15479. */
  15480. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15481. /**
  15482. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15483. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15484. * The `data` are either a numeric array either a Float32Array.
  15485. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15486. * 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).
  15487. * Note that a new underlying VertexBuffer object is created each call.
  15488. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15489. *
  15490. * Possible `kind` values :
  15491. * - VertexBuffer.PositionKind
  15492. * - VertexBuffer.UVKind
  15493. * - VertexBuffer.UV2Kind
  15494. * - VertexBuffer.UV3Kind
  15495. * - VertexBuffer.UV4Kind
  15496. * - VertexBuffer.UV5Kind
  15497. * - VertexBuffer.UV6Kind
  15498. * - VertexBuffer.ColorKind
  15499. * - VertexBuffer.MatricesIndicesKind
  15500. * - VertexBuffer.MatricesIndicesExtraKind
  15501. * - VertexBuffer.MatricesWeightsKind
  15502. * - VertexBuffer.MatricesWeightsExtraKind
  15503. *
  15504. * Returns the Mesh.
  15505. */
  15506. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15507. /**
  15508. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15509. * If the mesh has no geometry, it is simply returned as it is.
  15510. * The `data` are either a numeric array either a Float32Array.
  15511. * No new underlying VertexBuffer object is created.
  15512. * 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.
  15513. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15514. *
  15515. * Possible `kind` values :
  15516. * - VertexBuffer.PositionKind
  15517. * - VertexBuffer.UVKind
  15518. * - VertexBuffer.UV2Kind
  15519. * - VertexBuffer.UV3Kind
  15520. * - VertexBuffer.UV4Kind
  15521. * - VertexBuffer.UV5Kind
  15522. * - VertexBuffer.UV6Kind
  15523. * - VertexBuffer.ColorKind
  15524. * - VertexBuffer.MatricesIndicesKind
  15525. * - VertexBuffer.MatricesIndicesExtraKind
  15526. * - VertexBuffer.MatricesWeightsKind
  15527. * - VertexBuffer.MatricesWeightsExtraKind
  15528. *
  15529. * Returns the Mesh.
  15530. */
  15531. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15532. /**
  15533. * Sets the mesh indices.
  15534. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15535. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15536. * This method creates a new index buffer each call.
  15537. * Returns the Mesh.
  15538. */
  15539. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15540. /**
  15541. * Boolean : True if the mesh owns the requested kind of data.
  15542. */
  15543. isVerticesDataPresent(kind: string): boolean;
  15544. /**
  15545. * Returns an array of indices (IndicesArray).
  15546. */
  15547. getIndices(): Nullable<IndicesArray>;
  15548. get _positions(): Nullable<Vector3[]>;
  15549. /**
  15550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15551. * This means the mesh underlying bounding box and sphere are recomputed.
  15552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15553. * @returns the current mesh
  15554. */
  15555. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15556. /** @hidden */
  15557. _preActivate(): InstancedMesh;
  15558. /** @hidden */
  15559. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15560. /** @hidden */
  15561. _postActivate(): void;
  15562. getWorldMatrix(): Matrix;
  15563. get isAnInstance(): boolean;
  15564. /**
  15565. * Returns the current associated LOD AbstractMesh.
  15566. */
  15567. getLOD(camera: Camera): AbstractMesh;
  15568. /** @hidden */
  15569. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15570. /** @hidden */
  15571. _syncSubMeshes(): InstancedMesh;
  15572. /** @hidden */
  15573. _generatePointsArray(): boolean;
  15574. /**
  15575. * Creates a new InstancedMesh from the current mesh.
  15576. * - name (string) : the cloned mesh name
  15577. * - newParent (optional Node) : the optional Node to parent the clone to.
  15578. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15579. *
  15580. * Returns the clone.
  15581. */
  15582. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15583. /**
  15584. * Disposes the InstancedMesh.
  15585. * Returns nothing.
  15586. */
  15587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15588. }
  15589. module "babylonjs/Meshes/mesh" {
  15590. interface Mesh {
  15591. /**
  15592. * Register a custom buffer that will be instanced
  15593. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15594. * @param kind defines the buffer kind
  15595. * @param stride defines the stride in floats
  15596. */
  15597. registerInstancedBuffer(kind: string, stride: number): void;
  15598. /** @hidden */
  15599. _userInstancedBuffersStorage: {
  15600. data: {
  15601. [key: string]: Float32Array;
  15602. };
  15603. sizes: {
  15604. [key: string]: number;
  15605. };
  15606. vertexBuffers: {
  15607. [key: string]: Nullable<VertexBuffer>;
  15608. };
  15609. strides: {
  15610. [key: string]: number;
  15611. };
  15612. };
  15613. }
  15614. }
  15615. module "babylonjs/Meshes/abstractMesh" {
  15616. interface AbstractMesh {
  15617. /**
  15618. * Object used to store instanced buffers defined by user
  15619. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15620. */
  15621. instancedBuffers: {
  15622. [key: string]: any;
  15623. };
  15624. }
  15625. }
  15626. }
  15627. declare module "babylonjs/Materials/shaderMaterial" {
  15628. import { Scene } from "babylonjs/scene";
  15629. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15631. import { Mesh } from "babylonjs/Meshes/mesh";
  15632. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15634. import { Texture } from "babylonjs/Materials/Textures/texture";
  15635. import { Material } from "babylonjs/Materials/material";
  15636. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15637. /**
  15638. * Defines the options associated with the creation of a shader material.
  15639. */
  15640. export interface IShaderMaterialOptions {
  15641. /**
  15642. * Does the material work in alpha blend mode
  15643. */
  15644. needAlphaBlending: boolean;
  15645. /**
  15646. * Does the material work in alpha test mode
  15647. */
  15648. needAlphaTesting: boolean;
  15649. /**
  15650. * The list of attribute names used in the shader
  15651. */
  15652. attributes: string[];
  15653. /**
  15654. * The list of unifrom names used in the shader
  15655. */
  15656. uniforms: string[];
  15657. /**
  15658. * The list of UBO names used in the shader
  15659. */
  15660. uniformBuffers: string[];
  15661. /**
  15662. * The list of sampler names used in the shader
  15663. */
  15664. samplers: string[];
  15665. /**
  15666. * The list of defines used in the shader
  15667. */
  15668. defines: string[];
  15669. }
  15670. /**
  15671. * 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.
  15672. *
  15673. * This returned material effects how the mesh will look based on the code in the shaders.
  15674. *
  15675. * @see http://doc.babylonjs.com/how_to/shader_material
  15676. */
  15677. export class ShaderMaterial extends Material {
  15678. private _shaderPath;
  15679. private _options;
  15680. private _textures;
  15681. private _textureArrays;
  15682. private _floats;
  15683. private _ints;
  15684. private _floatsArrays;
  15685. private _colors3;
  15686. private _colors3Arrays;
  15687. private _colors4;
  15688. private _colors4Arrays;
  15689. private _vectors2;
  15690. private _vectors3;
  15691. private _vectors4;
  15692. private _matrices;
  15693. private _matrixArrays;
  15694. private _matrices3x3;
  15695. private _matrices2x2;
  15696. private _vectors2Arrays;
  15697. private _vectors3Arrays;
  15698. private _vectors4Arrays;
  15699. private _cachedWorldViewMatrix;
  15700. private _cachedWorldViewProjectionMatrix;
  15701. private _renderId;
  15702. private _multiview;
  15703. /**
  15704. * Instantiate a new shader material.
  15705. * 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.
  15706. * This returned material effects how the mesh will look based on the code in the shaders.
  15707. * @see http://doc.babylonjs.com/how_to/shader_material
  15708. * @param name Define the name of the material in the scene
  15709. * @param scene Define the scene the material belongs to
  15710. * @param shaderPath Defines the route to the shader code in one of three ways:
  15711. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15712. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15713. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15714. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15715. * @param options Define the options used to create the shader
  15716. */
  15717. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15718. /**
  15719. * Gets the shader path used to define the shader code
  15720. * It can be modified to trigger a new compilation
  15721. */
  15722. get shaderPath(): any;
  15723. /**
  15724. * Sets the shader path used to define the shader code
  15725. * It can be modified to trigger a new compilation
  15726. */
  15727. set shaderPath(shaderPath: any);
  15728. /**
  15729. * Gets the options used to compile the shader.
  15730. * They can be modified to trigger a new compilation
  15731. */
  15732. get options(): IShaderMaterialOptions;
  15733. /**
  15734. * Gets the current class name of the material e.g. "ShaderMaterial"
  15735. * Mainly use in serialization.
  15736. * @returns the class name
  15737. */
  15738. getClassName(): string;
  15739. /**
  15740. * Specifies if the material will require alpha blending
  15741. * @returns a boolean specifying if alpha blending is needed
  15742. */
  15743. needAlphaBlending(): boolean;
  15744. /**
  15745. * Specifies if this material should be rendered in alpha test mode
  15746. * @returns a boolean specifying if an alpha test is needed.
  15747. */
  15748. needAlphaTesting(): boolean;
  15749. private _checkUniform;
  15750. /**
  15751. * Set a texture in the shader.
  15752. * @param name Define the name of the uniform samplers as defined in the shader
  15753. * @param texture Define the texture to bind to this sampler
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setTexture(name: string, texture: Texture): ShaderMaterial;
  15757. /**
  15758. * Set a texture array in the shader.
  15759. * @param name Define the name of the uniform sampler array as defined in the shader
  15760. * @param textures Define the list of textures to bind to this sampler
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15764. /**
  15765. * Set a float in the shader.
  15766. * @param name Define the name of the uniform as defined in the shader
  15767. * @param value Define the value to give to the uniform
  15768. * @return the material itself allowing "fluent" like uniform updates
  15769. */
  15770. setFloat(name: string, value: number): ShaderMaterial;
  15771. /**
  15772. * Set a int in the shader.
  15773. * @param name Define the name of the uniform as defined in the shader
  15774. * @param value Define the value to give to the uniform
  15775. * @return the material itself allowing "fluent" like uniform updates
  15776. */
  15777. setInt(name: string, value: number): ShaderMaterial;
  15778. /**
  15779. * Set an array of floats in the shader.
  15780. * @param name Define the name of the uniform as defined in the shader
  15781. * @param value Define the value to give to the uniform
  15782. * @return the material itself allowing "fluent" like uniform updates
  15783. */
  15784. setFloats(name: string, value: number[]): ShaderMaterial;
  15785. /**
  15786. * Set a vec3 in the shader from a Color3.
  15787. * @param name Define the name of the uniform as defined in the shader
  15788. * @param value Define the value to give to the uniform
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setColor3(name: string, value: Color3): ShaderMaterial;
  15792. /**
  15793. * Set a vec3 array in the shader from a Color3 array.
  15794. * @param name Define the name of the uniform as defined in the shader
  15795. * @param value Define the value to give to the uniform
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15799. /**
  15800. * Set a vec4 in the shader from a Color4.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setColor4(name: string, value: Color4): ShaderMaterial;
  15806. /**
  15807. * Set a vec4 array in the shader from a Color4 array.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15813. /**
  15814. * Set a vec2 in the shader from a Vector2.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setVector2(name: string, value: Vector2): ShaderMaterial;
  15820. /**
  15821. * Set a vec3 in the shader from a Vector3.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setVector3(name: string, value: Vector3): ShaderMaterial;
  15827. /**
  15828. * Set a vec4 in the shader from a Vector4.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setVector4(name: string, value: Vector4): ShaderMaterial;
  15834. /**
  15835. * Set a mat4 in the shader from a Matrix.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15841. /**
  15842. * Set a float32Array in the shader from a matrix array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15848. /**
  15849. * Set a mat3 in the shader from a Float32Array.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15855. /**
  15856. * Set a mat2 in the shader from a Float32Array.
  15857. * @param name Define the name of the uniform as defined in the shader
  15858. * @param value Define the value to give to the uniform
  15859. * @return the material itself allowing "fluent" like uniform updates
  15860. */
  15861. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15862. /**
  15863. * Set a vec2 array in the shader from a number array.
  15864. * @param name Define the name of the uniform as defined in the shader
  15865. * @param value Define the value to give to the uniform
  15866. * @return the material itself allowing "fluent" like uniform updates
  15867. */
  15868. setArray2(name: string, value: number[]): ShaderMaterial;
  15869. /**
  15870. * Set a vec3 array in the shader from a number array.
  15871. * @param name Define the name of the uniform as defined in the shader
  15872. * @param value Define the value to give to the uniform
  15873. * @return the material itself allowing "fluent" like uniform updates
  15874. */
  15875. setArray3(name: string, value: number[]): ShaderMaterial;
  15876. /**
  15877. * Set a vec4 array in the shader from a number array.
  15878. * @param name Define the name of the uniform as defined in the shader
  15879. * @param value Define the value to give to the uniform
  15880. * @return the material itself allowing "fluent" like uniform updates
  15881. */
  15882. setArray4(name: string, value: number[]): ShaderMaterial;
  15883. private _checkCache;
  15884. /**
  15885. * Specifies that the submesh is ready to be used
  15886. * @param mesh defines the mesh to check
  15887. * @param subMesh defines which submesh to check
  15888. * @param useInstances specifies that instances should be used
  15889. * @returns a boolean indicating that the submesh is ready or not
  15890. */
  15891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15892. /**
  15893. * Checks if the material is ready to render the requested mesh
  15894. * @param mesh Define the mesh to render
  15895. * @param useInstances Define whether or not the material is used with instances
  15896. * @returns true if ready, otherwise false
  15897. */
  15898. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15899. /**
  15900. * Binds the world matrix to the material
  15901. * @param world defines the world transformation matrix
  15902. */
  15903. bindOnlyWorldMatrix(world: Matrix): void;
  15904. /**
  15905. * Binds the material to the mesh
  15906. * @param world defines the world transformation matrix
  15907. * @param mesh defines the mesh to bind the material to
  15908. */
  15909. bind(world: Matrix, mesh?: Mesh): void;
  15910. /**
  15911. * Gets the active textures from the material
  15912. * @returns an array of textures
  15913. */
  15914. getActiveTextures(): BaseTexture[];
  15915. /**
  15916. * Specifies if the material uses a texture
  15917. * @param texture defines the texture to check against the material
  15918. * @returns a boolean specifying if the material uses the texture
  15919. */
  15920. hasTexture(texture: BaseTexture): boolean;
  15921. /**
  15922. * Makes a duplicate of the material, and gives it a new name
  15923. * @param name defines the new name for the duplicated material
  15924. * @returns the cloned material
  15925. */
  15926. clone(name: string): ShaderMaterial;
  15927. /**
  15928. * Disposes the material
  15929. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15930. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15931. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15932. */
  15933. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15934. /**
  15935. * Serializes this material in a JSON representation
  15936. * @returns the serialized material object
  15937. */
  15938. serialize(): any;
  15939. /**
  15940. * Creates a shader material from parsed shader material data
  15941. * @param source defines the JSON represnetation of the material
  15942. * @param scene defines the hosting scene
  15943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15944. * @returns a new material
  15945. */
  15946. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15947. }
  15948. }
  15949. declare module "babylonjs/Shaders/color.fragment" {
  15950. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15951. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15952. /** @hidden */
  15953. export var colorPixelShader: {
  15954. name: string;
  15955. shader: string;
  15956. };
  15957. }
  15958. declare module "babylonjs/Shaders/color.vertex" {
  15959. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15961. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15962. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15963. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15964. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15965. /** @hidden */
  15966. export var colorVertexShader: {
  15967. name: string;
  15968. shader: string;
  15969. };
  15970. }
  15971. declare module "babylonjs/Meshes/linesMesh" {
  15972. import { Nullable } from "babylonjs/types";
  15973. import { Scene } from "babylonjs/scene";
  15974. import { Color3 } from "babylonjs/Maths/math.color";
  15975. import { Node } from "babylonjs/node";
  15976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15977. import { Mesh } from "babylonjs/Meshes/mesh";
  15978. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15979. import { Effect } from "babylonjs/Materials/effect";
  15980. import { Material } from "babylonjs/Materials/material";
  15981. import "babylonjs/Shaders/color.fragment";
  15982. import "babylonjs/Shaders/color.vertex";
  15983. /**
  15984. * Line mesh
  15985. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15986. */
  15987. export class LinesMesh extends Mesh {
  15988. /**
  15989. * If vertex color should be applied to the mesh
  15990. */
  15991. readonly useVertexColor?: boolean | undefined;
  15992. /**
  15993. * If vertex alpha should be applied to the mesh
  15994. */
  15995. readonly useVertexAlpha?: boolean | undefined;
  15996. /**
  15997. * Color of the line (Default: White)
  15998. */
  15999. color: Color3;
  16000. /**
  16001. * Alpha of the line (Default: 1)
  16002. */
  16003. alpha: number;
  16004. /**
  16005. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16006. * This margin is expressed in world space coordinates, so its value may vary.
  16007. * Default value is 0.1
  16008. */
  16009. intersectionThreshold: number;
  16010. private _colorShader;
  16011. private color4;
  16012. /**
  16013. * Creates a new LinesMesh
  16014. * @param name defines the name
  16015. * @param scene defines the hosting scene
  16016. * @param parent defines the parent mesh if any
  16017. * @param source defines the optional source LinesMesh used to clone data from
  16018. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16019. * When false, achieved by calling a clone(), also passing False.
  16020. * This will make creation of children, recursive.
  16021. * @param useVertexColor defines if this LinesMesh supports vertex color
  16022. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16023. */
  16024. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16025. /**
  16026. * If vertex color should be applied to the mesh
  16027. */
  16028. useVertexColor?: boolean | undefined,
  16029. /**
  16030. * If vertex alpha should be applied to the mesh
  16031. */
  16032. useVertexAlpha?: boolean | undefined);
  16033. private _addClipPlaneDefine;
  16034. private _removeClipPlaneDefine;
  16035. isReady(): boolean;
  16036. /**
  16037. * Returns the string "LineMesh"
  16038. */
  16039. getClassName(): string;
  16040. /**
  16041. * @hidden
  16042. */
  16043. get material(): Material;
  16044. /**
  16045. * @hidden
  16046. */
  16047. set material(value: Material);
  16048. /**
  16049. * @hidden
  16050. */
  16051. get checkCollisions(): boolean;
  16052. /** @hidden */
  16053. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16054. /** @hidden */
  16055. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16056. /**
  16057. * Disposes of the line mesh
  16058. * @param doNotRecurse If children should be disposed
  16059. */
  16060. dispose(doNotRecurse?: boolean): void;
  16061. /**
  16062. * Returns a new LineMesh object cloned from the current one.
  16063. */
  16064. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16065. /**
  16066. * Creates a new InstancedLinesMesh object from the mesh model.
  16067. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16068. * @param name defines the name of the new instance
  16069. * @returns a new InstancedLinesMesh
  16070. */
  16071. createInstance(name: string): InstancedLinesMesh;
  16072. }
  16073. /**
  16074. * Creates an instance based on a source LinesMesh
  16075. */
  16076. export class InstancedLinesMesh extends InstancedMesh {
  16077. /**
  16078. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16079. * This margin is expressed in world space coordinates, so its value may vary.
  16080. * Initilized with the intersectionThreshold value of the source LinesMesh
  16081. */
  16082. intersectionThreshold: number;
  16083. constructor(name: string, source: LinesMesh);
  16084. /**
  16085. * Returns the string "InstancedLinesMesh".
  16086. */
  16087. getClassName(): string;
  16088. }
  16089. }
  16090. declare module "babylonjs/Shaders/line.fragment" {
  16091. /** @hidden */
  16092. export var linePixelShader: {
  16093. name: string;
  16094. shader: string;
  16095. };
  16096. }
  16097. declare module "babylonjs/Shaders/line.vertex" {
  16098. /** @hidden */
  16099. export var lineVertexShader: {
  16100. name: string;
  16101. shader: string;
  16102. };
  16103. }
  16104. declare module "babylonjs/Rendering/edgesRenderer" {
  16105. import { Nullable } from "babylonjs/types";
  16106. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16108. import { Vector3 } from "babylonjs/Maths/math.vector";
  16109. import { IDisposable } from "babylonjs/scene";
  16110. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16111. import "babylonjs/Shaders/line.fragment";
  16112. import "babylonjs/Shaders/line.vertex";
  16113. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16114. module "babylonjs/Meshes/abstractMesh" {
  16115. interface AbstractMesh {
  16116. /**
  16117. * Gets the edgesRenderer associated with the mesh
  16118. */
  16119. edgesRenderer: Nullable<EdgesRenderer>;
  16120. }
  16121. }
  16122. module "babylonjs/Meshes/linesMesh" {
  16123. interface LinesMesh {
  16124. /**
  16125. * Enables the edge rendering mode on the mesh.
  16126. * This mode makes the mesh edges visible
  16127. * @param epsilon defines the maximal distance between two angles to detect a face
  16128. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16129. * @returns the currentAbstractMesh
  16130. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16131. */
  16132. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16133. }
  16134. }
  16135. module "babylonjs/Meshes/linesMesh" {
  16136. interface InstancedLinesMesh {
  16137. /**
  16138. * Enables the edge rendering mode on the mesh.
  16139. * This mode makes the mesh edges visible
  16140. * @param epsilon defines the maximal distance between two angles to detect a face
  16141. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16142. * @returns the current InstancedLinesMesh
  16143. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16144. */
  16145. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16146. }
  16147. }
  16148. /**
  16149. * Defines the minimum contract an Edges renderer should follow.
  16150. */
  16151. export interface IEdgesRenderer extends IDisposable {
  16152. /**
  16153. * Gets or sets a boolean indicating if the edgesRenderer is active
  16154. */
  16155. isEnabled: boolean;
  16156. /**
  16157. * Renders the edges of the attached mesh,
  16158. */
  16159. render(): void;
  16160. /**
  16161. * Checks wether or not the edges renderer is ready to render.
  16162. * @return true if ready, otherwise false.
  16163. */
  16164. isReady(): boolean;
  16165. }
  16166. /**
  16167. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16168. */
  16169. export class EdgesRenderer implements IEdgesRenderer {
  16170. /**
  16171. * Define the size of the edges with an orthographic camera
  16172. */
  16173. edgesWidthScalerForOrthographic: number;
  16174. /**
  16175. * Define the size of the edges with a perspective camera
  16176. */
  16177. edgesWidthScalerForPerspective: number;
  16178. protected _source: AbstractMesh;
  16179. protected _linesPositions: number[];
  16180. protected _linesNormals: number[];
  16181. protected _linesIndices: number[];
  16182. protected _epsilon: number;
  16183. protected _indicesCount: number;
  16184. protected _lineShader: ShaderMaterial;
  16185. protected _ib: DataBuffer;
  16186. protected _buffers: {
  16187. [key: string]: Nullable<VertexBuffer>;
  16188. };
  16189. protected _checkVerticesInsteadOfIndices: boolean;
  16190. private _meshRebuildObserver;
  16191. private _meshDisposeObserver;
  16192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16193. isEnabled: boolean;
  16194. /**
  16195. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16196. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16197. * @param source Mesh used to create edges
  16198. * @param epsilon sum of angles in adjacency to check for edge
  16199. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16200. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16201. */
  16202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16203. protected _prepareRessources(): void;
  16204. /** @hidden */
  16205. _rebuild(): void;
  16206. /**
  16207. * Releases the required resources for the edges renderer
  16208. */
  16209. dispose(): void;
  16210. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16211. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16212. /**
  16213. * Checks if the pair of p0 and p1 is en edge
  16214. * @param faceIndex
  16215. * @param edge
  16216. * @param faceNormals
  16217. * @param p0
  16218. * @param p1
  16219. * @private
  16220. */
  16221. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16222. /**
  16223. * push line into the position, normal and index buffer
  16224. * @protected
  16225. */
  16226. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16227. /**
  16228. * Generates lines edges from adjacencjes
  16229. * @private
  16230. */
  16231. _generateEdgesLines(): void;
  16232. /**
  16233. * Checks wether or not the edges renderer is ready to render.
  16234. * @return true if ready, otherwise false.
  16235. */
  16236. isReady(): boolean;
  16237. /**
  16238. * Renders the edges of the attached mesh,
  16239. */
  16240. render(): void;
  16241. }
  16242. /**
  16243. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16244. */
  16245. export class LineEdgesRenderer extends EdgesRenderer {
  16246. /**
  16247. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16248. * @param source LineMesh used to generate edges
  16249. * @param epsilon not important (specified angle for edge detection)
  16250. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16251. */
  16252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16253. /**
  16254. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16255. */
  16256. _generateEdgesLines(): void;
  16257. }
  16258. }
  16259. declare module "babylonjs/Rendering/renderingGroup" {
  16260. import { SmartArray } from "babylonjs/Misc/smartArray";
  16261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16263. import { Nullable } from "babylonjs/types";
  16264. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16265. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16266. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16267. import { Material } from "babylonjs/Materials/material";
  16268. import { Scene } from "babylonjs/scene";
  16269. /**
  16270. * This represents the object necessary to create a rendering group.
  16271. * This is exclusively used and created by the rendering manager.
  16272. * To modify the behavior, you use the available helpers in your scene or meshes.
  16273. * @hidden
  16274. */
  16275. export class RenderingGroup {
  16276. index: number;
  16277. private static _zeroVector;
  16278. private _scene;
  16279. private _opaqueSubMeshes;
  16280. private _transparentSubMeshes;
  16281. private _alphaTestSubMeshes;
  16282. private _depthOnlySubMeshes;
  16283. private _particleSystems;
  16284. private _spriteManagers;
  16285. private _opaqueSortCompareFn;
  16286. private _alphaTestSortCompareFn;
  16287. private _transparentSortCompareFn;
  16288. private _renderOpaque;
  16289. private _renderAlphaTest;
  16290. private _renderTransparent;
  16291. /** @hidden */
  16292. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16293. onBeforeTransparentRendering: () => void;
  16294. /**
  16295. * Set the opaque sort comparison function.
  16296. * If null the sub meshes will be render in the order they were created
  16297. */
  16298. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16299. /**
  16300. * Set the alpha test sort comparison function.
  16301. * If null the sub meshes will be render in the order they were created
  16302. */
  16303. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16304. /**
  16305. * Set the transparent sort comparison function.
  16306. * If null the sub meshes will be render in the order they were created
  16307. */
  16308. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16309. /**
  16310. * Creates a new rendering group.
  16311. * @param index The rendering group index
  16312. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16313. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16314. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16315. */
  16316. 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>);
  16317. /**
  16318. * Render all the sub meshes contained in the group.
  16319. * @param customRenderFunction Used to override the default render behaviour of the group.
  16320. * @returns true if rendered some submeshes.
  16321. */
  16322. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16323. /**
  16324. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private renderOpaqueSorted;
  16328. /**
  16329. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16330. * @param subMeshes The submeshes to render
  16331. */
  16332. private renderAlphaTestSorted;
  16333. /**
  16334. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16335. * @param subMeshes The submeshes to render
  16336. */
  16337. private renderTransparentSorted;
  16338. /**
  16339. * Renders the submeshes in a specified order.
  16340. * @param subMeshes The submeshes to sort before render
  16341. * @param sortCompareFn The comparison function use to sort
  16342. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16343. * @param transparent Specifies to activate blending if true
  16344. */
  16345. private static renderSorted;
  16346. /**
  16347. * Renders the submeshes in the order they were dispatched (no sort applied).
  16348. * @param subMeshes The submeshes to render
  16349. */
  16350. private static renderUnsorted;
  16351. /**
  16352. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16353. * are rendered back to front if in the same alpha index.
  16354. *
  16355. * @param a The first submesh
  16356. * @param b The second submesh
  16357. * @returns The result of the comparison
  16358. */
  16359. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16360. /**
  16361. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16362. * are rendered back to front.
  16363. *
  16364. * @param a The first submesh
  16365. * @param b The second submesh
  16366. * @returns The result of the comparison
  16367. */
  16368. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16369. /**
  16370. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16371. * are rendered front to back (prevent overdraw).
  16372. *
  16373. * @param a The first submesh
  16374. * @param b The second submesh
  16375. * @returns The result of the comparison
  16376. */
  16377. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16378. /**
  16379. * Resets the different lists of submeshes to prepare a new frame.
  16380. */
  16381. prepare(): void;
  16382. dispose(): void;
  16383. /**
  16384. * Inserts the submesh in its correct queue depending on its material.
  16385. * @param subMesh The submesh to dispatch
  16386. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16387. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16388. */
  16389. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16390. dispatchSprites(spriteManager: ISpriteManager): void;
  16391. dispatchParticles(particleSystem: IParticleSystem): void;
  16392. private _renderParticles;
  16393. private _renderSprites;
  16394. }
  16395. }
  16396. declare module "babylonjs/Rendering/renderingManager" {
  16397. import { Nullable } from "babylonjs/types";
  16398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16400. import { SmartArray } from "babylonjs/Misc/smartArray";
  16401. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16403. import { Material } from "babylonjs/Materials/material";
  16404. import { Scene } from "babylonjs/scene";
  16405. import { Camera } from "babylonjs/Cameras/camera";
  16406. /**
  16407. * Interface describing the different options available in the rendering manager
  16408. * regarding Auto Clear between groups.
  16409. */
  16410. export interface IRenderingManagerAutoClearSetup {
  16411. /**
  16412. * Defines whether or not autoclear is enable.
  16413. */
  16414. autoClear: boolean;
  16415. /**
  16416. * Defines whether or not to autoclear the depth buffer.
  16417. */
  16418. depth: boolean;
  16419. /**
  16420. * Defines whether or not to autoclear the stencil buffer.
  16421. */
  16422. stencil: boolean;
  16423. }
  16424. /**
  16425. * This class is used by the onRenderingGroupObservable
  16426. */
  16427. export class RenderingGroupInfo {
  16428. /**
  16429. * The Scene that being rendered
  16430. */
  16431. scene: Scene;
  16432. /**
  16433. * The camera currently used for the rendering pass
  16434. */
  16435. camera: Nullable<Camera>;
  16436. /**
  16437. * The ID of the renderingGroup being processed
  16438. */
  16439. renderingGroupId: number;
  16440. }
  16441. /**
  16442. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16443. * It is enable to manage the different groups as well as the different necessary sort functions.
  16444. * This should not be used directly aside of the few static configurations
  16445. */
  16446. export class RenderingManager {
  16447. /**
  16448. * The max id used for rendering groups (not included)
  16449. */
  16450. static MAX_RENDERINGGROUPS: number;
  16451. /**
  16452. * The min id used for rendering groups (included)
  16453. */
  16454. static MIN_RENDERINGGROUPS: number;
  16455. /**
  16456. * Used to globally prevent autoclearing scenes.
  16457. */
  16458. static AUTOCLEAR: boolean;
  16459. /**
  16460. * @hidden
  16461. */
  16462. _useSceneAutoClearSetup: boolean;
  16463. private _scene;
  16464. private _renderingGroups;
  16465. private _depthStencilBufferAlreadyCleaned;
  16466. private _autoClearDepthStencil;
  16467. private _customOpaqueSortCompareFn;
  16468. private _customAlphaTestSortCompareFn;
  16469. private _customTransparentSortCompareFn;
  16470. private _renderingGroupInfo;
  16471. /**
  16472. * Instantiates a new rendering group for a particular scene
  16473. * @param scene Defines the scene the groups belongs to
  16474. */
  16475. constructor(scene: Scene);
  16476. private _clearDepthStencilBuffer;
  16477. /**
  16478. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16479. * @hidden
  16480. */
  16481. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16482. /**
  16483. * Resets the different information of the group to prepare a new frame
  16484. * @hidden
  16485. */
  16486. reset(): void;
  16487. /**
  16488. * Dispose and release the group and its associated resources.
  16489. * @hidden
  16490. */
  16491. dispose(): void;
  16492. /**
  16493. * Clear the info related to rendering groups preventing retention points during dispose.
  16494. */
  16495. freeRenderingGroups(): void;
  16496. private _prepareRenderingGroup;
  16497. /**
  16498. * Add a sprite manager to the rendering manager in order to render it this frame.
  16499. * @param spriteManager Define the sprite manager to render
  16500. */
  16501. dispatchSprites(spriteManager: ISpriteManager): void;
  16502. /**
  16503. * Add a particle system to the rendering manager in order to render it this frame.
  16504. * @param particleSystem Define the particle system to render
  16505. */
  16506. dispatchParticles(particleSystem: IParticleSystem): void;
  16507. /**
  16508. * Add a submesh to the manager in order to render it this frame
  16509. * @param subMesh The submesh to dispatch
  16510. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16511. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16512. */
  16513. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16514. /**
  16515. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16516. * This allowed control for front to back rendering or reversly depending of the special needs.
  16517. *
  16518. * @param renderingGroupId The rendering group id corresponding to its index
  16519. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16520. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16521. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16522. */
  16523. 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;
  16524. /**
  16525. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16526. *
  16527. * @param renderingGroupId The rendering group id corresponding to its index
  16528. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16529. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16530. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16531. */
  16532. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16533. /**
  16534. * Gets the current auto clear configuration for one rendering group of the rendering
  16535. * manager.
  16536. * @param index the rendering group index to get the information for
  16537. * @returns The auto clear setup for the requested rendering group
  16538. */
  16539. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16540. }
  16541. }
  16542. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16543. import { SmartArray } from "babylonjs/Misc/smartArray";
  16544. import { Nullable } from "babylonjs/types";
  16545. import { Scene } from "babylonjs/scene";
  16546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16549. import { Mesh } from "babylonjs/Meshes/mesh";
  16550. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16551. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16552. import { Effect } from "babylonjs/Materials/effect";
  16553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16555. import "babylonjs/Shaders/shadowMap.fragment";
  16556. import "babylonjs/Shaders/shadowMap.vertex";
  16557. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16558. import { Observable } from "babylonjs/Misc/observable";
  16559. /**
  16560. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16561. */
  16562. export interface ICustomShaderOptions {
  16563. /**
  16564. * Gets or sets the custom shader name to use
  16565. */
  16566. shaderName: string;
  16567. /**
  16568. * The list of attribute names used in the shader
  16569. */
  16570. attributes?: string[];
  16571. /**
  16572. * The list of unifrom names used in the shader
  16573. */
  16574. uniforms?: string[];
  16575. /**
  16576. * The list of sampler names used in the shader
  16577. */
  16578. samplers?: string[];
  16579. /**
  16580. * The list of defines used in the shader
  16581. */
  16582. defines?: string[];
  16583. }
  16584. /**
  16585. * Interface to implement to create a shadow generator compatible with BJS.
  16586. */
  16587. export interface IShadowGenerator {
  16588. /**
  16589. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16590. * @returns The render target texture if present otherwise, null
  16591. */
  16592. getShadowMap(): Nullable<RenderTargetTexture>;
  16593. /**
  16594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16595. * @param subMesh The submesh we want to render in the shadow map
  16596. * @param useInstances Defines wether will draw in the map using instances
  16597. * @returns true if ready otherwise, false
  16598. */
  16599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16600. /**
  16601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16602. * @param defines Defines of the material we want to update
  16603. * @param lightIndex Index of the light in the enabled light list of the material
  16604. */
  16605. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16606. /**
  16607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16608. * defined in the generator but impacting the effect).
  16609. * It implies the unifroms available on the materials are the standard BJS ones.
  16610. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16611. * @param effect The effect we are binfing the information for
  16612. */
  16613. bindShadowLight(lightIndex: string, effect: Effect): void;
  16614. /**
  16615. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16616. * (eq to shadow prjection matrix * light transform matrix)
  16617. * @returns The transform matrix used to create the shadow map
  16618. */
  16619. getTransformMatrix(): Matrix;
  16620. /**
  16621. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16622. * Cube and 2D textures for instance.
  16623. */
  16624. recreateShadowMap(): void;
  16625. /**
  16626. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16627. * @param onCompiled Callback triggered at the and of the effects compilation
  16628. * @param options Sets of optional options forcing the compilation with different modes
  16629. */
  16630. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16631. useInstances: boolean;
  16632. }>): void;
  16633. /**
  16634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16635. * @param options Sets of optional options forcing the compilation with different modes
  16636. * @returns A promise that resolves when the compilation completes
  16637. */
  16638. forceCompilationAsync(options?: Partial<{
  16639. useInstances: boolean;
  16640. }>): Promise<void>;
  16641. /**
  16642. * Serializes the shadow generator setup to a json object.
  16643. * @returns The serialized JSON object
  16644. */
  16645. serialize(): any;
  16646. /**
  16647. * Disposes the Shadow map and related Textures and effects.
  16648. */
  16649. dispose(): void;
  16650. }
  16651. /**
  16652. * Default implementation IShadowGenerator.
  16653. * This is the main object responsible of generating shadows in the framework.
  16654. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16655. */
  16656. export class ShadowGenerator implements IShadowGenerator {
  16657. /**
  16658. * Name of the shadow generator class
  16659. */
  16660. static CLASSNAME: string;
  16661. /**
  16662. * Shadow generator mode None: no filtering applied.
  16663. */
  16664. static readonly FILTER_NONE: number;
  16665. /**
  16666. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16667. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16668. */
  16669. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16670. /**
  16671. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16672. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16673. */
  16674. static readonly FILTER_POISSONSAMPLING: number;
  16675. /**
  16676. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16677. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16678. */
  16679. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16680. /**
  16681. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16682. * edge artifacts on steep falloff.
  16683. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16684. */
  16685. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16686. /**
  16687. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16688. * edge artifacts on steep falloff.
  16689. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16690. */
  16691. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16692. /**
  16693. * Shadow generator mode PCF: Percentage Closer Filtering
  16694. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16695. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16696. */
  16697. static readonly FILTER_PCF: number;
  16698. /**
  16699. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16700. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16701. * Contact Hardening
  16702. */
  16703. static readonly FILTER_PCSS: number;
  16704. /**
  16705. * Reserved for PCF and PCSS
  16706. * Highest Quality.
  16707. *
  16708. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16709. *
  16710. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16711. */
  16712. static readonly QUALITY_HIGH: number;
  16713. /**
  16714. * Reserved for PCF and PCSS
  16715. * Good tradeoff for quality/perf cross devices
  16716. *
  16717. * Execute PCF on a 3*3 kernel.
  16718. *
  16719. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16720. */
  16721. static readonly QUALITY_MEDIUM: number;
  16722. /**
  16723. * Reserved for PCF and PCSS
  16724. * The lowest quality but the fastest.
  16725. *
  16726. * Execute PCF on a 1*1 kernel.
  16727. *
  16728. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16729. */
  16730. static readonly QUALITY_LOW: number;
  16731. /** Gets or sets the custom shader name to use */
  16732. customShaderOptions: ICustomShaderOptions;
  16733. /**
  16734. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16735. */
  16736. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16737. /**
  16738. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16739. */
  16740. onAfterShadowMapRenderObservable: Observable<Effect>;
  16741. /**
  16742. * Observable triggered before a mesh is rendered in the shadow map.
  16743. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16744. */
  16745. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16746. /**
  16747. * Observable triggered after a mesh is rendered in the shadow map.
  16748. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16749. */
  16750. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16751. protected _bias: number;
  16752. /**
  16753. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16754. */
  16755. get bias(): number;
  16756. /**
  16757. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16758. */
  16759. set bias(bias: number);
  16760. protected _normalBias: number;
  16761. /**
  16762. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16763. */
  16764. get normalBias(): number;
  16765. /**
  16766. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16767. */
  16768. set normalBias(normalBias: number);
  16769. protected _blurBoxOffset: number;
  16770. /**
  16771. * Gets the blur box offset: offset applied during the blur pass.
  16772. * Only useful if useKernelBlur = false
  16773. */
  16774. get blurBoxOffset(): number;
  16775. /**
  16776. * Sets the blur box offset: offset applied during the blur pass.
  16777. * Only useful if useKernelBlur = false
  16778. */
  16779. set blurBoxOffset(value: number);
  16780. protected _blurScale: number;
  16781. /**
  16782. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16783. * 2 means half of the size.
  16784. */
  16785. get blurScale(): number;
  16786. /**
  16787. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16788. * 2 means half of the size.
  16789. */
  16790. set blurScale(value: number);
  16791. protected _blurKernel: number;
  16792. /**
  16793. * Gets the blur kernel: kernel size of the blur pass.
  16794. * Only useful if useKernelBlur = true
  16795. */
  16796. get blurKernel(): number;
  16797. /**
  16798. * Sets the blur kernel: kernel size of the blur pass.
  16799. * Only useful if useKernelBlur = true
  16800. */
  16801. set blurKernel(value: number);
  16802. protected _useKernelBlur: boolean;
  16803. /**
  16804. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16805. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16806. */
  16807. get useKernelBlur(): boolean;
  16808. /**
  16809. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16810. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16811. */
  16812. set useKernelBlur(value: boolean);
  16813. protected _depthScale: number;
  16814. /**
  16815. * Gets the depth scale used in ESM mode.
  16816. */
  16817. get depthScale(): number;
  16818. /**
  16819. * Sets the depth scale used in ESM mode.
  16820. * This can override the scale stored on the light.
  16821. */
  16822. set depthScale(value: number);
  16823. protected _validateFilter(filter: number): number;
  16824. protected _filter: number;
  16825. /**
  16826. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16827. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16828. */
  16829. get filter(): number;
  16830. /**
  16831. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16832. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16833. */
  16834. set filter(value: number);
  16835. /**
  16836. * Gets if the current filter is set to Poisson Sampling.
  16837. */
  16838. get usePoissonSampling(): boolean;
  16839. /**
  16840. * Sets the current filter to Poisson Sampling.
  16841. */
  16842. set usePoissonSampling(value: boolean);
  16843. /**
  16844. * Gets if the current filter is set to ESM.
  16845. */
  16846. get useExponentialShadowMap(): boolean;
  16847. /**
  16848. * Sets the current filter is to ESM.
  16849. */
  16850. set useExponentialShadowMap(value: boolean);
  16851. /**
  16852. * Gets if the current filter is set to filtered ESM.
  16853. */
  16854. get useBlurExponentialShadowMap(): boolean;
  16855. /**
  16856. * Gets if the current filter is set to filtered ESM.
  16857. */
  16858. set useBlurExponentialShadowMap(value: boolean);
  16859. /**
  16860. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16861. * exponential to prevent steep falloff artifacts).
  16862. */
  16863. get useCloseExponentialShadowMap(): boolean;
  16864. /**
  16865. * Sets the current filter to "close ESM" (using the inverse of the
  16866. * exponential to prevent steep falloff artifacts).
  16867. */
  16868. set useCloseExponentialShadowMap(value: boolean);
  16869. /**
  16870. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16871. * exponential to prevent steep falloff artifacts).
  16872. */
  16873. get useBlurCloseExponentialShadowMap(): boolean;
  16874. /**
  16875. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16876. * exponential to prevent steep falloff artifacts).
  16877. */
  16878. set useBlurCloseExponentialShadowMap(value: boolean);
  16879. /**
  16880. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16881. */
  16882. get usePercentageCloserFiltering(): boolean;
  16883. /**
  16884. * Sets the current filter to "PCF" (percentage closer filtering).
  16885. */
  16886. set usePercentageCloserFiltering(value: boolean);
  16887. protected _filteringQuality: number;
  16888. /**
  16889. * Gets the PCF or PCSS Quality.
  16890. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16891. */
  16892. get filteringQuality(): number;
  16893. /**
  16894. * Sets the PCF or PCSS Quality.
  16895. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16896. */
  16897. set filteringQuality(filteringQuality: number);
  16898. /**
  16899. * Gets if the current filter is set to "PCSS" (contact hardening).
  16900. */
  16901. get useContactHardeningShadow(): boolean;
  16902. /**
  16903. * Sets the current filter to "PCSS" (contact hardening).
  16904. */
  16905. set useContactHardeningShadow(value: boolean);
  16906. protected _contactHardeningLightSizeUVRatio: number;
  16907. /**
  16908. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16909. * Using a ratio helps keeping shape stability independently of the map size.
  16910. *
  16911. * It does not account for the light projection as it was having too much
  16912. * instability during the light setup or during light position changes.
  16913. *
  16914. * Only valid if useContactHardeningShadow is true.
  16915. */
  16916. get contactHardeningLightSizeUVRatio(): number;
  16917. /**
  16918. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16919. * Using a ratio helps keeping shape stability independently of the map size.
  16920. *
  16921. * It does not account for the light projection as it was having too much
  16922. * instability during the light setup or during light position changes.
  16923. *
  16924. * Only valid if useContactHardeningShadow is true.
  16925. */
  16926. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16927. protected _darkness: number;
  16928. /** Gets or sets the actual darkness of a shadow */
  16929. get darkness(): number;
  16930. set darkness(value: number);
  16931. /**
  16932. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16933. * 0 means strongest and 1 would means no shadow.
  16934. * @returns the darkness.
  16935. */
  16936. getDarkness(): number;
  16937. /**
  16938. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16939. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16940. * @returns the shadow generator allowing fluent coding.
  16941. */
  16942. setDarkness(darkness: number): ShadowGenerator;
  16943. protected _transparencyShadow: boolean;
  16944. /** Gets or sets the ability to have transparent shadow */
  16945. get transparencyShadow(): boolean;
  16946. set transparencyShadow(value: boolean);
  16947. /**
  16948. * Sets the ability to have transparent shadow (boolean).
  16949. * @param transparent True if transparent else False
  16950. * @returns the shadow generator allowing fluent coding
  16951. */
  16952. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16953. protected _shadowMap: Nullable<RenderTargetTexture>;
  16954. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16955. /**
  16956. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16957. * @returns The render target texture if present otherwise, null
  16958. */
  16959. getShadowMap(): Nullable<RenderTargetTexture>;
  16960. /**
  16961. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16962. * @returns The render target texture if the shadow map is present otherwise, null
  16963. */
  16964. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16965. /**
  16966. * Gets the class name of that object
  16967. * @returns "ShadowGenerator"
  16968. */
  16969. getClassName(): string;
  16970. /**
  16971. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16972. * @param mesh Mesh to add
  16973. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16974. * @returns the Shadow Generator itself
  16975. */
  16976. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16977. /**
  16978. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16979. * @param mesh Mesh to remove
  16980. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16981. * @returns the Shadow Generator itself
  16982. */
  16983. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16984. /**
  16985. * Controls the extent to which the shadows fade out at the edge of the frustum
  16986. */
  16987. frustumEdgeFalloff: number;
  16988. protected _light: IShadowLight;
  16989. /**
  16990. * Returns the associated light object.
  16991. * @returns the light generating the shadow
  16992. */
  16993. getLight(): IShadowLight;
  16994. /**
  16995. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16996. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16997. * It might on the other hand introduce peter panning.
  16998. */
  16999. forceBackFacesOnly: boolean;
  17000. protected _scene: Scene;
  17001. protected _lightDirection: Vector3;
  17002. protected _effect: Effect;
  17003. protected _viewMatrix: Matrix;
  17004. protected _projectionMatrix: Matrix;
  17005. protected _transformMatrix: Matrix;
  17006. protected _cachedPosition: Vector3;
  17007. protected _cachedDirection: Vector3;
  17008. protected _cachedDefines: string;
  17009. protected _currentRenderID: number;
  17010. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17011. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17012. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17013. protected _blurPostProcesses: PostProcess[];
  17014. protected _mapSize: number;
  17015. protected _currentFaceIndex: number;
  17016. protected _currentFaceIndexCache: number;
  17017. protected _textureType: number;
  17018. protected _defaultTextureMatrix: Matrix;
  17019. protected _storedUniqueId: Nullable<number>;
  17020. /** @hidden */
  17021. static _SceneComponentInitialization: (scene: Scene) => void;
  17022. /**
  17023. * Creates a ShadowGenerator object.
  17024. * A ShadowGenerator is the required tool to use the shadows.
  17025. * Each light casting shadows needs to use its own ShadowGenerator.
  17026. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17027. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17028. * @param light The light object generating the shadows.
  17029. * @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.
  17030. */
  17031. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17032. protected _initializeGenerator(): void;
  17033. protected _createTargetRenderTexture(): void;
  17034. protected _initializeShadowMap(): void;
  17035. protected _initializeBlurRTTAndPostProcesses(): void;
  17036. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17037. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17038. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17039. protected _applyFilterValues(): void;
  17040. /**
  17041. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17042. * @param onCompiled Callback triggered at the and of the effects compilation
  17043. * @param options Sets of optional options forcing the compilation with different modes
  17044. */
  17045. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17046. useInstances: boolean;
  17047. }>): void;
  17048. /**
  17049. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17050. * @param options Sets of optional options forcing the compilation with different modes
  17051. * @returns A promise that resolves when the compilation completes
  17052. */
  17053. forceCompilationAsync(options?: Partial<{
  17054. useInstances: boolean;
  17055. }>): Promise<void>;
  17056. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17057. /**
  17058. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17059. * @param subMesh The submesh we want to render in the shadow map
  17060. * @param useInstances Defines wether will draw in the map using instances
  17061. * @returns true if ready otherwise, false
  17062. */
  17063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17064. /**
  17065. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17066. * @param defines Defines of the material we want to update
  17067. * @param lightIndex Index of the light in the enabled light list of the material
  17068. */
  17069. prepareDefines(defines: any, lightIndex: number): void;
  17070. /**
  17071. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17072. * defined in the generator but impacting the effect).
  17073. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17074. * @param effect The effect we are binfing the information for
  17075. */
  17076. bindShadowLight(lightIndex: string, effect: Effect): void;
  17077. /**
  17078. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17079. * (eq to shadow prjection matrix * light transform matrix)
  17080. * @returns The transform matrix used to create the shadow map
  17081. */
  17082. getTransformMatrix(): Matrix;
  17083. /**
  17084. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17085. * Cube and 2D textures for instance.
  17086. */
  17087. recreateShadowMap(): void;
  17088. protected _disposeBlurPostProcesses(): void;
  17089. protected _disposeRTTandPostProcesses(): void;
  17090. /**
  17091. * Disposes the ShadowGenerator.
  17092. * Returns nothing.
  17093. */
  17094. dispose(): void;
  17095. /**
  17096. * Serializes the shadow generator setup to a json object.
  17097. * @returns The serialized JSON object
  17098. */
  17099. serialize(): any;
  17100. /**
  17101. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17102. * @param parsedShadowGenerator The JSON object to parse
  17103. * @param scene The scene to create the shadow map for
  17104. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17105. * @returns The parsed shadow generator
  17106. */
  17107. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17108. }
  17109. }
  17110. declare module "babylonjs/Lights/light" {
  17111. import { Nullable } from "babylonjs/types";
  17112. import { Scene } from "babylonjs/scene";
  17113. import { Vector3 } from "babylonjs/Maths/math.vector";
  17114. import { Color3 } from "babylonjs/Maths/math.color";
  17115. import { Node } from "babylonjs/node";
  17116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17117. import { Effect } from "babylonjs/Materials/effect";
  17118. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17119. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17120. /**
  17121. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17122. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17123. * 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.
  17124. */
  17125. export abstract class Light extends Node {
  17126. /**
  17127. * Falloff Default: light is falling off following the material specification:
  17128. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17129. */
  17130. static readonly FALLOFF_DEFAULT: number;
  17131. /**
  17132. * Falloff Physical: light is falling off following the inverse squared distance law.
  17133. */
  17134. static readonly FALLOFF_PHYSICAL: number;
  17135. /**
  17136. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17137. * to enhance interoperability with other engines.
  17138. */
  17139. static readonly FALLOFF_GLTF: number;
  17140. /**
  17141. * Falloff Standard: light is falling off like in the standard material
  17142. * to enhance interoperability with other materials.
  17143. */
  17144. static readonly FALLOFF_STANDARD: number;
  17145. /**
  17146. * If every light affecting the material is in this lightmapMode,
  17147. * material.lightmapTexture adds or multiplies
  17148. * (depends on material.useLightmapAsShadowmap)
  17149. * after every other light calculations.
  17150. */
  17151. static readonly LIGHTMAP_DEFAULT: number;
  17152. /**
  17153. * material.lightmapTexture as only diffuse lighting from this light
  17154. * adds only specular lighting from this light
  17155. * adds dynamic shadows
  17156. */
  17157. static readonly LIGHTMAP_SPECULAR: number;
  17158. /**
  17159. * material.lightmapTexture as only lighting
  17160. * no light calculation from this light
  17161. * only adds dynamic shadows from this light
  17162. */
  17163. static readonly LIGHTMAP_SHADOWSONLY: number;
  17164. /**
  17165. * Each light type uses the default quantity according to its type:
  17166. * point/spot lights use luminous intensity
  17167. * directional lights use illuminance
  17168. */
  17169. static readonly INTENSITYMODE_AUTOMATIC: number;
  17170. /**
  17171. * lumen (lm)
  17172. */
  17173. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17174. /**
  17175. * candela (lm/sr)
  17176. */
  17177. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17178. /**
  17179. * lux (lm/m^2)
  17180. */
  17181. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17182. /**
  17183. * nit (cd/m^2)
  17184. */
  17185. static readonly INTENSITYMODE_LUMINANCE: number;
  17186. /**
  17187. * Light type const id of the point light.
  17188. */
  17189. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17190. /**
  17191. * Light type const id of the directional light.
  17192. */
  17193. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17194. /**
  17195. * Light type const id of the spot light.
  17196. */
  17197. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17198. /**
  17199. * Light type const id of the hemispheric light.
  17200. */
  17201. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17202. /**
  17203. * Diffuse gives the basic color to an object.
  17204. */
  17205. diffuse: Color3;
  17206. /**
  17207. * Specular produces a highlight color on an object.
  17208. * Note: This is note affecting PBR materials.
  17209. */
  17210. specular: Color3;
  17211. /**
  17212. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17213. * falling off base on range or angle.
  17214. * This can be set to any values in Light.FALLOFF_x.
  17215. *
  17216. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17217. * other types of materials.
  17218. */
  17219. falloffType: number;
  17220. /**
  17221. * Strength of the light.
  17222. * Note: By default it is define in the framework own unit.
  17223. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17224. */
  17225. intensity: number;
  17226. private _range;
  17227. protected _inverseSquaredRange: number;
  17228. /**
  17229. * Defines how far from the source the light is impacting in scene units.
  17230. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17231. */
  17232. get range(): number;
  17233. /**
  17234. * Defines how far from the source the light is impacting in scene units.
  17235. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17236. */
  17237. set range(value: number);
  17238. /**
  17239. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17240. * of light.
  17241. */
  17242. private _photometricScale;
  17243. private _intensityMode;
  17244. /**
  17245. * Gets the photometric scale used to interpret the intensity.
  17246. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17247. */
  17248. get intensityMode(): number;
  17249. /**
  17250. * Sets the photometric scale used to interpret the intensity.
  17251. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17252. */
  17253. set intensityMode(value: number);
  17254. private _radius;
  17255. /**
  17256. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17257. */
  17258. get radius(): number;
  17259. /**
  17260. * sets the light radius used by PBR Materials to simulate soft area lights.
  17261. */
  17262. set radius(value: number);
  17263. private _renderPriority;
  17264. /**
  17265. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17266. * exceeding the number allowed of the materials.
  17267. */
  17268. renderPriority: number;
  17269. private _shadowEnabled;
  17270. /**
  17271. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17272. * the current shadow generator.
  17273. */
  17274. get shadowEnabled(): boolean;
  17275. /**
  17276. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17277. * the current shadow generator.
  17278. */
  17279. set shadowEnabled(value: boolean);
  17280. private _includedOnlyMeshes;
  17281. /**
  17282. * Gets the only meshes impacted by this light.
  17283. */
  17284. get includedOnlyMeshes(): AbstractMesh[];
  17285. /**
  17286. * Sets the only meshes impacted by this light.
  17287. */
  17288. set includedOnlyMeshes(value: AbstractMesh[]);
  17289. private _excludedMeshes;
  17290. /**
  17291. * Gets the meshes not impacted by this light.
  17292. */
  17293. get excludedMeshes(): AbstractMesh[];
  17294. /**
  17295. * Sets the meshes not impacted by this light.
  17296. */
  17297. set excludedMeshes(value: AbstractMesh[]);
  17298. private _excludeWithLayerMask;
  17299. /**
  17300. * Gets the layer id use to find what meshes are not impacted by the light.
  17301. * Inactive if 0
  17302. */
  17303. get excludeWithLayerMask(): number;
  17304. /**
  17305. * Sets the layer id use to find what meshes are not impacted by the light.
  17306. * Inactive if 0
  17307. */
  17308. set excludeWithLayerMask(value: number);
  17309. private _includeOnlyWithLayerMask;
  17310. /**
  17311. * Gets the layer id use to find what meshes are impacted by the light.
  17312. * Inactive if 0
  17313. */
  17314. get includeOnlyWithLayerMask(): number;
  17315. /**
  17316. * Sets the layer id use to find what meshes are impacted by the light.
  17317. * Inactive if 0
  17318. */
  17319. set includeOnlyWithLayerMask(value: number);
  17320. private _lightmapMode;
  17321. /**
  17322. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17323. */
  17324. get lightmapMode(): number;
  17325. /**
  17326. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17327. */
  17328. set lightmapMode(value: number);
  17329. /**
  17330. * Shadow generator associted to the light.
  17331. * @hidden Internal use only.
  17332. */
  17333. _shadowGenerator: Nullable<IShadowGenerator>;
  17334. /**
  17335. * @hidden Internal use only.
  17336. */
  17337. _excludedMeshesIds: string[];
  17338. /**
  17339. * @hidden Internal use only.
  17340. */
  17341. _includedOnlyMeshesIds: string[];
  17342. /**
  17343. * The current light unifom buffer.
  17344. * @hidden Internal use only.
  17345. */
  17346. _uniformBuffer: UniformBuffer;
  17347. /** @hidden */
  17348. _renderId: number;
  17349. /**
  17350. * Creates a Light object in the scene.
  17351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17352. * @param name The firendly name of the light
  17353. * @param scene The scene the light belongs too
  17354. */
  17355. constructor(name: string, scene: Scene);
  17356. protected abstract _buildUniformLayout(): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightIndex The index of the light in the effect to update
  17361. * @returns The light
  17362. */
  17363. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17364. /**
  17365. * Sets the passed Effect "effect" with the Light textures.
  17366. * @param effect The effect to update
  17367. * @param lightIndex The index of the light in the effect to update
  17368. * @returns The light
  17369. */
  17370. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17371. /**
  17372. * Binds the lights information from the scene to the effect for the given mesh.
  17373. * @param lightIndex Light index
  17374. * @param scene The scene where the light belongs to
  17375. * @param effect The effect we are binding the data to
  17376. * @param useSpecular Defines if specular is supported
  17377. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17378. */
  17379. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17380. /**
  17381. * Sets the passed Effect "effect" with the Light information.
  17382. * @param effect The effect to update
  17383. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17384. * @returns The light
  17385. */
  17386. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17387. /**
  17388. * Returns the string "Light".
  17389. * @returns the class name
  17390. */
  17391. getClassName(): string;
  17392. /** @hidden */
  17393. readonly _isLight: boolean;
  17394. /**
  17395. * Converts the light information to a readable string for debug purpose.
  17396. * @param fullDetails Supports for multiple levels of logging within scene loading
  17397. * @returns the human readable light info
  17398. */
  17399. toString(fullDetails?: boolean): string;
  17400. /** @hidden */
  17401. protected _syncParentEnabledState(): void;
  17402. /**
  17403. * Set the enabled state of this node.
  17404. * @param value - the new enabled state
  17405. */
  17406. setEnabled(value: boolean): void;
  17407. /**
  17408. * Returns the Light associated shadow generator if any.
  17409. * @return the associated shadow generator.
  17410. */
  17411. getShadowGenerator(): Nullable<IShadowGenerator>;
  17412. /**
  17413. * Returns a Vector3, the absolute light position in the World.
  17414. * @returns the world space position of the light
  17415. */
  17416. getAbsolutePosition(): Vector3;
  17417. /**
  17418. * Specifies if the light will affect the passed mesh.
  17419. * @param mesh The mesh to test against the light
  17420. * @return true the mesh is affected otherwise, false.
  17421. */
  17422. canAffectMesh(mesh: AbstractMesh): boolean;
  17423. /**
  17424. * Sort function to order lights for rendering.
  17425. * @param a First Light object to compare to second.
  17426. * @param b Second Light object to compare first.
  17427. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17428. */
  17429. static CompareLightsPriority(a: Light, b: Light): number;
  17430. /**
  17431. * Releases resources associated with this node.
  17432. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17433. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17434. */
  17435. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17436. /**
  17437. * Returns the light type ID (integer).
  17438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17439. */
  17440. getTypeID(): number;
  17441. /**
  17442. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17443. * @returns the scaled intensity in intensity mode unit
  17444. */
  17445. getScaledIntensity(): number;
  17446. /**
  17447. * Returns a new Light object, named "name", from the current one.
  17448. * @param name The name of the cloned light
  17449. * @returns the new created light
  17450. */
  17451. clone(name: string): Nullable<Light>;
  17452. /**
  17453. * Serializes the current light into a Serialization object.
  17454. * @returns the serialized object.
  17455. */
  17456. serialize(): any;
  17457. /**
  17458. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17459. * This new light is named "name" and added to the passed scene.
  17460. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17461. * @param name The friendly name of the light
  17462. * @param scene The scene the new light will belong to
  17463. * @returns the constructor function
  17464. */
  17465. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17466. /**
  17467. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17468. * @param parsedLight The JSON representation of the light
  17469. * @param scene The scene to create the parsed light in
  17470. * @returns the created light after parsing
  17471. */
  17472. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17473. private _hookArrayForExcluded;
  17474. private _hookArrayForIncludedOnly;
  17475. private _resyncMeshes;
  17476. /**
  17477. * Forces the meshes to update their light related information in their rendering used effects
  17478. * @hidden Internal Use Only
  17479. */
  17480. _markMeshesAsLightDirty(): void;
  17481. /**
  17482. * Recomputes the cached photometric scale if needed.
  17483. */
  17484. private _computePhotometricScale;
  17485. /**
  17486. * Returns the Photometric Scale according to the light type and intensity mode.
  17487. */
  17488. private _getPhotometricScale;
  17489. /**
  17490. * Reorder the light in the scene according to their defined priority.
  17491. * @hidden Internal Use Only
  17492. */
  17493. _reorderLightsInScene(): void;
  17494. /**
  17495. * Prepares the list of defines specific to the light type.
  17496. * @param defines the list of defines
  17497. * @param lightIndex defines the index of the light for the effect
  17498. */
  17499. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17500. }
  17501. }
  17502. declare module "babylonjs/Actions/action" {
  17503. import { Observable } from "babylonjs/Misc/observable";
  17504. import { Condition } from "babylonjs/Actions/condition";
  17505. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17506. import { ActionManager } from "babylonjs/Actions/actionManager";
  17507. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17508. /**
  17509. * Interface used to define Action
  17510. */
  17511. export interface IAction {
  17512. /**
  17513. * Trigger for the action
  17514. */
  17515. trigger: number;
  17516. /** Options of the trigger */
  17517. triggerOptions: any;
  17518. /**
  17519. * Gets the trigger parameters
  17520. * @returns the trigger parameters
  17521. */
  17522. getTriggerParameter(): any;
  17523. /**
  17524. * Internal only - executes current action event
  17525. * @hidden
  17526. */
  17527. _executeCurrent(evt?: ActionEvent): void;
  17528. /**
  17529. * Serialize placeholder for child classes
  17530. * @param parent of child
  17531. * @returns the serialized object
  17532. */
  17533. serialize(parent: any): any;
  17534. /**
  17535. * Internal only
  17536. * @hidden
  17537. */
  17538. _prepare(): void;
  17539. /**
  17540. * Internal only - manager for action
  17541. * @hidden
  17542. */
  17543. _actionManager: AbstractActionManager;
  17544. /**
  17545. * Adds action to chain of actions, may be a DoNothingAction
  17546. * @param action defines the next action to execute
  17547. * @returns The action passed in
  17548. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17549. */
  17550. then(action: IAction): IAction;
  17551. }
  17552. /**
  17553. * The action to be carried out following a trigger
  17554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17555. */
  17556. export class Action implements IAction {
  17557. /** the trigger, with or without parameters, for the action */
  17558. triggerOptions: any;
  17559. /**
  17560. * Trigger for the action
  17561. */
  17562. trigger: number;
  17563. /**
  17564. * Internal only - manager for action
  17565. * @hidden
  17566. */
  17567. _actionManager: ActionManager;
  17568. private _nextActiveAction;
  17569. private _child;
  17570. private _condition?;
  17571. private _triggerParameter;
  17572. /**
  17573. * An event triggered prior to action being executed.
  17574. */
  17575. onBeforeExecuteObservable: Observable<Action>;
  17576. /**
  17577. * Creates a new Action
  17578. * @param triggerOptions the trigger, with or without parameters, for the action
  17579. * @param condition an optional determinant of action
  17580. */
  17581. constructor(
  17582. /** the trigger, with or without parameters, for the action */
  17583. triggerOptions: any, condition?: Condition);
  17584. /**
  17585. * Internal only
  17586. * @hidden
  17587. */
  17588. _prepare(): void;
  17589. /**
  17590. * Gets the trigger parameters
  17591. * @returns the trigger parameters
  17592. */
  17593. getTriggerParameter(): any;
  17594. /**
  17595. * Internal only - executes current action event
  17596. * @hidden
  17597. */
  17598. _executeCurrent(evt?: ActionEvent): void;
  17599. /**
  17600. * Execute placeholder for child classes
  17601. * @param evt optional action event
  17602. */
  17603. execute(evt?: ActionEvent): void;
  17604. /**
  17605. * Skips to next active action
  17606. */
  17607. skipToNextActiveAction(): void;
  17608. /**
  17609. * Adds action to chain of actions, may be a DoNothingAction
  17610. * @param action defines the next action to execute
  17611. * @returns The action passed in
  17612. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17613. */
  17614. then(action: Action): Action;
  17615. /**
  17616. * Internal only
  17617. * @hidden
  17618. */
  17619. _getProperty(propertyPath: string): string;
  17620. /**
  17621. * Internal only
  17622. * @hidden
  17623. */
  17624. _getEffectiveTarget(target: any, propertyPath: string): any;
  17625. /**
  17626. * Serialize placeholder for child classes
  17627. * @param parent of child
  17628. * @returns the serialized object
  17629. */
  17630. serialize(parent: any): any;
  17631. /**
  17632. * Internal only called by serialize
  17633. * @hidden
  17634. */
  17635. protected _serialize(serializedAction: any, parent?: any): any;
  17636. /**
  17637. * Internal only
  17638. * @hidden
  17639. */
  17640. static _SerializeValueAsString: (value: any) => string;
  17641. /**
  17642. * Internal only
  17643. * @hidden
  17644. */
  17645. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17646. name: string;
  17647. targetType: string;
  17648. value: string;
  17649. };
  17650. }
  17651. }
  17652. declare module "babylonjs/Actions/condition" {
  17653. import { ActionManager } from "babylonjs/Actions/actionManager";
  17654. /**
  17655. * A Condition applied to an Action
  17656. */
  17657. export class Condition {
  17658. /**
  17659. * Internal only - manager for action
  17660. * @hidden
  17661. */
  17662. _actionManager: ActionManager;
  17663. /**
  17664. * Internal only
  17665. * @hidden
  17666. */
  17667. _evaluationId: number;
  17668. /**
  17669. * Internal only
  17670. * @hidden
  17671. */
  17672. _currentResult: boolean;
  17673. /**
  17674. * Creates a new Condition
  17675. * @param actionManager the manager of the action the condition is applied to
  17676. */
  17677. constructor(actionManager: ActionManager);
  17678. /**
  17679. * Check if the current condition is valid
  17680. * @returns a boolean
  17681. */
  17682. isValid(): boolean;
  17683. /**
  17684. * Internal only
  17685. * @hidden
  17686. */
  17687. _getProperty(propertyPath: string): string;
  17688. /**
  17689. * Internal only
  17690. * @hidden
  17691. */
  17692. _getEffectiveTarget(target: any, propertyPath: string): any;
  17693. /**
  17694. * Serialize placeholder for child classes
  17695. * @returns the serialized object
  17696. */
  17697. serialize(): any;
  17698. /**
  17699. * Internal only
  17700. * @hidden
  17701. */
  17702. protected _serialize(serializedCondition: any): any;
  17703. }
  17704. /**
  17705. * Defines specific conditional operators as extensions of Condition
  17706. */
  17707. export class ValueCondition extends Condition {
  17708. /** path to specify the property of the target the conditional operator uses */
  17709. propertyPath: string;
  17710. /** the value compared by the conditional operator against the current value of the property */
  17711. value: any;
  17712. /** the conditional operator, default ValueCondition.IsEqual */
  17713. operator: number;
  17714. /**
  17715. * Internal only
  17716. * @hidden
  17717. */
  17718. private static _IsEqual;
  17719. /**
  17720. * Internal only
  17721. * @hidden
  17722. */
  17723. private static _IsDifferent;
  17724. /**
  17725. * Internal only
  17726. * @hidden
  17727. */
  17728. private static _IsGreater;
  17729. /**
  17730. * Internal only
  17731. * @hidden
  17732. */
  17733. private static _IsLesser;
  17734. /**
  17735. * returns the number for IsEqual
  17736. */
  17737. static get IsEqual(): number;
  17738. /**
  17739. * Returns the number for IsDifferent
  17740. */
  17741. static get IsDifferent(): number;
  17742. /**
  17743. * Returns the number for IsGreater
  17744. */
  17745. static get IsGreater(): number;
  17746. /**
  17747. * Returns the number for IsLesser
  17748. */
  17749. static get IsLesser(): number;
  17750. /**
  17751. * Internal only The action manager for the condition
  17752. * @hidden
  17753. */
  17754. _actionManager: ActionManager;
  17755. /**
  17756. * Internal only
  17757. * @hidden
  17758. */
  17759. private _target;
  17760. /**
  17761. * Internal only
  17762. * @hidden
  17763. */
  17764. private _effectiveTarget;
  17765. /**
  17766. * Internal only
  17767. * @hidden
  17768. */
  17769. private _property;
  17770. /**
  17771. * Creates a new ValueCondition
  17772. * @param actionManager manager for the action the condition applies to
  17773. * @param target for the action
  17774. * @param propertyPath path to specify the property of the target the conditional operator uses
  17775. * @param value the value compared by the conditional operator against the current value of the property
  17776. * @param operator the conditional operator, default ValueCondition.IsEqual
  17777. */
  17778. constructor(actionManager: ActionManager, target: any,
  17779. /** path to specify the property of the target the conditional operator uses */
  17780. propertyPath: string,
  17781. /** the value compared by the conditional operator against the current value of the property */
  17782. value: any,
  17783. /** the conditional operator, default ValueCondition.IsEqual */
  17784. operator?: number);
  17785. /**
  17786. * Compares the given value with the property value for the specified conditional operator
  17787. * @returns the result of the comparison
  17788. */
  17789. isValid(): boolean;
  17790. /**
  17791. * Serialize the ValueCondition into a JSON compatible object
  17792. * @returns serialization object
  17793. */
  17794. serialize(): any;
  17795. /**
  17796. * Gets the name of the conditional operator for the ValueCondition
  17797. * @param operator the conditional operator
  17798. * @returns the name
  17799. */
  17800. static GetOperatorName(operator: number): string;
  17801. }
  17802. /**
  17803. * Defines a predicate condition as an extension of Condition
  17804. */
  17805. export class PredicateCondition extends Condition {
  17806. /** defines the predicate function used to validate the condition */
  17807. predicate: () => boolean;
  17808. /**
  17809. * Internal only - manager for action
  17810. * @hidden
  17811. */
  17812. _actionManager: ActionManager;
  17813. /**
  17814. * Creates a new PredicateCondition
  17815. * @param actionManager manager for the action the condition applies to
  17816. * @param predicate defines the predicate function used to validate the condition
  17817. */
  17818. constructor(actionManager: ActionManager,
  17819. /** defines the predicate function used to validate the condition */
  17820. predicate: () => boolean);
  17821. /**
  17822. * @returns the validity of the predicate condition
  17823. */
  17824. isValid(): boolean;
  17825. }
  17826. /**
  17827. * Defines a state condition as an extension of Condition
  17828. */
  17829. export class StateCondition extends Condition {
  17830. /** Value to compare with target state */
  17831. value: string;
  17832. /**
  17833. * Internal only - manager for action
  17834. * @hidden
  17835. */
  17836. _actionManager: ActionManager;
  17837. /**
  17838. * Internal only
  17839. * @hidden
  17840. */
  17841. private _target;
  17842. /**
  17843. * Creates a new StateCondition
  17844. * @param actionManager manager for the action the condition applies to
  17845. * @param target of the condition
  17846. * @param value to compare with target state
  17847. */
  17848. constructor(actionManager: ActionManager, target: any,
  17849. /** Value to compare with target state */
  17850. value: string);
  17851. /**
  17852. * Gets a boolean indicating if the current condition is met
  17853. * @returns the validity of the state
  17854. */
  17855. isValid(): boolean;
  17856. /**
  17857. * Serialize the StateCondition into a JSON compatible object
  17858. * @returns serialization object
  17859. */
  17860. serialize(): any;
  17861. }
  17862. }
  17863. declare module "babylonjs/Actions/directActions" {
  17864. import { Action } from "babylonjs/Actions/action";
  17865. import { Condition } from "babylonjs/Actions/condition";
  17866. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17867. /**
  17868. * This defines an action responsible to toggle a boolean once triggered.
  17869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17870. */
  17871. export class SwitchBooleanAction extends Action {
  17872. /**
  17873. * The path to the boolean property in the target object
  17874. */
  17875. propertyPath: string;
  17876. private _target;
  17877. private _effectiveTarget;
  17878. private _property;
  17879. /**
  17880. * Instantiate the action
  17881. * @param triggerOptions defines the trigger options
  17882. * @param target defines the object containing the boolean
  17883. * @param propertyPath defines the path to the boolean property in the target object
  17884. * @param condition defines the trigger related conditions
  17885. */
  17886. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17887. /** @hidden */
  17888. _prepare(): void;
  17889. /**
  17890. * Execute the action toggle the boolean value.
  17891. */
  17892. execute(): void;
  17893. /**
  17894. * Serializes the actions and its related information.
  17895. * @param parent defines the object to serialize in
  17896. * @returns the serialized object
  17897. */
  17898. serialize(parent: any): any;
  17899. }
  17900. /**
  17901. * This defines an action responsible to set a the state field of the target
  17902. * to a desired value once triggered.
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17904. */
  17905. export class SetStateAction extends Action {
  17906. /**
  17907. * The value to store in the state field.
  17908. */
  17909. value: string;
  17910. private _target;
  17911. /**
  17912. * Instantiate the action
  17913. * @param triggerOptions defines the trigger options
  17914. * @param target defines the object containing the state property
  17915. * @param value defines the value to store in the state field
  17916. * @param condition defines the trigger related conditions
  17917. */
  17918. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17919. /**
  17920. * Execute the action and store the value on the target state property.
  17921. */
  17922. execute(): void;
  17923. /**
  17924. * Serializes the actions and its related information.
  17925. * @param parent defines the object to serialize in
  17926. * @returns the serialized object
  17927. */
  17928. serialize(parent: any): any;
  17929. }
  17930. /**
  17931. * This defines an action responsible to set a property of the target
  17932. * to a desired value once triggered.
  17933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17934. */
  17935. export class SetValueAction extends Action {
  17936. /**
  17937. * The path of the property to set in the target.
  17938. */
  17939. propertyPath: string;
  17940. /**
  17941. * The value to set in the property
  17942. */
  17943. value: any;
  17944. private _target;
  17945. private _effectiveTarget;
  17946. private _property;
  17947. /**
  17948. * Instantiate the action
  17949. * @param triggerOptions defines the trigger options
  17950. * @param target defines the object containing the property
  17951. * @param propertyPath defines the path of the property to set in the target
  17952. * @param value defines the value to set in the property
  17953. * @param condition defines the trigger related conditions
  17954. */
  17955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17956. /** @hidden */
  17957. _prepare(): void;
  17958. /**
  17959. * Execute the action and set the targetted property to the desired value.
  17960. */
  17961. execute(): void;
  17962. /**
  17963. * Serializes the actions and its related information.
  17964. * @param parent defines the object to serialize in
  17965. * @returns the serialized object
  17966. */
  17967. serialize(parent: any): any;
  17968. }
  17969. /**
  17970. * This defines an action responsible to increment the target value
  17971. * to a desired value once triggered.
  17972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17973. */
  17974. export class IncrementValueAction extends Action {
  17975. /**
  17976. * The path of the property to increment in the target.
  17977. */
  17978. propertyPath: string;
  17979. /**
  17980. * The value we should increment the property by.
  17981. */
  17982. value: any;
  17983. private _target;
  17984. private _effectiveTarget;
  17985. private _property;
  17986. /**
  17987. * Instantiate the action
  17988. * @param triggerOptions defines the trigger options
  17989. * @param target defines the object containing the property
  17990. * @param propertyPath defines the path of the property to increment in the target
  17991. * @param value defines the value value we should increment the property by
  17992. * @param condition defines the trigger related conditions
  17993. */
  17994. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17995. /** @hidden */
  17996. _prepare(): void;
  17997. /**
  17998. * Execute the action and increment the target of the value amount.
  17999. */
  18000. execute(): void;
  18001. /**
  18002. * Serializes the actions and its related information.
  18003. * @param parent defines the object to serialize in
  18004. * @returns the serialized object
  18005. */
  18006. serialize(parent: any): any;
  18007. }
  18008. /**
  18009. * This defines an action responsible to start an animation once triggered.
  18010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18011. */
  18012. export class PlayAnimationAction extends Action {
  18013. /**
  18014. * Where the animation should start (animation frame)
  18015. */
  18016. from: number;
  18017. /**
  18018. * Where the animation should stop (animation frame)
  18019. */
  18020. to: number;
  18021. /**
  18022. * Define if the animation should loop or stop after the first play.
  18023. */
  18024. loop?: boolean;
  18025. private _target;
  18026. /**
  18027. * Instantiate the action
  18028. * @param triggerOptions defines the trigger options
  18029. * @param target defines the target animation or animation name
  18030. * @param from defines from where the animation should start (animation frame)
  18031. * @param end defines where the animation should stop (animation frame)
  18032. * @param loop defines if the animation should loop or stop after the first play
  18033. * @param condition defines the trigger related conditions
  18034. */
  18035. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18036. /** @hidden */
  18037. _prepare(): void;
  18038. /**
  18039. * Execute the action and play the animation.
  18040. */
  18041. execute(): void;
  18042. /**
  18043. * Serializes the actions and its related information.
  18044. * @param parent defines the object to serialize in
  18045. * @returns the serialized object
  18046. */
  18047. serialize(parent: any): any;
  18048. }
  18049. /**
  18050. * This defines an action responsible to stop an animation once triggered.
  18051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18052. */
  18053. export class StopAnimationAction extends Action {
  18054. private _target;
  18055. /**
  18056. * Instantiate the action
  18057. * @param triggerOptions defines the trigger options
  18058. * @param target defines the target animation or animation name
  18059. * @param condition defines the trigger related conditions
  18060. */
  18061. constructor(triggerOptions: any, target: any, condition?: Condition);
  18062. /** @hidden */
  18063. _prepare(): void;
  18064. /**
  18065. * Execute the action and stop the animation.
  18066. */
  18067. execute(): void;
  18068. /**
  18069. * Serializes the actions and its related information.
  18070. * @param parent defines the object to serialize in
  18071. * @returns the serialized object
  18072. */
  18073. serialize(parent: any): any;
  18074. }
  18075. /**
  18076. * This defines an action responsible that does nothing once triggered.
  18077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18078. */
  18079. export class DoNothingAction extends Action {
  18080. /**
  18081. * Instantiate the action
  18082. * @param triggerOptions defines the trigger options
  18083. * @param condition defines the trigger related conditions
  18084. */
  18085. constructor(triggerOptions?: any, condition?: Condition);
  18086. /**
  18087. * Execute the action and do nothing.
  18088. */
  18089. execute(): void;
  18090. /**
  18091. * Serializes the actions and its related information.
  18092. * @param parent defines the object to serialize in
  18093. * @returns the serialized object
  18094. */
  18095. serialize(parent: any): any;
  18096. }
  18097. /**
  18098. * This defines an action responsible to trigger several actions once triggered.
  18099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18100. */
  18101. export class CombineAction extends Action {
  18102. /**
  18103. * The list of aggregated animations to run.
  18104. */
  18105. children: Action[];
  18106. /**
  18107. * Instantiate the action
  18108. * @param triggerOptions defines the trigger options
  18109. * @param children defines the list of aggregated animations to run
  18110. * @param condition defines the trigger related conditions
  18111. */
  18112. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18113. /** @hidden */
  18114. _prepare(): void;
  18115. /**
  18116. * Execute the action and executes all the aggregated actions.
  18117. */
  18118. execute(evt: ActionEvent): void;
  18119. /**
  18120. * Serializes the actions and its related information.
  18121. * @param parent defines the object to serialize in
  18122. * @returns the serialized object
  18123. */
  18124. serialize(parent: any): any;
  18125. }
  18126. /**
  18127. * This defines an action responsible to run code (external event) once triggered.
  18128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18129. */
  18130. export class ExecuteCodeAction extends Action {
  18131. /**
  18132. * The callback function to run.
  18133. */
  18134. func: (evt: ActionEvent) => void;
  18135. /**
  18136. * Instantiate the action
  18137. * @param triggerOptions defines the trigger options
  18138. * @param func defines the callback function to run
  18139. * @param condition defines the trigger related conditions
  18140. */
  18141. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18142. /**
  18143. * Execute the action and run the attached code.
  18144. */
  18145. execute(evt: ActionEvent): void;
  18146. }
  18147. /**
  18148. * This defines an action responsible to set the parent property of the target once triggered.
  18149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18150. */
  18151. export class SetParentAction extends Action {
  18152. private _parent;
  18153. private _target;
  18154. /**
  18155. * Instantiate the action
  18156. * @param triggerOptions defines the trigger options
  18157. * @param target defines the target containing the parent property
  18158. * @param parent defines from where the animation should start (animation frame)
  18159. * @param condition defines the trigger related conditions
  18160. */
  18161. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18162. /** @hidden */
  18163. _prepare(): void;
  18164. /**
  18165. * Execute the action and set the parent property.
  18166. */
  18167. execute(): void;
  18168. /**
  18169. * Serializes the actions and its related information.
  18170. * @param parent defines the object to serialize in
  18171. * @returns the serialized object
  18172. */
  18173. serialize(parent: any): any;
  18174. }
  18175. }
  18176. declare module "babylonjs/Actions/actionManager" {
  18177. import { Nullable } from "babylonjs/types";
  18178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18179. import { Scene } from "babylonjs/scene";
  18180. import { IAction } from "babylonjs/Actions/action";
  18181. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18182. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18183. /**
  18184. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18185. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18187. */
  18188. export class ActionManager extends AbstractActionManager {
  18189. /**
  18190. * Nothing
  18191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18192. */
  18193. static readonly NothingTrigger: number;
  18194. /**
  18195. * On pick
  18196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18197. */
  18198. static readonly OnPickTrigger: number;
  18199. /**
  18200. * On left pick
  18201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18202. */
  18203. static readonly OnLeftPickTrigger: number;
  18204. /**
  18205. * On right pick
  18206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18207. */
  18208. static readonly OnRightPickTrigger: number;
  18209. /**
  18210. * On center pick
  18211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18212. */
  18213. static readonly OnCenterPickTrigger: number;
  18214. /**
  18215. * On pick down
  18216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18217. */
  18218. static readonly OnPickDownTrigger: number;
  18219. /**
  18220. * On double pick
  18221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18222. */
  18223. static readonly OnDoublePickTrigger: number;
  18224. /**
  18225. * On pick up
  18226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18227. */
  18228. static readonly OnPickUpTrigger: number;
  18229. /**
  18230. * On pick out.
  18231. * This trigger will only be raised if you also declared a OnPickDown
  18232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18233. */
  18234. static readonly OnPickOutTrigger: number;
  18235. /**
  18236. * On long press
  18237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18238. */
  18239. static readonly OnLongPressTrigger: number;
  18240. /**
  18241. * On pointer over
  18242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18243. */
  18244. static readonly OnPointerOverTrigger: number;
  18245. /**
  18246. * On pointer out
  18247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18248. */
  18249. static readonly OnPointerOutTrigger: number;
  18250. /**
  18251. * On every frame
  18252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18253. */
  18254. static readonly OnEveryFrameTrigger: number;
  18255. /**
  18256. * On intersection enter
  18257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18258. */
  18259. static readonly OnIntersectionEnterTrigger: number;
  18260. /**
  18261. * On intersection exit
  18262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18263. */
  18264. static readonly OnIntersectionExitTrigger: number;
  18265. /**
  18266. * On key down
  18267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18268. */
  18269. static readonly OnKeyDownTrigger: number;
  18270. /**
  18271. * On key up
  18272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18273. */
  18274. static readonly OnKeyUpTrigger: number;
  18275. private _scene;
  18276. /**
  18277. * Creates a new action manager
  18278. * @param scene defines the hosting scene
  18279. */
  18280. constructor(scene: Scene);
  18281. /**
  18282. * Releases all associated resources
  18283. */
  18284. dispose(): void;
  18285. /**
  18286. * Gets hosting scene
  18287. * @returns the hosting scene
  18288. */
  18289. getScene(): Scene;
  18290. /**
  18291. * Does this action manager handles actions of any of the given triggers
  18292. * @param triggers defines the triggers to be tested
  18293. * @return a boolean indicating whether one (or more) of the triggers is handled
  18294. */
  18295. hasSpecificTriggers(triggers: number[]): boolean;
  18296. /**
  18297. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18298. * speed.
  18299. * @param triggerA defines the trigger to be tested
  18300. * @param triggerB defines the trigger to be tested
  18301. * @return a boolean indicating whether one (or more) of the triggers is handled
  18302. */
  18303. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18304. /**
  18305. * Does this action manager handles actions of a given trigger
  18306. * @param trigger defines the trigger to be tested
  18307. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18308. * @return whether the trigger is handled
  18309. */
  18310. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18311. /**
  18312. * Does this action manager has pointer triggers
  18313. */
  18314. get hasPointerTriggers(): boolean;
  18315. /**
  18316. * Does this action manager has pick triggers
  18317. */
  18318. get hasPickTriggers(): boolean;
  18319. /**
  18320. * Registers an action to this action manager
  18321. * @param action defines the action to be registered
  18322. * @return the action amended (prepared) after registration
  18323. */
  18324. registerAction(action: IAction): Nullable<IAction>;
  18325. /**
  18326. * Unregisters an action to this action manager
  18327. * @param action defines the action to be unregistered
  18328. * @return a boolean indicating whether the action has been unregistered
  18329. */
  18330. unregisterAction(action: IAction): Boolean;
  18331. /**
  18332. * Process a specific trigger
  18333. * @param trigger defines the trigger to process
  18334. * @param evt defines the event details to be processed
  18335. */
  18336. processTrigger(trigger: number, evt?: IActionEvent): void;
  18337. /** @hidden */
  18338. _getEffectiveTarget(target: any, propertyPath: string): any;
  18339. /** @hidden */
  18340. _getProperty(propertyPath: string): string;
  18341. /**
  18342. * Serialize this manager to a JSON object
  18343. * @param name defines the property name to store this manager
  18344. * @returns a JSON representation of this manager
  18345. */
  18346. serialize(name: string): any;
  18347. /**
  18348. * Creates a new ActionManager from a JSON data
  18349. * @param parsedActions defines the JSON data to read from
  18350. * @param object defines the hosting mesh
  18351. * @param scene defines the hosting scene
  18352. */
  18353. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18354. /**
  18355. * Get a trigger name by index
  18356. * @param trigger defines the trigger index
  18357. * @returns a trigger name
  18358. */
  18359. static GetTriggerName(trigger: number): string;
  18360. }
  18361. }
  18362. declare module "babylonjs/Sprites/sprite" {
  18363. import { Vector3 } from "babylonjs/Maths/math.vector";
  18364. import { Nullable } from "babylonjs/types";
  18365. import { ActionManager } from "babylonjs/Actions/actionManager";
  18366. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18367. import { Color4 } from "babylonjs/Maths/math.color";
  18368. /**
  18369. * Class used to represent a sprite
  18370. * @see http://doc.babylonjs.com/babylon101/sprites
  18371. */
  18372. export class Sprite {
  18373. /** defines the name */
  18374. name: string;
  18375. /** Gets or sets the current world position */
  18376. position: Vector3;
  18377. /** Gets or sets the main color */
  18378. color: Color4;
  18379. /** Gets or sets the width */
  18380. width: number;
  18381. /** Gets or sets the height */
  18382. height: number;
  18383. /** Gets or sets rotation angle */
  18384. angle: number;
  18385. /** Gets or sets the cell index in the sprite sheet */
  18386. cellIndex: number;
  18387. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18388. cellRef: string;
  18389. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18390. invertU: number;
  18391. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18392. invertV: number;
  18393. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18394. disposeWhenFinishedAnimating: boolean;
  18395. /** Gets the list of attached animations */
  18396. animations: Animation[];
  18397. /** Gets or sets a boolean indicating if the sprite can be picked */
  18398. isPickable: boolean;
  18399. /**
  18400. * Gets or sets the associated action manager
  18401. */
  18402. actionManager: Nullable<ActionManager>;
  18403. private _animationStarted;
  18404. private _loopAnimation;
  18405. private _fromIndex;
  18406. private _toIndex;
  18407. private _delay;
  18408. private _direction;
  18409. private _manager;
  18410. private _time;
  18411. private _onAnimationEnd;
  18412. /**
  18413. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18414. */
  18415. isVisible: boolean;
  18416. /**
  18417. * Gets or sets the sprite size
  18418. */
  18419. get size(): number;
  18420. set size(value: number);
  18421. /**
  18422. * Creates a new Sprite
  18423. * @param name defines the name
  18424. * @param manager defines the manager
  18425. */
  18426. constructor(
  18427. /** defines the name */
  18428. name: string, manager: ISpriteManager);
  18429. /**
  18430. * Starts an animation
  18431. * @param from defines the initial key
  18432. * @param to defines the end key
  18433. * @param loop defines if the animation must loop
  18434. * @param delay defines the start delay (in ms)
  18435. * @param onAnimationEnd defines a callback to call when animation ends
  18436. */
  18437. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18438. /** Stops current animation (if any) */
  18439. stopAnimation(): void;
  18440. /** @hidden */
  18441. _animate(deltaTime: number): void;
  18442. /** Release associated resources */
  18443. dispose(): void;
  18444. }
  18445. }
  18446. declare module "babylonjs/Collisions/pickingInfo" {
  18447. import { Nullable } from "babylonjs/types";
  18448. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18450. import { Sprite } from "babylonjs/Sprites/sprite";
  18451. import { Ray } from "babylonjs/Culling/ray";
  18452. /**
  18453. * Information about the result of picking within a scene
  18454. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18455. */
  18456. export class PickingInfo {
  18457. /** @hidden */
  18458. _pickingUnavailable: boolean;
  18459. /**
  18460. * If the pick collided with an object
  18461. */
  18462. hit: boolean;
  18463. /**
  18464. * Distance away where the pick collided
  18465. */
  18466. distance: number;
  18467. /**
  18468. * The location of pick collision
  18469. */
  18470. pickedPoint: Nullable<Vector3>;
  18471. /**
  18472. * The mesh corresponding the the pick collision
  18473. */
  18474. pickedMesh: Nullable<AbstractMesh>;
  18475. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18476. bu: number;
  18477. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18478. bv: number;
  18479. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18480. faceId: number;
  18481. /** Id of the the submesh that was picked */
  18482. subMeshId: number;
  18483. /** If a sprite was picked, this will be the sprite the pick collided with */
  18484. pickedSprite: Nullable<Sprite>;
  18485. /**
  18486. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18487. */
  18488. originMesh: Nullable<AbstractMesh>;
  18489. /**
  18490. * The ray that was used to perform the picking.
  18491. */
  18492. ray: Nullable<Ray>;
  18493. /**
  18494. * Gets the normal correspodning to the face the pick collided with
  18495. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18496. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18497. * @returns The normal correspodning to the face the pick collided with
  18498. */
  18499. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18500. /**
  18501. * Gets the texture coordinates of where the pick occured
  18502. * @returns the vector containing the coordnates of the texture
  18503. */
  18504. getTextureCoordinates(): Nullable<Vector2>;
  18505. }
  18506. }
  18507. declare module "babylonjs/Events/pointerEvents" {
  18508. import { Nullable } from "babylonjs/types";
  18509. import { Vector2 } from "babylonjs/Maths/math.vector";
  18510. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18511. import { Ray } from "babylonjs/Culling/ray";
  18512. /**
  18513. * Gather the list of pointer event types as constants.
  18514. */
  18515. export class PointerEventTypes {
  18516. /**
  18517. * 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.
  18518. */
  18519. static readonly POINTERDOWN: number;
  18520. /**
  18521. * The pointerup event is fired when a pointer is no longer active.
  18522. */
  18523. static readonly POINTERUP: number;
  18524. /**
  18525. * The pointermove event is fired when a pointer changes coordinates.
  18526. */
  18527. static readonly POINTERMOVE: number;
  18528. /**
  18529. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18530. */
  18531. static readonly POINTERWHEEL: number;
  18532. /**
  18533. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18534. */
  18535. static readonly POINTERPICK: number;
  18536. /**
  18537. * The pointertap event is fired when a the object has been touched and released without drag.
  18538. */
  18539. static readonly POINTERTAP: number;
  18540. /**
  18541. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18542. */
  18543. static readonly POINTERDOUBLETAP: number;
  18544. }
  18545. /**
  18546. * Base class of pointer info types.
  18547. */
  18548. export class PointerInfoBase {
  18549. /**
  18550. * Defines the type of event (PointerEventTypes)
  18551. */
  18552. type: number;
  18553. /**
  18554. * Defines the related dom event
  18555. */
  18556. event: PointerEvent | MouseWheelEvent;
  18557. /**
  18558. * Instantiates the base class of pointers info.
  18559. * @param type Defines the type of event (PointerEventTypes)
  18560. * @param event Defines the related dom event
  18561. */
  18562. constructor(
  18563. /**
  18564. * Defines the type of event (PointerEventTypes)
  18565. */
  18566. type: number,
  18567. /**
  18568. * Defines the related dom event
  18569. */
  18570. event: PointerEvent | MouseWheelEvent);
  18571. }
  18572. /**
  18573. * This class is used to store pointer related info for the onPrePointerObservable event.
  18574. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18575. */
  18576. export class PointerInfoPre extends PointerInfoBase {
  18577. /**
  18578. * Ray from a pointer if availible (eg. 6dof controller)
  18579. */
  18580. ray: Nullable<Ray>;
  18581. /**
  18582. * Defines the local position of the pointer on the canvas.
  18583. */
  18584. localPosition: Vector2;
  18585. /**
  18586. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18587. */
  18588. skipOnPointerObservable: boolean;
  18589. /**
  18590. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18591. * @param type Defines the type of event (PointerEventTypes)
  18592. * @param event Defines the related dom event
  18593. * @param localX Defines the local x coordinates of the pointer when the event occured
  18594. * @param localY Defines the local y coordinates of the pointer when the event occured
  18595. */
  18596. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18597. }
  18598. /**
  18599. * This type contains all the data related to a pointer event in Babylon.js.
  18600. * 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.
  18601. */
  18602. export class PointerInfo extends PointerInfoBase {
  18603. /**
  18604. * Defines the picking info associated to the info (if any)\
  18605. */
  18606. pickInfo: Nullable<PickingInfo>;
  18607. /**
  18608. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18609. * @param type Defines the type of event (PointerEventTypes)
  18610. * @param event Defines the related dom event
  18611. * @param pickInfo Defines the picking info associated to the info (if any)\
  18612. */
  18613. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18614. /**
  18615. * Defines the picking info associated to the info (if any)\
  18616. */
  18617. pickInfo: Nullable<PickingInfo>);
  18618. }
  18619. /**
  18620. * Data relating to a touch event on the screen.
  18621. */
  18622. export interface PointerTouch {
  18623. /**
  18624. * X coordinate of touch.
  18625. */
  18626. x: number;
  18627. /**
  18628. * Y coordinate of touch.
  18629. */
  18630. y: number;
  18631. /**
  18632. * Id of touch. Unique for each finger.
  18633. */
  18634. pointerId: number;
  18635. /**
  18636. * Event type passed from DOM.
  18637. */
  18638. type: any;
  18639. }
  18640. }
  18641. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18642. import { Observable } from "babylonjs/Misc/observable";
  18643. import { Nullable } from "babylonjs/types";
  18644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18645. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18646. /**
  18647. * Manage the mouse inputs to control the movement of a free camera.
  18648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18649. */
  18650. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18651. /**
  18652. * Define if touch is enabled in the mouse input
  18653. */
  18654. touchEnabled: boolean;
  18655. /**
  18656. * Defines the camera the input is attached to.
  18657. */
  18658. camera: FreeCamera;
  18659. /**
  18660. * Defines the buttons associated with the input to handle camera move.
  18661. */
  18662. buttons: number[];
  18663. /**
  18664. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18665. */
  18666. angularSensibility: number;
  18667. private _pointerInput;
  18668. private _onMouseMove;
  18669. private _observer;
  18670. private previousPosition;
  18671. /**
  18672. * Observable for when a pointer move event occurs containing the move offset
  18673. */
  18674. onPointerMovedObservable: Observable<{
  18675. offsetX: number;
  18676. offsetY: number;
  18677. }>;
  18678. /**
  18679. * @hidden
  18680. * If the camera should be rotated automatically based on pointer movement
  18681. */
  18682. _allowCameraRotation: boolean;
  18683. /**
  18684. * Manage the mouse inputs to control the movement of a free camera.
  18685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18686. * @param touchEnabled Defines if touch is enabled or not
  18687. */
  18688. constructor(
  18689. /**
  18690. * Define if touch is enabled in the mouse input
  18691. */
  18692. touchEnabled?: boolean);
  18693. /**
  18694. * Attach the input controls to a specific dom element to get the input from.
  18695. * @param element Defines the element the controls should be listened from
  18696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18697. */
  18698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18699. /**
  18700. * Called on JS contextmenu event.
  18701. * Override this method to provide functionality.
  18702. */
  18703. protected onContextMenu(evt: PointerEvent): void;
  18704. /**
  18705. * Detach the current controls from the specified dom element.
  18706. * @param element Defines the element to stop listening the inputs from
  18707. */
  18708. detachControl(element: Nullable<HTMLElement>): void;
  18709. /**
  18710. * Gets the class name of the current intput.
  18711. * @returns the class name
  18712. */
  18713. getClassName(): string;
  18714. /**
  18715. * Get the friendly name associated with the input class.
  18716. * @returns the input friendly name
  18717. */
  18718. getSimpleName(): string;
  18719. }
  18720. }
  18721. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18722. import { Nullable } from "babylonjs/types";
  18723. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18725. /**
  18726. * Manage the touch inputs to control the movement of a free camera.
  18727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18728. */
  18729. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18730. /**
  18731. * Defines the camera the input is attached to.
  18732. */
  18733. camera: FreeCamera;
  18734. /**
  18735. * Defines the touch sensibility for rotation.
  18736. * The higher the faster.
  18737. */
  18738. touchAngularSensibility: number;
  18739. /**
  18740. * Defines the touch sensibility for move.
  18741. * The higher the faster.
  18742. */
  18743. touchMoveSensibility: number;
  18744. private _offsetX;
  18745. private _offsetY;
  18746. private _pointerPressed;
  18747. private _pointerInput;
  18748. private _observer;
  18749. private _onLostFocus;
  18750. /**
  18751. * Attach the input controls to a specific dom element to get the input from.
  18752. * @param element Defines the element the controls should be listened from
  18753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18754. */
  18755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18756. /**
  18757. * Detach the current controls from the specified dom element.
  18758. * @param element Defines the element to stop listening the inputs from
  18759. */
  18760. detachControl(element: Nullable<HTMLElement>): void;
  18761. /**
  18762. * Update the current camera state depending on the inputs that have been used this frame.
  18763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18764. */
  18765. checkInputs(): void;
  18766. /**
  18767. * Gets the class name of the current intput.
  18768. * @returns the class name
  18769. */
  18770. getClassName(): string;
  18771. /**
  18772. * Get the friendly name associated with the input class.
  18773. * @returns the input friendly name
  18774. */
  18775. getSimpleName(): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18779. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18780. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18781. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18782. import { Nullable } from "babylonjs/types";
  18783. /**
  18784. * Default Inputs manager for the FreeCamera.
  18785. * It groups all the default supported inputs for ease of use.
  18786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18787. */
  18788. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18789. /**
  18790. * @hidden
  18791. */
  18792. _mouseInput: Nullable<FreeCameraMouseInput>;
  18793. /**
  18794. * Instantiates a new FreeCameraInputsManager.
  18795. * @param camera Defines the camera the inputs belong to
  18796. */
  18797. constructor(camera: FreeCamera);
  18798. /**
  18799. * Add keyboard input support to the input manager.
  18800. * @returns the current input manager
  18801. */
  18802. addKeyboard(): FreeCameraInputsManager;
  18803. /**
  18804. * Add mouse input support to the input manager.
  18805. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18806. * @returns the current input manager
  18807. */
  18808. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18809. /**
  18810. * Removes the mouse input support from the manager
  18811. * @returns the current input manager
  18812. */
  18813. removeMouse(): FreeCameraInputsManager;
  18814. /**
  18815. * Add touch input support to the input manager.
  18816. * @returns the current input manager
  18817. */
  18818. addTouch(): FreeCameraInputsManager;
  18819. /**
  18820. * Remove all attached input methods from a camera
  18821. */
  18822. clear(): void;
  18823. }
  18824. }
  18825. declare module "babylonjs/Cameras/freeCamera" {
  18826. import { Vector3 } from "babylonjs/Maths/math.vector";
  18827. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18828. import { Scene } from "babylonjs/scene";
  18829. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18830. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18831. /**
  18832. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18833. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18835. */
  18836. export class FreeCamera extends TargetCamera {
  18837. /**
  18838. * Define the collision ellipsoid of the camera.
  18839. * This is helpful to simulate a camera body like the player body around the camera
  18840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18841. */
  18842. ellipsoid: Vector3;
  18843. /**
  18844. * Define an offset for the position of the ellipsoid around the camera.
  18845. * This can be helpful to determine the center of the body near the gravity center of the body
  18846. * instead of its head.
  18847. */
  18848. ellipsoidOffset: Vector3;
  18849. /**
  18850. * Enable or disable collisions of the camera with the rest of the scene objects.
  18851. */
  18852. checkCollisions: boolean;
  18853. /**
  18854. * Enable or disable gravity on the camera.
  18855. */
  18856. applyGravity: boolean;
  18857. /**
  18858. * Define the input manager associated to the camera.
  18859. */
  18860. inputs: FreeCameraInputsManager;
  18861. /**
  18862. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18863. * Higher values reduce sensitivity.
  18864. */
  18865. get angularSensibility(): number;
  18866. /**
  18867. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18868. * Higher values reduce sensitivity.
  18869. */
  18870. set angularSensibility(value: number);
  18871. /**
  18872. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18873. */
  18874. get keysUp(): number[];
  18875. set keysUp(value: number[]);
  18876. /**
  18877. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18878. */
  18879. get keysDown(): number[];
  18880. set keysDown(value: number[]);
  18881. /**
  18882. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18883. */
  18884. get keysLeft(): number[];
  18885. set keysLeft(value: number[]);
  18886. /**
  18887. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18888. */
  18889. get keysRight(): number[];
  18890. set keysRight(value: number[]);
  18891. /**
  18892. * Event raised when the camera collide with a mesh in the scene.
  18893. */
  18894. onCollide: (collidedMesh: AbstractMesh) => void;
  18895. private _collider;
  18896. private _needMoveForGravity;
  18897. private _oldPosition;
  18898. private _diffPosition;
  18899. private _newPosition;
  18900. /** @hidden */
  18901. _localDirection: Vector3;
  18902. /** @hidden */
  18903. _transformedDirection: Vector3;
  18904. /**
  18905. * Instantiates a Free Camera.
  18906. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18907. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18908. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18909. * @param name Define the name of the camera in the scene
  18910. * @param position Define the start position of the camera in the scene
  18911. * @param scene Define the scene the camera belongs to
  18912. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18913. */
  18914. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18915. /**
  18916. * Attached controls to the current camera.
  18917. * @param element Defines the element the controls should be listened from
  18918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18919. */
  18920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18921. /**
  18922. * Detach the current controls from the camera.
  18923. * The camera will stop reacting to inputs.
  18924. * @param element Defines the element to stop listening the inputs from
  18925. */
  18926. detachControl(element: HTMLElement): void;
  18927. private _collisionMask;
  18928. /**
  18929. * Define a collision mask to limit the list of object the camera can collide with
  18930. */
  18931. get collisionMask(): number;
  18932. set collisionMask(mask: number);
  18933. /** @hidden */
  18934. _collideWithWorld(displacement: Vector3): void;
  18935. private _onCollisionPositionChange;
  18936. /** @hidden */
  18937. _checkInputs(): void;
  18938. /** @hidden */
  18939. _decideIfNeedsToMove(): boolean;
  18940. /** @hidden */
  18941. _updatePosition(): void;
  18942. /**
  18943. * Destroy the camera and release the current resources hold by it.
  18944. */
  18945. dispose(): void;
  18946. /**
  18947. * Gets the current object class name.
  18948. * @return the class name
  18949. */
  18950. getClassName(): string;
  18951. }
  18952. }
  18953. declare module "babylonjs/Gamepads/gamepad" {
  18954. import { Observable } from "babylonjs/Misc/observable";
  18955. /**
  18956. * Represents a gamepad control stick position
  18957. */
  18958. export class StickValues {
  18959. /**
  18960. * The x component of the control stick
  18961. */
  18962. x: number;
  18963. /**
  18964. * The y component of the control stick
  18965. */
  18966. y: number;
  18967. /**
  18968. * Initializes the gamepad x and y control stick values
  18969. * @param x The x component of the gamepad control stick value
  18970. * @param y The y component of the gamepad control stick value
  18971. */
  18972. constructor(
  18973. /**
  18974. * The x component of the control stick
  18975. */
  18976. x: number,
  18977. /**
  18978. * The y component of the control stick
  18979. */
  18980. y: number);
  18981. }
  18982. /**
  18983. * An interface which manages callbacks for gamepad button changes
  18984. */
  18985. export interface GamepadButtonChanges {
  18986. /**
  18987. * Called when a gamepad has been changed
  18988. */
  18989. changed: boolean;
  18990. /**
  18991. * Called when a gamepad press event has been triggered
  18992. */
  18993. pressChanged: boolean;
  18994. /**
  18995. * Called when a touch event has been triggered
  18996. */
  18997. touchChanged: boolean;
  18998. /**
  18999. * Called when a value has changed
  19000. */
  19001. valueChanged: boolean;
  19002. }
  19003. /**
  19004. * Represents a gamepad
  19005. */
  19006. export class Gamepad {
  19007. /**
  19008. * The id of the gamepad
  19009. */
  19010. id: string;
  19011. /**
  19012. * The index of the gamepad
  19013. */
  19014. index: number;
  19015. /**
  19016. * The browser gamepad
  19017. */
  19018. browserGamepad: any;
  19019. /**
  19020. * Specifies what type of gamepad this represents
  19021. */
  19022. type: number;
  19023. private _leftStick;
  19024. private _rightStick;
  19025. /** @hidden */
  19026. _isConnected: boolean;
  19027. private _leftStickAxisX;
  19028. private _leftStickAxisY;
  19029. private _rightStickAxisX;
  19030. private _rightStickAxisY;
  19031. /**
  19032. * Triggered when the left control stick has been changed
  19033. */
  19034. private _onleftstickchanged;
  19035. /**
  19036. * Triggered when the right control stick has been changed
  19037. */
  19038. private _onrightstickchanged;
  19039. /**
  19040. * Represents a gamepad controller
  19041. */
  19042. static GAMEPAD: number;
  19043. /**
  19044. * Represents a generic controller
  19045. */
  19046. static GENERIC: number;
  19047. /**
  19048. * Represents an XBox controller
  19049. */
  19050. static XBOX: number;
  19051. /**
  19052. * Represents a pose-enabled controller
  19053. */
  19054. static POSE_ENABLED: number;
  19055. /**
  19056. * Represents an Dual Shock controller
  19057. */
  19058. static DUALSHOCK: number;
  19059. /**
  19060. * Specifies whether the left control stick should be Y-inverted
  19061. */
  19062. protected _invertLeftStickY: boolean;
  19063. /**
  19064. * Specifies if the gamepad has been connected
  19065. */
  19066. get isConnected(): boolean;
  19067. /**
  19068. * Initializes the gamepad
  19069. * @param id The id of the gamepad
  19070. * @param index The index of the gamepad
  19071. * @param browserGamepad The browser gamepad
  19072. * @param leftStickX The x component of the left joystick
  19073. * @param leftStickY The y component of the left joystick
  19074. * @param rightStickX The x component of the right joystick
  19075. * @param rightStickY The y component of the right joystick
  19076. */
  19077. constructor(
  19078. /**
  19079. * The id of the gamepad
  19080. */
  19081. id: string,
  19082. /**
  19083. * The index of the gamepad
  19084. */
  19085. index: number,
  19086. /**
  19087. * The browser gamepad
  19088. */
  19089. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19090. /**
  19091. * Callback triggered when the left joystick has changed
  19092. * @param callback
  19093. */
  19094. onleftstickchanged(callback: (values: StickValues) => void): void;
  19095. /**
  19096. * Callback triggered when the right joystick has changed
  19097. * @param callback
  19098. */
  19099. onrightstickchanged(callback: (values: StickValues) => void): void;
  19100. /**
  19101. * Gets the left joystick
  19102. */
  19103. get leftStick(): StickValues;
  19104. /**
  19105. * Sets the left joystick values
  19106. */
  19107. set leftStick(newValues: StickValues);
  19108. /**
  19109. * Gets the right joystick
  19110. */
  19111. get rightStick(): StickValues;
  19112. /**
  19113. * Sets the right joystick value
  19114. */
  19115. set rightStick(newValues: StickValues);
  19116. /**
  19117. * Updates the gamepad joystick positions
  19118. */
  19119. update(): void;
  19120. /**
  19121. * Disposes the gamepad
  19122. */
  19123. dispose(): void;
  19124. }
  19125. /**
  19126. * Represents a generic gamepad
  19127. */
  19128. export class GenericPad extends Gamepad {
  19129. private _buttons;
  19130. private _onbuttondown;
  19131. private _onbuttonup;
  19132. /**
  19133. * Observable triggered when a button has been pressed
  19134. */
  19135. onButtonDownObservable: Observable<number>;
  19136. /**
  19137. * Observable triggered when a button has been released
  19138. */
  19139. onButtonUpObservable: Observable<number>;
  19140. /**
  19141. * Callback triggered when a button has been pressed
  19142. * @param callback Called when a button has been pressed
  19143. */
  19144. onbuttondown(callback: (buttonPressed: number) => void): void;
  19145. /**
  19146. * Callback triggered when a button has been released
  19147. * @param callback Called when a button has been released
  19148. */
  19149. onbuttonup(callback: (buttonReleased: number) => void): void;
  19150. /**
  19151. * Initializes the generic gamepad
  19152. * @param id The id of the generic gamepad
  19153. * @param index The index of the generic gamepad
  19154. * @param browserGamepad The browser gamepad
  19155. */
  19156. constructor(id: string, index: number, browserGamepad: any);
  19157. private _setButtonValue;
  19158. /**
  19159. * Updates the generic gamepad
  19160. */
  19161. update(): void;
  19162. /**
  19163. * Disposes the generic gamepad
  19164. */
  19165. dispose(): void;
  19166. }
  19167. }
  19168. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19169. import { Observable } from "babylonjs/Misc/observable";
  19170. import { Nullable } from "babylonjs/types";
  19171. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19174. import { Ray } from "babylonjs/Culling/ray";
  19175. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19176. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19177. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19178. /**
  19179. * Defines the types of pose enabled controllers that are supported
  19180. */
  19181. export enum PoseEnabledControllerType {
  19182. /**
  19183. * HTC Vive
  19184. */
  19185. VIVE = 0,
  19186. /**
  19187. * Oculus Rift
  19188. */
  19189. OCULUS = 1,
  19190. /**
  19191. * Windows mixed reality
  19192. */
  19193. WINDOWS = 2,
  19194. /**
  19195. * Samsung gear VR
  19196. */
  19197. GEAR_VR = 3,
  19198. /**
  19199. * Google Daydream
  19200. */
  19201. DAYDREAM = 4,
  19202. /**
  19203. * Generic
  19204. */
  19205. GENERIC = 5
  19206. }
  19207. /**
  19208. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19209. */
  19210. export interface MutableGamepadButton {
  19211. /**
  19212. * Value of the button/trigger
  19213. */
  19214. value: number;
  19215. /**
  19216. * If the button/trigger is currently touched
  19217. */
  19218. touched: boolean;
  19219. /**
  19220. * If the button/trigger is currently pressed
  19221. */
  19222. pressed: boolean;
  19223. }
  19224. /**
  19225. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19226. * @hidden
  19227. */
  19228. export interface ExtendedGamepadButton extends GamepadButton {
  19229. /**
  19230. * If the button/trigger is currently pressed
  19231. */
  19232. readonly pressed: boolean;
  19233. /**
  19234. * If the button/trigger is currently touched
  19235. */
  19236. readonly touched: boolean;
  19237. /**
  19238. * Value of the button/trigger
  19239. */
  19240. readonly value: number;
  19241. }
  19242. /** @hidden */
  19243. export interface _GamePadFactory {
  19244. /**
  19245. * Returns whether or not the current gamepad can be created for this type of controller.
  19246. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19247. * @returns true if it can be created, otherwise false
  19248. */
  19249. canCreate(gamepadInfo: any): boolean;
  19250. /**
  19251. * Creates a new instance of the Gamepad.
  19252. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19253. * @returns the new gamepad instance
  19254. */
  19255. create(gamepadInfo: any): Gamepad;
  19256. }
  19257. /**
  19258. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19259. */
  19260. export class PoseEnabledControllerHelper {
  19261. /** @hidden */
  19262. static _ControllerFactories: _GamePadFactory[];
  19263. /** @hidden */
  19264. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19265. /**
  19266. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19267. * @param vrGamepad the gamepad to initialized
  19268. * @returns a vr controller of the type the gamepad identified as
  19269. */
  19270. static InitiateController(vrGamepad: any): Gamepad;
  19271. }
  19272. /**
  19273. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19274. */
  19275. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19276. /**
  19277. * If the controller is used in a webXR session
  19278. */
  19279. isXR: boolean;
  19280. private _deviceRoomPosition;
  19281. private _deviceRoomRotationQuaternion;
  19282. /**
  19283. * The device position in babylon space
  19284. */
  19285. devicePosition: Vector3;
  19286. /**
  19287. * The device rotation in babylon space
  19288. */
  19289. deviceRotationQuaternion: Quaternion;
  19290. /**
  19291. * The scale factor of the device in babylon space
  19292. */
  19293. deviceScaleFactor: number;
  19294. /**
  19295. * (Likely devicePosition should be used instead) The device position in its room space
  19296. */
  19297. position: Vector3;
  19298. /**
  19299. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19300. */
  19301. rotationQuaternion: Quaternion;
  19302. /**
  19303. * The type of controller (Eg. Windows mixed reality)
  19304. */
  19305. controllerType: PoseEnabledControllerType;
  19306. protected _calculatedPosition: Vector3;
  19307. private _calculatedRotation;
  19308. /**
  19309. * The raw pose from the device
  19310. */
  19311. rawPose: DevicePose;
  19312. private _trackPosition;
  19313. private _maxRotationDistFromHeadset;
  19314. private _draggedRoomRotation;
  19315. /**
  19316. * @hidden
  19317. */
  19318. _disableTrackPosition(fixedPosition: Vector3): void;
  19319. /**
  19320. * Internal, the mesh attached to the controller
  19321. * @hidden
  19322. */
  19323. _mesh: Nullable<AbstractMesh>;
  19324. private _poseControlledCamera;
  19325. private _leftHandSystemQuaternion;
  19326. /**
  19327. * Internal, matrix used to convert room space to babylon space
  19328. * @hidden
  19329. */
  19330. _deviceToWorld: Matrix;
  19331. /**
  19332. * Node to be used when casting a ray from the controller
  19333. * @hidden
  19334. */
  19335. _pointingPoseNode: Nullable<TransformNode>;
  19336. /**
  19337. * Name of the child mesh that can be used to cast a ray from the controller
  19338. */
  19339. static readonly POINTING_POSE: string;
  19340. /**
  19341. * Creates a new PoseEnabledController from a gamepad
  19342. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19343. */
  19344. constructor(browserGamepad: any);
  19345. private _workingMatrix;
  19346. /**
  19347. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19348. */
  19349. update(): void;
  19350. /**
  19351. * Updates only the pose device and mesh without doing any button event checking
  19352. */
  19353. protected _updatePoseAndMesh(): void;
  19354. /**
  19355. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19356. * @param poseData raw pose fromthe device
  19357. */
  19358. updateFromDevice(poseData: DevicePose): void;
  19359. /**
  19360. * @hidden
  19361. */
  19362. _meshAttachedObservable: Observable<AbstractMesh>;
  19363. /**
  19364. * Attaches a mesh to the controller
  19365. * @param mesh the mesh to be attached
  19366. */
  19367. attachToMesh(mesh: AbstractMesh): void;
  19368. /**
  19369. * Attaches the controllers mesh to a camera
  19370. * @param camera the camera the mesh should be attached to
  19371. */
  19372. attachToPoseControlledCamera(camera: TargetCamera): void;
  19373. /**
  19374. * Disposes of the controller
  19375. */
  19376. dispose(): void;
  19377. /**
  19378. * The mesh that is attached to the controller
  19379. */
  19380. get mesh(): Nullable<AbstractMesh>;
  19381. /**
  19382. * Gets the ray of the controller in the direction the controller is pointing
  19383. * @param length the length the resulting ray should be
  19384. * @returns a ray in the direction the controller is pointing
  19385. */
  19386. getForwardRay(length?: number): Ray;
  19387. }
  19388. }
  19389. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19390. import { Observable } from "babylonjs/Misc/observable";
  19391. import { Scene } from "babylonjs/scene";
  19392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19393. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19394. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19395. import { Nullable } from "babylonjs/types";
  19396. /**
  19397. * Defines the WebVRController object that represents controllers tracked in 3D space
  19398. */
  19399. export abstract class WebVRController extends PoseEnabledController {
  19400. /**
  19401. * Internal, the default controller model for the controller
  19402. */
  19403. protected _defaultModel: Nullable<AbstractMesh>;
  19404. /**
  19405. * Fired when the trigger state has changed
  19406. */
  19407. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19408. /**
  19409. * Fired when the main button state has changed
  19410. */
  19411. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19412. /**
  19413. * Fired when the secondary button state has changed
  19414. */
  19415. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19416. /**
  19417. * Fired when the pad state has changed
  19418. */
  19419. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19420. /**
  19421. * Fired when controllers stick values have changed
  19422. */
  19423. onPadValuesChangedObservable: Observable<StickValues>;
  19424. /**
  19425. * Array of button availible on the controller
  19426. */
  19427. protected _buttons: Array<MutableGamepadButton>;
  19428. private _onButtonStateChange;
  19429. /**
  19430. * Fired when a controller button's state has changed
  19431. * @param callback the callback containing the button that was modified
  19432. */
  19433. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19434. /**
  19435. * X and Y axis corresponding to the controllers joystick
  19436. */
  19437. pad: StickValues;
  19438. /**
  19439. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19440. */
  19441. hand: string;
  19442. /**
  19443. * The default controller model for the controller
  19444. */
  19445. get defaultModel(): Nullable<AbstractMesh>;
  19446. /**
  19447. * Creates a new WebVRController from a gamepad
  19448. * @param vrGamepad the gamepad that the WebVRController should be created from
  19449. */
  19450. constructor(vrGamepad: any);
  19451. /**
  19452. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19453. */
  19454. update(): void;
  19455. /**
  19456. * Function to be called when a button is modified
  19457. */
  19458. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19459. /**
  19460. * Loads a mesh and attaches it to the controller
  19461. * @param scene the scene the mesh should be added to
  19462. * @param meshLoaded callback for when the mesh has been loaded
  19463. */
  19464. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19465. private _setButtonValue;
  19466. private _changes;
  19467. private _checkChanges;
  19468. /**
  19469. * Disposes of th webVRCOntroller
  19470. */
  19471. dispose(): void;
  19472. }
  19473. }
  19474. declare module "babylonjs/Lights/hemisphericLight" {
  19475. import { Nullable } from "babylonjs/types";
  19476. import { Scene } from "babylonjs/scene";
  19477. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19478. import { Color3 } from "babylonjs/Maths/math.color";
  19479. import { Effect } from "babylonjs/Materials/effect";
  19480. import { Light } from "babylonjs/Lights/light";
  19481. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19482. /**
  19483. * The HemisphericLight simulates the ambient environment light,
  19484. * so the passed direction is the light reflection direction, not the incoming direction.
  19485. */
  19486. export class HemisphericLight extends Light {
  19487. /**
  19488. * The groundColor is the light in the opposite direction to the one specified during creation.
  19489. * 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.
  19490. */
  19491. groundColor: Color3;
  19492. /**
  19493. * The light reflection direction, not the incoming direction.
  19494. */
  19495. direction: Vector3;
  19496. /**
  19497. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19498. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19499. * The HemisphericLight can't cast shadows.
  19500. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19501. * @param name The friendly name of the light
  19502. * @param direction The direction of the light reflection
  19503. * @param scene The scene the light belongs to
  19504. */
  19505. constructor(name: string, direction: Vector3, scene: Scene);
  19506. protected _buildUniformLayout(): void;
  19507. /**
  19508. * Returns the string "HemisphericLight".
  19509. * @return The class name
  19510. */
  19511. getClassName(): string;
  19512. /**
  19513. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19514. * Returns the updated direction.
  19515. * @param target The target the direction should point to
  19516. * @return The computed direction
  19517. */
  19518. setDirectionToTarget(target: Vector3): Vector3;
  19519. /**
  19520. * Returns the shadow generator associated to the light.
  19521. * @returns Always null for hemispheric lights because it does not support shadows.
  19522. */
  19523. getShadowGenerator(): Nullable<IShadowGenerator>;
  19524. /**
  19525. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19526. * @param effect The effect to update
  19527. * @param lightIndex The index of the light in the effect to update
  19528. * @returns The hemispheric light
  19529. */
  19530. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19531. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19532. /**
  19533. * Computes the world matrix of the node
  19534. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19535. * @param useWasUpdatedFlag defines a reserved property
  19536. * @returns the world matrix
  19537. */
  19538. computeWorldMatrix(): Matrix;
  19539. /**
  19540. * Returns the integer 3.
  19541. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19542. */
  19543. getTypeID(): number;
  19544. /**
  19545. * Prepares the list of defines specific to the light type.
  19546. * @param defines the list of defines
  19547. * @param lightIndex defines the index of the light for the effect
  19548. */
  19549. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19550. }
  19551. }
  19552. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19553. /** @hidden */
  19554. export var vrMultiviewToSingleviewPixelShader: {
  19555. name: string;
  19556. shader: string;
  19557. };
  19558. }
  19559. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19560. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19561. import { Scene } from "babylonjs/scene";
  19562. /**
  19563. * Renders to multiple views with a single draw call
  19564. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19565. */
  19566. export class MultiviewRenderTarget extends RenderTargetTexture {
  19567. /**
  19568. * Creates a multiview render target
  19569. * @param scene scene used with the render target
  19570. * @param size the size of the render target (used for each view)
  19571. */
  19572. constructor(scene: Scene, size?: number | {
  19573. width: number;
  19574. height: number;
  19575. } | {
  19576. ratio: number;
  19577. });
  19578. /**
  19579. * @hidden
  19580. * @param faceIndex the face index, if its a cube texture
  19581. */
  19582. _bindFrameBuffer(faceIndex?: number): void;
  19583. /**
  19584. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19585. * @returns the view count
  19586. */
  19587. getViewCount(): number;
  19588. }
  19589. }
  19590. declare module "babylonjs/Maths/math.frustum" {
  19591. import { Matrix } from "babylonjs/Maths/math.vector";
  19592. import { DeepImmutable } from "babylonjs/types";
  19593. import { Plane } from "babylonjs/Maths/math.plane";
  19594. /**
  19595. * Represents a camera frustum
  19596. */
  19597. export class Frustum {
  19598. /**
  19599. * Gets the planes representing the frustum
  19600. * @param transform matrix to be applied to the returned planes
  19601. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19602. */
  19603. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19604. /**
  19605. * Gets the near frustum plane transformed by the transform matrix
  19606. * @param transform transformation matrix to be applied to the resulting frustum plane
  19607. * @param frustumPlane the resuling frustum plane
  19608. */
  19609. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19610. /**
  19611. * Gets the far frustum plane transformed by the transform matrix
  19612. * @param transform transformation matrix to be applied to the resulting frustum plane
  19613. * @param frustumPlane the resuling frustum plane
  19614. */
  19615. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19616. /**
  19617. * Gets the left frustum plane transformed by the transform matrix
  19618. * @param transform transformation matrix to be applied to the resulting frustum plane
  19619. * @param frustumPlane the resuling frustum plane
  19620. */
  19621. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19622. /**
  19623. * Gets the right frustum plane transformed by the transform matrix
  19624. * @param transform transformation matrix to be applied to the resulting frustum plane
  19625. * @param frustumPlane the resuling frustum plane
  19626. */
  19627. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19628. /**
  19629. * Gets the top frustum plane transformed by the transform matrix
  19630. * @param transform transformation matrix to be applied to the resulting frustum plane
  19631. * @param frustumPlane the resuling frustum plane
  19632. */
  19633. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19634. /**
  19635. * Gets the bottom frustum plane transformed by the transform matrix
  19636. * @param transform transformation matrix to be applied to the resulting frustum plane
  19637. * @param frustumPlane the resuling frustum plane
  19638. */
  19639. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19640. /**
  19641. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19642. * @param transform transformation matrix to be applied to the resulting frustum planes
  19643. * @param frustumPlanes the resuling frustum planes
  19644. */
  19645. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19646. }
  19647. }
  19648. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19649. import { Camera } from "babylonjs/Cameras/camera";
  19650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19651. import { Nullable } from "babylonjs/types";
  19652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19653. import { Matrix } from "babylonjs/Maths/math.vector";
  19654. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19655. module "babylonjs/Engines/engine" {
  19656. interface Engine {
  19657. /**
  19658. * Creates a new multiview render target
  19659. * @param width defines the width of the texture
  19660. * @param height defines the height of the texture
  19661. * @returns the created multiview texture
  19662. */
  19663. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19664. /**
  19665. * Binds a multiview framebuffer to be drawn to
  19666. * @param multiviewTexture texture to bind
  19667. */
  19668. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19669. }
  19670. }
  19671. module "babylonjs/Cameras/camera" {
  19672. interface Camera {
  19673. /**
  19674. * @hidden
  19675. * 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)
  19676. */
  19677. _useMultiviewToSingleView: boolean;
  19678. /**
  19679. * @hidden
  19680. * 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)
  19681. */
  19682. _multiviewTexture: Nullable<RenderTargetTexture>;
  19683. /**
  19684. * @hidden
  19685. * ensures the multiview texture of the camera exists and has the specified width/height
  19686. * @param width height to set on the multiview texture
  19687. * @param height width to set on the multiview texture
  19688. */
  19689. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19690. }
  19691. }
  19692. module "babylonjs/scene" {
  19693. interface Scene {
  19694. /** @hidden */
  19695. _transformMatrixR: Matrix;
  19696. /** @hidden */
  19697. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19698. /** @hidden */
  19699. _createMultiviewUbo(): void;
  19700. /** @hidden */
  19701. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19702. /** @hidden */
  19703. _renderMultiviewToSingleView(camera: Camera): void;
  19704. }
  19705. }
  19706. }
  19707. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19708. import { Camera } from "babylonjs/Cameras/camera";
  19709. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19710. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19711. import "babylonjs/Engines/Extensions/engine.multiview";
  19712. /**
  19713. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19714. * This will not be used for webXR as it supports displaying texture arrays directly
  19715. */
  19716. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19717. /**
  19718. * Initializes a VRMultiviewToSingleview
  19719. * @param name name of the post process
  19720. * @param camera camera to be applied to
  19721. * @param scaleFactor scaling factor to the size of the output texture
  19722. */
  19723. constructor(name: string, camera: Camera, scaleFactor: number);
  19724. }
  19725. }
  19726. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19727. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19728. import { Nullable } from "babylonjs/types";
  19729. import { Size } from "babylonjs/Maths/math.size";
  19730. import { Observable } from "babylonjs/Misc/observable";
  19731. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19732. /**
  19733. * Interface used to define additional presentation attributes
  19734. */
  19735. export interface IVRPresentationAttributes {
  19736. /**
  19737. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19738. */
  19739. highRefreshRate: boolean;
  19740. /**
  19741. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19742. */
  19743. foveationLevel: number;
  19744. }
  19745. module "babylonjs/Engines/engine" {
  19746. interface Engine {
  19747. /** @hidden */
  19748. _vrDisplay: any;
  19749. /** @hidden */
  19750. _vrSupported: boolean;
  19751. /** @hidden */
  19752. _oldSize: Size;
  19753. /** @hidden */
  19754. _oldHardwareScaleFactor: number;
  19755. /** @hidden */
  19756. _vrExclusivePointerMode: boolean;
  19757. /** @hidden */
  19758. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19759. /** @hidden */
  19760. _onVRDisplayPointerRestricted: () => void;
  19761. /** @hidden */
  19762. _onVRDisplayPointerUnrestricted: () => void;
  19763. /** @hidden */
  19764. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19765. /** @hidden */
  19766. _onVrDisplayDisconnect: Nullable<() => void>;
  19767. /** @hidden */
  19768. _onVrDisplayPresentChange: Nullable<() => void>;
  19769. /**
  19770. * Observable signaled when VR display mode changes
  19771. */
  19772. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19773. /**
  19774. * Observable signaled when VR request present is complete
  19775. */
  19776. onVRRequestPresentComplete: Observable<boolean>;
  19777. /**
  19778. * Observable signaled when VR request present starts
  19779. */
  19780. onVRRequestPresentStart: Observable<Engine>;
  19781. /**
  19782. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19783. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19784. */
  19785. isInVRExclusivePointerMode: boolean;
  19786. /**
  19787. * Gets a boolean indicating if a webVR device was detected
  19788. * @returns true if a webVR device was detected
  19789. */
  19790. isVRDevicePresent(): boolean;
  19791. /**
  19792. * Gets the current webVR device
  19793. * @returns the current webVR device (or null)
  19794. */
  19795. getVRDevice(): any;
  19796. /**
  19797. * Initializes a webVR display and starts listening to display change events
  19798. * The onVRDisplayChangedObservable will be notified upon these changes
  19799. * @returns A promise containing a VRDisplay and if vr is supported
  19800. */
  19801. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19802. /** @hidden */
  19803. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19804. /**
  19805. * Gets or sets the presentation attributes used to configure VR rendering
  19806. */
  19807. vrPresentationAttributes?: IVRPresentationAttributes;
  19808. /**
  19809. * Call this function to switch to webVR mode
  19810. * Will do nothing if webVR is not supported or if there is no webVR device
  19811. * @param options the webvr options provided to the camera. mainly used for multiview
  19812. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19813. */
  19814. enableVR(options: WebVROptions): void;
  19815. /** @hidden */
  19816. _onVRFullScreenTriggered(): void;
  19817. }
  19818. }
  19819. }
  19820. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19821. import { Nullable } from "babylonjs/types";
  19822. import { Observable } from "babylonjs/Misc/observable";
  19823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19824. import { Scene } from "babylonjs/scene";
  19825. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19826. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19827. import { Node } from "babylonjs/node";
  19828. import { Ray } from "babylonjs/Culling/ray";
  19829. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19830. import "babylonjs/Engines/Extensions/engine.webVR";
  19831. /**
  19832. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19833. * IMPORTANT!! The data is right-hand data.
  19834. * @export
  19835. * @interface DevicePose
  19836. */
  19837. export interface DevicePose {
  19838. /**
  19839. * The position of the device, values in array are [x,y,z].
  19840. */
  19841. readonly position: Nullable<Float32Array>;
  19842. /**
  19843. * The linearVelocity of the device, values in array are [x,y,z].
  19844. */
  19845. readonly linearVelocity: Nullable<Float32Array>;
  19846. /**
  19847. * The linearAcceleration of the device, values in array are [x,y,z].
  19848. */
  19849. readonly linearAcceleration: Nullable<Float32Array>;
  19850. /**
  19851. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19852. */
  19853. readonly orientation: Nullable<Float32Array>;
  19854. /**
  19855. * The angularVelocity of the device, values in array are [x,y,z].
  19856. */
  19857. readonly angularVelocity: Nullable<Float32Array>;
  19858. /**
  19859. * The angularAcceleration of the device, values in array are [x,y,z].
  19860. */
  19861. readonly angularAcceleration: Nullable<Float32Array>;
  19862. }
  19863. /**
  19864. * Interface representing a pose controlled object in Babylon.
  19865. * A pose controlled object has both regular pose values as well as pose values
  19866. * from an external device such as a VR head mounted display
  19867. */
  19868. export interface PoseControlled {
  19869. /**
  19870. * The position of the object in babylon space.
  19871. */
  19872. position: Vector3;
  19873. /**
  19874. * The rotation quaternion of the object in babylon space.
  19875. */
  19876. rotationQuaternion: Quaternion;
  19877. /**
  19878. * The position of the device in babylon space.
  19879. */
  19880. devicePosition?: Vector3;
  19881. /**
  19882. * The rotation quaternion of the device in babylon space.
  19883. */
  19884. deviceRotationQuaternion: Quaternion;
  19885. /**
  19886. * The raw pose coming from the device.
  19887. */
  19888. rawPose: Nullable<DevicePose>;
  19889. /**
  19890. * The scale of the device to be used when translating from device space to babylon space.
  19891. */
  19892. deviceScaleFactor: number;
  19893. /**
  19894. * Updates the poseControlled values based on the input device pose.
  19895. * @param poseData the pose data to update the object with
  19896. */
  19897. updateFromDevice(poseData: DevicePose): void;
  19898. }
  19899. /**
  19900. * Set of options to customize the webVRCamera
  19901. */
  19902. export interface WebVROptions {
  19903. /**
  19904. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19905. */
  19906. trackPosition?: boolean;
  19907. /**
  19908. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19909. */
  19910. positionScale?: number;
  19911. /**
  19912. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19913. */
  19914. displayName?: string;
  19915. /**
  19916. * Should the native controller meshes be initialized. (default: true)
  19917. */
  19918. controllerMeshes?: boolean;
  19919. /**
  19920. * Creating a default HemiLight only on controllers. (default: true)
  19921. */
  19922. defaultLightingOnControllers?: boolean;
  19923. /**
  19924. * If you don't want to use the default VR button of the helper. (default: false)
  19925. */
  19926. useCustomVRButton?: boolean;
  19927. /**
  19928. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19929. */
  19930. customVRButton?: HTMLButtonElement;
  19931. /**
  19932. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19933. */
  19934. rayLength?: number;
  19935. /**
  19936. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19937. */
  19938. defaultHeight?: number;
  19939. /**
  19940. * If multiview should be used if availible (default: false)
  19941. */
  19942. useMultiview?: boolean;
  19943. }
  19944. /**
  19945. * This represents a WebVR camera.
  19946. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19947. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19948. */
  19949. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19950. private webVROptions;
  19951. /**
  19952. * @hidden
  19953. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19954. */
  19955. _vrDevice: any;
  19956. /**
  19957. * The rawPose of the vrDevice.
  19958. */
  19959. rawPose: Nullable<DevicePose>;
  19960. private _onVREnabled;
  19961. private _specsVersion;
  19962. private _attached;
  19963. private _frameData;
  19964. protected _descendants: Array<Node>;
  19965. private _deviceRoomPosition;
  19966. /** @hidden */
  19967. _deviceRoomRotationQuaternion: Quaternion;
  19968. private _standingMatrix;
  19969. /**
  19970. * Represents device position in babylon space.
  19971. */
  19972. devicePosition: Vector3;
  19973. /**
  19974. * Represents device rotation in babylon space.
  19975. */
  19976. deviceRotationQuaternion: Quaternion;
  19977. /**
  19978. * The scale of the device to be used when translating from device space to babylon space.
  19979. */
  19980. deviceScaleFactor: number;
  19981. private _deviceToWorld;
  19982. private _worldToDevice;
  19983. /**
  19984. * References to the webVR controllers for the vrDevice.
  19985. */
  19986. controllers: Array<WebVRController>;
  19987. /**
  19988. * Emits an event when a controller is attached.
  19989. */
  19990. onControllersAttachedObservable: Observable<WebVRController[]>;
  19991. /**
  19992. * Emits an event when a controller's mesh has been loaded;
  19993. */
  19994. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19995. /**
  19996. * Emits an event when the HMD's pose has been updated.
  19997. */
  19998. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19999. private _poseSet;
  20000. /**
  20001. * If the rig cameras be used as parent instead of this camera.
  20002. */
  20003. rigParenting: boolean;
  20004. private _lightOnControllers;
  20005. private _defaultHeight?;
  20006. /**
  20007. * Instantiates a WebVRFreeCamera.
  20008. * @param name The name of the WebVRFreeCamera
  20009. * @param position The starting anchor position for the camera
  20010. * @param scene The scene the camera belongs to
  20011. * @param webVROptions a set of customizable options for the webVRCamera
  20012. */
  20013. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20014. /**
  20015. * Gets the device distance from the ground in meters.
  20016. * @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.
  20017. */
  20018. deviceDistanceToRoomGround(): number;
  20019. /**
  20020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20021. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20022. */
  20023. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20024. /**
  20025. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20026. * @returns A promise with a boolean set to if the standing matrix is supported.
  20027. */
  20028. useStandingMatrixAsync(): Promise<boolean>;
  20029. /**
  20030. * Disposes the camera
  20031. */
  20032. dispose(): void;
  20033. /**
  20034. * Gets a vrController by name.
  20035. * @param name The name of the controller to retreive
  20036. * @returns the controller matching the name specified or null if not found
  20037. */
  20038. getControllerByName(name: string): Nullable<WebVRController>;
  20039. private _leftController;
  20040. /**
  20041. * The controller corresponding to the users left hand.
  20042. */
  20043. get leftController(): Nullable<WebVRController>;
  20044. private _rightController;
  20045. /**
  20046. * The controller corresponding to the users right hand.
  20047. */
  20048. get rightController(): Nullable<WebVRController>;
  20049. /**
  20050. * Casts a ray forward from the vrCamera's gaze.
  20051. * @param length Length of the ray (default: 100)
  20052. * @returns the ray corresponding to the gaze
  20053. */
  20054. getForwardRay(length?: number): Ray;
  20055. /**
  20056. * @hidden
  20057. * Updates the camera based on device's frame data
  20058. */
  20059. _checkInputs(): void;
  20060. /**
  20061. * Updates the poseControlled values based on the input device pose.
  20062. * @param poseData Pose coming from the device
  20063. */
  20064. updateFromDevice(poseData: DevicePose): void;
  20065. private _htmlElementAttached;
  20066. private _detachIfAttached;
  20067. /**
  20068. * WebVR's attach control will start broadcasting frames to the device.
  20069. * Note that in certain browsers (chrome for example) this function must be called
  20070. * within a user-interaction callback. Example:
  20071. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20072. *
  20073. * @param element html element to attach the vrDevice to
  20074. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20075. */
  20076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20077. /**
  20078. * Detaches the camera from the html element and disables VR
  20079. *
  20080. * @param element html element to detach from
  20081. */
  20082. detachControl(element: HTMLElement): void;
  20083. /**
  20084. * @returns the name of this class
  20085. */
  20086. getClassName(): string;
  20087. /**
  20088. * Calls resetPose on the vrDisplay
  20089. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20090. */
  20091. resetToCurrentRotation(): void;
  20092. /**
  20093. * @hidden
  20094. * Updates the rig cameras (left and right eye)
  20095. */
  20096. _updateRigCameras(): void;
  20097. private _workingVector;
  20098. private _oneVector;
  20099. private _workingMatrix;
  20100. private updateCacheCalled;
  20101. private _correctPositionIfNotTrackPosition;
  20102. /**
  20103. * @hidden
  20104. * Updates the cached values of the camera
  20105. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20106. */
  20107. _updateCache(ignoreParentClass?: boolean): void;
  20108. /**
  20109. * @hidden
  20110. * Get current device position in babylon world
  20111. */
  20112. _computeDevicePosition(): void;
  20113. /**
  20114. * Updates the current device position and rotation in the babylon world
  20115. */
  20116. update(): void;
  20117. /**
  20118. * @hidden
  20119. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20120. * @returns an identity matrix
  20121. */
  20122. _getViewMatrix(): Matrix;
  20123. private _tmpMatrix;
  20124. /**
  20125. * This function is called by the two RIG cameras.
  20126. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20127. * @hidden
  20128. */
  20129. _getWebVRViewMatrix(): Matrix;
  20130. /** @hidden */
  20131. _getWebVRProjectionMatrix(): Matrix;
  20132. private _onGamepadConnectedObserver;
  20133. private _onGamepadDisconnectedObserver;
  20134. private _updateCacheWhenTrackingDisabledObserver;
  20135. /**
  20136. * Initializes the controllers and their meshes
  20137. */
  20138. initControllers(): void;
  20139. }
  20140. }
  20141. declare module "babylonjs/PostProcesses/postProcess" {
  20142. import { Nullable } from "babylonjs/types";
  20143. import { SmartArray } from "babylonjs/Misc/smartArray";
  20144. import { Observable } from "babylonjs/Misc/observable";
  20145. import { Vector2 } from "babylonjs/Maths/math.vector";
  20146. import { Camera } from "babylonjs/Cameras/camera";
  20147. import { Effect } from "babylonjs/Materials/effect";
  20148. import "babylonjs/Shaders/postprocess.vertex";
  20149. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20150. import { Engine } from "babylonjs/Engines/engine";
  20151. import { Color4 } from "babylonjs/Maths/math.color";
  20152. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20154. /**
  20155. * Size options for a post process
  20156. */
  20157. export type PostProcessOptions = {
  20158. width: number;
  20159. height: number;
  20160. };
  20161. /**
  20162. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20163. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20164. */
  20165. export class PostProcess {
  20166. /** Name of the PostProcess. */
  20167. name: string;
  20168. /**
  20169. * Gets or sets the unique id of the post process
  20170. */
  20171. uniqueId: number;
  20172. /**
  20173. * Width of the texture to apply the post process on
  20174. */
  20175. width: number;
  20176. /**
  20177. * Height of the texture to apply the post process on
  20178. */
  20179. height: number;
  20180. /**
  20181. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20182. * @hidden
  20183. */
  20184. _outputTexture: Nullable<InternalTexture>;
  20185. /**
  20186. * Sampling mode used by the shader
  20187. * See https://doc.babylonjs.com/classes/3.1/texture
  20188. */
  20189. renderTargetSamplingMode: number;
  20190. /**
  20191. * Clear color to use when screen clearing
  20192. */
  20193. clearColor: Color4;
  20194. /**
  20195. * If the buffer needs to be cleared before applying the post process. (default: true)
  20196. * Should be set to false if shader will overwrite all previous pixels.
  20197. */
  20198. autoClear: boolean;
  20199. /**
  20200. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20201. */
  20202. alphaMode: number;
  20203. /**
  20204. * Sets the setAlphaBlendConstants of the babylon engine
  20205. */
  20206. alphaConstants: Color4;
  20207. /**
  20208. * Animations to be used for the post processing
  20209. */
  20210. animations: import("babylonjs/Animations/animation").Animation[];
  20211. /**
  20212. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20213. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20214. */
  20215. enablePixelPerfectMode: boolean;
  20216. /**
  20217. * Force the postprocess to be applied without taking in account viewport
  20218. */
  20219. forceFullscreenViewport: boolean;
  20220. /**
  20221. * List of inspectable custom properties (used by the Inspector)
  20222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20223. */
  20224. inspectableCustomProperties: IInspectable[];
  20225. /**
  20226. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20227. *
  20228. * | Value | Type | Description |
  20229. * | ----- | ----------------------------------- | ----------- |
  20230. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20231. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20232. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20233. *
  20234. */
  20235. scaleMode: number;
  20236. /**
  20237. * Force textures to be a power of two (default: false)
  20238. */
  20239. alwaysForcePOT: boolean;
  20240. private _samples;
  20241. /**
  20242. * Number of sample textures (default: 1)
  20243. */
  20244. get samples(): number;
  20245. set samples(n: number);
  20246. /**
  20247. * Modify the scale of the post process to be the same as the viewport (default: false)
  20248. */
  20249. adaptScaleToCurrentViewport: boolean;
  20250. private _camera;
  20251. private _scene;
  20252. private _engine;
  20253. private _options;
  20254. private _reusable;
  20255. private _textureType;
  20256. private _textureFormat;
  20257. /**
  20258. * Smart array of input and output textures for the post process.
  20259. * @hidden
  20260. */
  20261. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20262. /**
  20263. * The index in _textures that corresponds to the output texture.
  20264. * @hidden
  20265. */
  20266. _currentRenderTextureInd: number;
  20267. private _effect;
  20268. private _samplers;
  20269. private _fragmentUrl;
  20270. private _vertexUrl;
  20271. private _parameters;
  20272. private _scaleRatio;
  20273. protected _indexParameters: any;
  20274. private _shareOutputWithPostProcess;
  20275. private _texelSize;
  20276. private _forcedOutputTexture;
  20277. /**
  20278. * Returns the fragment url or shader name used in the post process.
  20279. * @returns the fragment url or name in the shader store.
  20280. */
  20281. getEffectName(): string;
  20282. /**
  20283. * An event triggered when the postprocess is activated.
  20284. */
  20285. onActivateObservable: Observable<Camera>;
  20286. private _onActivateObserver;
  20287. /**
  20288. * A function that is added to the onActivateObservable
  20289. */
  20290. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20291. /**
  20292. * An event triggered when the postprocess changes its size.
  20293. */
  20294. onSizeChangedObservable: Observable<PostProcess>;
  20295. private _onSizeChangedObserver;
  20296. /**
  20297. * A function that is added to the onSizeChangedObservable
  20298. */
  20299. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20300. /**
  20301. * An event triggered when the postprocess applies its effect.
  20302. */
  20303. onApplyObservable: Observable<Effect>;
  20304. private _onApplyObserver;
  20305. /**
  20306. * A function that is added to the onApplyObservable
  20307. */
  20308. set onApply(callback: (effect: Effect) => void);
  20309. /**
  20310. * An event triggered before rendering the postprocess
  20311. */
  20312. onBeforeRenderObservable: Observable<Effect>;
  20313. private _onBeforeRenderObserver;
  20314. /**
  20315. * A function that is added to the onBeforeRenderObservable
  20316. */
  20317. set onBeforeRender(callback: (effect: Effect) => void);
  20318. /**
  20319. * An event triggered after rendering the postprocess
  20320. */
  20321. onAfterRenderObservable: Observable<Effect>;
  20322. private _onAfterRenderObserver;
  20323. /**
  20324. * A function that is added to the onAfterRenderObservable
  20325. */
  20326. set onAfterRender(callback: (efect: Effect) => void);
  20327. /**
  20328. * 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
  20329. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20330. */
  20331. get inputTexture(): InternalTexture;
  20332. set inputTexture(value: InternalTexture);
  20333. /**
  20334. * Gets the camera which post process is applied to.
  20335. * @returns The camera the post process is applied to.
  20336. */
  20337. getCamera(): Camera;
  20338. /**
  20339. * Gets the texel size of the postprocess.
  20340. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20341. */
  20342. get texelSize(): Vector2;
  20343. /**
  20344. * Creates a new instance PostProcess
  20345. * @param name The name of the PostProcess.
  20346. * @param fragmentUrl The url of the fragment shader to be used.
  20347. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20348. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20349. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20350. * @param camera The camera to apply the render pass to.
  20351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20352. * @param engine The engine which the post process will be applied. (default: current engine)
  20353. * @param reusable If the post process can be reused on the same frame. (default: false)
  20354. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20355. * @param textureType Type of textures used when performing the post process. (default: 0)
  20356. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20357. * @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
  20358. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20359. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20360. */
  20361. constructor(
  20362. /** Name of the PostProcess. */
  20363. 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);
  20364. /**
  20365. * Gets a string idenfifying the name of the class
  20366. * @returns "PostProcess" string
  20367. */
  20368. getClassName(): string;
  20369. /**
  20370. * Gets the engine which this post process belongs to.
  20371. * @returns The engine the post process was enabled with.
  20372. */
  20373. getEngine(): Engine;
  20374. /**
  20375. * The effect that is created when initializing the post process.
  20376. * @returns The created effect corresponding the the postprocess.
  20377. */
  20378. getEffect(): Effect;
  20379. /**
  20380. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20381. * @param postProcess The post process to share the output with.
  20382. * @returns This post process.
  20383. */
  20384. shareOutputWith(postProcess: PostProcess): PostProcess;
  20385. /**
  20386. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20387. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20388. */
  20389. useOwnOutput(): void;
  20390. /**
  20391. * Updates the effect with the current post process compile time values and recompiles the shader.
  20392. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20393. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20394. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20395. * @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
  20396. * @param onCompiled Called when the shader has been compiled.
  20397. * @param onError Called if there is an error when compiling a shader.
  20398. */
  20399. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20400. /**
  20401. * The post process is reusable if it can be used multiple times within one frame.
  20402. * @returns If the post process is reusable
  20403. */
  20404. isReusable(): boolean;
  20405. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20406. markTextureDirty(): void;
  20407. /**
  20408. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20409. * 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.
  20410. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20411. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20412. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20413. * @returns The target texture that was bound to be written to.
  20414. */
  20415. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20416. /**
  20417. * If the post process is supported.
  20418. */
  20419. get isSupported(): boolean;
  20420. /**
  20421. * The aspect ratio of the output texture.
  20422. */
  20423. get aspectRatio(): number;
  20424. /**
  20425. * Get a value indicating if the post-process is ready to be used
  20426. * @returns true if the post-process is ready (shader is compiled)
  20427. */
  20428. isReady(): boolean;
  20429. /**
  20430. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20431. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20432. */
  20433. apply(): Nullable<Effect>;
  20434. private _disposeTextures;
  20435. /**
  20436. * Disposes the post process.
  20437. * @param camera The camera to dispose the post process on.
  20438. */
  20439. dispose(camera?: Camera): void;
  20440. }
  20441. }
  20442. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20443. /** @hidden */
  20444. export var kernelBlurVaryingDeclaration: {
  20445. name: string;
  20446. shader: string;
  20447. };
  20448. }
  20449. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20450. /** @hidden */
  20451. export var kernelBlurFragment: {
  20452. name: string;
  20453. shader: string;
  20454. };
  20455. }
  20456. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20457. /** @hidden */
  20458. export var kernelBlurFragment2: {
  20459. name: string;
  20460. shader: string;
  20461. };
  20462. }
  20463. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20464. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20466. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20467. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20468. /** @hidden */
  20469. export var kernelBlurPixelShader: {
  20470. name: string;
  20471. shader: string;
  20472. };
  20473. }
  20474. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20475. /** @hidden */
  20476. export var kernelBlurVertex: {
  20477. name: string;
  20478. shader: string;
  20479. };
  20480. }
  20481. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20482. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20483. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20484. /** @hidden */
  20485. export var kernelBlurVertexShader: {
  20486. name: string;
  20487. shader: string;
  20488. };
  20489. }
  20490. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20491. import { Vector2 } from "babylonjs/Maths/math.vector";
  20492. import { Nullable } from "babylonjs/types";
  20493. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20494. import { Camera } from "babylonjs/Cameras/camera";
  20495. import { Effect } from "babylonjs/Materials/effect";
  20496. import { Engine } from "babylonjs/Engines/engine";
  20497. import "babylonjs/Shaders/kernelBlur.fragment";
  20498. import "babylonjs/Shaders/kernelBlur.vertex";
  20499. /**
  20500. * The Blur Post Process which blurs an image based on a kernel and direction.
  20501. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20502. */
  20503. export class BlurPostProcess extends PostProcess {
  20504. /** The direction in which to blur the image. */
  20505. direction: Vector2;
  20506. private blockCompilation;
  20507. protected _kernel: number;
  20508. protected _idealKernel: number;
  20509. protected _packedFloat: boolean;
  20510. private _staticDefines;
  20511. /**
  20512. * Sets the length in pixels of the blur sample region
  20513. */
  20514. set kernel(v: number);
  20515. /**
  20516. * Gets the length in pixels of the blur sample region
  20517. */
  20518. get kernel(): number;
  20519. /**
  20520. * Sets wether or not the blur needs to unpack/repack floats
  20521. */
  20522. set packedFloat(v: boolean);
  20523. /**
  20524. * Gets wether or not the blur is unpacking/repacking floats
  20525. */
  20526. get packedFloat(): boolean;
  20527. /**
  20528. * Creates a new instance BlurPostProcess
  20529. * @param name The name of the effect.
  20530. * @param direction The direction in which to blur the image.
  20531. * @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.
  20532. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20533. * @param camera The camera to apply the render pass to.
  20534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20535. * @param engine The engine which the post process will be applied. (default: current engine)
  20536. * @param reusable If the post process can be reused on the same frame. (default: false)
  20537. * @param textureType Type of textures used when performing the post process. (default: 0)
  20538. * @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)
  20539. */
  20540. constructor(name: string,
  20541. /** The direction in which to blur the image. */
  20542. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20543. /**
  20544. * Updates the effect with the current post process compile time values and recompiles the shader.
  20545. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20546. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20547. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20548. * @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
  20549. * @param onCompiled Called when the shader has been compiled.
  20550. * @param onError Called if there is an error when compiling a shader.
  20551. */
  20552. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20553. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20554. /**
  20555. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20556. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20557. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20558. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20559. * The gaps between physical kernels are compensated for in the weighting of the samples
  20560. * @param idealKernel Ideal blur kernel.
  20561. * @return Nearest best kernel.
  20562. */
  20563. protected _nearestBestKernel(idealKernel: number): number;
  20564. /**
  20565. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20566. * @param x The point on the Gaussian distribution to sample.
  20567. * @return the value of the Gaussian function at x.
  20568. */
  20569. protected _gaussianWeight(x: number): number;
  20570. /**
  20571. * Generates a string that can be used as a floating point number in GLSL.
  20572. * @param x Value to print.
  20573. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20574. * @return GLSL float string.
  20575. */
  20576. protected _glslFloat(x: number, decimalFigures?: number): string;
  20577. }
  20578. }
  20579. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20580. import { Scene } from "babylonjs/scene";
  20581. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20582. import { Plane } from "babylonjs/Maths/math.plane";
  20583. /**
  20584. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20585. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20586. * You can then easily use it as a reflectionTexture on a flat surface.
  20587. * In case the surface is not a plane, please consider relying on reflection probes.
  20588. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20589. */
  20590. export class MirrorTexture extends RenderTargetTexture {
  20591. private scene;
  20592. /**
  20593. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20594. * 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.
  20595. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20596. */
  20597. mirrorPlane: Plane;
  20598. /**
  20599. * Define the blur ratio used to blur the reflection if needed.
  20600. */
  20601. set blurRatio(value: number);
  20602. get blurRatio(): number;
  20603. /**
  20604. * Define the adaptive blur kernel used to blur the reflection if needed.
  20605. * This will autocompute the closest best match for the `blurKernel`
  20606. */
  20607. set adaptiveBlurKernel(value: number);
  20608. /**
  20609. * Define the blur kernel used to blur the reflection if needed.
  20610. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20611. */
  20612. set blurKernel(value: number);
  20613. /**
  20614. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20615. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20616. */
  20617. set blurKernelX(value: number);
  20618. get blurKernelX(): number;
  20619. /**
  20620. * Define the blur kernel on the Y Axis 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 blurKernelY(value: number);
  20624. get blurKernelY(): number;
  20625. private _autoComputeBlurKernel;
  20626. protected _onRatioRescale(): void;
  20627. private _updateGammaSpace;
  20628. private _imageProcessingConfigChangeObserver;
  20629. private _transformMatrix;
  20630. private _mirrorMatrix;
  20631. private _savedViewMatrix;
  20632. private _blurX;
  20633. private _blurY;
  20634. private _adaptiveBlurKernel;
  20635. private _blurKernelX;
  20636. private _blurKernelY;
  20637. private _blurRatio;
  20638. /**
  20639. * Instantiates a Mirror Texture.
  20640. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20641. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20642. * You can then easily use it as a reflectionTexture on a flat surface.
  20643. * In case the surface is not a plane, please consider relying on reflection probes.
  20644. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20645. * @param name
  20646. * @param size
  20647. * @param scene
  20648. * @param generateMipMaps
  20649. * @param type
  20650. * @param samplingMode
  20651. * @param generateDepthBuffer
  20652. */
  20653. constructor(name: string, size: number | {
  20654. width: number;
  20655. height: number;
  20656. } | {
  20657. ratio: number;
  20658. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20659. private _preparePostProcesses;
  20660. /**
  20661. * Clone the mirror texture.
  20662. * @returns the cloned texture
  20663. */
  20664. clone(): MirrorTexture;
  20665. /**
  20666. * Serialize the texture to a JSON representation you could use in Parse later on
  20667. * @returns the serialized JSON representation
  20668. */
  20669. serialize(): any;
  20670. /**
  20671. * Dispose the texture and release its associated resources.
  20672. */
  20673. dispose(): void;
  20674. }
  20675. }
  20676. declare module "babylonjs/Materials/Textures/texture" {
  20677. import { Observable } from "babylonjs/Misc/observable";
  20678. import { Nullable } from "babylonjs/types";
  20679. import { Matrix } from "babylonjs/Maths/math.vector";
  20680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20681. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20682. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20683. import { Scene } from "babylonjs/scene";
  20684. /**
  20685. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20686. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20687. */
  20688. export class Texture extends BaseTexture {
  20689. /**
  20690. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20691. */
  20692. static SerializeBuffers: boolean;
  20693. /** @hidden */
  20694. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20695. /** @hidden */
  20696. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20697. /** @hidden */
  20698. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20699. /** nearest is mag = nearest and min = nearest and mip = linear */
  20700. static readonly NEAREST_SAMPLINGMODE: number;
  20701. /** nearest is mag = nearest and min = nearest and mip = linear */
  20702. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20703. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20704. static readonly BILINEAR_SAMPLINGMODE: number;
  20705. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20706. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20707. /** Trilinear is mag = linear and min = linear and mip = linear */
  20708. static readonly TRILINEAR_SAMPLINGMODE: number;
  20709. /** Trilinear is mag = linear and min = linear and mip = linear */
  20710. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20711. /** mag = nearest and min = nearest and mip = nearest */
  20712. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20713. /** mag = nearest and min = linear and mip = nearest */
  20714. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20715. /** mag = nearest and min = linear and mip = linear */
  20716. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20717. /** mag = nearest and min = linear and mip = none */
  20718. static readonly NEAREST_LINEAR: number;
  20719. /** mag = nearest and min = nearest and mip = none */
  20720. static readonly NEAREST_NEAREST: number;
  20721. /** mag = linear and min = nearest and mip = nearest */
  20722. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20723. /** mag = linear and min = nearest and mip = linear */
  20724. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20725. /** mag = linear and min = linear and mip = none */
  20726. static readonly LINEAR_LINEAR: number;
  20727. /** mag = linear and min = nearest and mip = none */
  20728. static readonly LINEAR_NEAREST: number;
  20729. /** Explicit coordinates mode */
  20730. static readonly EXPLICIT_MODE: number;
  20731. /** Spherical coordinates mode */
  20732. static readonly SPHERICAL_MODE: number;
  20733. /** Planar coordinates mode */
  20734. static readonly PLANAR_MODE: number;
  20735. /** Cubic coordinates mode */
  20736. static readonly CUBIC_MODE: number;
  20737. /** Projection coordinates mode */
  20738. static readonly PROJECTION_MODE: number;
  20739. /** Inverse Cubic coordinates mode */
  20740. static readonly SKYBOX_MODE: number;
  20741. /** Inverse Cubic coordinates mode */
  20742. static readonly INVCUBIC_MODE: number;
  20743. /** Equirectangular coordinates mode */
  20744. static readonly EQUIRECTANGULAR_MODE: number;
  20745. /** Equirectangular Fixed coordinates mode */
  20746. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20747. /** Equirectangular Fixed Mirrored coordinates mode */
  20748. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20749. /** Texture is not repeating outside of 0..1 UVs */
  20750. static readonly CLAMP_ADDRESSMODE: number;
  20751. /** Texture is repeating outside of 0..1 UVs */
  20752. static readonly WRAP_ADDRESSMODE: number;
  20753. /** Texture is repeating and mirrored */
  20754. static readonly MIRROR_ADDRESSMODE: number;
  20755. /**
  20756. * 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
  20757. */
  20758. static UseSerializedUrlIfAny: boolean;
  20759. /**
  20760. * Define the url of the texture.
  20761. */
  20762. url: Nullable<string>;
  20763. /**
  20764. * Define an offset on the texture to offset the u coordinates of the UVs
  20765. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20766. */
  20767. uOffset: number;
  20768. /**
  20769. * Define an offset on the texture to offset the v coordinates of the UVs
  20770. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20771. */
  20772. vOffset: number;
  20773. /**
  20774. * Define an offset on the texture to scale the u coordinates of the UVs
  20775. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20776. */
  20777. uScale: number;
  20778. /**
  20779. * Define an offset on the texture to scale the v coordinates of the UVs
  20780. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20781. */
  20782. vScale: number;
  20783. /**
  20784. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20785. * @see http://doc.babylonjs.com/how_to/more_materials
  20786. */
  20787. uAng: number;
  20788. /**
  20789. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20790. * @see http://doc.babylonjs.com/how_to/more_materials
  20791. */
  20792. vAng: number;
  20793. /**
  20794. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20795. * @see http://doc.babylonjs.com/how_to/more_materials
  20796. */
  20797. wAng: number;
  20798. /**
  20799. * Defines the center of rotation (U)
  20800. */
  20801. uRotationCenter: number;
  20802. /**
  20803. * Defines the center of rotation (V)
  20804. */
  20805. vRotationCenter: number;
  20806. /**
  20807. * Defines the center of rotation (W)
  20808. */
  20809. wRotationCenter: number;
  20810. /**
  20811. * Are mip maps generated for this texture or not.
  20812. */
  20813. get noMipmap(): boolean;
  20814. /**
  20815. * List of inspectable custom properties (used by the Inspector)
  20816. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20817. */
  20818. inspectableCustomProperties: Nullable<IInspectable[]>;
  20819. private _noMipmap;
  20820. /** @hidden */
  20821. _invertY: boolean;
  20822. private _rowGenerationMatrix;
  20823. private _cachedTextureMatrix;
  20824. private _projectionModeMatrix;
  20825. private _t0;
  20826. private _t1;
  20827. private _t2;
  20828. private _cachedUOffset;
  20829. private _cachedVOffset;
  20830. private _cachedUScale;
  20831. private _cachedVScale;
  20832. private _cachedUAng;
  20833. private _cachedVAng;
  20834. private _cachedWAng;
  20835. private _cachedProjectionMatrixId;
  20836. private _cachedCoordinatesMode;
  20837. /** @hidden */
  20838. protected _initialSamplingMode: number;
  20839. /** @hidden */
  20840. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20841. private _deleteBuffer;
  20842. protected _format: Nullable<number>;
  20843. private _delayedOnLoad;
  20844. private _delayedOnError;
  20845. private _mimeType?;
  20846. /**
  20847. * Observable triggered once the texture has been loaded.
  20848. */
  20849. onLoadObservable: Observable<Texture>;
  20850. protected _isBlocking: boolean;
  20851. /**
  20852. * Is the texture preventing material to render while loading.
  20853. * If false, a default texture will be used instead of the loading one during the preparation step.
  20854. */
  20855. set isBlocking(value: boolean);
  20856. get isBlocking(): boolean;
  20857. /**
  20858. * Get the current sampling mode associated with the texture.
  20859. */
  20860. get samplingMode(): number;
  20861. /**
  20862. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20863. */
  20864. get invertY(): boolean;
  20865. /**
  20866. * Instantiates a new texture.
  20867. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20868. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20869. * @param url defines the url of the picture to load as a texture
  20870. * @param scene defines the scene or engine the texture will belong to
  20871. * @param noMipmap defines if the texture will require mip maps or not
  20872. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20873. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20874. * @param onLoad defines a callback triggered when the texture has been loaded
  20875. * @param onError defines a callback triggered when an error occurred during the loading session
  20876. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20877. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20878. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20879. * @param mimeType defines an optional mime type information
  20880. */
  20881. 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);
  20882. /**
  20883. * Update the url (and optional buffer) of this texture if url was null during construction.
  20884. * @param url the url of the texture
  20885. * @param buffer the buffer of the texture (defaults to null)
  20886. * @param onLoad callback called when the texture is loaded (defaults to null)
  20887. */
  20888. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20889. /**
  20890. * Finish the loading sequence of a texture flagged as delayed load.
  20891. * @hidden
  20892. */
  20893. delayLoad(): void;
  20894. private _prepareRowForTextureGeneration;
  20895. /**
  20896. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20897. * @returns the transform matrix of the texture.
  20898. */
  20899. getTextureMatrix(uBase?: number): Matrix;
  20900. /**
  20901. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20902. * @returns The reflection texture transform
  20903. */
  20904. getReflectionTextureMatrix(): Matrix;
  20905. /**
  20906. * Clones the texture.
  20907. * @returns the cloned texture
  20908. */
  20909. clone(): Texture;
  20910. /**
  20911. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20912. * @returns The JSON representation of the texture
  20913. */
  20914. serialize(): any;
  20915. /**
  20916. * Get the current class name of the texture useful for serialization or dynamic coding.
  20917. * @returns "Texture"
  20918. */
  20919. getClassName(): string;
  20920. /**
  20921. * Dispose the texture and release its associated resources.
  20922. */
  20923. dispose(): void;
  20924. /**
  20925. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20926. * @param parsedTexture Define the JSON representation of the texture
  20927. * @param scene Define the scene the parsed texture should be instantiated in
  20928. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20929. * @returns The parsed texture if successful
  20930. */
  20931. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20932. /**
  20933. * Creates a texture from its base 64 representation.
  20934. * @param data Define the base64 payload without the data: prefix
  20935. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20936. * @param scene Define the scene the texture should belong to
  20937. * @param noMipmap Forces the texture to not create mip map information if true
  20938. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20939. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20940. * @param onLoad define a callback triggered when the texture has been loaded
  20941. * @param onError define a callback triggered when an error occurred during the loading session
  20942. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20943. * @returns the created texture
  20944. */
  20945. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20946. /**
  20947. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20948. * @param data Define the base64 payload without the data: prefix
  20949. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20950. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20951. * @param scene Define the scene the texture should belong to
  20952. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20953. * @param noMipmap Forces the texture to not create mip map information if true
  20954. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20955. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20956. * @param onLoad define a callback triggered when the texture has been loaded
  20957. * @param onError define a callback triggered when an error occurred during the loading session
  20958. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20959. * @returns the created texture
  20960. */
  20961. 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;
  20962. }
  20963. }
  20964. declare module "babylonjs/PostProcesses/postProcessManager" {
  20965. import { Nullable } from "babylonjs/types";
  20966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20968. import { Scene } from "babylonjs/scene";
  20969. /**
  20970. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20971. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20972. */
  20973. export class PostProcessManager {
  20974. private _scene;
  20975. private _indexBuffer;
  20976. private _vertexBuffers;
  20977. /**
  20978. * Creates a new instance PostProcess
  20979. * @param scene The scene that the post process is associated with.
  20980. */
  20981. constructor(scene: Scene);
  20982. private _prepareBuffers;
  20983. private _buildIndexBuffer;
  20984. /**
  20985. * Rebuilds the vertex buffers of the manager.
  20986. * @hidden
  20987. */
  20988. _rebuild(): void;
  20989. /**
  20990. * Prepares a frame to be run through a post process.
  20991. * @param sourceTexture The input texture to the post procesess. (default: null)
  20992. * @param postProcesses An array of post processes to be run. (default: null)
  20993. * @returns True if the post processes were able to be run.
  20994. * @hidden
  20995. */
  20996. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20997. /**
  20998. * Manually render a set of post processes to a texture.
  20999. * @param postProcesses An array of post processes to be run.
  21000. * @param targetTexture The target texture to render to.
  21001. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21002. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21003. * @param lodLevel defines which lod of the texture to render to
  21004. */
  21005. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21006. /**
  21007. * Finalize the result of the output of the postprocesses.
  21008. * @param doNotPresent If true the result will not be displayed to the screen.
  21009. * @param targetTexture The target texture to render to.
  21010. * @param faceIndex The index of the face to bind the target texture to.
  21011. * @param postProcesses The array of post processes to render.
  21012. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21013. * @hidden
  21014. */
  21015. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21016. /**
  21017. * Disposes of the post process manager.
  21018. */
  21019. dispose(): void;
  21020. }
  21021. }
  21022. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21023. import { Observable } from "babylonjs/Misc/observable";
  21024. import { SmartArray } from "babylonjs/Misc/smartArray";
  21025. import { Nullable, Immutable } from "babylonjs/types";
  21026. import { Camera } from "babylonjs/Cameras/camera";
  21027. import { Scene } from "babylonjs/scene";
  21028. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21029. import { Color4 } from "babylonjs/Maths/math.color";
  21030. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21034. import { Texture } from "babylonjs/Materials/Textures/texture";
  21035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21036. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21037. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21038. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21039. import { Engine } from "babylonjs/Engines/engine";
  21040. /**
  21041. * This Helps creating a texture that will be created from a camera in your scene.
  21042. * It is basically a dynamic texture that could be used to create special effects for instance.
  21043. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21044. */
  21045. export class RenderTargetTexture extends Texture {
  21046. isCube: boolean;
  21047. /**
  21048. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21049. */
  21050. static readonly REFRESHRATE_RENDER_ONCE: number;
  21051. /**
  21052. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21053. */
  21054. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21055. /**
  21056. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21057. * the central point of your effect and can save a lot of performances.
  21058. */
  21059. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21060. /**
  21061. * Use this predicate to dynamically define the list of mesh you want to render.
  21062. * If set, the renderList property will be overwritten.
  21063. */
  21064. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21065. private _renderList;
  21066. /**
  21067. * Use this list to define the list of mesh you want to render.
  21068. */
  21069. get renderList(): Nullable<Array<AbstractMesh>>;
  21070. set renderList(value: Nullable<Array<AbstractMesh>>);
  21071. /**
  21072. * Use this function to overload the renderList array at rendering time.
  21073. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21074. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21075. * the cube (if the RTT is a cube, else layerOrFace=0).
  21076. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21077. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21078. * hold dummy elements!
  21079. */
  21080. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21081. private _hookArray;
  21082. /**
  21083. * Define if particles should be rendered in your texture.
  21084. */
  21085. renderParticles: boolean;
  21086. /**
  21087. * Define if sprites should be rendered in your texture.
  21088. */
  21089. renderSprites: boolean;
  21090. /**
  21091. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21092. */
  21093. coordinatesMode: number;
  21094. /**
  21095. * Define the camera used to render the texture.
  21096. */
  21097. activeCamera: Nullable<Camera>;
  21098. /**
  21099. * Override the render function of the texture with your own one.
  21100. */
  21101. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21102. /**
  21103. * Define if camera post processes should be use while rendering the texture.
  21104. */
  21105. useCameraPostProcesses: boolean;
  21106. /**
  21107. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21108. */
  21109. ignoreCameraViewport: boolean;
  21110. private _postProcessManager;
  21111. private _postProcesses;
  21112. private _resizeObserver;
  21113. /**
  21114. * An event triggered when the texture is unbind.
  21115. */
  21116. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21117. /**
  21118. * An event triggered when the texture is unbind.
  21119. */
  21120. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21121. private _onAfterUnbindObserver;
  21122. /**
  21123. * Set a after unbind callback in the texture.
  21124. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21125. */
  21126. set onAfterUnbind(callback: () => void);
  21127. /**
  21128. * An event triggered before rendering the texture
  21129. */
  21130. onBeforeRenderObservable: Observable<number>;
  21131. private _onBeforeRenderObserver;
  21132. /**
  21133. * Set a before render callback in the texture.
  21134. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21135. */
  21136. set onBeforeRender(callback: (faceIndex: number) => void);
  21137. /**
  21138. * An event triggered after rendering the texture
  21139. */
  21140. onAfterRenderObservable: Observable<number>;
  21141. private _onAfterRenderObserver;
  21142. /**
  21143. * Set a after render callback in the texture.
  21144. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21145. */
  21146. set onAfterRender(callback: (faceIndex: number) => void);
  21147. /**
  21148. * An event triggered after the texture clear
  21149. */
  21150. onClearObservable: Observable<Engine>;
  21151. private _onClearObserver;
  21152. /**
  21153. * Set a clear callback in the texture.
  21154. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21155. */
  21156. set onClear(callback: (Engine: Engine) => void);
  21157. /**
  21158. * An event triggered when the texture is resized.
  21159. */
  21160. onResizeObservable: Observable<RenderTargetTexture>;
  21161. /**
  21162. * Define the clear color of the Render Target if it should be different from the scene.
  21163. */
  21164. clearColor: Color4;
  21165. protected _size: number | {
  21166. width: number;
  21167. height: number;
  21168. layers?: number;
  21169. };
  21170. protected _initialSizeParameter: number | {
  21171. width: number;
  21172. height: number;
  21173. } | {
  21174. ratio: number;
  21175. };
  21176. protected _sizeRatio: Nullable<number>;
  21177. /** @hidden */
  21178. _generateMipMaps: boolean;
  21179. protected _renderingManager: RenderingManager;
  21180. /** @hidden */
  21181. _waitingRenderList: string[];
  21182. protected _doNotChangeAspectRatio: boolean;
  21183. protected _currentRefreshId: number;
  21184. protected _refreshRate: number;
  21185. protected _textureMatrix: Matrix;
  21186. protected _samples: number;
  21187. protected _renderTargetOptions: RenderTargetCreationOptions;
  21188. /**
  21189. * Gets render target creation options that were used.
  21190. */
  21191. get renderTargetOptions(): RenderTargetCreationOptions;
  21192. protected _engine: Engine;
  21193. protected _onRatioRescale(): void;
  21194. /**
  21195. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21196. * It must define where the camera used to render the texture is set
  21197. */
  21198. boundingBoxPosition: Vector3;
  21199. private _boundingBoxSize;
  21200. /**
  21201. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21202. * When defined, the cubemap will switch to local mode
  21203. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21204. * @example https://www.babylonjs-playground.com/#RNASML
  21205. */
  21206. set boundingBoxSize(value: Vector3);
  21207. get boundingBoxSize(): Vector3;
  21208. /**
  21209. * In case the RTT has been created with a depth texture, get the associated
  21210. * depth texture.
  21211. * Otherwise, return null.
  21212. */
  21213. get depthStencilTexture(): Nullable<InternalTexture>;
  21214. /**
  21215. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21216. * or used a shadow, depth texture...
  21217. * @param name The friendly name of the texture
  21218. * @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)
  21219. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21220. * @param generateMipMaps True if mip maps need to be generated after render.
  21221. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21222. * @param type The type of the buffer in the RTT (int, half float, float...)
  21223. * @param isCube True if a cube texture needs to be created
  21224. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21225. * @param generateDepthBuffer True to generate a depth buffer
  21226. * @param generateStencilBuffer True to generate a stencil buffer
  21227. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21228. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21229. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21230. */
  21231. constructor(name: string, size: number | {
  21232. width: number;
  21233. height: number;
  21234. layers?: number;
  21235. } | {
  21236. ratio: number;
  21237. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21238. /**
  21239. * Creates a depth stencil texture.
  21240. * This is only available in WebGL 2 or with the depth texture extension available.
  21241. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21242. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21243. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21244. */
  21245. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21246. private _processSizeParameter;
  21247. /**
  21248. * Define the number of samples to use in case of MSAA.
  21249. * It defaults to one meaning no MSAA has been enabled.
  21250. */
  21251. get samples(): number;
  21252. set samples(value: number);
  21253. /**
  21254. * Resets the refresh counter of the texture and start bak from scratch.
  21255. * Could be useful to regenerate the texture if it is setup to render only once.
  21256. */
  21257. resetRefreshCounter(): void;
  21258. /**
  21259. * Define the refresh rate of the texture or the rendering frequency.
  21260. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21261. */
  21262. get refreshRate(): number;
  21263. set refreshRate(value: number);
  21264. /**
  21265. * Adds a post process to the render target rendering passes.
  21266. * @param postProcess define the post process to add
  21267. */
  21268. addPostProcess(postProcess: PostProcess): void;
  21269. /**
  21270. * Clear all the post processes attached to the render target
  21271. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21272. */
  21273. clearPostProcesses(dispose?: boolean): void;
  21274. /**
  21275. * Remove one of the post process from the list of attached post processes to the texture
  21276. * @param postProcess define the post process to remove from the list
  21277. */
  21278. removePostProcess(postProcess: PostProcess): void;
  21279. /** @hidden */
  21280. _shouldRender(): boolean;
  21281. /**
  21282. * Gets the actual render size of the texture.
  21283. * @returns the width of the render size
  21284. */
  21285. getRenderSize(): number;
  21286. /**
  21287. * Gets the actual render width of the texture.
  21288. * @returns the width of the render size
  21289. */
  21290. getRenderWidth(): number;
  21291. /**
  21292. * Gets the actual render height of the texture.
  21293. * @returns the height of the render size
  21294. */
  21295. getRenderHeight(): number;
  21296. /**
  21297. * Gets the actual number of layers of the texture.
  21298. * @returns the number of layers
  21299. */
  21300. getRenderLayers(): number;
  21301. /**
  21302. * Get if the texture can be rescaled or not.
  21303. */
  21304. get canRescale(): boolean;
  21305. /**
  21306. * Resize the texture using a ratio.
  21307. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21308. */
  21309. scale(ratio: number): void;
  21310. /**
  21311. * Get the texture reflection matrix used to rotate/transform the reflection.
  21312. * @returns the reflection matrix
  21313. */
  21314. getReflectionTextureMatrix(): Matrix;
  21315. /**
  21316. * Resize the texture to a new desired size.
  21317. * Be carrefull as it will recreate all the data in the new texture.
  21318. * @param size Define the new size. It can be:
  21319. * - a number for squared texture,
  21320. * - an object containing { width: number, height: number }
  21321. * - or an object containing a ratio { ratio: number }
  21322. */
  21323. resize(size: number | {
  21324. width: number;
  21325. height: number;
  21326. } | {
  21327. ratio: number;
  21328. }): void;
  21329. private _defaultRenderListPrepared;
  21330. /**
  21331. * Renders all the objects from the render list into the texture.
  21332. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21333. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21334. */
  21335. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21336. private _bestReflectionRenderTargetDimension;
  21337. private _prepareRenderingManager;
  21338. /**
  21339. * @hidden
  21340. * @param faceIndex face index to bind to if this is a cubetexture
  21341. * @param layer defines the index of the texture to bind in the array
  21342. */
  21343. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21344. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21345. private renderToTarget;
  21346. /**
  21347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21348. * This allowed control for front to back rendering or reversly depending of the special needs.
  21349. *
  21350. * @param renderingGroupId The rendering group id corresponding to its index
  21351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21354. */
  21355. 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;
  21356. /**
  21357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21358. *
  21359. * @param renderingGroupId The rendering group id corresponding to its index
  21360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21361. */
  21362. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21363. /**
  21364. * Clones the texture.
  21365. * @returns the cloned texture
  21366. */
  21367. clone(): RenderTargetTexture;
  21368. /**
  21369. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21370. * @returns The JSON representation of the texture
  21371. */
  21372. serialize(): any;
  21373. /**
  21374. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21375. */
  21376. disposeFramebufferObjects(): void;
  21377. /**
  21378. * Dispose the texture and release its associated resources.
  21379. */
  21380. dispose(): void;
  21381. /** @hidden */
  21382. _rebuild(): void;
  21383. /**
  21384. * Clear the info related to rendering groups preventing retention point in material dispose.
  21385. */
  21386. freeRenderingGroups(): void;
  21387. /**
  21388. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21389. * @returns the view count
  21390. */
  21391. getViewCount(): number;
  21392. }
  21393. }
  21394. declare module "babylonjs/Materials/material" {
  21395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21396. import { SmartArray } from "babylonjs/Misc/smartArray";
  21397. import { Observable } from "babylonjs/Misc/observable";
  21398. import { Nullable } from "babylonjs/types";
  21399. import { Scene } from "babylonjs/scene";
  21400. import { Matrix } from "babylonjs/Maths/math.vector";
  21401. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21404. import { Effect } from "babylonjs/Materials/effect";
  21405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21406. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21407. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21408. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21409. import { Mesh } from "babylonjs/Meshes/mesh";
  21410. import { Animation } from "babylonjs/Animations/animation";
  21411. /**
  21412. * Options for compiling materials.
  21413. */
  21414. export interface IMaterialCompilationOptions {
  21415. /**
  21416. * Defines whether clip planes are enabled.
  21417. */
  21418. clipPlane: boolean;
  21419. /**
  21420. * Defines whether instances are enabled.
  21421. */
  21422. useInstances: boolean;
  21423. }
  21424. /**
  21425. * Base class for the main features of a material in Babylon.js
  21426. */
  21427. export class Material implements IAnimatable {
  21428. /**
  21429. * Returns the triangle fill mode
  21430. */
  21431. static readonly TriangleFillMode: number;
  21432. /**
  21433. * Returns the wireframe mode
  21434. */
  21435. static readonly WireFrameFillMode: number;
  21436. /**
  21437. * Returns the point fill mode
  21438. */
  21439. static readonly PointFillMode: number;
  21440. /**
  21441. * Returns the point list draw mode
  21442. */
  21443. static readonly PointListDrawMode: number;
  21444. /**
  21445. * Returns the line list draw mode
  21446. */
  21447. static readonly LineListDrawMode: number;
  21448. /**
  21449. * Returns the line loop draw mode
  21450. */
  21451. static readonly LineLoopDrawMode: number;
  21452. /**
  21453. * Returns the line strip draw mode
  21454. */
  21455. static readonly LineStripDrawMode: number;
  21456. /**
  21457. * Returns the triangle strip draw mode
  21458. */
  21459. static readonly TriangleStripDrawMode: number;
  21460. /**
  21461. * Returns the triangle fan draw mode
  21462. */
  21463. static readonly TriangleFanDrawMode: number;
  21464. /**
  21465. * Stores the clock-wise side orientation
  21466. */
  21467. static readonly ClockWiseSideOrientation: number;
  21468. /**
  21469. * Stores the counter clock-wise side orientation
  21470. */
  21471. static readonly CounterClockWiseSideOrientation: number;
  21472. /**
  21473. * The dirty texture flag value
  21474. */
  21475. static readonly TextureDirtyFlag: number;
  21476. /**
  21477. * The dirty light flag value
  21478. */
  21479. static readonly LightDirtyFlag: number;
  21480. /**
  21481. * The dirty fresnel flag value
  21482. */
  21483. static readonly FresnelDirtyFlag: number;
  21484. /**
  21485. * The dirty attribute flag value
  21486. */
  21487. static readonly AttributesDirtyFlag: number;
  21488. /**
  21489. * The dirty misc flag value
  21490. */
  21491. static readonly MiscDirtyFlag: number;
  21492. /**
  21493. * The all dirty flag value
  21494. */
  21495. static readonly AllDirtyFlag: number;
  21496. /**
  21497. * The ID of the material
  21498. */
  21499. id: string;
  21500. /**
  21501. * Gets or sets the unique id of the material
  21502. */
  21503. uniqueId: number;
  21504. /**
  21505. * The name of the material
  21506. */
  21507. name: string;
  21508. /**
  21509. * Gets or sets user defined metadata
  21510. */
  21511. metadata: any;
  21512. /**
  21513. * For internal use only. Please do not use.
  21514. */
  21515. reservedDataStore: any;
  21516. /**
  21517. * Specifies if the ready state should be checked on each call
  21518. */
  21519. checkReadyOnEveryCall: boolean;
  21520. /**
  21521. * Specifies if the ready state should be checked once
  21522. */
  21523. checkReadyOnlyOnce: boolean;
  21524. /**
  21525. * The state of the material
  21526. */
  21527. state: string;
  21528. /**
  21529. * The alpha value of the material
  21530. */
  21531. protected _alpha: number;
  21532. /**
  21533. * List of inspectable custom properties (used by the Inspector)
  21534. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21535. */
  21536. inspectableCustomProperties: IInspectable[];
  21537. /**
  21538. * Sets the alpha value of the material
  21539. */
  21540. set alpha(value: number);
  21541. /**
  21542. * Gets the alpha value of the material
  21543. */
  21544. get alpha(): number;
  21545. /**
  21546. * Specifies if back face culling is enabled
  21547. */
  21548. protected _backFaceCulling: boolean;
  21549. /**
  21550. * Sets the back-face culling state
  21551. */
  21552. set backFaceCulling(value: boolean);
  21553. /**
  21554. * Gets the back-face culling state
  21555. */
  21556. get backFaceCulling(): boolean;
  21557. /**
  21558. * Stores the value for side orientation
  21559. */
  21560. sideOrientation: number;
  21561. /**
  21562. * Callback triggered when the material is compiled
  21563. */
  21564. onCompiled: Nullable<(effect: Effect) => void>;
  21565. /**
  21566. * Callback triggered when an error occurs
  21567. */
  21568. onError: Nullable<(effect: Effect, errors: string) => void>;
  21569. /**
  21570. * Callback triggered to get the render target textures
  21571. */
  21572. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21573. /**
  21574. * Gets a boolean indicating that current material needs to register RTT
  21575. */
  21576. get hasRenderTargetTextures(): boolean;
  21577. /**
  21578. * Specifies if the material should be serialized
  21579. */
  21580. doNotSerialize: boolean;
  21581. /**
  21582. * @hidden
  21583. */
  21584. _storeEffectOnSubMeshes: boolean;
  21585. /**
  21586. * Stores the animations for the material
  21587. */
  21588. animations: Nullable<Array<Animation>>;
  21589. /**
  21590. * An event triggered when the material is disposed
  21591. */
  21592. onDisposeObservable: Observable<Material>;
  21593. /**
  21594. * An observer which watches for dispose events
  21595. */
  21596. private _onDisposeObserver;
  21597. private _onUnBindObservable;
  21598. /**
  21599. * Called during a dispose event
  21600. */
  21601. set onDispose(callback: () => void);
  21602. private _onBindObservable;
  21603. /**
  21604. * An event triggered when the material is bound
  21605. */
  21606. get onBindObservable(): Observable<AbstractMesh>;
  21607. /**
  21608. * An observer which watches for bind events
  21609. */
  21610. private _onBindObserver;
  21611. /**
  21612. * Called during a bind event
  21613. */
  21614. set onBind(callback: (Mesh: AbstractMesh) => void);
  21615. /**
  21616. * An event triggered when the material is unbound
  21617. */
  21618. get onUnBindObservable(): Observable<Material>;
  21619. /**
  21620. * Stores the value of the alpha mode
  21621. */
  21622. private _alphaMode;
  21623. /**
  21624. * Sets the value of the alpha mode.
  21625. *
  21626. * | Value | Type | Description |
  21627. * | --- | --- | --- |
  21628. * | 0 | ALPHA_DISABLE | |
  21629. * | 1 | ALPHA_ADD | |
  21630. * | 2 | ALPHA_COMBINE | |
  21631. * | 3 | ALPHA_SUBTRACT | |
  21632. * | 4 | ALPHA_MULTIPLY | |
  21633. * | 5 | ALPHA_MAXIMIZED | |
  21634. * | 6 | ALPHA_ONEONE | |
  21635. * | 7 | ALPHA_PREMULTIPLIED | |
  21636. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21637. * | 9 | ALPHA_INTERPOLATE | |
  21638. * | 10 | ALPHA_SCREENMODE | |
  21639. *
  21640. */
  21641. set alphaMode(value: number);
  21642. /**
  21643. * Gets the value of the alpha mode
  21644. */
  21645. get alphaMode(): number;
  21646. /**
  21647. * Stores the state of the need depth pre-pass value
  21648. */
  21649. private _needDepthPrePass;
  21650. /**
  21651. * Sets the need depth pre-pass value
  21652. */
  21653. set needDepthPrePass(value: boolean);
  21654. /**
  21655. * Gets the depth pre-pass value
  21656. */
  21657. get needDepthPrePass(): boolean;
  21658. /**
  21659. * Specifies if depth writing should be disabled
  21660. */
  21661. disableDepthWrite: boolean;
  21662. /**
  21663. * Specifies if depth writing should be forced
  21664. */
  21665. forceDepthWrite: boolean;
  21666. /**
  21667. * Specifies the depth function that should be used. 0 means the default engine function
  21668. */
  21669. depthFunction: number;
  21670. /**
  21671. * Specifies if there should be a separate pass for culling
  21672. */
  21673. separateCullingPass: boolean;
  21674. /**
  21675. * Stores the state specifing if fog should be enabled
  21676. */
  21677. private _fogEnabled;
  21678. /**
  21679. * Sets the state for enabling fog
  21680. */
  21681. set fogEnabled(value: boolean);
  21682. /**
  21683. * Gets the value of the fog enabled state
  21684. */
  21685. get fogEnabled(): boolean;
  21686. /**
  21687. * Stores the size of points
  21688. */
  21689. pointSize: number;
  21690. /**
  21691. * Stores the z offset value
  21692. */
  21693. zOffset: number;
  21694. /**
  21695. * Gets a value specifying if wireframe mode is enabled
  21696. */
  21697. get wireframe(): boolean;
  21698. /**
  21699. * Sets the state of wireframe mode
  21700. */
  21701. set wireframe(value: boolean);
  21702. /**
  21703. * Gets the value specifying if point clouds are enabled
  21704. */
  21705. get pointsCloud(): boolean;
  21706. /**
  21707. * Sets the state of point cloud mode
  21708. */
  21709. set pointsCloud(value: boolean);
  21710. /**
  21711. * Gets the material fill mode
  21712. */
  21713. get fillMode(): number;
  21714. /**
  21715. * Sets the material fill mode
  21716. */
  21717. set fillMode(value: number);
  21718. /**
  21719. * @hidden
  21720. * Stores the effects for the material
  21721. */
  21722. _effect: Nullable<Effect>;
  21723. /**
  21724. * Specifies if uniform buffers should be used
  21725. */
  21726. private _useUBO;
  21727. /**
  21728. * Stores a reference to the scene
  21729. */
  21730. private _scene;
  21731. /**
  21732. * Stores the fill mode state
  21733. */
  21734. private _fillMode;
  21735. /**
  21736. * Specifies if the depth write state should be cached
  21737. */
  21738. private _cachedDepthWriteState;
  21739. /**
  21740. * Specifies if the depth function state should be cached
  21741. */
  21742. private _cachedDepthFunctionState;
  21743. /**
  21744. * Stores the uniform buffer
  21745. */
  21746. protected _uniformBuffer: UniformBuffer;
  21747. /** @hidden */
  21748. _indexInSceneMaterialArray: number;
  21749. /** @hidden */
  21750. meshMap: Nullable<{
  21751. [id: string]: AbstractMesh | undefined;
  21752. }>;
  21753. /**
  21754. * Creates a material instance
  21755. * @param name defines the name of the material
  21756. * @param scene defines the scene to reference
  21757. * @param doNotAdd specifies if the material should be added to the scene
  21758. */
  21759. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21760. /**
  21761. * Returns a string representation of the current material
  21762. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21763. * @returns a string with material information
  21764. */
  21765. toString(fullDetails?: boolean): string;
  21766. /**
  21767. * Gets the class name of the material
  21768. * @returns a string with the class name of the material
  21769. */
  21770. getClassName(): string;
  21771. /**
  21772. * Specifies if updates for the material been locked
  21773. */
  21774. get isFrozen(): boolean;
  21775. /**
  21776. * Locks updates for the material
  21777. */
  21778. freeze(): void;
  21779. /**
  21780. * Unlocks updates for the material
  21781. */
  21782. unfreeze(): void;
  21783. /**
  21784. * Specifies if the material is ready to be used
  21785. * @param mesh defines the mesh to check
  21786. * @param useInstances specifies if instances should be used
  21787. * @returns a boolean indicating if the material is ready to be used
  21788. */
  21789. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21790. /**
  21791. * Specifies that the submesh is ready to be used
  21792. * @param mesh defines the mesh to check
  21793. * @param subMesh defines which submesh to check
  21794. * @param useInstances specifies that instances should be used
  21795. * @returns a boolean indicating that the submesh is ready or not
  21796. */
  21797. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21798. /**
  21799. * Returns the material effect
  21800. * @returns the effect associated with the material
  21801. */
  21802. getEffect(): Nullable<Effect>;
  21803. /**
  21804. * Returns the current scene
  21805. * @returns a Scene
  21806. */
  21807. getScene(): Scene;
  21808. /**
  21809. * Specifies if the material will require alpha blending
  21810. * @returns a boolean specifying if alpha blending is needed
  21811. */
  21812. needAlphaBlending(): boolean;
  21813. /**
  21814. * Specifies if the mesh will require alpha blending
  21815. * @param mesh defines the mesh to check
  21816. * @returns a boolean specifying if alpha blending is needed for the mesh
  21817. */
  21818. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21819. /**
  21820. * Specifies if this material should be rendered in alpha test mode
  21821. * @returns a boolean specifying if an alpha test is needed.
  21822. */
  21823. needAlphaTesting(): boolean;
  21824. /**
  21825. * Gets the texture used for the alpha test
  21826. * @returns the texture to use for alpha testing
  21827. */
  21828. getAlphaTestTexture(): Nullable<BaseTexture>;
  21829. /**
  21830. * Marks the material to indicate that it needs to be re-calculated
  21831. */
  21832. markDirty(): void;
  21833. /** @hidden */
  21834. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21835. /**
  21836. * Binds the material to the mesh
  21837. * @param world defines the world transformation matrix
  21838. * @param mesh defines the mesh to bind the material to
  21839. */
  21840. bind(world: Matrix, mesh?: Mesh): void;
  21841. /**
  21842. * Binds the submesh to the material
  21843. * @param world defines the world transformation matrix
  21844. * @param mesh defines the mesh containing the submesh
  21845. * @param subMesh defines the submesh to bind the material to
  21846. */
  21847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21848. /**
  21849. * Binds the world matrix to the material
  21850. * @param world defines the world transformation matrix
  21851. */
  21852. bindOnlyWorldMatrix(world: Matrix): void;
  21853. /**
  21854. * Binds the scene's uniform buffer to the effect.
  21855. * @param effect defines the effect to bind to the scene uniform buffer
  21856. * @param sceneUbo defines the uniform buffer storing scene data
  21857. */
  21858. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21859. /**
  21860. * Binds the view matrix to the effect
  21861. * @param effect defines the effect to bind the view matrix to
  21862. */
  21863. bindView(effect: Effect): void;
  21864. /**
  21865. * Binds the view projection matrix to the effect
  21866. * @param effect defines the effect to bind the view projection matrix to
  21867. */
  21868. bindViewProjection(effect: Effect): void;
  21869. /**
  21870. * Specifies if material alpha testing should be turned on for the mesh
  21871. * @param mesh defines the mesh to check
  21872. */
  21873. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21874. /**
  21875. * Processes to execute after binding the material to a mesh
  21876. * @param mesh defines the rendered mesh
  21877. */
  21878. protected _afterBind(mesh?: Mesh): void;
  21879. /**
  21880. * Unbinds the material from the mesh
  21881. */
  21882. unbind(): void;
  21883. /**
  21884. * Gets the active textures from the material
  21885. * @returns an array of textures
  21886. */
  21887. getActiveTextures(): BaseTexture[];
  21888. /**
  21889. * Specifies if the material uses a texture
  21890. * @param texture defines the texture to check against the material
  21891. * @returns a boolean specifying if the material uses the texture
  21892. */
  21893. hasTexture(texture: BaseTexture): boolean;
  21894. /**
  21895. * Makes a duplicate of the material, and gives it a new name
  21896. * @param name defines the new name for the duplicated material
  21897. * @returns the cloned material
  21898. */
  21899. clone(name: string): Nullable<Material>;
  21900. /**
  21901. * Gets the meshes bound to the material
  21902. * @returns an array of meshes bound to the material
  21903. */
  21904. getBindedMeshes(): AbstractMesh[];
  21905. /**
  21906. * Force shader compilation
  21907. * @param mesh defines the mesh associated with this material
  21908. * @param onCompiled defines a function to execute once the material is compiled
  21909. * @param options defines the options to configure the compilation
  21910. * @param onError defines a function to execute if the material fails compiling
  21911. */
  21912. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21913. /**
  21914. * Force shader compilation
  21915. * @param mesh defines the mesh that will use this material
  21916. * @param options defines additional options for compiling the shaders
  21917. * @returns a promise that resolves when the compilation completes
  21918. */
  21919. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21920. private static readonly _AllDirtyCallBack;
  21921. private static readonly _ImageProcessingDirtyCallBack;
  21922. private static readonly _TextureDirtyCallBack;
  21923. private static readonly _FresnelDirtyCallBack;
  21924. private static readonly _MiscDirtyCallBack;
  21925. private static readonly _LightsDirtyCallBack;
  21926. private static readonly _AttributeDirtyCallBack;
  21927. private static _FresnelAndMiscDirtyCallBack;
  21928. private static _TextureAndMiscDirtyCallBack;
  21929. private static readonly _DirtyCallbackArray;
  21930. private static readonly _RunDirtyCallBacks;
  21931. /**
  21932. * Marks a define in the material to indicate that it needs to be re-computed
  21933. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21934. */
  21935. markAsDirty(flag: number): void;
  21936. /**
  21937. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21938. * @param func defines a function which checks material defines against the submeshes
  21939. */
  21940. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21941. /**
  21942. * Indicates that we need to re-calculated for all submeshes
  21943. */
  21944. protected _markAllSubMeshesAsAllDirty(): void;
  21945. /**
  21946. * Indicates that image processing needs to be re-calculated for all submeshes
  21947. */
  21948. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21949. /**
  21950. * Indicates that textures need to be re-calculated for all submeshes
  21951. */
  21952. protected _markAllSubMeshesAsTexturesDirty(): void;
  21953. /**
  21954. * Indicates that fresnel needs to be re-calculated for all submeshes
  21955. */
  21956. protected _markAllSubMeshesAsFresnelDirty(): void;
  21957. /**
  21958. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21959. */
  21960. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21961. /**
  21962. * Indicates that lights need to be re-calculated for all submeshes
  21963. */
  21964. protected _markAllSubMeshesAsLightsDirty(): void;
  21965. /**
  21966. * Indicates that attributes need to be re-calculated for all submeshes
  21967. */
  21968. protected _markAllSubMeshesAsAttributesDirty(): void;
  21969. /**
  21970. * Indicates that misc needs to be re-calculated for all submeshes
  21971. */
  21972. protected _markAllSubMeshesAsMiscDirty(): void;
  21973. /**
  21974. * Indicates that textures and misc need to be re-calculated for all submeshes
  21975. */
  21976. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21977. /**
  21978. * Disposes the material
  21979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21981. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21982. */
  21983. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21984. /** @hidden */
  21985. private releaseVertexArrayObject;
  21986. /**
  21987. * Serializes this material
  21988. * @returns the serialized material object
  21989. */
  21990. serialize(): any;
  21991. /**
  21992. * Creates a material from parsed material data
  21993. * @param parsedMaterial defines parsed material data
  21994. * @param scene defines the hosting scene
  21995. * @param rootUrl defines the root URL to use to load textures
  21996. * @returns a new material
  21997. */
  21998. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21999. }
  22000. }
  22001. declare module "babylonjs/Materials/multiMaterial" {
  22002. import { Nullable } from "babylonjs/types";
  22003. import { Scene } from "babylonjs/scene";
  22004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22005. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22007. import { Material } from "babylonjs/Materials/material";
  22008. /**
  22009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22010. * separate meshes. This can be use to improve performances.
  22011. * @see http://doc.babylonjs.com/how_to/multi_materials
  22012. */
  22013. export class MultiMaterial extends Material {
  22014. private _subMaterials;
  22015. /**
  22016. * Gets or Sets the list of Materials used within the multi material.
  22017. * They need to be ordered according to the submeshes order in the associated mesh
  22018. */
  22019. get subMaterials(): Nullable<Material>[];
  22020. set subMaterials(value: Nullable<Material>[]);
  22021. /**
  22022. * Function used to align with Node.getChildren()
  22023. * @returns the list of Materials used within the multi material
  22024. */
  22025. getChildren(): Nullable<Material>[];
  22026. /**
  22027. * Instantiates a new Multi Material
  22028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22029. * separate meshes. This can be use to improve performances.
  22030. * @see http://doc.babylonjs.com/how_to/multi_materials
  22031. * @param name Define the name in the scene
  22032. * @param scene Define the scene the material belongs to
  22033. */
  22034. constructor(name: string, scene: Scene);
  22035. private _hookArray;
  22036. /**
  22037. * Get one of the submaterial by its index in the submaterials array
  22038. * @param index The index to look the sub material at
  22039. * @returns The Material if the index has been defined
  22040. */
  22041. getSubMaterial(index: number): Nullable<Material>;
  22042. /**
  22043. * Get the list of active textures for the whole sub materials list.
  22044. * @returns All the textures that will be used during the rendering
  22045. */
  22046. getActiveTextures(): BaseTexture[];
  22047. /**
  22048. * Gets the current class name of the material e.g. "MultiMaterial"
  22049. * Mainly use in serialization.
  22050. * @returns the class name
  22051. */
  22052. getClassName(): string;
  22053. /**
  22054. * Checks if the material is ready to render the requested sub mesh
  22055. * @param mesh Define the mesh the submesh belongs to
  22056. * @param subMesh Define the sub mesh to look readyness for
  22057. * @param useInstances Define whether or not the material is used with instances
  22058. * @returns true if ready, otherwise false
  22059. */
  22060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22061. /**
  22062. * Clones the current material and its related sub materials
  22063. * @param name Define the name of the newly cloned material
  22064. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22065. * @returns the cloned material
  22066. */
  22067. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22068. /**
  22069. * Serializes the materials into a JSON representation.
  22070. * @returns the JSON representation
  22071. */
  22072. serialize(): any;
  22073. /**
  22074. * Dispose the material and release its associated resources
  22075. * @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)
  22076. * @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)
  22077. * @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)
  22078. */
  22079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22080. /**
  22081. * Creates a MultiMaterial from parsed MultiMaterial data.
  22082. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22083. * @param scene defines the hosting scene
  22084. * @returns a new MultiMaterial
  22085. */
  22086. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22087. }
  22088. }
  22089. declare module "babylonjs/Meshes/subMesh" {
  22090. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22092. import { Engine } from "babylonjs/Engines/engine";
  22093. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22094. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22095. import { Effect } from "babylonjs/Materials/effect";
  22096. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22097. import { Plane } from "babylonjs/Maths/math.plane";
  22098. import { Collider } from "babylonjs/Collisions/collider";
  22099. import { Material } from "babylonjs/Materials/material";
  22100. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22102. import { Mesh } from "babylonjs/Meshes/mesh";
  22103. import { Ray } from "babylonjs/Culling/ray";
  22104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22105. /**
  22106. * Base class for submeshes
  22107. */
  22108. export class BaseSubMesh {
  22109. /** @hidden */
  22110. _materialDefines: Nullable<MaterialDefines>;
  22111. /** @hidden */
  22112. _materialEffect: Nullable<Effect>;
  22113. /**
  22114. * Gets material defines used by the effect associated to the sub mesh
  22115. */
  22116. get materialDefines(): Nullable<MaterialDefines>;
  22117. /**
  22118. * Sets material defines used by the effect associated to the sub mesh
  22119. */
  22120. set materialDefines(defines: Nullable<MaterialDefines>);
  22121. /**
  22122. * Gets associated effect
  22123. */
  22124. get effect(): Nullable<Effect>;
  22125. /**
  22126. * Sets associated effect (effect used to render this submesh)
  22127. * @param effect defines the effect to associate with
  22128. * @param defines defines the set of defines used to compile this effect
  22129. */
  22130. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22131. }
  22132. /**
  22133. * Defines a subdivision inside a mesh
  22134. */
  22135. export class SubMesh extends BaseSubMesh implements ICullable {
  22136. /** the material index to use */
  22137. materialIndex: number;
  22138. /** vertex index start */
  22139. verticesStart: number;
  22140. /** vertices count */
  22141. verticesCount: number;
  22142. /** index start */
  22143. indexStart: number;
  22144. /** indices count */
  22145. indexCount: number;
  22146. /** @hidden */
  22147. _linesIndexCount: number;
  22148. private _mesh;
  22149. private _renderingMesh;
  22150. private _boundingInfo;
  22151. private _linesIndexBuffer;
  22152. /** @hidden */
  22153. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22154. /** @hidden */
  22155. _trianglePlanes: Plane[];
  22156. /** @hidden */
  22157. _lastColliderTransformMatrix: Nullable<Matrix>;
  22158. /** @hidden */
  22159. _renderId: number;
  22160. /** @hidden */
  22161. _alphaIndex: number;
  22162. /** @hidden */
  22163. _distanceToCamera: number;
  22164. /** @hidden */
  22165. _id: number;
  22166. private _currentMaterial;
  22167. /**
  22168. * Add a new submesh to a mesh
  22169. * @param materialIndex defines the material index to use
  22170. * @param verticesStart defines vertex index start
  22171. * @param verticesCount defines vertices count
  22172. * @param indexStart defines index start
  22173. * @param indexCount defines indices count
  22174. * @param mesh defines the parent mesh
  22175. * @param renderingMesh defines an optional rendering mesh
  22176. * @param createBoundingBox defines if bounding box should be created for this submesh
  22177. * @returns the new submesh
  22178. */
  22179. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22180. /**
  22181. * Creates a new submesh
  22182. * @param materialIndex defines the material index to use
  22183. * @param verticesStart defines vertex index start
  22184. * @param verticesCount defines vertices count
  22185. * @param indexStart defines index start
  22186. * @param indexCount defines indices count
  22187. * @param mesh defines the parent mesh
  22188. * @param renderingMesh defines an optional rendering mesh
  22189. * @param createBoundingBox defines if bounding box should be created for this submesh
  22190. */
  22191. constructor(
  22192. /** the material index to use */
  22193. materialIndex: number,
  22194. /** vertex index start */
  22195. verticesStart: number,
  22196. /** vertices count */
  22197. verticesCount: number,
  22198. /** index start */
  22199. indexStart: number,
  22200. /** indices count */
  22201. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22202. /**
  22203. * Returns true if this submesh covers the entire parent mesh
  22204. * @ignorenaming
  22205. */
  22206. get IsGlobal(): boolean;
  22207. /**
  22208. * Returns the submesh BoudingInfo object
  22209. * @returns current bounding info (or mesh's one if the submesh is global)
  22210. */
  22211. getBoundingInfo(): BoundingInfo;
  22212. /**
  22213. * Sets the submesh BoundingInfo
  22214. * @param boundingInfo defines the new bounding info to use
  22215. * @returns the SubMesh
  22216. */
  22217. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22218. /**
  22219. * Returns the mesh of the current submesh
  22220. * @return the parent mesh
  22221. */
  22222. getMesh(): AbstractMesh;
  22223. /**
  22224. * Returns the rendering mesh of the submesh
  22225. * @returns the rendering mesh (could be different from parent mesh)
  22226. */
  22227. getRenderingMesh(): Mesh;
  22228. /**
  22229. * Returns the submesh material
  22230. * @returns null or the current material
  22231. */
  22232. getMaterial(): Nullable<Material>;
  22233. /**
  22234. * Sets a new updated BoundingInfo object to the submesh
  22235. * @param data defines an optional position array to use to determine the bounding info
  22236. * @returns the SubMesh
  22237. */
  22238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22239. /** @hidden */
  22240. _checkCollision(collider: Collider): boolean;
  22241. /**
  22242. * Updates the submesh BoundingInfo
  22243. * @param world defines the world matrix to use to update the bounding info
  22244. * @returns the submesh
  22245. */
  22246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22247. /**
  22248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22249. * @param frustumPlanes defines the frustum planes
  22250. * @returns true if the submesh is intersecting with the frustum
  22251. */
  22252. isInFrustum(frustumPlanes: Plane[]): boolean;
  22253. /**
  22254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22255. * @param frustumPlanes defines the frustum planes
  22256. * @returns true if the submesh is inside the frustum
  22257. */
  22258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22259. /**
  22260. * Renders the submesh
  22261. * @param enableAlphaMode defines if alpha needs to be used
  22262. * @returns the submesh
  22263. */
  22264. render(enableAlphaMode: boolean): SubMesh;
  22265. /**
  22266. * @hidden
  22267. */
  22268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22269. /**
  22270. * Checks if the submesh intersects with a ray
  22271. * @param ray defines the ray to test
  22272. * @returns true is the passed ray intersects the submesh bounding box
  22273. */
  22274. canIntersects(ray: Ray): boolean;
  22275. /**
  22276. * Intersects current submesh with a ray
  22277. * @param ray defines the ray to test
  22278. * @param positions defines mesh's positions array
  22279. * @param indices defines mesh's indices array
  22280. * @param fastCheck defines if only bounding info should be used
  22281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22282. * @returns intersection info or null if no intersection
  22283. */
  22284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22285. /** @hidden */
  22286. private _intersectLines;
  22287. /** @hidden */
  22288. private _intersectUnIndexedLines;
  22289. /** @hidden */
  22290. private _intersectTriangles;
  22291. /** @hidden */
  22292. private _intersectUnIndexedTriangles;
  22293. /** @hidden */
  22294. _rebuild(): void;
  22295. /**
  22296. * Creates a new submesh from the passed mesh
  22297. * @param newMesh defines the new hosting mesh
  22298. * @param newRenderingMesh defines an optional rendering mesh
  22299. * @returns the new submesh
  22300. */
  22301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22302. /**
  22303. * Release associated resources
  22304. */
  22305. dispose(): void;
  22306. /**
  22307. * Gets the class name
  22308. * @returns the string "SubMesh".
  22309. */
  22310. getClassName(): string;
  22311. /**
  22312. * Creates a new submesh from indices data
  22313. * @param materialIndex the index of the main mesh material
  22314. * @param startIndex the index where to start the copy in the mesh indices array
  22315. * @param indexCount the number of indices to copy then from the startIndex
  22316. * @param mesh the main mesh to create the submesh from
  22317. * @param renderingMesh the optional rendering mesh
  22318. * @returns a new submesh
  22319. */
  22320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22321. }
  22322. }
  22323. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22324. /**
  22325. * Class used to represent data loading progression
  22326. */
  22327. export class SceneLoaderFlags {
  22328. private static _ForceFullSceneLoadingForIncremental;
  22329. private static _ShowLoadingScreen;
  22330. private static _CleanBoneMatrixWeights;
  22331. private static _loggingLevel;
  22332. /**
  22333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22334. */
  22335. static get ForceFullSceneLoadingForIncremental(): boolean;
  22336. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22337. /**
  22338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22339. */
  22340. static get ShowLoadingScreen(): boolean;
  22341. static set ShowLoadingScreen(value: boolean);
  22342. /**
  22343. * Defines the current logging level (while loading the scene)
  22344. * @ignorenaming
  22345. */
  22346. static get loggingLevel(): number;
  22347. static set loggingLevel(value: number);
  22348. /**
  22349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22350. */
  22351. static get CleanBoneMatrixWeights(): boolean;
  22352. static set CleanBoneMatrixWeights(value: boolean);
  22353. }
  22354. }
  22355. declare module "babylonjs/Meshes/geometry" {
  22356. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22357. import { Scene } from "babylonjs/scene";
  22358. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22359. import { Engine } from "babylonjs/Engines/engine";
  22360. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22361. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22362. import { Effect } from "babylonjs/Materials/effect";
  22363. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22365. import { Mesh } from "babylonjs/Meshes/mesh";
  22366. /**
  22367. * Class used to store geometry data (vertex buffers + index buffer)
  22368. */
  22369. export class Geometry implements IGetSetVerticesData {
  22370. /**
  22371. * Gets or sets the ID of the geometry
  22372. */
  22373. id: string;
  22374. /**
  22375. * Gets or sets the unique ID of the geometry
  22376. */
  22377. uniqueId: number;
  22378. /**
  22379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22380. */
  22381. delayLoadState: number;
  22382. /**
  22383. * Gets the file containing the data to load when running in delay load state
  22384. */
  22385. delayLoadingFile: Nullable<string>;
  22386. /**
  22387. * Callback called when the geometry is updated
  22388. */
  22389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22390. private _scene;
  22391. private _engine;
  22392. private _meshes;
  22393. private _totalVertices;
  22394. /** @hidden */
  22395. _indices: IndicesArray;
  22396. /** @hidden */
  22397. _vertexBuffers: {
  22398. [key: string]: VertexBuffer;
  22399. };
  22400. private _isDisposed;
  22401. private _extend;
  22402. private _boundingBias;
  22403. /** @hidden */
  22404. _delayInfo: Array<string>;
  22405. private _indexBuffer;
  22406. private _indexBufferIsUpdatable;
  22407. /** @hidden */
  22408. _boundingInfo: Nullable<BoundingInfo>;
  22409. /** @hidden */
  22410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22411. /** @hidden */
  22412. _softwareSkinningFrameId: number;
  22413. private _vertexArrayObjects;
  22414. private _updatable;
  22415. /** @hidden */
  22416. _positions: Nullable<Vector3[]>;
  22417. /**
  22418. * 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
  22419. */
  22420. get boundingBias(): Vector2;
  22421. /**
  22422. * 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
  22423. */
  22424. set boundingBias(value: Vector2);
  22425. /**
  22426. * Static function used to attach a new empty geometry to a mesh
  22427. * @param mesh defines the mesh to attach the geometry to
  22428. * @returns the new Geometry
  22429. */
  22430. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22431. /**
  22432. * Creates a new geometry
  22433. * @param id defines the unique ID
  22434. * @param scene defines the hosting scene
  22435. * @param vertexData defines the VertexData used to get geometry data
  22436. * @param updatable defines if geometry must be updatable (false by default)
  22437. * @param mesh defines the mesh that will be associated with the geometry
  22438. */
  22439. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22440. /**
  22441. * Gets the current extend of the geometry
  22442. */
  22443. get extend(): {
  22444. minimum: Vector3;
  22445. maximum: Vector3;
  22446. };
  22447. /**
  22448. * Gets the hosting scene
  22449. * @returns the hosting Scene
  22450. */
  22451. getScene(): Scene;
  22452. /**
  22453. * Gets the hosting engine
  22454. * @returns the hosting Engine
  22455. */
  22456. getEngine(): Engine;
  22457. /**
  22458. * Defines if the geometry is ready to use
  22459. * @returns true if the geometry is ready to be used
  22460. */
  22461. isReady(): boolean;
  22462. /**
  22463. * Gets a value indicating that the geometry should not be serialized
  22464. */
  22465. get doNotSerialize(): boolean;
  22466. /** @hidden */
  22467. _rebuild(): void;
  22468. /**
  22469. * Affects all geometry data in one call
  22470. * @param vertexData defines the geometry data
  22471. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22472. */
  22473. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22474. /**
  22475. * Set specific vertex data
  22476. * @param kind defines the data kind (Position, normal, etc...)
  22477. * @param data defines the vertex data to use
  22478. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22479. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22480. */
  22481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22482. /**
  22483. * Removes a specific vertex data
  22484. * @param kind defines the data kind (Position, normal, etc...)
  22485. */
  22486. removeVerticesData(kind: string): void;
  22487. /**
  22488. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22489. * @param buffer defines the vertex buffer to use
  22490. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22491. */
  22492. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22493. /**
  22494. * Update a specific vertex buffer
  22495. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22496. * It will do nothing if the buffer is not updatable
  22497. * @param kind defines the data kind (Position, normal, etc...)
  22498. * @param data defines the data to use
  22499. * @param offset defines the offset in the target buffer where to store the data
  22500. * @param useBytes set to true if the offset is in bytes
  22501. */
  22502. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22503. /**
  22504. * Update a specific vertex buffer
  22505. * This function will create a new buffer if the current one is not updatable
  22506. * @param kind defines the data kind (Position, normal, etc...)
  22507. * @param data defines the data to use
  22508. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22509. */
  22510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22511. private _updateBoundingInfo;
  22512. /** @hidden */
  22513. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22514. /**
  22515. * Gets total number of vertices
  22516. * @returns the total number of vertices
  22517. */
  22518. getTotalVertices(): number;
  22519. /**
  22520. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22521. * @param kind defines the data kind (Position, normal, etc...)
  22522. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22523. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22524. * @returns a float array containing vertex data
  22525. */
  22526. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22527. /**
  22528. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22529. * @param kind defines the data kind (Position, normal, etc...)
  22530. * @returns true if the vertex buffer with the specified kind is updatable
  22531. */
  22532. isVertexBufferUpdatable(kind: string): boolean;
  22533. /**
  22534. * Gets a specific vertex buffer
  22535. * @param kind defines the data kind (Position, normal, etc...)
  22536. * @returns a VertexBuffer
  22537. */
  22538. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22539. /**
  22540. * Returns all vertex buffers
  22541. * @return an object holding all vertex buffers indexed by kind
  22542. */
  22543. getVertexBuffers(): Nullable<{
  22544. [key: string]: VertexBuffer;
  22545. }>;
  22546. /**
  22547. * Gets a boolean indicating if specific vertex buffer is present
  22548. * @param kind defines the data kind (Position, normal, etc...)
  22549. * @returns true if data is present
  22550. */
  22551. isVerticesDataPresent(kind: string): boolean;
  22552. /**
  22553. * Gets a list of all attached data kinds (Position, normal, etc...)
  22554. * @returns a list of string containing all kinds
  22555. */
  22556. getVerticesDataKinds(): string[];
  22557. /**
  22558. * Update index buffer
  22559. * @param indices defines the indices to store in the index buffer
  22560. * @param offset defines the offset in the target buffer where to store the data
  22561. * @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)
  22562. */
  22563. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22564. /**
  22565. * Creates a new index buffer
  22566. * @param indices defines the indices to store in the index buffer
  22567. * @param totalVertices defines the total number of vertices (could be null)
  22568. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22569. */
  22570. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22571. /**
  22572. * Return the total number of indices
  22573. * @returns the total number of indices
  22574. */
  22575. getTotalIndices(): number;
  22576. /**
  22577. * Gets the index buffer array
  22578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22580. * @returns the index buffer array
  22581. */
  22582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22583. /**
  22584. * Gets the index buffer
  22585. * @return the index buffer
  22586. */
  22587. getIndexBuffer(): Nullable<DataBuffer>;
  22588. /** @hidden */
  22589. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22590. /**
  22591. * Release the associated resources for a specific mesh
  22592. * @param mesh defines the source mesh
  22593. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22594. */
  22595. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22596. /**
  22597. * Apply current geometry to a given mesh
  22598. * @param mesh defines the mesh to apply geometry to
  22599. */
  22600. applyToMesh(mesh: Mesh): void;
  22601. private _updateExtend;
  22602. private _applyToMesh;
  22603. private notifyUpdate;
  22604. /**
  22605. * Load the geometry if it was flagged as delay loaded
  22606. * @param scene defines the hosting scene
  22607. * @param onLoaded defines a callback called when the geometry is loaded
  22608. */
  22609. load(scene: Scene, onLoaded?: () => void): void;
  22610. private _queueLoad;
  22611. /**
  22612. * Invert the geometry to move from a right handed system to a left handed one.
  22613. */
  22614. toLeftHanded(): void;
  22615. /** @hidden */
  22616. _resetPointsArrayCache(): void;
  22617. /** @hidden */
  22618. _generatePointsArray(): boolean;
  22619. /**
  22620. * Gets a value indicating if the geometry is disposed
  22621. * @returns true if the geometry was disposed
  22622. */
  22623. isDisposed(): boolean;
  22624. private _disposeVertexArrayObjects;
  22625. /**
  22626. * Free all associated resources
  22627. */
  22628. dispose(): void;
  22629. /**
  22630. * Clone the current geometry into a new geometry
  22631. * @param id defines the unique ID of the new geometry
  22632. * @returns a new geometry object
  22633. */
  22634. copy(id: string): Geometry;
  22635. /**
  22636. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22637. * @return a JSON representation of the current geometry data (without the vertices data)
  22638. */
  22639. serialize(): any;
  22640. private toNumberArray;
  22641. /**
  22642. * Serialize all vertices data into a JSON oject
  22643. * @returns a JSON representation of the current geometry data
  22644. */
  22645. serializeVerticeData(): any;
  22646. /**
  22647. * Extracts a clone of a mesh geometry
  22648. * @param mesh defines the source mesh
  22649. * @param id defines the unique ID of the new geometry object
  22650. * @returns the new geometry object
  22651. */
  22652. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22653. /**
  22654. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22655. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22656. * Be aware Math.random() could cause collisions, but:
  22657. * "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"
  22658. * @returns a string containing a new GUID
  22659. */
  22660. static RandomId(): string;
  22661. /** @hidden */
  22662. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22663. private static _CleanMatricesWeights;
  22664. /**
  22665. * Create a new geometry from persisted data (Using .babylon file format)
  22666. * @param parsedVertexData defines the persisted data
  22667. * @param scene defines the hosting scene
  22668. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22669. * @returns the new geometry object
  22670. */
  22671. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22672. }
  22673. }
  22674. declare module "babylonjs/Meshes/mesh.vertexData" {
  22675. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22676. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22677. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22678. import { Geometry } from "babylonjs/Meshes/geometry";
  22679. import { Mesh } from "babylonjs/Meshes/mesh";
  22680. /**
  22681. * Define an interface for all classes that will get and set the data on vertices
  22682. */
  22683. export interface IGetSetVerticesData {
  22684. /**
  22685. * Gets a boolean indicating if specific vertex data is present
  22686. * @param kind defines the vertex data kind to use
  22687. * @returns true is data kind is present
  22688. */
  22689. isVerticesDataPresent(kind: string): boolean;
  22690. /**
  22691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22692. * @param kind defines the data kind (Position, normal, etc...)
  22693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22695. * @returns a float array containing vertex data
  22696. */
  22697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22698. /**
  22699. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22700. * @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.
  22701. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22702. * @returns the indices array or an empty array if the mesh has no geometry
  22703. */
  22704. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22705. /**
  22706. * Set specific vertex data
  22707. * @param kind defines the data kind (Position, normal, etc...)
  22708. * @param data defines the vertex data to use
  22709. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22710. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22711. */
  22712. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22713. /**
  22714. * Update a specific associated vertex buffer
  22715. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22716. * - VertexBuffer.PositionKind
  22717. * - VertexBuffer.UVKind
  22718. * - VertexBuffer.UV2Kind
  22719. * - VertexBuffer.UV3Kind
  22720. * - VertexBuffer.UV4Kind
  22721. * - VertexBuffer.UV5Kind
  22722. * - VertexBuffer.UV6Kind
  22723. * - VertexBuffer.ColorKind
  22724. * - VertexBuffer.MatricesIndicesKind
  22725. * - VertexBuffer.MatricesIndicesExtraKind
  22726. * - VertexBuffer.MatricesWeightsKind
  22727. * - VertexBuffer.MatricesWeightsExtraKind
  22728. * @param data defines the data source
  22729. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22730. * @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)
  22731. */
  22732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22733. /**
  22734. * Creates a new index buffer
  22735. * @param indices defines the indices to store in the index buffer
  22736. * @param totalVertices defines the total number of vertices (could be null)
  22737. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22738. */
  22739. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22740. }
  22741. /**
  22742. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22743. */
  22744. export class VertexData {
  22745. /**
  22746. * Mesh side orientation : usually the external or front surface
  22747. */
  22748. static readonly FRONTSIDE: number;
  22749. /**
  22750. * Mesh side orientation : usually the internal or back surface
  22751. */
  22752. static readonly BACKSIDE: number;
  22753. /**
  22754. * Mesh side orientation : both internal and external or front and back surfaces
  22755. */
  22756. static readonly DOUBLESIDE: number;
  22757. /**
  22758. * Mesh side orientation : by default, `FRONTSIDE`
  22759. */
  22760. static readonly DEFAULTSIDE: number;
  22761. /**
  22762. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22763. */
  22764. positions: Nullable<FloatArray>;
  22765. /**
  22766. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22767. */
  22768. normals: Nullable<FloatArray>;
  22769. /**
  22770. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22771. */
  22772. tangents: Nullable<FloatArray>;
  22773. /**
  22774. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22775. */
  22776. uvs: Nullable<FloatArray>;
  22777. /**
  22778. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22779. */
  22780. uvs2: Nullable<FloatArray>;
  22781. /**
  22782. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22783. */
  22784. uvs3: Nullable<FloatArray>;
  22785. /**
  22786. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22787. */
  22788. uvs4: Nullable<FloatArray>;
  22789. /**
  22790. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22791. */
  22792. uvs5: Nullable<FloatArray>;
  22793. /**
  22794. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22795. */
  22796. uvs6: Nullable<FloatArray>;
  22797. /**
  22798. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22799. */
  22800. colors: Nullable<FloatArray>;
  22801. /**
  22802. * 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).
  22803. */
  22804. matricesIndices: Nullable<FloatArray>;
  22805. /**
  22806. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22807. */
  22808. matricesWeights: Nullable<FloatArray>;
  22809. /**
  22810. * An array extending the number of possible indices
  22811. */
  22812. matricesIndicesExtra: Nullable<FloatArray>;
  22813. /**
  22814. * An array extending the number of possible weights when the number of indices is extended
  22815. */
  22816. matricesWeightsExtra: Nullable<FloatArray>;
  22817. /**
  22818. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22819. */
  22820. indices: Nullable<IndicesArray>;
  22821. /**
  22822. * Uses the passed data array to set the set the values for the specified kind of data
  22823. * @param data a linear array of floating numbers
  22824. * @param kind the type of data that is being set, eg positions, colors etc
  22825. */
  22826. set(data: FloatArray, kind: string): void;
  22827. /**
  22828. * Associates the vertexData to the passed Mesh.
  22829. * Sets it as updatable or not (default `false`)
  22830. * @param mesh the mesh the vertexData is applied to
  22831. * @param updatable when used and having the value true allows new data to update the vertexData
  22832. * @returns the VertexData
  22833. */
  22834. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22835. /**
  22836. * Associates the vertexData to the passed Geometry.
  22837. * Sets it as updatable or not (default `false`)
  22838. * @param geometry the geometry the vertexData is applied to
  22839. * @param updatable when used and having the value true allows new data to update the vertexData
  22840. * @returns VertexData
  22841. */
  22842. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22843. /**
  22844. * Updates the associated mesh
  22845. * @param mesh the mesh to be updated
  22846. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22847. * @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
  22848. * @returns VertexData
  22849. */
  22850. updateMesh(mesh: Mesh): VertexData;
  22851. /**
  22852. * Updates the associated geometry
  22853. * @param geometry the geometry to be updated
  22854. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22855. * @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
  22856. * @returns VertexData.
  22857. */
  22858. updateGeometry(geometry: Geometry): VertexData;
  22859. private _applyTo;
  22860. private _update;
  22861. /**
  22862. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22863. * @param matrix the transforming matrix
  22864. * @returns the VertexData
  22865. */
  22866. transform(matrix: Matrix): VertexData;
  22867. /**
  22868. * Merges the passed VertexData into the current one
  22869. * @param other the VertexData to be merged into the current one
  22870. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22871. * @returns the modified VertexData
  22872. */
  22873. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22874. private _mergeElement;
  22875. private _validate;
  22876. /**
  22877. * Serializes the VertexData
  22878. * @returns a serialized object
  22879. */
  22880. serialize(): any;
  22881. /**
  22882. * Extracts the vertexData from a mesh
  22883. * @param mesh the mesh from which to extract the VertexData
  22884. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22885. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22886. * @returns the object VertexData associated to the passed mesh
  22887. */
  22888. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22889. /**
  22890. * Extracts the vertexData from the geometry
  22891. * @param geometry the geometry from which to extract the VertexData
  22892. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22893. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22894. * @returns the object VertexData associated to the passed mesh
  22895. */
  22896. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22897. private static _ExtractFrom;
  22898. /**
  22899. * Creates the VertexData for a Ribbon
  22900. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22901. * * pathArray array of paths, each of which an array of successive Vector3
  22902. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22903. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22904. * * 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
  22905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22906. * * 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)
  22907. * * 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)
  22908. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22909. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22910. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22911. * @returns the VertexData of the ribbon
  22912. */
  22913. static CreateRibbon(options: {
  22914. pathArray: Vector3[][];
  22915. closeArray?: boolean;
  22916. closePath?: boolean;
  22917. offset?: number;
  22918. sideOrientation?: number;
  22919. frontUVs?: Vector4;
  22920. backUVs?: Vector4;
  22921. invertUV?: boolean;
  22922. uvs?: Vector2[];
  22923. colors?: Color4[];
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22929. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22930. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22931. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22932. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22933. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the box
  22938. */
  22939. static CreateBox(options: {
  22940. size?: number;
  22941. width?: number;
  22942. height?: number;
  22943. depth?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. frontUVs?: Vector4;
  22948. backUVs?: Vector4;
  22949. }): VertexData;
  22950. /**
  22951. * Creates the VertexData for a tiled box
  22952. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22953. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22954. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22955. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22957. * @returns the VertexData of the box
  22958. */
  22959. static CreateTiledBox(options: {
  22960. pattern?: number;
  22961. width?: number;
  22962. height?: number;
  22963. depth?: number;
  22964. tileSize?: number;
  22965. tileWidth?: number;
  22966. tileHeight?: number;
  22967. alignHorizontal?: number;
  22968. alignVertical?: number;
  22969. faceUV?: Vector4[];
  22970. faceColors?: Color4[];
  22971. sideOrientation?: number;
  22972. }): VertexData;
  22973. /**
  22974. * Creates the VertexData for a tiled plane
  22975. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22976. * * pattern a limited pattern arrangement depending on the number
  22977. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22978. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22979. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22981. * * 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)
  22982. * * 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)
  22983. * @returns the VertexData of the tiled plane
  22984. */
  22985. static CreateTiledPlane(options: {
  22986. pattern?: number;
  22987. tileSize?: number;
  22988. tileWidth?: number;
  22989. tileHeight?: number;
  22990. size?: number;
  22991. width?: number;
  22992. height?: number;
  22993. alignHorizontal?: number;
  22994. alignVertical?: number;
  22995. sideOrientation?: number;
  22996. frontUVs?: Vector4;
  22997. backUVs?: Vector4;
  22998. }): VertexData;
  22999. /**
  23000. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23002. * * segments sets the number of horizontal strips optional, default 32
  23003. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23004. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23005. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23006. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23007. * * 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
  23008. * * 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
  23009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23010. * * 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)
  23011. * * 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)
  23012. * @returns the VertexData of the ellipsoid
  23013. */
  23014. static CreateSphere(options: {
  23015. segments?: number;
  23016. diameter?: number;
  23017. diameterX?: number;
  23018. diameterY?: number;
  23019. diameterZ?: number;
  23020. arc?: number;
  23021. slice?: number;
  23022. sideOrientation?: number;
  23023. frontUVs?: Vector4;
  23024. backUVs?: Vector4;
  23025. }): VertexData;
  23026. /**
  23027. * Creates the VertexData for a cylinder, cone or prism
  23028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23029. * * height sets the height (y direction) of the cylinder, optional, default 2
  23030. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23031. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23032. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23033. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23034. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23035. * * 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
  23036. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23037. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23038. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23039. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23041. * * 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)
  23042. * * 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)
  23043. * @returns the VertexData of the cylinder, cone or prism
  23044. */
  23045. static CreateCylinder(options: {
  23046. height?: number;
  23047. diameterTop?: number;
  23048. diameterBottom?: number;
  23049. diameter?: number;
  23050. tessellation?: number;
  23051. subdivisions?: number;
  23052. arc?: number;
  23053. faceColors?: Color4[];
  23054. faceUV?: Vector4[];
  23055. hasRings?: boolean;
  23056. enclose?: boolean;
  23057. sideOrientation?: number;
  23058. frontUVs?: Vector4;
  23059. backUVs?: Vector4;
  23060. }): VertexData;
  23061. /**
  23062. * Creates the VertexData for a torus
  23063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23064. * * diameter the diameter of the torus, optional default 1
  23065. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23066. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23068. * * 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)
  23069. * * 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)
  23070. * @returns the VertexData of the torus
  23071. */
  23072. static CreateTorus(options: {
  23073. diameter?: number;
  23074. thickness?: number;
  23075. tessellation?: number;
  23076. sideOrientation?: number;
  23077. frontUVs?: Vector4;
  23078. backUVs?: Vector4;
  23079. }): VertexData;
  23080. /**
  23081. * Creates the VertexData of the LineSystem
  23082. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23083. * - lines an array of lines, each line being an array of successive Vector3
  23084. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23085. * @returns the VertexData of the LineSystem
  23086. */
  23087. static CreateLineSystem(options: {
  23088. lines: Vector3[][];
  23089. colors?: Nullable<Color4[][]>;
  23090. }): VertexData;
  23091. /**
  23092. * Create the VertexData for a DashedLines
  23093. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23094. * - points an array successive Vector3
  23095. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23096. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23097. * - dashNb the intended total number of dashes, optional, default 200
  23098. * @returns the VertexData for the DashedLines
  23099. */
  23100. static CreateDashedLines(options: {
  23101. points: Vector3[];
  23102. dashSize?: number;
  23103. gapSize?: number;
  23104. dashNb?: number;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for a Ground
  23108. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23109. * - width the width (x direction) of the ground, optional, default 1
  23110. * - height the height (z direction) of the ground, optional, default 1
  23111. * - subdivisions the number of subdivisions per side, optional, default 1
  23112. * @returns the VertexData of the Ground
  23113. */
  23114. static CreateGround(options: {
  23115. width?: number;
  23116. height?: number;
  23117. subdivisions?: number;
  23118. subdivisionsX?: number;
  23119. subdivisionsY?: number;
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23123. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23124. * * xmin the ground minimum X coordinate, optional, default -1
  23125. * * zmin the ground minimum Z coordinate, optional, default -1
  23126. * * xmax the ground maximum X coordinate, optional, default 1
  23127. * * zmax the ground maximum Z coordinate, optional, default 1
  23128. * * 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}
  23129. * * 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}
  23130. * @returns the VertexData of the TiledGround
  23131. */
  23132. static CreateTiledGround(options: {
  23133. xmin: number;
  23134. zmin: number;
  23135. xmax: number;
  23136. zmax: number;
  23137. subdivisions?: {
  23138. w: number;
  23139. h: number;
  23140. };
  23141. precision?: {
  23142. w: number;
  23143. h: number;
  23144. };
  23145. }): VertexData;
  23146. /**
  23147. * Creates the VertexData of the Ground designed from a heightmap
  23148. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23149. * * width the width (x direction) of the ground
  23150. * * height the height (z direction) of the ground
  23151. * * subdivisions the number of subdivisions per side
  23152. * * minHeight the minimum altitude on the ground, optional, default 0
  23153. * * maxHeight the maximum altitude on the ground, optional default 1
  23154. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23155. * * buffer the array holding the image color data
  23156. * * bufferWidth the width of image
  23157. * * bufferHeight the height of image
  23158. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23159. * @returns the VertexData of the Ground designed from a heightmap
  23160. */
  23161. static CreateGroundFromHeightMap(options: {
  23162. width: number;
  23163. height: number;
  23164. subdivisions: number;
  23165. minHeight: number;
  23166. maxHeight: number;
  23167. colorFilter: Color3;
  23168. buffer: Uint8Array;
  23169. bufferWidth: number;
  23170. bufferHeight: number;
  23171. alphaFilter: number;
  23172. }): VertexData;
  23173. /**
  23174. * Creates the VertexData for a Plane
  23175. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23176. * * size sets the width and height of the plane to the value of size, optional default 1
  23177. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23178. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23180. * * 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)
  23181. * * 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)
  23182. * @returns the VertexData of the box
  23183. */
  23184. static CreatePlane(options: {
  23185. size?: number;
  23186. width?: number;
  23187. height?: number;
  23188. sideOrientation?: number;
  23189. frontUVs?: Vector4;
  23190. backUVs?: Vector4;
  23191. }): VertexData;
  23192. /**
  23193. * Creates the VertexData of the Disc or regular Polygon
  23194. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23195. * * radius the radius of the disc, optional default 0.5
  23196. * * tessellation the number of polygon sides, optional, default 64
  23197. * * 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
  23198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23199. * * 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)
  23200. * * 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)
  23201. * @returns the VertexData of the box
  23202. */
  23203. static CreateDisc(options: {
  23204. radius?: number;
  23205. tessellation?: number;
  23206. arc?: number;
  23207. sideOrientation?: number;
  23208. frontUVs?: Vector4;
  23209. backUVs?: Vector4;
  23210. }): VertexData;
  23211. /**
  23212. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23213. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23214. * @param polygon a mesh built from polygonTriangulation.build()
  23215. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23216. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23217. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23218. * @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)
  23219. * @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)
  23220. * @returns the VertexData of the Polygon
  23221. */
  23222. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23223. /**
  23224. * Creates the VertexData of the IcoSphere
  23225. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23226. * * radius the radius of the IcoSphere, optional default 1
  23227. * * radiusX allows stretching in the x direction, optional, default radius
  23228. * * radiusY allows stretching in the y direction, optional, default radius
  23229. * * radiusZ allows stretching in the z direction, optional, default radius
  23230. * * flat when true creates a flat shaded mesh, optional, default true
  23231. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23233. * * 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)
  23234. * * 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)
  23235. * @returns the VertexData of the IcoSphere
  23236. */
  23237. static CreateIcoSphere(options: {
  23238. radius?: number;
  23239. radiusX?: number;
  23240. radiusY?: number;
  23241. radiusZ?: number;
  23242. flat?: boolean;
  23243. subdivisions?: number;
  23244. sideOrientation?: number;
  23245. frontUVs?: Vector4;
  23246. backUVs?: Vector4;
  23247. }): VertexData;
  23248. /**
  23249. * Creates the VertexData for a Polyhedron
  23250. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23251. * * type provided types are:
  23252. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23253. * * 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)
  23254. * * size the size of the IcoSphere, optional default 1
  23255. * * sizeX allows stretching in the x direction, optional, default size
  23256. * * sizeY allows stretching in the y direction, optional, default size
  23257. * * sizeZ allows stretching in the z direction, optional, default size
  23258. * * 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
  23259. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23260. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23261. * * flat when true creates a flat shaded mesh, optional, default true
  23262. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23264. * * 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)
  23265. * * 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)
  23266. * @returns the VertexData of the Polyhedron
  23267. */
  23268. static CreatePolyhedron(options: {
  23269. type?: number;
  23270. size?: number;
  23271. sizeX?: number;
  23272. sizeY?: number;
  23273. sizeZ?: number;
  23274. custom?: any;
  23275. faceUV?: Vector4[];
  23276. faceColors?: Color4[];
  23277. flat?: boolean;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Creates the VertexData for a TorusKnot
  23284. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23285. * * radius the radius of the torus knot, optional, default 2
  23286. * * tube the thickness of the tube, optional, default 0.5
  23287. * * radialSegments the number of sides on each tube segments, optional, default 32
  23288. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23289. * * p the number of windings around the z axis, optional, default 2
  23290. * * q the number of windings around the x axis, optional, default 3
  23291. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23292. * * 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)
  23293. * * 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)
  23294. * @returns the VertexData of the Torus Knot
  23295. */
  23296. static CreateTorusKnot(options: {
  23297. radius?: number;
  23298. tube?: number;
  23299. radialSegments?: number;
  23300. tubularSegments?: number;
  23301. p?: number;
  23302. q?: number;
  23303. sideOrientation?: number;
  23304. frontUVs?: Vector4;
  23305. backUVs?: Vector4;
  23306. }): VertexData;
  23307. /**
  23308. * Compute normals for given positions and indices
  23309. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23310. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23311. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23312. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23313. * * facetNormals : optional array of facet normals (vector3)
  23314. * * facetPositions : optional array of facet positions (vector3)
  23315. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23316. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23317. * * bInfo : optional bounding info, required for facetPartitioning computation
  23318. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23319. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23320. * * useRightHandedSystem: optional boolean to for right handed system computation
  23321. * * depthSort : optional boolean to enable the facet depth sort computation
  23322. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23323. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23324. */
  23325. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23326. facetNormals?: any;
  23327. facetPositions?: any;
  23328. facetPartitioning?: any;
  23329. ratio?: number;
  23330. bInfo?: any;
  23331. bbSize?: Vector3;
  23332. subDiv?: any;
  23333. useRightHandedSystem?: boolean;
  23334. depthSort?: boolean;
  23335. distanceTo?: Vector3;
  23336. depthSortedFacets?: any;
  23337. }): void;
  23338. /** @hidden */
  23339. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23340. /**
  23341. * Applies VertexData created from the imported parameters to the geometry
  23342. * @param parsedVertexData the parsed data from an imported file
  23343. * @param geometry the geometry to apply the VertexData to
  23344. */
  23345. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23346. }
  23347. }
  23348. declare module "babylonjs/Morph/morphTarget" {
  23349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23350. import { Observable } from "babylonjs/Misc/observable";
  23351. import { Nullable, FloatArray } from "babylonjs/types";
  23352. import { Scene } from "babylonjs/scene";
  23353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23354. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23355. /**
  23356. * Defines a target to use with MorphTargetManager
  23357. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23358. */
  23359. export class MorphTarget implements IAnimatable {
  23360. /** defines the name of the target */
  23361. name: string;
  23362. /**
  23363. * Gets or sets the list of animations
  23364. */
  23365. animations: import("babylonjs/Animations/animation").Animation[];
  23366. private _scene;
  23367. private _positions;
  23368. private _normals;
  23369. private _tangents;
  23370. private _uvs;
  23371. private _influence;
  23372. private _uniqueId;
  23373. /**
  23374. * Observable raised when the influence changes
  23375. */
  23376. onInfluenceChanged: Observable<boolean>;
  23377. /** @hidden */
  23378. _onDataLayoutChanged: Observable<void>;
  23379. /**
  23380. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23381. */
  23382. get influence(): number;
  23383. set influence(influence: number);
  23384. /**
  23385. * Gets or sets the id of the morph Target
  23386. */
  23387. id: string;
  23388. private _animationPropertiesOverride;
  23389. /**
  23390. * Gets or sets the animation properties override
  23391. */
  23392. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23393. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23394. /**
  23395. * Creates a new MorphTarget
  23396. * @param name defines the name of the target
  23397. * @param influence defines the influence to use
  23398. * @param scene defines the scene the morphtarget belongs to
  23399. */
  23400. constructor(
  23401. /** defines the name of the target */
  23402. name: string, influence?: number, scene?: Nullable<Scene>);
  23403. /**
  23404. * Gets the unique ID of this manager
  23405. */
  23406. get uniqueId(): number;
  23407. /**
  23408. * Gets a boolean defining if the target contains position data
  23409. */
  23410. get hasPositions(): boolean;
  23411. /**
  23412. * Gets a boolean defining if the target contains normal data
  23413. */
  23414. get hasNormals(): boolean;
  23415. /**
  23416. * Gets a boolean defining if the target contains tangent data
  23417. */
  23418. get hasTangents(): boolean;
  23419. /**
  23420. * Gets a boolean defining if the target contains texture coordinates data
  23421. */
  23422. get hasUVs(): boolean;
  23423. /**
  23424. * Affects position data to this target
  23425. * @param data defines the position data to use
  23426. */
  23427. setPositions(data: Nullable<FloatArray>): void;
  23428. /**
  23429. * Gets the position data stored in this target
  23430. * @returns a FloatArray containing the position data (or null if not present)
  23431. */
  23432. getPositions(): Nullable<FloatArray>;
  23433. /**
  23434. * Affects normal data to this target
  23435. * @param data defines the normal data to use
  23436. */
  23437. setNormals(data: Nullable<FloatArray>): void;
  23438. /**
  23439. * Gets the normal data stored in this target
  23440. * @returns a FloatArray containing the normal data (or null if not present)
  23441. */
  23442. getNormals(): Nullable<FloatArray>;
  23443. /**
  23444. * Affects tangent data to this target
  23445. * @param data defines the tangent data to use
  23446. */
  23447. setTangents(data: Nullable<FloatArray>): void;
  23448. /**
  23449. * Gets the tangent data stored in this target
  23450. * @returns a FloatArray containing the tangent data (or null if not present)
  23451. */
  23452. getTangents(): Nullable<FloatArray>;
  23453. /**
  23454. * Affects texture coordinates data to this target
  23455. * @param data defines the texture coordinates data to use
  23456. */
  23457. setUVs(data: Nullable<FloatArray>): void;
  23458. /**
  23459. * Gets the texture coordinates data stored in this target
  23460. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23461. */
  23462. getUVs(): Nullable<FloatArray>;
  23463. /**
  23464. * Clone the current target
  23465. * @returns a new MorphTarget
  23466. */
  23467. clone(): MorphTarget;
  23468. /**
  23469. * Serializes the current target into a Serialization object
  23470. * @returns the serialized object
  23471. */
  23472. serialize(): any;
  23473. /**
  23474. * Returns the string "MorphTarget"
  23475. * @returns "MorphTarget"
  23476. */
  23477. getClassName(): string;
  23478. /**
  23479. * Creates a new target from serialized data
  23480. * @param serializationObject defines the serialized data to use
  23481. * @returns a new MorphTarget
  23482. */
  23483. static Parse(serializationObject: any): MorphTarget;
  23484. /**
  23485. * Creates a MorphTarget from mesh data
  23486. * @param mesh defines the source mesh
  23487. * @param name defines the name to use for the new target
  23488. * @param influence defines the influence to attach to the target
  23489. * @returns a new MorphTarget
  23490. */
  23491. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23492. }
  23493. }
  23494. declare module "babylonjs/Morph/morphTargetManager" {
  23495. import { Nullable } from "babylonjs/types";
  23496. import { Scene } from "babylonjs/scene";
  23497. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23498. /**
  23499. * This class is used to deform meshes using morphing between different targets
  23500. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23501. */
  23502. export class MorphTargetManager {
  23503. private _targets;
  23504. private _targetInfluenceChangedObservers;
  23505. private _targetDataLayoutChangedObservers;
  23506. private _activeTargets;
  23507. private _scene;
  23508. private _influences;
  23509. private _supportsNormals;
  23510. private _supportsTangents;
  23511. private _supportsUVs;
  23512. private _vertexCount;
  23513. private _uniqueId;
  23514. private _tempInfluences;
  23515. /**
  23516. * Gets or sets a boolean indicating if normals must be morphed
  23517. */
  23518. enableNormalMorphing: boolean;
  23519. /**
  23520. * Gets or sets a boolean indicating if tangents must be morphed
  23521. */
  23522. enableTangentMorphing: boolean;
  23523. /**
  23524. * Gets or sets a boolean indicating if UV must be morphed
  23525. */
  23526. enableUVMorphing: boolean;
  23527. /**
  23528. * Creates a new MorphTargetManager
  23529. * @param scene defines the current scene
  23530. */
  23531. constructor(scene?: Nullable<Scene>);
  23532. /**
  23533. * Gets the unique ID of this manager
  23534. */
  23535. get uniqueId(): number;
  23536. /**
  23537. * Gets the number of vertices handled by this manager
  23538. */
  23539. get vertexCount(): number;
  23540. /**
  23541. * Gets a boolean indicating if this manager supports morphing of normals
  23542. */
  23543. get supportsNormals(): boolean;
  23544. /**
  23545. * Gets a boolean indicating if this manager supports morphing of tangents
  23546. */
  23547. get supportsTangents(): boolean;
  23548. /**
  23549. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23550. */
  23551. get supportsUVs(): boolean;
  23552. /**
  23553. * Gets the number of targets stored in this manager
  23554. */
  23555. get numTargets(): number;
  23556. /**
  23557. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23558. */
  23559. get numInfluencers(): number;
  23560. /**
  23561. * Gets the list of influences (one per target)
  23562. */
  23563. get influences(): Float32Array;
  23564. /**
  23565. * Gets the active target at specified index. An active target is a target with an influence > 0
  23566. * @param index defines the index to check
  23567. * @returns the requested target
  23568. */
  23569. getActiveTarget(index: number): MorphTarget;
  23570. /**
  23571. * Gets the target at specified index
  23572. * @param index defines the index to check
  23573. * @returns the requested target
  23574. */
  23575. getTarget(index: number): MorphTarget;
  23576. /**
  23577. * Add a new target to this manager
  23578. * @param target defines the target to add
  23579. */
  23580. addTarget(target: MorphTarget): void;
  23581. /**
  23582. * Removes a target from the manager
  23583. * @param target defines the target to remove
  23584. */
  23585. removeTarget(target: MorphTarget): void;
  23586. /**
  23587. * Clone the current manager
  23588. * @returns a new MorphTargetManager
  23589. */
  23590. clone(): MorphTargetManager;
  23591. /**
  23592. * Serializes the current manager into a Serialization object
  23593. * @returns the serialized object
  23594. */
  23595. serialize(): any;
  23596. private _syncActiveTargets;
  23597. /**
  23598. * Syncrhonize the targets with all the meshes using this morph target manager
  23599. */
  23600. synchronize(): void;
  23601. /**
  23602. * Creates a new MorphTargetManager from serialized data
  23603. * @param serializationObject defines the serialized data
  23604. * @param scene defines the hosting scene
  23605. * @returns the new MorphTargetManager
  23606. */
  23607. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23608. }
  23609. }
  23610. declare module "babylonjs/Meshes/meshLODLevel" {
  23611. import { Mesh } from "babylonjs/Meshes/mesh";
  23612. import { Nullable } from "babylonjs/types";
  23613. /**
  23614. * Class used to represent a specific level of detail of a mesh
  23615. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23616. */
  23617. export class MeshLODLevel {
  23618. /** Defines the distance where this level should start being displayed */
  23619. distance: number;
  23620. /** Defines the mesh to use to render this level */
  23621. mesh: Nullable<Mesh>;
  23622. /**
  23623. * Creates a new LOD level
  23624. * @param distance defines the distance where this level should star being displayed
  23625. * @param mesh defines the mesh to use to render this level
  23626. */
  23627. constructor(
  23628. /** Defines the distance where this level should start being displayed */
  23629. distance: number,
  23630. /** Defines the mesh to use to render this level */
  23631. mesh: Nullable<Mesh>);
  23632. }
  23633. }
  23634. declare module "babylonjs/Meshes/groundMesh" {
  23635. import { Scene } from "babylonjs/scene";
  23636. import { Vector3 } from "babylonjs/Maths/math.vector";
  23637. import { Mesh } from "babylonjs/Meshes/mesh";
  23638. /**
  23639. * Mesh representing the gorund
  23640. */
  23641. export class GroundMesh extends Mesh {
  23642. /** If octree should be generated */
  23643. generateOctree: boolean;
  23644. private _heightQuads;
  23645. /** @hidden */
  23646. _subdivisionsX: number;
  23647. /** @hidden */
  23648. _subdivisionsY: number;
  23649. /** @hidden */
  23650. _width: number;
  23651. /** @hidden */
  23652. _height: number;
  23653. /** @hidden */
  23654. _minX: number;
  23655. /** @hidden */
  23656. _maxX: number;
  23657. /** @hidden */
  23658. _minZ: number;
  23659. /** @hidden */
  23660. _maxZ: number;
  23661. constructor(name: string, scene: Scene);
  23662. /**
  23663. * "GroundMesh"
  23664. * @returns "GroundMesh"
  23665. */
  23666. getClassName(): string;
  23667. /**
  23668. * The minimum of x and y subdivisions
  23669. */
  23670. get subdivisions(): number;
  23671. /**
  23672. * X subdivisions
  23673. */
  23674. get subdivisionsX(): number;
  23675. /**
  23676. * Y subdivisions
  23677. */
  23678. get subdivisionsY(): number;
  23679. /**
  23680. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23681. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23682. * @param chunksCount the number of subdivisions for x and y
  23683. * @param octreeBlocksSize (Default: 32)
  23684. */
  23685. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23686. /**
  23687. * Returns a height (y) value in the Worl system :
  23688. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23689. * @param x x coordinate
  23690. * @param z z coordinate
  23691. * @returns the ground y position if (x, z) are outside the ground surface.
  23692. */
  23693. getHeightAtCoordinates(x: number, z: number): number;
  23694. /**
  23695. * Returns a normalized vector (Vector3) orthogonal to the ground
  23696. * at the ground coordinates (x, z) expressed in the World system.
  23697. * @param x x coordinate
  23698. * @param z z coordinate
  23699. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23700. */
  23701. getNormalAtCoordinates(x: number, z: number): Vector3;
  23702. /**
  23703. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23704. * at the ground coordinates (x, z) expressed in the World system.
  23705. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23706. * @param x x coordinate
  23707. * @param z z coordinate
  23708. * @param ref vector to store the result
  23709. * @returns the GroundMesh.
  23710. */
  23711. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23712. /**
  23713. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23714. * if the ground has been updated.
  23715. * This can be used in the render loop.
  23716. * @returns the GroundMesh.
  23717. */
  23718. updateCoordinateHeights(): GroundMesh;
  23719. private _getFacetAt;
  23720. private _initHeightQuads;
  23721. private _computeHeightQuads;
  23722. /**
  23723. * Serializes this ground mesh
  23724. * @param serializationObject object to write serialization to
  23725. */
  23726. serialize(serializationObject: any): void;
  23727. /**
  23728. * Parses a serialized ground mesh
  23729. * @param parsedMesh the serialized mesh
  23730. * @param scene the scene to create the ground mesh in
  23731. * @returns the created ground mesh
  23732. */
  23733. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23734. }
  23735. }
  23736. declare module "babylonjs/Physics/physicsJoint" {
  23737. import { Vector3 } from "babylonjs/Maths/math.vector";
  23738. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23739. /**
  23740. * Interface for Physics-Joint data
  23741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23742. */
  23743. export interface PhysicsJointData {
  23744. /**
  23745. * The main pivot of the joint
  23746. */
  23747. mainPivot?: Vector3;
  23748. /**
  23749. * The connected pivot of the joint
  23750. */
  23751. connectedPivot?: Vector3;
  23752. /**
  23753. * The main axis of the joint
  23754. */
  23755. mainAxis?: Vector3;
  23756. /**
  23757. * The connected axis of the joint
  23758. */
  23759. connectedAxis?: Vector3;
  23760. /**
  23761. * The collision of the joint
  23762. */
  23763. collision?: boolean;
  23764. /**
  23765. * Native Oimo/Cannon/Energy data
  23766. */
  23767. nativeParams?: any;
  23768. }
  23769. /**
  23770. * This is a holder class for the physics joint created by the physics plugin
  23771. * It holds a set of functions to control the underlying joint
  23772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23773. */
  23774. export class PhysicsJoint {
  23775. /**
  23776. * The type of the physics joint
  23777. */
  23778. type: number;
  23779. /**
  23780. * The data for the physics joint
  23781. */
  23782. jointData: PhysicsJointData;
  23783. private _physicsJoint;
  23784. protected _physicsPlugin: IPhysicsEnginePlugin;
  23785. /**
  23786. * Initializes the physics joint
  23787. * @param type The type of the physics joint
  23788. * @param jointData The data for the physics joint
  23789. */
  23790. constructor(
  23791. /**
  23792. * The type of the physics joint
  23793. */
  23794. type: number,
  23795. /**
  23796. * The data for the physics joint
  23797. */
  23798. jointData: PhysicsJointData);
  23799. /**
  23800. * Gets the physics joint
  23801. */
  23802. get physicsJoint(): any;
  23803. /**
  23804. * Sets the physics joint
  23805. */
  23806. set physicsJoint(newJoint: any);
  23807. /**
  23808. * Sets the physics plugin
  23809. */
  23810. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23811. /**
  23812. * Execute a function that is physics-plugin specific.
  23813. * @param {Function} func the function that will be executed.
  23814. * It accepts two parameters: the physics world and the physics joint
  23815. */
  23816. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23817. /**
  23818. * Distance-Joint type
  23819. */
  23820. static DistanceJoint: number;
  23821. /**
  23822. * Hinge-Joint type
  23823. */
  23824. static HingeJoint: number;
  23825. /**
  23826. * Ball-and-Socket joint type
  23827. */
  23828. static BallAndSocketJoint: number;
  23829. /**
  23830. * Wheel-Joint type
  23831. */
  23832. static WheelJoint: number;
  23833. /**
  23834. * Slider-Joint type
  23835. */
  23836. static SliderJoint: number;
  23837. /**
  23838. * Prismatic-Joint type
  23839. */
  23840. static PrismaticJoint: number;
  23841. /**
  23842. * Universal-Joint type
  23843. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23844. */
  23845. static UniversalJoint: number;
  23846. /**
  23847. * Hinge-Joint 2 type
  23848. */
  23849. static Hinge2Joint: number;
  23850. /**
  23851. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23852. */
  23853. static PointToPointJoint: number;
  23854. /**
  23855. * Spring-Joint type
  23856. */
  23857. static SpringJoint: number;
  23858. /**
  23859. * Lock-Joint type
  23860. */
  23861. static LockJoint: number;
  23862. }
  23863. /**
  23864. * A class representing a physics distance joint
  23865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23866. */
  23867. export class DistanceJoint extends PhysicsJoint {
  23868. /**
  23869. *
  23870. * @param jointData The data for the Distance-Joint
  23871. */
  23872. constructor(jointData: DistanceJointData);
  23873. /**
  23874. * Update the predefined distance.
  23875. * @param maxDistance The maximum preferred distance
  23876. * @param minDistance The minimum preferred distance
  23877. */
  23878. updateDistance(maxDistance: number, minDistance?: number): void;
  23879. }
  23880. /**
  23881. * Represents a Motor-Enabled Joint
  23882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23883. */
  23884. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23885. /**
  23886. * Initializes the Motor-Enabled Joint
  23887. * @param type The type of the joint
  23888. * @param jointData The physica joint data for the joint
  23889. */
  23890. constructor(type: number, jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param force the force to apply
  23895. * @param maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a single physics Hinge-Joint
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class HingeJoint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge-Joint
  23913. * @param jointData The joint data for the Hinge-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} force the force to apply
  23920. * @param {number} maxForce max force for this motor.
  23921. */
  23922. setMotor(force?: number, maxForce?: number): void;
  23923. /**
  23924. * Set the motor's limits.
  23925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23926. * @param upperLimit The upper limit of the motor
  23927. * @param lowerLimit The lower limit of the motor
  23928. */
  23929. setLimit(upperLimit: number, lowerLimit?: number): void;
  23930. }
  23931. /**
  23932. * This class represents a dual hinge physics joint (same as wheel joint)
  23933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23934. */
  23935. export class Hinge2Joint extends MotorEnabledJoint {
  23936. /**
  23937. * Initializes the Hinge2-Joint
  23938. * @param jointData The joint data for the Hinge2-Joint
  23939. */
  23940. constructor(jointData: PhysicsJointData);
  23941. /**
  23942. * Set the motor values.
  23943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23944. * @param {number} targetSpeed the speed the motor is to reach
  23945. * @param {number} maxForce max force for this motor.
  23946. * @param {motorIndex} the motor's index, 0 or 1.
  23947. */
  23948. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Set the motor limits.
  23951. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23952. * @param {number} upperLimit the upper limit
  23953. * @param {number} lowerLimit lower limit
  23954. * @param {motorIndex} the motor's index, 0 or 1.
  23955. */
  23956. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23957. }
  23958. /**
  23959. * Interface for a motor enabled joint
  23960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23961. */
  23962. export interface IMotorEnabledJoint {
  23963. /**
  23964. * Physics joint
  23965. */
  23966. physicsJoint: any;
  23967. /**
  23968. * Sets the motor of the motor-enabled joint
  23969. * @param force The force of the motor
  23970. * @param maxForce The maximum force of the motor
  23971. * @param motorIndex The index of the motor
  23972. */
  23973. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23974. /**
  23975. * Sets the limit of the motor
  23976. * @param upperLimit The upper limit of the motor
  23977. * @param lowerLimit The lower limit of the motor
  23978. * @param motorIndex The index of the motor
  23979. */
  23980. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23981. }
  23982. /**
  23983. * Joint data for a Distance-Joint
  23984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23985. */
  23986. export interface DistanceJointData extends PhysicsJointData {
  23987. /**
  23988. * Max distance the 2 joint objects can be apart
  23989. */
  23990. maxDistance: number;
  23991. }
  23992. /**
  23993. * Joint data from a spring joint
  23994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23995. */
  23996. export interface SpringJointData extends PhysicsJointData {
  23997. /**
  23998. * Length of the spring
  23999. */
  24000. length: number;
  24001. /**
  24002. * Stiffness of the spring
  24003. */
  24004. stiffness: number;
  24005. /**
  24006. * Damping of the spring
  24007. */
  24008. damping: number;
  24009. /** this callback will be called when applying the force to the impostors. */
  24010. forceApplicationCallback: () => void;
  24011. }
  24012. }
  24013. declare module "babylonjs/Physics/physicsRaycastResult" {
  24014. import { Vector3 } from "babylonjs/Maths/math.vector";
  24015. /**
  24016. * Holds the data for the raycast result
  24017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24018. */
  24019. export class PhysicsRaycastResult {
  24020. private _hasHit;
  24021. private _hitDistance;
  24022. private _hitNormalWorld;
  24023. private _hitPointWorld;
  24024. private _rayFromWorld;
  24025. private _rayToWorld;
  24026. /**
  24027. * Gets if there was a hit
  24028. */
  24029. get hasHit(): boolean;
  24030. /**
  24031. * Gets the distance from the hit
  24032. */
  24033. get hitDistance(): number;
  24034. /**
  24035. * Gets the hit normal/direction in the world
  24036. */
  24037. get hitNormalWorld(): Vector3;
  24038. /**
  24039. * Gets the hit point in the world
  24040. */
  24041. get hitPointWorld(): Vector3;
  24042. /**
  24043. * Gets the ray "start point" of the ray in the world
  24044. */
  24045. get rayFromWorld(): Vector3;
  24046. /**
  24047. * Gets the ray "end point" of the ray in the world
  24048. */
  24049. get rayToWorld(): Vector3;
  24050. /**
  24051. * Sets the hit data (normal & point in world space)
  24052. * @param hitNormalWorld defines the normal in world space
  24053. * @param hitPointWorld defines the point in world space
  24054. */
  24055. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24056. /**
  24057. * Sets the distance from the start point to the hit point
  24058. * @param distance
  24059. */
  24060. setHitDistance(distance: number): void;
  24061. /**
  24062. * Calculates the distance manually
  24063. */
  24064. calculateHitDistance(): void;
  24065. /**
  24066. * Resets all the values to default
  24067. * @param from The from point on world space
  24068. * @param to The to point on world space
  24069. */
  24070. reset(from?: Vector3, to?: Vector3): void;
  24071. }
  24072. /**
  24073. * Interface for the size containing width and height
  24074. */
  24075. interface IXYZ {
  24076. /**
  24077. * X
  24078. */
  24079. x: number;
  24080. /**
  24081. * Y
  24082. */
  24083. y: number;
  24084. /**
  24085. * Z
  24086. */
  24087. z: number;
  24088. }
  24089. }
  24090. declare module "babylonjs/Physics/IPhysicsEngine" {
  24091. import { Nullable } from "babylonjs/types";
  24092. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24094. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24095. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24096. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24097. /**
  24098. * Interface used to describe a physics joint
  24099. */
  24100. export interface PhysicsImpostorJoint {
  24101. /** Defines the main impostor to which the joint is linked */
  24102. mainImpostor: PhysicsImpostor;
  24103. /** Defines the impostor that is connected to the main impostor using this joint */
  24104. connectedImpostor: PhysicsImpostor;
  24105. /** Defines the joint itself */
  24106. joint: PhysicsJoint;
  24107. }
  24108. /** @hidden */
  24109. export interface IPhysicsEnginePlugin {
  24110. world: any;
  24111. name: string;
  24112. setGravity(gravity: Vector3): void;
  24113. setTimeStep(timeStep: number): void;
  24114. getTimeStep(): number;
  24115. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24116. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24117. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24118. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24119. removePhysicsBody(impostor: PhysicsImpostor): void;
  24120. generateJoint(joint: PhysicsImpostorJoint): void;
  24121. removeJoint(joint: PhysicsImpostorJoint): void;
  24122. isSupported(): boolean;
  24123. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24124. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24126. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24128. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24130. getBodyMass(impostor: PhysicsImpostor): number;
  24131. getBodyFriction(impostor: PhysicsImpostor): number;
  24132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24133. getBodyRestitution(impostor: PhysicsImpostor): number;
  24134. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24135. getBodyPressure?(impostor: PhysicsImpostor): number;
  24136. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24137. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24138. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24139. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24140. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24141. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24142. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24143. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24144. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24145. sleepBody(impostor: PhysicsImpostor): void;
  24146. wakeUpBody(impostor: PhysicsImpostor): void;
  24147. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24148. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24149. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24150. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24151. getRadius(impostor: PhysicsImpostor): number;
  24152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24153. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24154. dispose(): void;
  24155. }
  24156. /**
  24157. * Interface used to define a physics engine
  24158. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24159. */
  24160. export interface IPhysicsEngine {
  24161. /**
  24162. * Gets the gravity vector used by the simulation
  24163. */
  24164. gravity: Vector3;
  24165. /**
  24166. * Sets the gravity vector used by the simulation
  24167. * @param gravity defines the gravity vector to use
  24168. */
  24169. setGravity(gravity: Vector3): void;
  24170. /**
  24171. * Set the time step of the physics engine.
  24172. * Default is 1/60.
  24173. * To slow it down, enter 1/600 for example.
  24174. * To speed it up, 1/30
  24175. * @param newTimeStep the new timestep to apply to this world.
  24176. */
  24177. setTimeStep(newTimeStep: number): void;
  24178. /**
  24179. * Get the time step of the physics engine.
  24180. * @returns the current time step
  24181. */
  24182. getTimeStep(): number;
  24183. /**
  24184. * Set the sub time step of the physics engine.
  24185. * Default is 0 meaning there is no sub steps
  24186. * To increase physics resolution precision, set a small value (like 1 ms)
  24187. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24188. */
  24189. setSubTimeStep(subTimeStep: number): void;
  24190. /**
  24191. * Get the sub time step of the physics engine.
  24192. * @returns the current sub time step
  24193. */
  24194. getSubTimeStep(): number;
  24195. /**
  24196. * Release all resources
  24197. */
  24198. dispose(): void;
  24199. /**
  24200. * Gets the name of the current physics plugin
  24201. * @returns the name of the plugin
  24202. */
  24203. getPhysicsPluginName(): string;
  24204. /**
  24205. * Adding a new impostor for the impostor tracking.
  24206. * This will be done by the impostor itself.
  24207. * @param impostor the impostor to add
  24208. */
  24209. addImpostor(impostor: PhysicsImpostor): void;
  24210. /**
  24211. * Remove an impostor from the engine.
  24212. * This impostor and its mesh will not longer be updated by the physics engine.
  24213. * @param impostor the impostor to remove
  24214. */
  24215. removeImpostor(impostor: PhysicsImpostor): void;
  24216. /**
  24217. * Add a joint to the physics engine
  24218. * @param mainImpostor defines the main impostor to which the joint is added.
  24219. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24220. * @param joint defines the joint that will connect both impostors.
  24221. */
  24222. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24223. /**
  24224. * Removes a joint from the simulation
  24225. * @param mainImpostor defines the impostor used with the joint
  24226. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24227. * @param joint defines the joint to remove
  24228. */
  24229. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24230. /**
  24231. * Gets the current plugin used to run the simulation
  24232. * @returns current plugin
  24233. */
  24234. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24235. /**
  24236. * Gets the list of physic impostors
  24237. * @returns an array of PhysicsImpostor
  24238. */
  24239. getImpostors(): Array<PhysicsImpostor>;
  24240. /**
  24241. * Gets the impostor for a physics enabled object
  24242. * @param object defines the object impersonated by the impostor
  24243. * @returns the PhysicsImpostor or null if not found
  24244. */
  24245. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24246. /**
  24247. * Gets the impostor for a physics body object
  24248. * @param body defines physics body used by the impostor
  24249. * @returns the PhysicsImpostor or null if not found
  24250. */
  24251. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24252. /**
  24253. * Does a raycast in the physics world
  24254. * @param from when should the ray start?
  24255. * @param to when should the ray end?
  24256. * @returns PhysicsRaycastResult
  24257. */
  24258. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24259. /**
  24260. * Called by the scene. No need to call it.
  24261. * @param delta defines the timespam between frames
  24262. */
  24263. _step(delta: number): void;
  24264. }
  24265. }
  24266. declare module "babylonjs/Physics/physicsImpostor" {
  24267. import { Nullable, IndicesArray } from "babylonjs/types";
  24268. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24269. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24271. import { Scene } from "babylonjs/scene";
  24272. import { Bone } from "babylonjs/Bones/bone";
  24273. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24274. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24275. import { Space } from "babylonjs/Maths/math.axis";
  24276. /**
  24277. * The interface for the physics imposter parameters
  24278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24279. */
  24280. export interface PhysicsImpostorParameters {
  24281. /**
  24282. * The mass of the physics imposter
  24283. */
  24284. mass: number;
  24285. /**
  24286. * The friction of the physics imposter
  24287. */
  24288. friction?: number;
  24289. /**
  24290. * The coefficient of restitution of the physics imposter
  24291. */
  24292. restitution?: number;
  24293. /**
  24294. * The native options of the physics imposter
  24295. */
  24296. nativeOptions?: any;
  24297. /**
  24298. * Specifies if the parent should be ignored
  24299. */
  24300. ignoreParent?: boolean;
  24301. /**
  24302. * Specifies if bi-directional transformations should be disabled
  24303. */
  24304. disableBidirectionalTransformation?: boolean;
  24305. /**
  24306. * The pressure inside the physics imposter, soft object only
  24307. */
  24308. pressure?: number;
  24309. /**
  24310. * The stiffness the physics imposter, soft object only
  24311. */
  24312. stiffness?: number;
  24313. /**
  24314. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24315. */
  24316. velocityIterations?: number;
  24317. /**
  24318. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24319. */
  24320. positionIterations?: number;
  24321. /**
  24322. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24323. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24324. * Add to fix multiple points
  24325. */
  24326. fixedPoints?: number;
  24327. /**
  24328. * The collision margin around a soft object
  24329. */
  24330. margin?: number;
  24331. /**
  24332. * The collision margin around a soft object
  24333. */
  24334. damping?: number;
  24335. /**
  24336. * The path for a rope based on an extrusion
  24337. */
  24338. path?: any;
  24339. /**
  24340. * The shape of an extrusion used for a rope based on an extrusion
  24341. */
  24342. shape?: any;
  24343. }
  24344. /**
  24345. * Interface for a physics-enabled object
  24346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24347. */
  24348. export interface IPhysicsEnabledObject {
  24349. /**
  24350. * The position of the physics-enabled object
  24351. */
  24352. position: Vector3;
  24353. /**
  24354. * The rotation of the physics-enabled object
  24355. */
  24356. rotationQuaternion: Nullable<Quaternion>;
  24357. /**
  24358. * The scale of the physics-enabled object
  24359. */
  24360. scaling: Vector3;
  24361. /**
  24362. * The rotation of the physics-enabled object
  24363. */
  24364. rotation?: Vector3;
  24365. /**
  24366. * The parent of the physics-enabled object
  24367. */
  24368. parent?: any;
  24369. /**
  24370. * The bounding info of the physics-enabled object
  24371. * @returns The bounding info of the physics-enabled object
  24372. */
  24373. getBoundingInfo(): BoundingInfo;
  24374. /**
  24375. * Computes the world matrix
  24376. * @param force Specifies if the world matrix should be computed by force
  24377. * @returns A world matrix
  24378. */
  24379. computeWorldMatrix(force: boolean): Matrix;
  24380. /**
  24381. * Gets the world matrix
  24382. * @returns A world matrix
  24383. */
  24384. getWorldMatrix?(): Matrix;
  24385. /**
  24386. * Gets the child meshes
  24387. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24388. * @returns An array of abstract meshes
  24389. */
  24390. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24391. /**
  24392. * Gets the vertex data
  24393. * @param kind The type of vertex data
  24394. * @returns A nullable array of numbers, or a float32 array
  24395. */
  24396. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24397. /**
  24398. * Gets the indices from the mesh
  24399. * @returns A nullable array of index arrays
  24400. */
  24401. getIndices?(): Nullable<IndicesArray>;
  24402. /**
  24403. * Gets the scene from the mesh
  24404. * @returns the indices array or null
  24405. */
  24406. getScene?(): Scene;
  24407. /**
  24408. * Gets the absolute position from the mesh
  24409. * @returns the absolute position
  24410. */
  24411. getAbsolutePosition(): Vector3;
  24412. /**
  24413. * Gets the absolute pivot point from the mesh
  24414. * @returns the absolute pivot point
  24415. */
  24416. getAbsolutePivotPoint(): Vector3;
  24417. /**
  24418. * Rotates the mesh
  24419. * @param axis The axis of rotation
  24420. * @param amount The amount of rotation
  24421. * @param space The space of the rotation
  24422. * @returns The rotation transform node
  24423. */
  24424. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24425. /**
  24426. * Translates the mesh
  24427. * @param axis The axis of translation
  24428. * @param distance The distance of translation
  24429. * @param space The space of the translation
  24430. * @returns The transform node
  24431. */
  24432. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24433. /**
  24434. * Sets the absolute position of the mesh
  24435. * @param absolutePosition The absolute position of the mesh
  24436. * @returns The transform node
  24437. */
  24438. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24439. /**
  24440. * Gets the class name of the mesh
  24441. * @returns The class name
  24442. */
  24443. getClassName(): string;
  24444. }
  24445. /**
  24446. * Represents a physics imposter
  24447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24448. */
  24449. export class PhysicsImpostor {
  24450. /**
  24451. * The physics-enabled object used as the physics imposter
  24452. */
  24453. object: IPhysicsEnabledObject;
  24454. /**
  24455. * The type of the physics imposter
  24456. */
  24457. type: number;
  24458. private _options;
  24459. private _scene?;
  24460. /**
  24461. * The default object size of the imposter
  24462. */
  24463. static DEFAULT_OBJECT_SIZE: Vector3;
  24464. /**
  24465. * The identity quaternion of the imposter
  24466. */
  24467. static IDENTITY_QUATERNION: Quaternion;
  24468. /** @hidden */
  24469. _pluginData: any;
  24470. private _physicsEngine;
  24471. private _physicsBody;
  24472. private _bodyUpdateRequired;
  24473. private _onBeforePhysicsStepCallbacks;
  24474. private _onAfterPhysicsStepCallbacks;
  24475. /** @hidden */
  24476. _onPhysicsCollideCallbacks: Array<{
  24477. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24478. otherImpostors: Array<PhysicsImpostor>;
  24479. }>;
  24480. private _deltaPosition;
  24481. private _deltaRotation;
  24482. private _deltaRotationConjugated;
  24483. /** @hidden */
  24484. _isFromLine: boolean;
  24485. private _parent;
  24486. private _isDisposed;
  24487. private static _tmpVecs;
  24488. private static _tmpQuat;
  24489. /**
  24490. * Specifies if the physics imposter is disposed
  24491. */
  24492. get isDisposed(): boolean;
  24493. /**
  24494. * Gets the mass of the physics imposter
  24495. */
  24496. get mass(): number;
  24497. set mass(value: number);
  24498. /**
  24499. * Gets the coefficient of friction
  24500. */
  24501. get friction(): number;
  24502. /**
  24503. * Sets the coefficient of friction
  24504. */
  24505. set friction(value: number);
  24506. /**
  24507. * Gets the coefficient of restitution
  24508. */
  24509. get restitution(): number;
  24510. /**
  24511. * Sets the coefficient of restitution
  24512. */
  24513. set restitution(value: number);
  24514. /**
  24515. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24516. */
  24517. get pressure(): number;
  24518. /**
  24519. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24520. */
  24521. set pressure(value: number);
  24522. /**
  24523. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24524. */
  24525. get stiffness(): number;
  24526. /**
  24527. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24528. */
  24529. set stiffness(value: number);
  24530. /**
  24531. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24532. */
  24533. get velocityIterations(): number;
  24534. /**
  24535. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24536. */
  24537. set velocityIterations(value: number);
  24538. /**
  24539. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24540. */
  24541. get positionIterations(): number;
  24542. /**
  24543. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24544. */
  24545. set positionIterations(value: number);
  24546. /**
  24547. * The unique id of the physics imposter
  24548. * set by the physics engine when adding this impostor to the array
  24549. */
  24550. uniqueId: number;
  24551. /**
  24552. * @hidden
  24553. */
  24554. soft: boolean;
  24555. /**
  24556. * @hidden
  24557. */
  24558. segments: number;
  24559. private _joints;
  24560. /**
  24561. * Initializes the physics imposter
  24562. * @param object The physics-enabled object used as the physics imposter
  24563. * @param type The type of the physics imposter
  24564. * @param _options The options for the physics imposter
  24565. * @param _scene The Babylon scene
  24566. */
  24567. constructor(
  24568. /**
  24569. * The physics-enabled object used as the physics imposter
  24570. */
  24571. object: IPhysicsEnabledObject,
  24572. /**
  24573. * The type of the physics imposter
  24574. */
  24575. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24576. /**
  24577. * This function will completly initialize this impostor.
  24578. * It will create a new body - but only if this mesh has no parent.
  24579. * If it has, this impostor will not be used other than to define the impostor
  24580. * of the child mesh.
  24581. * @hidden
  24582. */
  24583. _init(): void;
  24584. private _getPhysicsParent;
  24585. /**
  24586. * Should a new body be generated.
  24587. * @returns boolean specifying if body initialization is required
  24588. */
  24589. isBodyInitRequired(): boolean;
  24590. /**
  24591. * Sets the updated scaling
  24592. * @param updated Specifies if the scaling is updated
  24593. */
  24594. setScalingUpdated(): void;
  24595. /**
  24596. * Force a regeneration of this or the parent's impostor's body.
  24597. * Use under cautious - This will remove all joints already implemented.
  24598. */
  24599. forceUpdate(): void;
  24600. /**
  24601. * Gets the body that holds this impostor. Either its own, or its parent.
  24602. */
  24603. get physicsBody(): any;
  24604. /**
  24605. * Get the parent of the physics imposter
  24606. * @returns Physics imposter or null
  24607. */
  24608. get parent(): Nullable<PhysicsImpostor>;
  24609. /**
  24610. * Sets the parent of the physics imposter
  24611. */
  24612. set parent(value: Nullable<PhysicsImpostor>);
  24613. /**
  24614. * Set the physics body. Used mainly by the physics engine/plugin
  24615. */
  24616. set physicsBody(physicsBody: any);
  24617. /**
  24618. * Resets the update flags
  24619. */
  24620. resetUpdateFlags(): void;
  24621. /**
  24622. * Gets the object extend size
  24623. * @returns the object extend size
  24624. */
  24625. getObjectExtendSize(): Vector3;
  24626. /**
  24627. * Gets the object center
  24628. * @returns The object center
  24629. */
  24630. getObjectCenter(): Vector3;
  24631. /**
  24632. * Get a specific parameter from the options parameters
  24633. * @param paramName The object parameter name
  24634. * @returns The object parameter
  24635. */
  24636. getParam(paramName: string): any;
  24637. /**
  24638. * Sets a specific parameter in the options given to the physics plugin
  24639. * @param paramName The parameter name
  24640. * @param value The value of the parameter
  24641. */
  24642. setParam(paramName: string, value: number): void;
  24643. /**
  24644. * Specifically change the body's mass option. Won't recreate the physics body object
  24645. * @param mass The mass of the physics imposter
  24646. */
  24647. setMass(mass: number): void;
  24648. /**
  24649. * Gets the linear velocity
  24650. * @returns linear velocity or null
  24651. */
  24652. getLinearVelocity(): Nullable<Vector3>;
  24653. /**
  24654. * Sets the linear velocity
  24655. * @param velocity linear velocity or null
  24656. */
  24657. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24658. /**
  24659. * Gets the angular velocity
  24660. * @returns angular velocity or null
  24661. */
  24662. getAngularVelocity(): Nullable<Vector3>;
  24663. /**
  24664. * Sets the angular velocity
  24665. * @param velocity The velocity or null
  24666. */
  24667. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24668. /**
  24669. * Execute a function with the physics plugin native code
  24670. * Provide a function the will have two variables - the world object and the physics body object
  24671. * @param func The function to execute with the physics plugin native code
  24672. */
  24673. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24674. /**
  24675. * Register a function that will be executed before the physics world is stepping forward
  24676. * @param func The function to execute before the physics world is stepped forward
  24677. */
  24678. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24679. /**
  24680. * Unregister a function that will be executed before the physics world is stepping forward
  24681. * @param func The function to execute before the physics world is stepped forward
  24682. */
  24683. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24684. /**
  24685. * Register a function that will be executed after the physics step
  24686. * @param func The function to execute after physics step
  24687. */
  24688. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24689. /**
  24690. * Unregisters a function that will be executed after the physics step
  24691. * @param func The function to execute after physics step
  24692. */
  24693. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24694. /**
  24695. * register a function that will be executed when this impostor collides against a different body
  24696. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24697. * @param func Callback that is executed on collision
  24698. */
  24699. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24700. /**
  24701. * Unregisters the physics imposter on contact
  24702. * @param collideAgainst The physics object to collide against
  24703. * @param func Callback to execute on collision
  24704. */
  24705. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24706. private _tmpQuat;
  24707. private _tmpQuat2;
  24708. /**
  24709. * Get the parent rotation
  24710. * @returns The parent rotation
  24711. */
  24712. getParentsRotation(): Quaternion;
  24713. /**
  24714. * this function is executed by the physics engine.
  24715. */
  24716. beforeStep: () => void;
  24717. /**
  24718. * this function is executed by the physics engine
  24719. */
  24720. afterStep: () => void;
  24721. /**
  24722. * Legacy collision detection event support
  24723. */
  24724. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24725. /**
  24726. * event and body object due to cannon's event-based architecture.
  24727. */
  24728. onCollide: (e: {
  24729. body: any;
  24730. }) => void;
  24731. /**
  24732. * Apply a force
  24733. * @param force The force to apply
  24734. * @param contactPoint The contact point for the force
  24735. * @returns The physics imposter
  24736. */
  24737. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24738. /**
  24739. * Apply an impulse
  24740. * @param force The impulse force
  24741. * @param contactPoint The contact point for the impulse force
  24742. * @returns The physics imposter
  24743. */
  24744. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24745. /**
  24746. * A help function to create a joint
  24747. * @param otherImpostor A physics imposter used to create a joint
  24748. * @param jointType The type of joint
  24749. * @param jointData The data for the joint
  24750. * @returns The physics imposter
  24751. */
  24752. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24753. /**
  24754. * Add a joint to this impostor with a different impostor
  24755. * @param otherImpostor A physics imposter used to add a joint
  24756. * @param joint The joint to add
  24757. * @returns The physics imposter
  24758. */
  24759. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24760. /**
  24761. * Add an anchor to a cloth impostor
  24762. * @param otherImpostor rigid impostor to anchor to
  24763. * @param width ratio across width from 0 to 1
  24764. * @param height ratio up height from 0 to 1
  24765. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24766. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24767. * @returns impostor the soft imposter
  24768. */
  24769. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24770. /**
  24771. * Add a hook to a rope impostor
  24772. * @param otherImpostor rigid impostor to anchor to
  24773. * @param length ratio across rope from 0 to 1
  24774. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24775. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24776. * @returns impostor the rope imposter
  24777. */
  24778. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24779. /**
  24780. * Will keep this body still, in a sleep mode.
  24781. * @returns the physics imposter
  24782. */
  24783. sleep(): PhysicsImpostor;
  24784. /**
  24785. * Wake the body up.
  24786. * @returns The physics imposter
  24787. */
  24788. wakeUp(): PhysicsImpostor;
  24789. /**
  24790. * Clones the physics imposter
  24791. * @param newObject The physics imposter clones to this physics-enabled object
  24792. * @returns A nullable physics imposter
  24793. */
  24794. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24795. /**
  24796. * Disposes the physics imposter
  24797. */
  24798. dispose(): void;
  24799. /**
  24800. * Sets the delta position
  24801. * @param position The delta position amount
  24802. */
  24803. setDeltaPosition(position: Vector3): void;
  24804. /**
  24805. * Sets the delta rotation
  24806. * @param rotation The delta rotation amount
  24807. */
  24808. setDeltaRotation(rotation: Quaternion): void;
  24809. /**
  24810. * Gets the box size of the physics imposter and stores the result in the input parameter
  24811. * @param result Stores the box size
  24812. * @returns The physics imposter
  24813. */
  24814. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24815. /**
  24816. * Gets the radius of the physics imposter
  24817. * @returns Radius of the physics imposter
  24818. */
  24819. getRadius(): number;
  24820. /**
  24821. * Sync a bone with this impostor
  24822. * @param bone The bone to sync to the impostor.
  24823. * @param boneMesh The mesh that the bone is influencing.
  24824. * @param jointPivot The pivot of the joint / bone in local space.
  24825. * @param distToJoint Optional distance from the impostor to the joint.
  24826. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24827. */
  24828. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24829. /**
  24830. * Sync impostor to a bone
  24831. * @param bone The bone that the impostor will be synced to.
  24832. * @param boneMesh The mesh that the bone is influencing.
  24833. * @param jointPivot The pivot of the joint / bone in local space.
  24834. * @param distToJoint Optional distance from the impostor to the joint.
  24835. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24836. * @param boneAxis Optional vector3 axis the bone is aligned with
  24837. */
  24838. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24839. /**
  24840. * No-Imposter type
  24841. */
  24842. static NoImpostor: number;
  24843. /**
  24844. * Sphere-Imposter type
  24845. */
  24846. static SphereImpostor: number;
  24847. /**
  24848. * Box-Imposter type
  24849. */
  24850. static BoxImpostor: number;
  24851. /**
  24852. * Plane-Imposter type
  24853. */
  24854. static PlaneImpostor: number;
  24855. /**
  24856. * Mesh-imposter type
  24857. */
  24858. static MeshImpostor: number;
  24859. /**
  24860. * Capsule-Impostor type (Ammo.js plugin only)
  24861. */
  24862. static CapsuleImpostor: number;
  24863. /**
  24864. * Cylinder-Imposter type
  24865. */
  24866. static CylinderImpostor: number;
  24867. /**
  24868. * Particle-Imposter type
  24869. */
  24870. static ParticleImpostor: number;
  24871. /**
  24872. * Heightmap-Imposter type
  24873. */
  24874. static HeightmapImpostor: number;
  24875. /**
  24876. * ConvexHull-Impostor type (Ammo.js plugin only)
  24877. */
  24878. static ConvexHullImpostor: number;
  24879. /**
  24880. * Custom-Imposter type (Ammo.js plugin only)
  24881. */
  24882. static CustomImpostor: number;
  24883. /**
  24884. * Rope-Imposter type
  24885. */
  24886. static RopeImpostor: number;
  24887. /**
  24888. * Cloth-Imposter type
  24889. */
  24890. static ClothImpostor: number;
  24891. /**
  24892. * Softbody-Imposter type
  24893. */
  24894. static SoftbodyImpostor: number;
  24895. }
  24896. }
  24897. declare module "babylonjs/Meshes/mesh" {
  24898. import { Observable } from "babylonjs/Misc/observable";
  24899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24900. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24901. import { Camera } from "babylonjs/Cameras/camera";
  24902. import { Scene } from "babylonjs/scene";
  24903. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24904. import { Color4 } from "babylonjs/Maths/math.color";
  24905. import { Engine } from "babylonjs/Engines/engine";
  24906. import { Node } from "babylonjs/node";
  24907. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24908. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24909. import { Buffer } from "babylonjs/Meshes/buffer";
  24910. import { Geometry } from "babylonjs/Meshes/geometry";
  24911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24912. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24913. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24914. import { Effect } from "babylonjs/Materials/effect";
  24915. import { Material } from "babylonjs/Materials/material";
  24916. import { Skeleton } from "babylonjs/Bones/skeleton";
  24917. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24918. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24919. import { Path3D } from "babylonjs/Maths/math.path";
  24920. import { Plane } from "babylonjs/Maths/math.plane";
  24921. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24922. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24923. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24924. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24925. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24926. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24927. /**
  24928. * @hidden
  24929. **/
  24930. export class _CreationDataStorage {
  24931. closePath?: boolean;
  24932. closeArray?: boolean;
  24933. idx: number[];
  24934. dashSize: number;
  24935. gapSize: number;
  24936. path3D: Path3D;
  24937. pathArray: Vector3[][];
  24938. arc: number;
  24939. radius: number;
  24940. cap: number;
  24941. tessellation: number;
  24942. }
  24943. /**
  24944. * @hidden
  24945. **/
  24946. class _InstanceDataStorage {
  24947. visibleInstances: any;
  24948. batchCache: _InstancesBatch;
  24949. instancesBufferSize: number;
  24950. instancesBuffer: Nullable<Buffer>;
  24951. instancesData: Float32Array;
  24952. overridenInstanceCount: number;
  24953. isFrozen: boolean;
  24954. previousBatch: Nullable<_InstancesBatch>;
  24955. hardwareInstancedRendering: boolean;
  24956. sideOrientation: number;
  24957. manualUpdate: boolean;
  24958. }
  24959. /**
  24960. * @hidden
  24961. **/
  24962. export class _InstancesBatch {
  24963. mustReturn: boolean;
  24964. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24965. renderSelf: boolean[];
  24966. hardwareInstancedRendering: boolean[];
  24967. }
  24968. /**
  24969. * Class used to represent renderable models
  24970. */
  24971. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24972. /**
  24973. * Mesh side orientation : usually the external or front surface
  24974. */
  24975. static readonly FRONTSIDE: number;
  24976. /**
  24977. * Mesh side orientation : usually the internal or back surface
  24978. */
  24979. static readonly BACKSIDE: number;
  24980. /**
  24981. * Mesh side orientation : both internal and external or front and back surfaces
  24982. */
  24983. static readonly DOUBLESIDE: number;
  24984. /**
  24985. * Mesh side orientation : by default, `FRONTSIDE`
  24986. */
  24987. static readonly DEFAULTSIDE: number;
  24988. /**
  24989. * Mesh cap setting : no cap
  24990. */
  24991. static readonly NO_CAP: number;
  24992. /**
  24993. * Mesh cap setting : one cap at the beginning of the mesh
  24994. */
  24995. static readonly CAP_START: number;
  24996. /**
  24997. * Mesh cap setting : one cap at the end of the mesh
  24998. */
  24999. static readonly CAP_END: number;
  25000. /**
  25001. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25002. */
  25003. static readonly CAP_ALL: number;
  25004. /**
  25005. * Mesh pattern setting : no flip or rotate
  25006. */
  25007. static readonly NO_FLIP: number;
  25008. /**
  25009. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25010. */
  25011. static readonly FLIP_TILE: number;
  25012. /**
  25013. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25014. */
  25015. static readonly ROTATE_TILE: number;
  25016. /**
  25017. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25018. */
  25019. static readonly FLIP_ROW: number;
  25020. /**
  25021. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25022. */
  25023. static readonly ROTATE_ROW: number;
  25024. /**
  25025. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25026. */
  25027. static readonly FLIP_N_ROTATE_TILE: number;
  25028. /**
  25029. * Mesh pattern setting : rotate pattern and rotate
  25030. */
  25031. static readonly FLIP_N_ROTATE_ROW: number;
  25032. /**
  25033. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25034. */
  25035. static readonly CENTER: number;
  25036. /**
  25037. * Mesh tile positioning : part tiles on left
  25038. */
  25039. static readonly LEFT: number;
  25040. /**
  25041. * Mesh tile positioning : part tiles on right
  25042. */
  25043. static readonly RIGHT: number;
  25044. /**
  25045. * Mesh tile positioning : part tiles on top
  25046. */
  25047. static readonly TOP: number;
  25048. /**
  25049. * Mesh tile positioning : part tiles on bottom
  25050. */
  25051. static readonly BOTTOM: number;
  25052. /**
  25053. * Gets the default side orientation.
  25054. * @param orientation the orientation to value to attempt to get
  25055. * @returns the default orientation
  25056. * @hidden
  25057. */
  25058. static _GetDefaultSideOrientation(orientation?: number): number;
  25059. private _internalMeshDataInfo;
  25060. /**
  25061. * An event triggered before rendering the mesh
  25062. */
  25063. get onBeforeRenderObservable(): Observable<Mesh>;
  25064. /**
  25065. * An event triggered before binding the mesh
  25066. */
  25067. get onBeforeBindObservable(): Observable<Mesh>;
  25068. /**
  25069. * An event triggered after rendering the mesh
  25070. */
  25071. get onAfterRenderObservable(): Observable<Mesh>;
  25072. /**
  25073. * An event triggered before drawing the mesh
  25074. */
  25075. get onBeforeDrawObservable(): Observable<Mesh>;
  25076. private _onBeforeDrawObserver;
  25077. /**
  25078. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25079. */
  25080. set onBeforeDraw(callback: () => void);
  25081. get hasInstances(): boolean;
  25082. /**
  25083. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25084. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25085. */
  25086. delayLoadState: number;
  25087. /**
  25088. * Gets the list of instances created from this mesh
  25089. * it is not supposed to be modified manually.
  25090. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25091. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25092. */
  25093. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25094. /**
  25095. * Gets the file containing delay loading data for this mesh
  25096. */
  25097. delayLoadingFile: string;
  25098. /** @hidden */
  25099. _binaryInfo: any;
  25100. /**
  25101. * User defined function used to change how LOD level selection is done
  25102. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25103. */
  25104. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25105. /**
  25106. * Gets or sets the morph target manager
  25107. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25108. */
  25109. get morphTargetManager(): Nullable<MorphTargetManager>;
  25110. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25111. /** @hidden */
  25112. _creationDataStorage: Nullable<_CreationDataStorage>;
  25113. /** @hidden */
  25114. _geometry: Nullable<Geometry>;
  25115. /** @hidden */
  25116. _delayInfo: Array<string>;
  25117. /** @hidden */
  25118. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25119. /** @hidden */
  25120. _instanceDataStorage: _InstanceDataStorage;
  25121. private _effectiveMaterial;
  25122. /** @hidden */
  25123. _shouldGenerateFlatShading: boolean;
  25124. /** @hidden */
  25125. _originalBuilderSideOrientation: number;
  25126. /**
  25127. * Use this property to change the original side orientation defined at construction time
  25128. */
  25129. overrideMaterialSideOrientation: Nullable<number>;
  25130. /**
  25131. * Gets the source mesh (the one used to clone this one from)
  25132. */
  25133. get source(): Nullable<Mesh>;
  25134. /**
  25135. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25136. */
  25137. get isUnIndexed(): boolean;
  25138. set isUnIndexed(value: boolean);
  25139. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25140. get worldMatrixInstancedBuffer(): Float32Array;
  25141. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25142. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25143. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25144. /**
  25145. * @constructor
  25146. * @param name The value used by scene.getMeshByName() to do a lookup.
  25147. * @param scene The scene to add this mesh to.
  25148. * @param parent The parent of this mesh, if it has one
  25149. * @param source An optional Mesh from which geometry is shared, cloned.
  25150. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25151. * When false, achieved by calling a clone(), also passing False.
  25152. * This will make creation of children, recursive.
  25153. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25154. */
  25155. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25156. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25157. doNotInstantiate: boolean;
  25158. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25159. /**
  25160. * Gets the class name
  25161. * @returns the string "Mesh".
  25162. */
  25163. getClassName(): string;
  25164. /** @hidden */
  25165. get _isMesh(): boolean;
  25166. /**
  25167. * Returns a description of this mesh
  25168. * @param fullDetails define if full details about this mesh must be used
  25169. * @returns a descriptive string representing this mesh
  25170. */
  25171. toString(fullDetails?: boolean): string;
  25172. /** @hidden */
  25173. _unBindEffect(): void;
  25174. /**
  25175. * Gets a boolean indicating if this mesh has LOD
  25176. */
  25177. get hasLODLevels(): boolean;
  25178. /**
  25179. * Gets the list of MeshLODLevel associated with the current mesh
  25180. * @returns an array of MeshLODLevel
  25181. */
  25182. getLODLevels(): MeshLODLevel[];
  25183. private _sortLODLevels;
  25184. /**
  25185. * Add a mesh as LOD level triggered at the given distance.
  25186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25187. * @param distance The distance from the center of the object to show this level
  25188. * @param mesh The mesh to be added as LOD level (can be null)
  25189. * @return This mesh (for chaining)
  25190. */
  25191. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25192. /**
  25193. * Returns the LOD level mesh at the passed distance or null if not found.
  25194. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25195. * @param distance The distance from the center of the object to show this level
  25196. * @returns a Mesh or `null`
  25197. */
  25198. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25199. /**
  25200. * Remove a mesh from the LOD array
  25201. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25202. * @param mesh defines the mesh to be removed
  25203. * @return This mesh (for chaining)
  25204. */
  25205. removeLODLevel(mesh: Mesh): Mesh;
  25206. /**
  25207. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25208. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25209. * @param camera defines the camera to use to compute distance
  25210. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25211. * @return This mesh (for chaining)
  25212. */
  25213. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25214. /**
  25215. * Gets the mesh internal Geometry object
  25216. */
  25217. get geometry(): Nullable<Geometry>;
  25218. /**
  25219. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25220. * @returns the total number of vertices
  25221. */
  25222. getTotalVertices(): number;
  25223. /**
  25224. * Returns the content of an associated vertex buffer
  25225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25226. * - VertexBuffer.PositionKind
  25227. * - VertexBuffer.UVKind
  25228. * - VertexBuffer.UV2Kind
  25229. * - VertexBuffer.UV3Kind
  25230. * - VertexBuffer.UV4Kind
  25231. * - VertexBuffer.UV5Kind
  25232. * - VertexBuffer.UV6Kind
  25233. * - VertexBuffer.ColorKind
  25234. * - VertexBuffer.MatricesIndicesKind
  25235. * - VertexBuffer.MatricesIndicesExtraKind
  25236. * - VertexBuffer.MatricesWeightsKind
  25237. * - VertexBuffer.MatricesWeightsExtraKind
  25238. * @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
  25239. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25240. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25241. */
  25242. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25243. /**
  25244. * Returns the mesh VertexBuffer object from the requested `kind`
  25245. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25246. * - VertexBuffer.PositionKind
  25247. * - VertexBuffer.NormalKind
  25248. * - VertexBuffer.UVKind
  25249. * - VertexBuffer.UV2Kind
  25250. * - VertexBuffer.UV3Kind
  25251. * - VertexBuffer.UV4Kind
  25252. * - VertexBuffer.UV5Kind
  25253. * - VertexBuffer.UV6Kind
  25254. * - VertexBuffer.ColorKind
  25255. * - VertexBuffer.MatricesIndicesKind
  25256. * - VertexBuffer.MatricesIndicesExtraKind
  25257. * - VertexBuffer.MatricesWeightsKind
  25258. * - VertexBuffer.MatricesWeightsExtraKind
  25259. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25260. */
  25261. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25262. /**
  25263. * Tests if a specific vertex buffer is associated with this mesh
  25264. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25265. * - VertexBuffer.PositionKind
  25266. * - VertexBuffer.NormalKind
  25267. * - VertexBuffer.UVKind
  25268. * - VertexBuffer.UV2Kind
  25269. * - VertexBuffer.UV3Kind
  25270. * - VertexBuffer.UV4Kind
  25271. * - VertexBuffer.UV5Kind
  25272. * - VertexBuffer.UV6Kind
  25273. * - VertexBuffer.ColorKind
  25274. * - VertexBuffer.MatricesIndicesKind
  25275. * - VertexBuffer.MatricesIndicesExtraKind
  25276. * - VertexBuffer.MatricesWeightsKind
  25277. * - VertexBuffer.MatricesWeightsExtraKind
  25278. * @returns a boolean
  25279. */
  25280. isVerticesDataPresent(kind: string): boolean;
  25281. /**
  25282. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25283. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25284. * - VertexBuffer.PositionKind
  25285. * - VertexBuffer.UVKind
  25286. * - VertexBuffer.UV2Kind
  25287. * - VertexBuffer.UV3Kind
  25288. * - VertexBuffer.UV4Kind
  25289. * - VertexBuffer.UV5Kind
  25290. * - VertexBuffer.UV6Kind
  25291. * - VertexBuffer.ColorKind
  25292. * - VertexBuffer.MatricesIndicesKind
  25293. * - VertexBuffer.MatricesIndicesExtraKind
  25294. * - VertexBuffer.MatricesWeightsKind
  25295. * - VertexBuffer.MatricesWeightsExtraKind
  25296. * @returns a boolean
  25297. */
  25298. isVertexBufferUpdatable(kind: string): boolean;
  25299. /**
  25300. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25301. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25302. * - VertexBuffer.PositionKind
  25303. * - VertexBuffer.NormalKind
  25304. * - VertexBuffer.UVKind
  25305. * - VertexBuffer.UV2Kind
  25306. * - VertexBuffer.UV3Kind
  25307. * - VertexBuffer.UV4Kind
  25308. * - VertexBuffer.UV5Kind
  25309. * - VertexBuffer.UV6Kind
  25310. * - VertexBuffer.ColorKind
  25311. * - VertexBuffer.MatricesIndicesKind
  25312. * - VertexBuffer.MatricesIndicesExtraKind
  25313. * - VertexBuffer.MatricesWeightsKind
  25314. * - VertexBuffer.MatricesWeightsExtraKind
  25315. * @returns an array of strings
  25316. */
  25317. getVerticesDataKinds(): string[];
  25318. /**
  25319. * Returns a positive integer : the total number of indices in this mesh geometry.
  25320. * @returns the numner of indices or zero if the mesh has no geometry.
  25321. */
  25322. getTotalIndices(): number;
  25323. /**
  25324. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25325. * @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.
  25326. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25327. * @returns the indices array or an empty array if the mesh has no geometry
  25328. */
  25329. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25330. get isBlocked(): boolean;
  25331. /**
  25332. * Determine if the current mesh is ready to be rendered
  25333. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25334. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25335. * @returns true if all associated assets are ready (material, textures, shaders)
  25336. */
  25337. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25338. /**
  25339. * 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.
  25340. */
  25341. get areNormalsFrozen(): boolean;
  25342. /**
  25343. * 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.
  25344. * @returns the current mesh
  25345. */
  25346. freezeNormals(): Mesh;
  25347. /**
  25348. * 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
  25349. * @returns the current mesh
  25350. */
  25351. unfreezeNormals(): Mesh;
  25352. /**
  25353. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25354. */
  25355. set overridenInstanceCount(count: number);
  25356. /** @hidden */
  25357. _preActivate(): Mesh;
  25358. /** @hidden */
  25359. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25360. /** @hidden */
  25361. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25362. /**
  25363. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25364. * This means the mesh underlying bounding box and sphere are recomputed.
  25365. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25366. * @returns the current mesh
  25367. */
  25368. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25369. /** @hidden */
  25370. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25371. /**
  25372. * This function will subdivide the mesh into multiple submeshes
  25373. * @param count defines the expected number of submeshes
  25374. */
  25375. subdivide(count: number): void;
  25376. /**
  25377. * Copy a FloatArray into a specific associated vertex buffer
  25378. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25379. * - VertexBuffer.PositionKind
  25380. * - VertexBuffer.UVKind
  25381. * - VertexBuffer.UV2Kind
  25382. * - VertexBuffer.UV3Kind
  25383. * - VertexBuffer.UV4Kind
  25384. * - VertexBuffer.UV5Kind
  25385. * - VertexBuffer.UV6Kind
  25386. * - VertexBuffer.ColorKind
  25387. * - VertexBuffer.MatricesIndicesKind
  25388. * - VertexBuffer.MatricesIndicesExtraKind
  25389. * - VertexBuffer.MatricesWeightsKind
  25390. * - VertexBuffer.MatricesWeightsExtraKind
  25391. * @param data defines the data source
  25392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25393. * @param stride defines the data stride size (can be null)
  25394. * @returns the current mesh
  25395. */
  25396. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25397. /**
  25398. * Delete a vertex buffer associated with this mesh
  25399. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25400. * - VertexBuffer.PositionKind
  25401. * - VertexBuffer.UVKind
  25402. * - VertexBuffer.UV2Kind
  25403. * - VertexBuffer.UV3Kind
  25404. * - VertexBuffer.UV4Kind
  25405. * - VertexBuffer.UV5Kind
  25406. * - VertexBuffer.UV6Kind
  25407. * - VertexBuffer.ColorKind
  25408. * - VertexBuffer.MatricesIndicesKind
  25409. * - VertexBuffer.MatricesIndicesExtraKind
  25410. * - VertexBuffer.MatricesWeightsKind
  25411. * - VertexBuffer.MatricesWeightsExtraKind
  25412. */
  25413. removeVerticesData(kind: string): void;
  25414. /**
  25415. * Flags an associated vertex buffer as updatable
  25416. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25417. * - VertexBuffer.PositionKind
  25418. * - VertexBuffer.UVKind
  25419. * - VertexBuffer.UV2Kind
  25420. * - VertexBuffer.UV3Kind
  25421. * - VertexBuffer.UV4Kind
  25422. * - VertexBuffer.UV5Kind
  25423. * - VertexBuffer.UV6Kind
  25424. * - VertexBuffer.ColorKind
  25425. * - VertexBuffer.MatricesIndicesKind
  25426. * - VertexBuffer.MatricesIndicesExtraKind
  25427. * - VertexBuffer.MatricesWeightsKind
  25428. * - VertexBuffer.MatricesWeightsExtraKind
  25429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25430. */
  25431. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25432. /**
  25433. * Sets the mesh global Vertex Buffer
  25434. * @param buffer defines the buffer to use
  25435. * @returns the current mesh
  25436. */
  25437. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25438. /**
  25439. * Update a specific associated vertex buffer
  25440. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25441. * - VertexBuffer.PositionKind
  25442. * - VertexBuffer.UVKind
  25443. * - VertexBuffer.UV2Kind
  25444. * - VertexBuffer.UV3Kind
  25445. * - VertexBuffer.UV4Kind
  25446. * - VertexBuffer.UV5Kind
  25447. * - VertexBuffer.UV6Kind
  25448. * - VertexBuffer.ColorKind
  25449. * - VertexBuffer.MatricesIndicesKind
  25450. * - VertexBuffer.MatricesIndicesExtraKind
  25451. * - VertexBuffer.MatricesWeightsKind
  25452. * - VertexBuffer.MatricesWeightsExtraKind
  25453. * @param data defines the data source
  25454. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25455. * @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)
  25456. * @returns the current mesh
  25457. */
  25458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25459. /**
  25460. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25461. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25462. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25463. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25464. * @returns the current mesh
  25465. */
  25466. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25467. /**
  25468. * Creates a un-shared specific occurence of the geometry for the mesh.
  25469. * @returns the current mesh
  25470. */
  25471. makeGeometryUnique(): Mesh;
  25472. /**
  25473. * Set the index buffer of this mesh
  25474. * @param indices defines the source data
  25475. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25476. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25477. * @returns the current mesh
  25478. */
  25479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25480. /**
  25481. * Update the current index buffer
  25482. * @param indices defines the source data
  25483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25484. * @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)
  25485. * @returns the current mesh
  25486. */
  25487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25488. /**
  25489. * Invert the geometry to move from a right handed system to a left handed one.
  25490. * @returns the current mesh
  25491. */
  25492. toLeftHanded(): Mesh;
  25493. /** @hidden */
  25494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25495. /** @hidden */
  25496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25497. /**
  25498. * Registers for this mesh a javascript function called just before the rendering process
  25499. * @param func defines the function to call before rendering this mesh
  25500. * @returns the current mesh
  25501. */
  25502. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25503. /**
  25504. * Disposes a previously registered javascript function called before the rendering
  25505. * @param func defines the function to remove
  25506. * @returns the current mesh
  25507. */
  25508. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25509. /**
  25510. * Registers for this mesh a javascript function called just after the rendering is complete
  25511. * @param func defines the function to call after rendering this mesh
  25512. * @returns the current mesh
  25513. */
  25514. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25515. /**
  25516. * Disposes a previously registered javascript function called after the rendering.
  25517. * @param func defines the function to remove
  25518. * @returns the current mesh
  25519. */
  25520. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25521. /** @hidden */
  25522. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25523. /** @hidden */
  25524. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25525. /** @hidden */
  25526. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25527. /** @hidden */
  25528. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25529. /** @hidden */
  25530. _rebuild(): void;
  25531. /** @hidden */
  25532. _freeze(): void;
  25533. /** @hidden */
  25534. _unFreeze(): void;
  25535. /**
  25536. * 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
  25537. * @param subMesh defines the subMesh to render
  25538. * @param enableAlphaMode defines if alpha mode can be changed
  25539. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25540. * @returns the current mesh
  25541. */
  25542. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25543. private _onBeforeDraw;
  25544. /**
  25545. * Renormalize the mesh and patch it up if there are no weights
  25546. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25547. * However in the case of zero weights then we set just a single influence to 1.
  25548. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25549. */
  25550. cleanMatrixWeights(): void;
  25551. private normalizeSkinFourWeights;
  25552. private normalizeSkinWeightsAndExtra;
  25553. /**
  25554. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25555. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25556. * the user know there was an issue with importing the mesh
  25557. * @returns a validation object with skinned, valid and report string
  25558. */
  25559. validateSkinning(): {
  25560. skinned: boolean;
  25561. valid: boolean;
  25562. report: string;
  25563. };
  25564. /** @hidden */
  25565. _checkDelayState(): Mesh;
  25566. private _queueLoad;
  25567. /**
  25568. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25569. * A mesh is in the frustum if its bounding box intersects the frustum
  25570. * @param frustumPlanes defines the frustum to test
  25571. * @returns true if the mesh is in the frustum planes
  25572. */
  25573. isInFrustum(frustumPlanes: Plane[]): boolean;
  25574. /**
  25575. * Sets the mesh material by the material or multiMaterial `id` property
  25576. * @param id is a string identifying the material or the multiMaterial
  25577. * @returns the current mesh
  25578. */
  25579. setMaterialByID(id: string): Mesh;
  25580. /**
  25581. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25582. * @returns an array of IAnimatable
  25583. */
  25584. getAnimatables(): IAnimatable[];
  25585. /**
  25586. * Modifies the mesh geometry according to the passed transformation matrix.
  25587. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25588. * The mesh normals are modified using the same transformation.
  25589. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25590. * @param transform defines the transform matrix to use
  25591. * @see http://doc.babylonjs.com/resources/baking_transformations
  25592. * @returns the current mesh
  25593. */
  25594. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25595. /**
  25596. * Modifies the mesh geometry according to its own current World Matrix.
  25597. * The mesh World Matrix is then reset.
  25598. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25599. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25600. * @see http://doc.babylonjs.com/resources/baking_transformations
  25601. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25602. * @returns the current mesh
  25603. */
  25604. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25605. /** @hidden */
  25606. get _positions(): Nullable<Vector3[]>;
  25607. /** @hidden */
  25608. _resetPointsArrayCache(): Mesh;
  25609. /** @hidden */
  25610. _generatePointsArray(): boolean;
  25611. /**
  25612. * Returns a new Mesh object generated from the current mesh properties.
  25613. * This method must not get confused with createInstance()
  25614. * @param name is a string, the name given to the new mesh
  25615. * @param newParent can be any Node object (default `null`)
  25616. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25617. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25618. * @returns a new mesh
  25619. */
  25620. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25621. /**
  25622. * Releases resources associated with this mesh.
  25623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25625. */
  25626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25627. /** @hidden */
  25628. _disposeInstanceSpecificData(): void;
  25629. /**
  25630. * Modifies the mesh geometry according to a displacement map.
  25631. * 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.
  25632. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25633. * @param url is a string, the URL from the image file is to be downloaded.
  25634. * @param minHeight is the lower limit of the displacement.
  25635. * @param maxHeight is the upper limit of the displacement.
  25636. * @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.
  25637. * @param uvOffset is an optional vector2 used to offset UV.
  25638. * @param uvScale is an optional vector2 used to scale UV.
  25639. * @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.
  25640. * @returns the Mesh.
  25641. */
  25642. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25643. /**
  25644. * Modifies the mesh geometry according to a displacementMap buffer.
  25645. * 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.
  25646. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25647. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25648. * @param heightMapWidth is the width of the buffer image.
  25649. * @param heightMapHeight is the height of the buffer image.
  25650. * @param minHeight is the lower limit of the displacement.
  25651. * @param maxHeight is the upper limit of the displacement.
  25652. * @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.
  25653. * @param uvOffset is an optional vector2 used to offset UV.
  25654. * @param uvScale is an optional vector2 used to scale UV.
  25655. * @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.
  25656. * @returns the Mesh.
  25657. */
  25658. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25659. /**
  25660. * Modify the mesh to get a flat shading rendering.
  25661. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25662. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25663. * @returns current mesh
  25664. */
  25665. convertToFlatShadedMesh(): Mesh;
  25666. /**
  25667. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25668. * In other words, more vertices, no more indices and a single bigger VBO.
  25669. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25670. * @returns current mesh
  25671. */
  25672. convertToUnIndexedMesh(): Mesh;
  25673. /**
  25674. * Inverses facet orientations.
  25675. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25676. * @param flipNormals will also inverts the normals
  25677. * @returns current mesh
  25678. */
  25679. flipFaces(flipNormals?: boolean): Mesh;
  25680. /**
  25681. * Increase the number of facets and hence vertices in a mesh
  25682. * Vertex normals are interpolated from existing vertex normals
  25683. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25684. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25685. */
  25686. increaseVertices(numberPerEdge: number): void;
  25687. /**
  25688. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25689. * This will undo any application of covertToFlatShadedMesh
  25690. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25691. */
  25692. forceSharedVertices(): void;
  25693. /** @hidden */
  25694. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25695. /** @hidden */
  25696. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25697. /**
  25698. * Creates a new InstancedMesh object from the mesh model.
  25699. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25700. * @param name defines the name of the new instance
  25701. * @returns a new InstancedMesh
  25702. */
  25703. createInstance(name: string): InstancedMesh;
  25704. /**
  25705. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25706. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25707. * @returns the current mesh
  25708. */
  25709. synchronizeInstances(): Mesh;
  25710. /**
  25711. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25712. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25713. * This should be used together with the simplification to avoid disappearing triangles.
  25714. * @param successCallback an optional success callback to be called after the optimization finished.
  25715. * @returns the current mesh
  25716. */
  25717. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25718. /**
  25719. * Serialize current mesh
  25720. * @param serializationObject defines the object which will receive the serialization data
  25721. */
  25722. serialize(serializationObject: any): void;
  25723. /** @hidden */
  25724. _syncGeometryWithMorphTargetManager(): void;
  25725. /** @hidden */
  25726. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25727. /**
  25728. * Returns a new Mesh object parsed from the source provided.
  25729. * @param parsedMesh is the source
  25730. * @param scene defines the hosting scene
  25731. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25732. * @returns a new Mesh
  25733. */
  25734. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25735. /**
  25736. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25737. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25738. * @param name defines the name of the mesh to create
  25739. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25740. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25741. * @param closePath creates a seam between the first and the last points of each path of the path array
  25742. * @param offset is taken in account only if the `pathArray` is containing a single path
  25743. * @param scene defines the hosting scene
  25744. * @param updatable defines if the mesh must be flagged as updatable
  25745. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25746. * @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)
  25747. * @returns a new Mesh
  25748. */
  25749. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25750. /**
  25751. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25752. * @param name defines the name of the mesh to create
  25753. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25754. * @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
  25755. * @param scene defines the hosting scene
  25756. * @param updatable defines if the mesh must be flagged as updatable
  25757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25758. * @returns a new Mesh
  25759. */
  25760. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25761. /**
  25762. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25763. * @param name defines the name of the mesh to create
  25764. * @param size sets the size (float) of each box side (default 1)
  25765. * @param scene defines the hosting scene
  25766. * @param updatable defines if the mesh must be flagged as updatable
  25767. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25768. * @returns a new Mesh
  25769. */
  25770. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25771. /**
  25772. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25773. * @param name defines the name of the mesh to create
  25774. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25775. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25782. /**
  25783. * Creates a hemisphere 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. * @returns a new Mesh
  25789. */
  25790. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25791. /**
  25792. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25793. * @param name defines the name of the mesh to create
  25794. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25795. * @param diameterTop set the top cap diameter (floats, default 1)
  25796. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25797. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25798. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25799. * @param scene defines the hosting scene
  25800. * @param updatable defines if the mesh must be flagged as updatable
  25801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25802. * @returns a new Mesh
  25803. */
  25804. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25805. /**
  25806. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25807. * @param name defines the name of the mesh to create
  25808. * @param diameter sets the diameter size (float) of the torus (default 1)
  25809. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25810. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25817. /**
  25818. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25821. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25822. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25823. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25824. * @param p the number of windings on X axis (positive integers, default 2)
  25825. * @param q the number of windings on Y axis (positive integers, default 3)
  25826. * @param scene defines the hosting scene
  25827. * @param updatable defines if the mesh must be flagged as updatable
  25828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25829. * @returns a new Mesh
  25830. */
  25831. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25832. /**
  25833. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25834. * @param name defines the name of the mesh to create
  25835. * @param points is an array successive Vector3
  25836. * @param scene defines the hosting scene
  25837. * @param updatable defines if the mesh must be flagged as updatable
  25838. * @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).
  25839. * @returns a new Mesh
  25840. */
  25841. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25842. /**
  25843. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25844. * @param name defines the name of the mesh to create
  25845. * @param points is an array successive Vector3
  25846. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25847. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25848. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25849. * @param scene defines the hosting scene
  25850. * @param updatable defines if the mesh must be flagged as updatable
  25851. * @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)
  25852. * @returns a new Mesh
  25853. */
  25854. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25855. /**
  25856. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25857. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25858. * 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.
  25859. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25860. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25861. * Remember you can only change the shape positions, not their number when updating a polygon.
  25862. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25863. * @param name defines the name of the mesh to create
  25864. * @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
  25865. * @param scene defines the hosting scene
  25866. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25867. * @param updatable defines if the mesh must be flagged as updatable
  25868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25869. * @param earcutInjection can be used to inject your own earcut reference
  25870. * @returns a new Mesh
  25871. */
  25872. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25873. /**
  25874. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25875. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25876. * @param name defines the name of the mesh to create
  25877. * @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
  25878. * @param depth defines the height of extrusion
  25879. * @param scene defines the hosting scene
  25880. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25881. * @param updatable defines if the mesh must be flagged as updatable
  25882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25883. * @param earcutInjection can be used to inject your own earcut reference
  25884. * @returns a new Mesh
  25885. */
  25886. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25887. /**
  25888. * Creates an extruded shape mesh.
  25889. * 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
  25890. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25891. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25892. * @param name defines the name of the mesh to create
  25893. * @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
  25894. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25895. * @param scale is the value to scale the shape
  25896. * @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
  25897. * @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
  25898. * @param scene defines the hosting scene
  25899. * @param updatable defines if the mesh must be flagged as updatable
  25900. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25901. * @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)
  25902. * @returns a new Mesh
  25903. */
  25904. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25905. /**
  25906. * Creates an custom extruded shape mesh.
  25907. * The custom extrusion is a parametric shape.
  25908. * It has no predefined shape. Its final shape will depend on the input parameters.
  25909. * Please consider using the same method from the MeshBuilder class instead
  25910. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25911. * @param name defines the name of the mesh to create
  25912. * @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
  25913. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25914. * @param scaleFunction is a custom Javascript function called on each path point
  25915. * @param rotationFunction is a custom Javascript function called on each path point
  25916. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25917. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25918. * @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
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @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)
  25923. * @returns a new Mesh
  25924. */
  25925. 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;
  25926. /**
  25927. * Creates lathe mesh.
  25928. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25929. * Please consider using the same method from the MeshBuilder class instead
  25930. * @param name defines the name of the mesh to create
  25931. * @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
  25932. * @param radius is the radius value of the lathe
  25933. * @param tessellation is the side number of the lathe.
  25934. * @param scene defines the hosting scene
  25935. * @param updatable defines if the mesh must be flagged as updatable
  25936. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25937. * @returns a new Mesh
  25938. */
  25939. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25940. /**
  25941. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25942. * @param name defines the name of the mesh to create
  25943. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25944. * @param scene defines the hosting scene
  25945. * @param updatable defines if the mesh must be flagged as updatable
  25946. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25947. * @returns a new Mesh
  25948. */
  25949. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25950. /**
  25951. * Creates a ground mesh.
  25952. * Please consider using the same method from the MeshBuilder class instead
  25953. * @param name defines the name of the mesh to create
  25954. * @param width set the width of the ground
  25955. * @param height set the height of the ground
  25956. * @param subdivisions sets the number of subdivisions per side
  25957. * @param scene defines the hosting scene
  25958. * @param updatable defines if the mesh must be flagged as updatable
  25959. * @returns a new Mesh
  25960. */
  25961. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25962. /**
  25963. * Creates a tiled ground mesh.
  25964. * Please consider using the same method from the MeshBuilder class instead
  25965. * @param name defines the name of the mesh to create
  25966. * @param xmin set the ground minimum X coordinate
  25967. * @param zmin set the ground minimum Y coordinate
  25968. * @param xmax set the ground maximum X coordinate
  25969. * @param zmax set the ground maximum Z coordinate
  25970. * @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
  25971. * @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
  25972. * @param scene defines the hosting scene
  25973. * @param updatable defines if the mesh must be flagged as updatable
  25974. * @returns a new Mesh
  25975. */
  25976. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25977. w: number;
  25978. h: number;
  25979. }, precision: {
  25980. w: number;
  25981. h: number;
  25982. }, scene: Scene, updatable?: boolean): Mesh;
  25983. /**
  25984. * Creates a ground mesh from a height map.
  25985. * Please consider using the same method from the MeshBuilder class instead
  25986. * @see http://doc.babylonjs.com/babylon101/height_map
  25987. * @param name defines the name of the mesh to create
  25988. * @param url sets the URL of the height map image resource
  25989. * @param width set the ground width size
  25990. * @param height set the ground height size
  25991. * @param subdivisions sets the number of subdivision per side
  25992. * @param minHeight is the minimum altitude on the ground
  25993. * @param maxHeight is the maximum altitude on the ground
  25994. * @param scene defines the hosting scene
  25995. * @param updatable defines if the mesh must be flagged as updatable
  25996. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25997. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25998. * @returns a new Mesh
  25999. */
  26000. 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;
  26001. /**
  26002. * Creates a tube mesh.
  26003. * The tube is a parametric shape.
  26004. * It has no predefined shape. Its final shape will depend on the input parameters.
  26005. * Please consider using the same method from the MeshBuilder class instead
  26006. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26007. * @param name defines the name of the mesh to create
  26008. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26009. * @param radius sets the tube radius size
  26010. * @param tessellation is the number of sides on the tubular surface
  26011. * @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
  26012. * @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
  26013. * @param scene defines the hosting scene
  26014. * @param updatable defines if the mesh must be flagged as updatable
  26015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26016. * @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)
  26017. * @returns a new Mesh
  26018. */
  26019. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26020. (i: number, distance: number): number;
  26021. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26022. /**
  26023. * Creates a polyhedron mesh.
  26024. * Please consider using the same method from the MeshBuilder class instead.
  26025. * * 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
  26026. * * The parameter `size` (positive float, default 1) sets the polygon size
  26027. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26028. * * 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`
  26029. * * 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
  26030. * * 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)`)
  26031. * * 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
  26032. * * 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
  26033. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26034. * * If you create a double-sided mesh, you can choose what parts of 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
  26035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26036. * @param name defines the name of the mesh to create
  26037. * @param options defines the options used to create the mesh
  26038. * @param scene defines the hosting scene
  26039. * @returns a new Mesh
  26040. */
  26041. static CreatePolyhedron(name: string, options: {
  26042. type?: number;
  26043. size?: number;
  26044. sizeX?: number;
  26045. sizeY?: number;
  26046. sizeZ?: number;
  26047. custom?: any;
  26048. faceUV?: Vector4[];
  26049. faceColors?: Color4[];
  26050. updatable?: boolean;
  26051. sideOrientation?: number;
  26052. }, scene: Scene): Mesh;
  26053. /**
  26054. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26055. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26056. * * 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`)
  26057. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26058. * * 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
  26059. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26060. * * If you create a double-sided mesh, you can choose what parts of 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
  26061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26062. * @param name defines the name of the mesh
  26063. * @param options defines the options used to create the mesh
  26064. * @param scene defines the hosting scene
  26065. * @returns a new Mesh
  26066. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26067. */
  26068. static CreateIcoSphere(name: string, options: {
  26069. radius?: number;
  26070. flat?: boolean;
  26071. subdivisions?: number;
  26072. sideOrientation?: number;
  26073. updatable?: boolean;
  26074. }, scene: Scene): Mesh;
  26075. /**
  26076. * Creates a decal mesh.
  26077. * Please consider using the same method from the MeshBuilder class instead.
  26078. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26079. * @param name defines the name of the mesh
  26080. * @param sourceMesh defines the mesh receiving the decal
  26081. * @param position sets the position of the decal in world coordinates
  26082. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26083. * @param size sets the decal scaling
  26084. * @param angle sets the angle to rotate the decal
  26085. * @returns a new Mesh
  26086. */
  26087. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26088. /**
  26089. * Prepare internal position array for software CPU skinning
  26090. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26091. */
  26092. setPositionsForCPUSkinning(): Float32Array;
  26093. /**
  26094. * Prepare internal normal array for software CPU skinning
  26095. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26096. */
  26097. setNormalsForCPUSkinning(): Float32Array;
  26098. /**
  26099. * Updates the vertex buffer by applying transformation from the bones
  26100. * @param skeleton defines the skeleton to apply to current mesh
  26101. * @returns the current mesh
  26102. */
  26103. applySkeleton(skeleton: Skeleton): Mesh;
  26104. /**
  26105. * 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
  26106. * @param meshes defines the list of meshes to scan
  26107. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26108. */
  26109. static MinMax(meshes: AbstractMesh[]): {
  26110. min: Vector3;
  26111. max: Vector3;
  26112. };
  26113. /**
  26114. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26115. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26116. * @returns a vector3
  26117. */
  26118. static Center(meshesOrMinMaxVector: {
  26119. min: Vector3;
  26120. max: Vector3;
  26121. } | AbstractMesh[]): Vector3;
  26122. /**
  26123. * Merge the array of meshes into a single mesh for performance reasons.
  26124. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26125. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26126. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26127. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26128. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26129. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26130. * @returns a new mesh
  26131. */
  26132. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26133. /** @hidden */
  26134. addInstance(instance: InstancedMesh): void;
  26135. /** @hidden */
  26136. removeInstance(instance: InstancedMesh): void;
  26137. }
  26138. }
  26139. declare module "babylonjs/Cameras/camera" {
  26140. import { SmartArray } from "babylonjs/Misc/smartArray";
  26141. import { Observable } from "babylonjs/Misc/observable";
  26142. import { Nullable } from "babylonjs/types";
  26143. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26144. import { Scene } from "babylonjs/scene";
  26145. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26146. import { Node } from "babylonjs/node";
  26147. import { Mesh } from "babylonjs/Meshes/mesh";
  26148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26149. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26150. import { Viewport } from "babylonjs/Maths/math.viewport";
  26151. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26154. import { Ray } from "babylonjs/Culling/ray";
  26155. /**
  26156. * This is the base class of all the camera used in the application.
  26157. * @see http://doc.babylonjs.com/features/cameras
  26158. */
  26159. export class Camera extends Node {
  26160. /** @hidden */
  26161. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26162. /**
  26163. * This is the default projection mode used by the cameras.
  26164. * It helps recreating a feeling of perspective and better appreciate depth.
  26165. * This is the best way to simulate real life cameras.
  26166. */
  26167. static readonly PERSPECTIVE_CAMERA: number;
  26168. /**
  26169. * This helps creating camera with an orthographic mode.
  26170. * 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.
  26171. */
  26172. static readonly ORTHOGRAPHIC_CAMERA: number;
  26173. /**
  26174. * This is the default FOV mode for perspective cameras.
  26175. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26176. */
  26177. static readonly FOVMODE_VERTICAL_FIXED: number;
  26178. /**
  26179. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26180. */
  26181. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26182. /**
  26183. * This specifies ther is no need for a camera rig.
  26184. * Basically only one eye is rendered corresponding to the camera.
  26185. */
  26186. static readonly RIG_MODE_NONE: number;
  26187. /**
  26188. * Simulates a camera Rig with one blue eye and one red eye.
  26189. * This can be use with 3d blue and red glasses.
  26190. */
  26191. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26192. /**
  26193. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26194. */
  26195. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26196. /**
  26197. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26198. */
  26199. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26200. /**
  26201. * Defines that both eyes of the camera will be rendered over under each other.
  26202. */
  26203. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26204. /**
  26205. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26206. */
  26207. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26208. /**
  26209. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26210. */
  26211. static readonly RIG_MODE_VR: number;
  26212. /**
  26213. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26214. */
  26215. static readonly RIG_MODE_WEBVR: number;
  26216. /**
  26217. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26218. */
  26219. static readonly RIG_MODE_CUSTOM: number;
  26220. /**
  26221. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26222. */
  26223. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26224. /**
  26225. * Define the input manager associated with the camera.
  26226. */
  26227. inputs: CameraInputsManager<Camera>;
  26228. /** @hidden */
  26229. _position: Vector3;
  26230. /**
  26231. * Define the current local position of the camera in the scene
  26232. */
  26233. get position(): Vector3;
  26234. set position(newPosition: Vector3);
  26235. /**
  26236. * The vector the camera should consider as up.
  26237. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26238. */
  26239. upVector: Vector3;
  26240. /**
  26241. * Define the current limit on the left side for an orthographic camera
  26242. * In scene unit
  26243. */
  26244. orthoLeft: Nullable<number>;
  26245. /**
  26246. * Define the current limit on the right side for an orthographic camera
  26247. * In scene unit
  26248. */
  26249. orthoRight: Nullable<number>;
  26250. /**
  26251. * Define the current limit on the bottom side for an orthographic camera
  26252. * In scene unit
  26253. */
  26254. orthoBottom: Nullable<number>;
  26255. /**
  26256. * Define the current limit on the top side for an orthographic camera
  26257. * In scene unit
  26258. */
  26259. orthoTop: Nullable<number>;
  26260. /**
  26261. * Field Of View is set in Radians. (default is 0.8)
  26262. */
  26263. fov: number;
  26264. /**
  26265. * Define the minimum distance the camera can see from.
  26266. * This is important to note that the depth buffer are not infinite and the closer it starts
  26267. * the more your scene might encounter depth fighting issue.
  26268. */
  26269. minZ: number;
  26270. /**
  26271. * Define the maximum distance the camera can see to.
  26272. * This is important to note that the depth buffer are not infinite and the further it end
  26273. * the more your scene might encounter depth fighting issue.
  26274. */
  26275. maxZ: number;
  26276. /**
  26277. * Define the default inertia of the camera.
  26278. * This helps giving a smooth feeling to the camera movement.
  26279. */
  26280. inertia: number;
  26281. /**
  26282. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26283. */
  26284. mode: number;
  26285. /**
  26286. * Define whether the camera is intermediate.
  26287. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26288. */
  26289. isIntermediate: boolean;
  26290. /**
  26291. * Define the viewport of the camera.
  26292. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26293. */
  26294. viewport: Viewport;
  26295. /**
  26296. * Restricts the camera to viewing objects with the same layerMask.
  26297. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26298. */
  26299. layerMask: number;
  26300. /**
  26301. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26302. */
  26303. fovMode: number;
  26304. /**
  26305. * Rig mode of the camera.
  26306. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26307. * This is normally controlled byt the camera themselves as internal use.
  26308. */
  26309. cameraRigMode: number;
  26310. /**
  26311. * Defines the distance between both "eyes" in case of a RIG
  26312. */
  26313. interaxialDistance: number;
  26314. /**
  26315. * Defines if stereoscopic rendering is done side by side or over under.
  26316. */
  26317. isStereoscopicSideBySide: boolean;
  26318. /**
  26319. * 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
  26320. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26321. * else in the scene. (Eg. security camera)
  26322. *
  26323. * 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)
  26324. */
  26325. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26326. /**
  26327. * When set, the camera will render to this render target instead of the default canvas
  26328. *
  26329. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26330. */
  26331. outputRenderTarget: Nullable<RenderTargetTexture>;
  26332. /**
  26333. * Observable triggered when the camera view matrix has changed.
  26334. */
  26335. onViewMatrixChangedObservable: Observable<Camera>;
  26336. /**
  26337. * Observable triggered when the camera Projection matrix has changed.
  26338. */
  26339. onProjectionMatrixChangedObservable: Observable<Camera>;
  26340. /**
  26341. * Observable triggered when the inputs have been processed.
  26342. */
  26343. onAfterCheckInputsObservable: Observable<Camera>;
  26344. /**
  26345. * Observable triggered when reset has been called and applied to the camera.
  26346. */
  26347. onRestoreStateObservable: Observable<Camera>;
  26348. /**
  26349. * Is this camera a part of a rig system?
  26350. */
  26351. isRigCamera: boolean;
  26352. /**
  26353. * If isRigCamera set to true this will be set with the parent camera.
  26354. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26355. */
  26356. rigParent?: Camera;
  26357. /** @hidden */
  26358. _cameraRigParams: any;
  26359. /** @hidden */
  26360. _rigCameras: Camera[];
  26361. /** @hidden */
  26362. _rigPostProcess: Nullable<PostProcess>;
  26363. protected _webvrViewMatrix: Matrix;
  26364. /** @hidden */
  26365. _skipRendering: boolean;
  26366. /** @hidden */
  26367. _projectionMatrix: Matrix;
  26368. /** @hidden */
  26369. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26370. /** @hidden */
  26371. _activeMeshes: SmartArray<AbstractMesh>;
  26372. protected _globalPosition: Vector3;
  26373. /** @hidden */
  26374. _computedViewMatrix: Matrix;
  26375. private _doNotComputeProjectionMatrix;
  26376. private _transformMatrix;
  26377. private _frustumPlanes;
  26378. private _refreshFrustumPlanes;
  26379. private _storedFov;
  26380. private _stateStored;
  26381. /**
  26382. * Instantiates a new camera object.
  26383. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26384. * @see http://doc.babylonjs.com/features/cameras
  26385. * @param name Defines the name of the camera in the scene
  26386. * @param position Defines the position of the camera
  26387. * @param scene Defines the scene the camera belongs too
  26388. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26389. */
  26390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26391. /**
  26392. * Store current camera state (fov, position, etc..)
  26393. * @returns the camera
  26394. */
  26395. storeState(): Camera;
  26396. /**
  26397. * Restores the camera state values if it has been stored. You must call storeState() first
  26398. */
  26399. protected _restoreStateValues(): boolean;
  26400. /**
  26401. * Restored camera state. You must call storeState() first.
  26402. * @returns true if restored and false otherwise
  26403. */
  26404. restoreState(): boolean;
  26405. /**
  26406. * Gets the class name of the camera.
  26407. * @returns the class name
  26408. */
  26409. getClassName(): string;
  26410. /** @hidden */
  26411. readonly _isCamera: boolean;
  26412. /**
  26413. * Gets a string representation of the camera useful for debug purpose.
  26414. * @param fullDetails Defines that a more verboe level of logging is required
  26415. * @returns the string representation
  26416. */
  26417. toString(fullDetails?: boolean): string;
  26418. /**
  26419. * Gets the current world space position of the camera.
  26420. */
  26421. get globalPosition(): Vector3;
  26422. /**
  26423. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26424. * @returns the active meshe list
  26425. */
  26426. getActiveMeshes(): SmartArray<AbstractMesh>;
  26427. /**
  26428. * Check whether a mesh is part of the current active mesh list of the camera
  26429. * @param mesh Defines the mesh to check
  26430. * @returns true if active, false otherwise
  26431. */
  26432. isActiveMesh(mesh: Mesh): boolean;
  26433. /**
  26434. * Is this camera ready to be used/rendered
  26435. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26436. * @return true if the camera is ready
  26437. */
  26438. isReady(completeCheck?: boolean): boolean;
  26439. /** @hidden */
  26440. _initCache(): void;
  26441. /** @hidden */
  26442. _updateCache(ignoreParentClass?: boolean): void;
  26443. /** @hidden */
  26444. _isSynchronized(): boolean;
  26445. /** @hidden */
  26446. _isSynchronizedViewMatrix(): boolean;
  26447. /** @hidden */
  26448. _isSynchronizedProjectionMatrix(): boolean;
  26449. /**
  26450. * Attach the input controls to a specific dom element to get the input from.
  26451. * @param element Defines the element the controls should be listened from
  26452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26453. */
  26454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26455. /**
  26456. * Detach the current controls from the specified dom element.
  26457. * @param element Defines the element to stop listening the inputs from
  26458. */
  26459. detachControl(element: HTMLElement): void;
  26460. /**
  26461. * Update the camera state according to the different inputs gathered during the frame.
  26462. */
  26463. update(): void;
  26464. /** @hidden */
  26465. _checkInputs(): void;
  26466. /** @hidden */
  26467. get rigCameras(): Camera[];
  26468. /**
  26469. * Gets the post process used by the rig cameras
  26470. */
  26471. get rigPostProcess(): Nullable<PostProcess>;
  26472. /**
  26473. * Internal, gets the first post proces.
  26474. * @returns the first post process to be run on this camera.
  26475. */
  26476. _getFirstPostProcess(): Nullable<PostProcess>;
  26477. private _cascadePostProcessesToRigCams;
  26478. /**
  26479. * Attach a post process to the camera.
  26480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26481. * @param postProcess The post process to attach to the camera
  26482. * @param insertAt The position of the post process in case several of them are in use in the scene
  26483. * @returns the position the post process has been inserted at
  26484. */
  26485. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26486. /**
  26487. * Detach a post process to the camera.
  26488. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26489. * @param postProcess The post process to detach from the camera
  26490. */
  26491. detachPostProcess(postProcess: PostProcess): void;
  26492. /**
  26493. * Gets the current world matrix of the camera
  26494. */
  26495. getWorldMatrix(): Matrix;
  26496. /** @hidden */
  26497. _getViewMatrix(): Matrix;
  26498. /**
  26499. * Gets the current view matrix of the camera.
  26500. * @param force forces the camera to recompute the matrix without looking at the cached state
  26501. * @returns the view matrix
  26502. */
  26503. getViewMatrix(force?: boolean): Matrix;
  26504. /**
  26505. * Freeze the projection matrix.
  26506. * It will prevent the cache check of the camera projection compute and can speed up perf
  26507. * if no parameter of the camera are meant to change
  26508. * @param projection Defines manually a projection if necessary
  26509. */
  26510. freezeProjectionMatrix(projection?: Matrix): void;
  26511. /**
  26512. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26513. */
  26514. unfreezeProjectionMatrix(): void;
  26515. /**
  26516. * Gets the current projection matrix of the camera.
  26517. * @param force forces the camera to recompute the matrix without looking at the cached state
  26518. * @returns the projection matrix
  26519. */
  26520. getProjectionMatrix(force?: boolean): Matrix;
  26521. /**
  26522. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26523. * @returns a Matrix
  26524. */
  26525. getTransformationMatrix(): Matrix;
  26526. private _updateFrustumPlanes;
  26527. /**
  26528. * Checks if a cullable object (mesh...) is in the camera frustum
  26529. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26530. * @param target The object to check
  26531. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26532. * @returns true if the object is in frustum otherwise false
  26533. */
  26534. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26535. /**
  26536. * Checks if a cullable object (mesh...) is in the camera frustum
  26537. * Unlike isInFrustum this cheks the full bounding box
  26538. * @param target The object to check
  26539. * @returns true if the object is in frustum otherwise false
  26540. */
  26541. isCompletelyInFrustum(target: ICullable): boolean;
  26542. /**
  26543. * Gets a ray in the forward direction from the camera.
  26544. * @param length Defines the length of the ray to create
  26545. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26546. * @param origin Defines the start point of the ray which defaults to the camera position
  26547. * @returns the forward ray
  26548. */
  26549. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26550. /**
  26551. * Releases resources associated with this node.
  26552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26554. */
  26555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26556. /** @hidden */
  26557. _isLeftCamera: boolean;
  26558. /**
  26559. * Gets the left camera of a rig setup in case of Rigged Camera
  26560. */
  26561. get isLeftCamera(): boolean;
  26562. /** @hidden */
  26563. _isRightCamera: boolean;
  26564. /**
  26565. * Gets the right camera of a rig setup in case of Rigged Camera
  26566. */
  26567. get isRightCamera(): boolean;
  26568. /**
  26569. * Gets the left camera of a rig setup in case of Rigged Camera
  26570. */
  26571. get leftCamera(): Nullable<FreeCamera>;
  26572. /**
  26573. * Gets the right camera of a rig setup in case of Rigged Camera
  26574. */
  26575. get rightCamera(): Nullable<FreeCamera>;
  26576. /**
  26577. * Gets the left camera target of a rig setup in case of Rigged Camera
  26578. * @returns the target position
  26579. */
  26580. getLeftTarget(): Nullable<Vector3>;
  26581. /**
  26582. * Gets the right camera target of a rig setup in case of Rigged Camera
  26583. * @returns the target position
  26584. */
  26585. getRightTarget(): Nullable<Vector3>;
  26586. /**
  26587. * @hidden
  26588. */
  26589. setCameraRigMode(mode: number, rigParams: any): void;
  26590. /** @hidden */
  26591. static _setStereoscopicRigMode(camera: Camera): void;
  26592. /** @hidden */
  26593. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26594. /** @hidden */
  26595. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26596. /** @hidden */
  26597. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26598. /** @hidden */
  26599. _getVRProjectionMatrix(): Matrix;
  26600. protected _updateCameraRotationMatrix(): void;
  26601. protected _updateWebVRCameraRotationMatrix(): void;
  26602. /**
  26603. * This function MUST be overwritten by the different WebVR cameras available.
  26604. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26605. * @hidden
  26606. */
  26607. _getWebVRProjectionMatrix(): Matrix;
  26608. /**
  26609. * This function MUST be overwritten by the different WebVR cameras available.
  26610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26611. * @hidden
  26612. */
  26613. _getWebVRViewMatrix(): Matrix;
  26614. /** @hidden */
  26615. setCameraRigParameter(name: string, value: any): void;
  26616. /**
  26617. * needs to be overridden by children so sub has required properties to be copied
  26618. * @hidden
  26619. */
  26620. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26621. /**
  26622. * May need to be overridden by children
  26623. * @hidden
  26624. */
  26625. _updateRigCameras(): void;
  26626. /** @hidden */
  26627. _setupInputs(): void;
  26628. /**
  26629. * Serialiaze the camera setup to a json represention
  26630. * @returns the JSON representation
  26631. */
  26632. serialize(): any;
  26633. /**
  26634. * Clones the current camera.
  26635. * @param name The cloned camera name
  26636. * @returns the cloned camera
  26637. */
  26638. clone(name: string): Camera;
  26639. /**
  26640. * Gets the direction of the camera relative to a given local axis.
  26641. * @param localAxis Defines the reference axis to provide a relative direction.
  26642. * @return the direction
  26643. */
  26644. getDirection(localAxis: Vector3): Vector3;
  26645. /**
  26646. * Returns the current camera absolute rotation
  26647. */
  26648. get absoluteRotation(): Quaternion;
  26649. /**
  26650. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26651. * @param localAxis Defines the reference axis to provide a relative direction.
  26652. * @param result Defines the vector to store the result in
  26653. */
  26654. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26655. /**
  26656. * Gets a camera constructor for a given camera type
  26657. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26658. * @param name The name of the camera the result will be able to instantiate
  26659. * @param scene The scene the result will construct the camera in
  26660. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26661. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26662. * @returns a factory method to construc the camera
  26663. */
  26664. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26665. /**
  26666. * Compute the world matrix of the camera.
  26667. * @returns the camera world matrix
  26668. */
  26669. computeWorldMatrix(): Matrix;
  26670. /**
  26671. * Parse a JSON and creates the camera from the parsed information
  26672. * @param parsedCamera The JSON to parse
  26673. * @param scene The scene to instantiate the camera in
  26674. * @returns the newly constructed camera
  26675. */
  26676. static Parse(parsedCamera: any, scene: Scene): Camera;
  26677. }
  26678. }
  26679. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26680. import { Nullable } from "babylonjs/types";
  26681. import { Scene } from "babylonjs/scene";
  26682. import { Vector4 } from "babylonjs/Maths/math.vector";
  26683. import { Mesh } from "babylonjs/Meshes/mesh";
  26684. /**
  26685. * Class containing static functions to help procedurally build meshes
  26686. */
  26687. export class DiscBuilder {
  26688. /**
  26689. * Creates a plane polygonal mesh. By default, this is a disc
  26690. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26691. * * 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
  26692. * * 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
  26693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26696. * @param name defines the name of the mesh
  26697. * @param options defines the options used to create the mesh
  26698. * @param scene defines the hosting scene
  26699. * @returns the plane polygonal mesh
  26700. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26701. */
  26702. static CreateDisc(name: string, options: {
  26703. radius?: number;
  26704. tessellation?: number;
  26705. arc?: number;
  26706. updatable?: boolean;
  26707. sideOrientation?: number;
  26708. frontUVs?: Vector4;
  26709. backUVs?: Vector4;
  26710. }, scene?: Nullable<Scene>): Mesh;
  26711. }
  26712. }
  26713. declare module "babylonjs/Materials/fresnelParameters" {
  26714. import { Color3 } from "babylonjs/Maths/math.color";
  26715. /**
  26716. * This represents all the required information to add a fresnel effect on a material:
  26717. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26718. */
  26719. export class FresnelParameters {
  26720. private _isEnabled;
  26721. /**
  26722. * Define if the fresnel effect is enable or not.
  26723. */
  26724. get isEnabled(): boolean;
  26725. set isEnabled(value: boolean);
  26726. /**
  26727. * Define the color used on edges (grazing angle)
  26728. */
  26729. leftColor: Color3;
  26730. /**
  26731. * Define the color used on center
  26732. */
  26733. rightColor: Color3;
  26734. /**
  26735. * Define bias applied to computed fresnel term
  26736. */
  26737. bias: number;
  26738. /**
  26739. * Defined the power exponent applied to fresnel term
  26740. */
  26741. power: number;
  26742. /**
  26743. * Clones the current fresnel and its valuues
  26744. * @returns a clone fresnel configuration
  26745. */
  26746. clone(): FresnelParameters;
  26747. /**
  26748. * Serializes the current fresnel parameters to a JSON representation.
  26749. * @return the JSON serialization
  26750. */
  26751. serialize(): any;
  26752. /**
  26753. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26754. * @param parsedFresnelParameters Define the JSON representation
  26755. * @returns the parsed parameters
  26756. */
  26757. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26758. }
  26759. }
  26760. declare module "babylonjs/Materials/pushMaterial" {
  26761. import { Nullable } from "babylonjs/types";
  26762. import { Scene } from "babylonjs/scene";
  26763. import { Matrix } from "babylonjs/Maths/math.vector";
  26764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26765. import { Mesh } from "babylonjs/Meshes/mesh";
  26766. import { Material } from "babylonjs/Materials/material";
  26767. import { Effect } from "babylonjs/Materials/effect";
  26768. /**
  26769. * Base class of materials working in push mode in babylon JS
  26770. * @hidden
  26771. */
  26772. export class PushMaterial extends Material {
  26773. protected _activeEffect: Effect;
  26774. protected _normalMatrix: Matrix;
  26775. /**
  26776. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26777. * This means that the material can keep using a previous shader while a new one is being compiled.
  26778. * This is mostly used when shader parallel compilation is supported (true by default)
  26779. */
  26780. allowShaderHotSwapping: boolean;
  26781. constructor(name: string, scene: Scene);
  26782. getEffect(): Effect;
  26783. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26784. /**
  26785. * Binds the given world matrix to the active effect
  26786. *
  26787. * @param world the matrix to bind
  26788. */
  26789. bindOnlyWorldMatrix(world: Matrix): void;
  26790. /**
  26791. * Binds the given normal matrix to the active effect
  26792. *
  26793. * @param normalMatrix the matrix to bind
  26794. */
  26795. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26796. bind(world: Matrix, mesh?: Mesh): void;
  26797. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26798. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26799. }
  26800. }
  26801. declare module "babylonjs/Materials/materialFlags" {
  26802. /**
  26803. * This groups all the flags used to control the materials channel.
  26804. */
  26805. export class MaterialFlags {
  26806. private static _DiffuseTextureEnabled;
  26807. /**
  26808. * Are diffuse textures enabled in the application.
  26809. */
  26810. static get DiffuseTextureEnabled(): boolean;
  26811. static set DiffuseTextureEnabled(value: boolean);
  26812. private static _AmbientTextureEnabled;
  26813. /**
  26814. * Are ambient textures enabled in the application.
  26815. */
  26816. static get AmbientTextureEnabled(): boolean;
  26817. static set AmbientTextureEnabled(value: boolean);
  26818. private static _OpacityTextureEnabled;
  26819. /**
  26820. * Are opacity textures enabled in the application.
  26821. */
  26822. static get OpacityTextureEnabled(): boolean;
  26823. static set OpacityTextureEnabled(value: boolean);
  26824. private static _ReflectionTextureEnabled;
  26825. /**
  26826. * Are reflection textures enabled in the application.
  26827. */
  26828. static get ReflectionTextureEnabled(): boolean;
  26829. static set ReflectionTextureEnabled(value: boolean);
  26830. private static _EmissiveTextureEnabled;
  26831. /**
  26832. * Are emissive textures enabled in the application.
  26833. */
  26834. static get EmissiveTextureEnabled(): boolean;
  26835. static set EmissiveTextureEnabled(value: boolean);
  26836. private static _SpecularTextureEnabled;
  26837. /**
  26838. * Are specular textures enabled in the application.
  26839. */
  26840. static get SpecularTextureEnabled(): boolean;
  26841. static set SpecularTextureEnabled(value: boolean);
  26842. private static _BumpTextureEnabled;
  26843. /**
  26844. * Are bump textures enabled in the application.
  26845. */
  26846. static get BumpTextureEnabled(): boolean;
  26847. static set BumpTextureEnabled(value: boolean);
  26848. private static _LightmapTextureEnabled;
  26849. /**
  26850. * Are lightmap textures enabled in the application.
  26851. */
  26852. static get LightmapTextureEnabled(): boolean;
  26853. static set LightmapTextureEnabled(value: boolean);
  26854. private static _RefractionTextureEnabled;
  26855. /**
  26856. * Are refraction textures enabled in the application.
  26857. */
  26858. static get RefractionTextureEnabled(): boolean;
  26859. static set RefractionTextureEnabled(value: boolean);
  26860. private static _ColorGradingTextureEnabled;
  26861. /**
  26862. * Are color grading textures enabled in the application.
  26863. */
  26864. static get ColorGradingTextureEnabled(): boolean;
  26865. static set ColorGradingTextureEnabled(value: boolean);
  26866. private static _FresnelEnabled;
  26867. /**
  26868. * Are fresnels enabled in the application.
  26869. */
  26870. static get FresnelEnabled(): boolean;
  26871. static set FresnelEnabled(value: boolean);
  26872. private static _ClearCoatTextureEnabled;
  26873. /**
  26874. * Are clear coat textures enabled in the application.
  26875. */
  26876. static get ClearCoatTextureEnabled(): boolean;
  26877. static set ClearCoatTextureEnabled(value: boolean);
  26878. private static _ClearCoatBumpTextureEnabled;
  26879. /**
  26880. * Are clear coat bump textures enabled in the application.
  26881. */
  26882. static get ClearCoatBumpTextureEnabled(): boolean;
  26883. static set ClearCoatBumpTextureEnabled(value: boolean);
  26884. private static _ClearCoatTintTextureEnabled;
  26885. /**
  26886. * Are clear coat tint textures enabled in the application.
  26887. */
  26888. static get ClearCoatTintTextureEnabled(): boolean;
  26889. static set ClearCoatTintTextureEnabled(value: boolean);
  26890. private static _SheenTextureEnabled;
  26891. /**
  26892. * Are sheen textures enabled in the application.
  26893. */
  26894. static get SheenTextureEnabled(): boolean;
  26895. static set SheenTextureEnabled(value: boolean);
  26896. private static _AnisotropicTextureEnabled;
  26897. /**
  26898. * Are anisotropic textures enabled in the application.
  26899. */
  26900. static get AnisotropicTextureEnabled(): boolean;
  26901. static set AnisotropicTextureEnabled(value: boolean);
  26902. private static _ThicknessTextureEnabled;
  26903. /**
  26904. * Are thickness textures enabled in the application.
  26905. */
  26906. static get ThicknessTextureEnabled(): boolean;
  26907. static set ThicknessTextureEnabled(value: boolean);
  26908. }
  26909. }
  26910. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26911. /** @hidden */
  26912. export var defaultFragmentDeclaration: {
  26913. name: string;
  26914. shader: string;
  26915. };
  26916. }
  26917. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26918. /** @hidden */
  26919. export var defaultUboDeclaration: {
  26920. name: string;
  26921. shader: string;
  26922. };
  26923. }
  26924. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26925. /** @hidden */
  26926. export var lightFragmentDeclaration: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26932. /** @hidden */
  26933. export var lightUboDeclaration: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26939. /** @hidden */
  26940. export var lightsFragmentFunctions: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26946. /** @hidden */
  26947. export var shadowsFragmentFunctions: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26953. /** @hidden */
  26954. export var fresnelFunction: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26960. /** @hidden */
  26961. export var reflectionFunction: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26967. /** @hidden */
  26968. export var bumpFragmentFunctions: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26974. /** @hidden */
  26975. export var logDepthDeclaration: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26981. /** @hidden */
  26982. export var bumpFragment: {
  26983. name: string;
  26984. shader: string;
  26985. };
  26986. }
  26987. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26988. /** @hidden */
  26989. export var depthPrePass: {
  26990. name: string;
  26991. shader: string;
  26992. };
  26993. }
  26994. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26995. /** @hidden */
  26996. export var lightFragment: {
  26997. name: string;
  26998. shader: string;
  26999. };
  27000. }
  27001. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27002. /** @hidden */
  27003. export var logDepthFragment: {
  27004. name: string;
  27005. shader: string;
  27006. };
  27007. }
  27008. declare module "babylonjs/Shaders/default.fragment" {
  27009. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27010. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27011. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27012. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27013. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27014. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27015. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27016. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27017. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27018. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27019. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27020. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27021. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27022. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27023. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27024. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27025. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27026. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27027. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27028. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27029. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27030. /** @hidden */
  27031. export var defaultPixelShader: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27037. /** @hidden */
  27038. export var defaultVertexDeclaration: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27044. /** @hidden */
  27045. export var bumpVertexDeclaration: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27051. /** @hidden */
  27052. export var bumpVertex: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27058. /** @hidden */
  27059. export var fogVertex: {
  27060. name: string;
  27061. shader: string;
  27062. };
  27063. }
  27064. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27065. /** @hidden */
  27066. export var shadowsVertex: {
  27067. name: string;
  27068. shader: string;
  27069. };
  27070. }
  27071. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27072. /** @hidden */
  27073. export var pointCloudVertex: {
  27074. name: string;
  27075. shader: string;
  27076. };
  27077. }
  27078. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27079. /** @hidden */
  27080. export var logDepthVertex: {
  27081. name: string;
  27082. shader: string;
  27083. };
  27084. }
  27085. declare module "babylonjs/Shaders/default.vertex" {
  27086. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27087. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27089. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27091. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27092. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27093. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27094. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27095. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27096. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27097. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27098. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27099. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27100. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27101. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27102. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27103. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27104. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27105. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27106. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27107. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27108. /** @hidden */
  27109. export var defaultVertexShader: {
  27110. name: string;
  27111. shader: string;
  27112. };
  27113. }
  27114. declare module "babylonjs/Materials/standardMaterial" {
  27115. import { SmartArray } from "babylonjs/Misc/smartArray";
  27116. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27117. import { Nullable } from "babylonjs/types";
  27118. import { Scene } from "babylonjs/scene";
  27119. import { Matrix } from "babylonjs/Maths/math.vector";
  27120. import { Color3 } from "babylonjs/Maths/math.color";
  27121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27123. import { Mesh } from "babylonjs/Meshes/mesh";
  27124. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27125. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27126. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27127. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27128. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27130. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27131. import "babylonjs/Shaders/default.fragment";
  27132. import "babylonjs/Shaders/default.vertex";
  27133. /** @hidden */
  27134. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27135. MAINUV1: boolean;
  27136. MAINUV2: boolean;
  27137. DIFFUSE: boolean;
  27138. DIFFUSEDIRECTUV: number;
  27139. AMBIENT: boolean;
  27140. AMBIENTDIRECTUV: number;
  27141. OPACITY: boolean;
  27142. OPACITYDIRECTUV: number;
  27143. OPACITYRGB: boolean;
  27144. REFLECTION: boolean;
  27145. EMISSIVE: boolean;
  27146. EMISSIVEDIRECTUV: number;
  27147. SPECULAR: boolean;
  27148. SPECULARDIRECTUV: number;
  27149. BUMP: boolean;
  27150. BUMPDIRECTUV: number;
  27151. PARALLAX: boolean;
  27152. PARALLAXOCCLUSION: boolean;
  27153. SPECULAROVERALPHA: boolean;
  27154. CLIPPLANE: boolean;
  27155. CLIPPLANE2: boolean;
  27156. CLIPPLANE3: boolean;
  27157. CLIPPLANE4: boolean;
  27158. CLIPPLANE5: boolean;
  27159. CLIPPLANE6: boolean;
  27160. ALPHATEST: boolean;
  27161. DEPTHPREPASS: boolean;
  27162. ALPHAFROMDIFFUSE: boolean;
  27163. POINTSIZE: boolean;
  27164. FOG: boolean;
  27165. SPECULARTERM: boolean;
  27166. DIFFUSEFRESNEL: boolean;
  27167. OPACITYFRESNEL: boolean;
  27168. REFLECTIONFRESNEL: boolean;
  27169. REFRACTIONFRESNEL: boolean;
  27170. EMISSIVEFRESNEL: boolean;
  27171. FRESNEL: boolean;
  27172. NORMAL: boolean;
  27173. UV1: boolean;
  27174. UV2: boolean;
  27175. VERTEXCOLOR: boolean;
  27176. VERTEXALPHA: boolean;
  27177. NUM_BONE_INFLUENCERS: number;
  27178. BonesPerMesh: number;
  27179. BONETEXTURE: boolean;
  27180. INSTANCES: boolean;
  27181. GLOSSINESS: boolean;
  27182. ROUGHNESS: boolean;
  27183. EMISSIVEASILLUMINATION: boolean;
  27184. LINKEMISSIVEWITHDIFFUSE: boolean;
  27185. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27186. LIGHTMAP: boolean;
  27187. LIGHTMAPDIRECTUV: number;
  27188. OBJECTSPACE_NORMALMAP: boolean;
  27189. USELIGHTMAPASSHADOWMAP: boolean;
  27190. REFLECTIONMAP_3D: boolean;
  27191. REFLECTIONMAP_SPHERICAL: boolean;
  27192. REFLECTIONMAP_PLANAR: boolean;
  27193. REFLECTIONMAP_CUBIC: boolean;
  27194. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27195. REFLECTIONMAP_PROJECTION: boolean;
  27196. REFLECTIONMAP_SKYBOX: boolean;
  27197. REFLECTIONMAP_EXPLICIT: boolean;
  27198. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27199. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27200. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27201. INVERTCUBICMAP: boolean;
  27202. LOGARITHMICDEPTH: boolean;
  27203. REFRACTION: boolean;
  27204. REFRACTIONMAP_3D: boolean;
  27205. REFLECTIONOVERALPHA: boolean;
  27206. TWOSIDEDLIGHTING: boolean;
  27207. SHADOWFLOAT: boolean;
  27208. MORPHTARGETS: boolean;
  27209. MORPHTARGETS_NORMAL: boolean;
  27210. MORPHTARGETS_TANGENT: boolean;
  27211. MORPHTARGETS_UV: boolean;
  27212. NUM_MORPH_INFLUENCERS: number;
  27213. NONUNIFORMSCALING: boolean;
  27214. PREMULTIPLYALPHA: boolean;
  27215. IMAGEPROCESSING: boolean;
  27216. VIGNETTE: boolean;
  27217. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27218. VIGNETTEBLENDMODEOPAQUE: boolean;
  27219. TONEMAPPING: boolean;
  27220. TONEMAPPING_ACES: boolean;
  27221. CONTRAST: boolean;
  27222. COLORCURVES: boolean;
  27223. COLORGRADING: boolean;
  27224. COLORGRADING3D: boolean;
  27225. SAMPLER3DGREENDEPTH: boolean;
  27226. SAMPLER3DBGRMAP: boolean;
  27227. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27228. MULTIVIEW: boolean;
  27229. /**
  27230. * If the reflection texture on this material is in linear color space
  27231. * @hidden
  27232. */
  27233. IS_REFLECTION_LINEAR: boolean;
  27234. /**
  27235. * If the refraction texture on this material is in linear color space
  27236. * @hidden
  27237. */
  27238. IS_REFRACTION_LINEAR: boolean;
  27239. EXPOSURE: boolean;
  27240. constructor();
  27241. setReflectionMode(modeToEnable: string): void;
  27242. }
  27243. /**
  27244. * This is the default material used in Babylon. It is the best trade off between quality
  27245. * and performances.
  27246. * @see http://doc.babylonjs.com/babylon101/materials
  27247. */
  27248. export class StandardMaterial extends PushMaterial {
  27249. private _diffuseTexture;
  27250. /**
  27251. * The basic texture of the material as viewed under a light.
  27252. */
  27253. diffuseTexture: Nullable<BaseTexture>;
  27254. private _ambientTexture;
  27255. /**
  27256. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27257. */
  27258. ambientTexture: Nullable<BaseTexture>;
  27259. private _opacityTexture;
  27260. /**
  27261. * Define the transparency of the material from a texture.
  27262. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27263. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27264. */
  27265. opacityTexture: Nullable<BaseTexture>;
  27266. private _reflectionTexture;
  27267. /**
  27268. * Define the texture used to display the reflection.
  27269. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27270. */
  27271. reflectionTexture: Nullable<BaseTexture>;
  27272. private _emissiveTexture;
  27273. /**
  27274. * Define texture of the material as if self lit.
  27275. * This will be mixed in the final result even in the absence of light.
  27276. */
  27277. emissiveTexture: Nullable<BaseTexture>;
  27278. private _specularTexture;
  27279. /**
  27280. * Define how the color and intensity of the highlight given by the light in the material.
  27281. */
  27282. specularTexture: Nullable<BaseTexture>;
  27283. private _bumpTexture;
  27284. /**
  27285. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27286. * 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.
  27287. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27288. */
  27289. bumpTexture: Nullable<BaseTexture>;
  27290. private _lightmapTexture;
  27291. /**
  27292. * Complex lighting can be computationally expensive to compute at runtime.
  27293. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27294. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27295. */
  27296. lightmapTexture: Nullable<BaseTexture>;
  27297. private _refractionTexture;
  27298. /**
  27299. * Define the texture used to display the refraction.
  27300. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27301. */
  27302. refractionTexture: Nullable<BaseTexture>;
  27303. /**
  27304. * The color of the material lit by the environmental background lighting.
  27305. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27306. */
  27307. ambientColor: Color3;
  27308. /**
  27309. * The basic color of the material as viewed under a light.
  27310. */
  27311. diffuseColor: Color3;
  27312. /**
  27313. * Define how the color and intensity of the highlight given by the light in the material.
  27314. */
  27315. specularColor: Color3;
  27316. /**
  27317. * Define the color of the material as if self lit.
  27318. * This will be mixed in the final result even in the absence of light.
  27319. */
  27320. emissiveColor: Color3;
  27321. /**
  27322. * Defines how sharp are the highlights in the material.
  27323. * The bigger the value the sharper giving a more glossy feeling to the result.
  27324. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27325. */
  27326. specularPower: number;
  27327. private _useAlphaFromDiffuseTexture;
  27328. /**
  27329. * Does the transparency come from the diffuse texture alpha channel.
  27330. */
  27331. useAlphaFromDiffuseTexture: boolean;
  27332. private _useEmissiveAsIllumination;
  27333. /**
  27334. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27335. */
  27336. useEmissiveAsIllumination: boolean;
  27337. private _linkEmissiveWithDiffuse;
  27338. /**
  27339. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27340. * the emissive level when the final color is close to one.
  27341. */
  27342. linkEmissiveWithDiffuse: boolean;
  27343. private _useSpecularOverAlpha;
  27344. /**
  27345. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27346. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27347. */
  27348. useSpecularOverAlpha: boolean;
  27349. private _useReflectionOverAlpha;
  27350. /**
  27351. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27352. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27353. */
  27354. useReflectionOverAlpha: boolean;
  27355. private _disableLighting;
  27356. /**
  27357. * Does lights from the scene impacts this material.
  27358. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27359. */
  27360. disableLighting: boolean;
  27361. private _useObjectSpaceNormalMap;
  27362. /**
  27363. * Allows using an object space normal map (instead of tangent space).
  27364. */
  27365. useObjectSpaceNormalMap: boolean;
  27366. private _useParallax;
  27367. /**
  27368. * Is parallax enabled or not.
  27369. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27370. */
  27371. useParallax: boolean;
  27372. private _useParallaxOcclusion;
  27373. /**
  27374. * Is parallax occlusion enabled or not.
  27375. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27376. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27377. */
  27378. useParallaxOcclusion: boolean;
  27379. /**
  27380. * 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.
  27381. */
  27382. parallaxScaleBias: number;
  27383. private _roughness;
  27384. /**
  27385. * Helps to define how blurry the reflections should appears in the material.
  27386. */
  27387. roughness: number;
  27388. /**
  27389. * In case of refraction, define the value of the index of refraction.
  27390. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27391. */
  27392. indexOfRefraction: number;
  27393. /**
  27394. * Invert the refraction texture alongside the y axis.
  27395. * It can be useful with procedural textures or probe for instance.
  27396. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27397. */
  27398. invertRefractionY: boolean;
  27399. /**
  27400. * Defines the alpha limits in alpha test mode.
  27401. */
  27402. alphaCutOff: number;
  27403. private _useLightmapAsShadowmap;
  27404. /**
  27405. * In case of light mapping, define whether the map contains light or shadow informations.
  27406. */
  27407. useLightmapAsShadowmap: boolean;
  27408. private _diffuseFresnelParameters;
  27409. /**
  27410. * Define the diffuse fresnel parameters of the material.
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27412. */
  27413. diffuseFresnelParameters: FresnelParameters;
  27414. private _opacityFresnelParameters;
  27415. /**
  27416. * Define the opacity fresnel parameters of the material.
  27417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27418. */
  27419. opacityFresnelParameters: FresnelParameters;
  27420. private _reflectionFresnelParameters;
  27421. /**
  27422. * Define the reflection fresnel parameters of the material.
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27424. */
  27425. reflectionFresnelParameters: FresnelParameters;
  27426. private _refractionFresnelParameters;
  27427. /**
  27428. * Define the refraction fresnel parameters of the material.
  27429. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27430. */
  27431. refractionFresnelParameters: FresnelParameters;
  27432. private _emissiveFresnelParameters;
  27433. /**
  27434. * Define the emissive fresnel parameters of the material.
  27435. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27436. */
  27437. emissiveFresnelParameters: FresnelParameters;
  27438. private _useReflectionFresnelFromSpecular;
  27439. /**
  27440. * If true automatically deducts the fresnels values from the material specularity.
  27441. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27442. */
  27443. useReflectionFresnelFromSpecular: boolean;
  27444. private _useGlossinessFromSpecularMapAlpha;
  27445. /**
  27446. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27447. */
  27448. useGlossinessFromSpecularMapAlpha: boolean;
  27449. private _maxSimultaneousLights;
  27450. /**
  27451. * Defines the maximum number of lights that can be used in the material
  27452. */
  27453. maxSimultaneousLights: number;
  27454. private _invertNormalMapX;
  27455. /**
  27456. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27457. */
  27458. invertNormalMapX: boolean;
  27459. private _invertNormalMapY;
  27460. /**
  27461. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27462. */
  27463. invertNormalMapY: boolean;
  27464. private _twoSidedLighting;
  27465. /**
  27466. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27467. */
  27468. twoSidedLighting: boolean;
  27469. /**
  27470. * Default configuration related to image processing available in the standard Material.
  27471. */
  27472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27473. /**
  27474. * Gets the image processing configuration used either in this material.
  27475. */
  27476. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27477. /**
  27478. * Sets the Default image processing configuration used either in the this material.
  27479. *
  27480. * If sets to null, the scene one is in use.
  27481. */
  27482. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27483. /**
  27484. * Keep track of the image processing observer to allow dispose and replace.
  27485. */
  27486. private _imageProcessingObserver;
  27487. /**
  27488. * Attaches a new image processing configuration to the Standard Material.
  27489. * @param configuration
  27490. */
  27491. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27492. /**
  27493. * Gets wether the color curves effect is enabled.
  27494. */
  27495. get cameraColorCurvesEnabled(): boolean;
  27496. /**
  27497. * Sets wether the color curves effect is enabled.
  27498. */
  27499. set cameraColorCurvesEnabled(value: boolean);
  27500. /**
  27501. * Gets wether the color grading effect is enabled.
  27502. */
  27503. get cameraColorGradingEnabled(): boolean;
  27504. /**
  27505. * Gets wether the color grading effect is enabled.
  27506. */
  27507. set cameraColorGradingEnabled(value: boolean);
  27508. /**
  27509. * Gets wether tonemapping is enabled or not.
  27510. */
  27511. get cameraToneMappingEnabled(): boolean;
  27512. /**
  27513. * Sets wether tonemapping is enabled or not
  27514. */
  27515. set cameraToneMappingEnabled(value: boolean);
  27516. /**
  27517. * The camera exposure used on this material.
  27518. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27519. * This corresponds to a photographic exposure.
  27520. */
  27521. get cameraExposure(): number;
  27522. /**
  27523. * The camera exposure used on this material.
  27524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27525. * This corresponds to a photographic exposure.
  27526. */
  27527. set cameraExposure(value: number);
  27528. /**
  27529. * Gets The camera contrast used on this material.
  27530. */
  27531. get cameraContrast(): number;
  27532. /**
  27533. * Sets The camera contrast used on this material.
  27534. */
  27535. set cameraContrast(value: number);
  27536. /**
  27537. * Gets the Color Grading 2D Lookup Texture.
  27538. */
  27539. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27540. /**
  27541. * Sets the Color Grading 2D Lookup Texture.
  27542. */
  27543. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27544. /**
  27545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27547. * 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;
  27548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27549. */
  27550. get cameraColorCurves(): Nullable<ColorCurves>;
  27551. /**
  27552. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27553. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27554. * 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;
  27555. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27556. */
  27557. set cameraColorCurves(value: Nullable<ColorCurves>);
  27558. /**
  27559. * Custom callback helping to override the default shader used in the material.
  27560. */
  27561. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27562. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27563. protected _worldViewProjectionMatrix: Matrix;
  27564. protected _globalAmbientColor: Color3;
  27565. protected _useLogarithmicDepth: boolean;
  27566. protected _rebuildInParallel: boolean;
  27567. /**
  27568. * Instantiates a new standard material.
  27569. * This is the default material used in Babylon. It is the best trade off between quality
  27570. * and performances.
  27571. * @see http://doc.babylonjs.com/babylon101/materials
  27572. * @param name Define the name of the material in the scene
  27573. * @param scene Define the scene the material belong to
  27574. */
  27575. constructor(name: string, scene: Scene);
  27576. /**
  27577. * Gets a boolean indicating that current material needs to register RTT
  27578. */
  27579. get hasRenderTargetTextures(): boolean;
  27580. /**
  27581. * Gets the current class name of the material e.g. "StandardMaterial"
  27582. * Mainly use in serialization.
  27583. * @returns the class name
  27584. */
  27585. getClassName(): string;
  27586. /**
  27587. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27588. * You can try switching to logarithmic depth.
  27589. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27590. */
  27591. get useLogarithmicDepth(): boolean;
  27592. set useLogarithmicDepth(value: boolean);
  27593. /**
  27594. * Specifies if the material will require alpha blending
  27595. * @returns a boolean specifying if alpha blending is needed
  27596. */
  27597. needAlphaBlending(): boolean;
  27598. /**
  27599. * Specifies if this material should be rendered in alpha test mode
  27600. * @returns a boolean specifying if an alpha test is needed.
  27601. */
  27602. needAlphaTesting(): boolean;
  27603. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27604. /**
  27605. * Get the texture used for alpha test purpose.
  27606. * @returns the diffuse texture in case of the standard material.
  27607. */
  27608. getAlphaTestTexture(): Nullable<BaseTexture>;
  27609. /**
  27610. * Get if the submesh is ready to be used and all its information available.
  27611. * Child classes can use it to update shaders
  27612. * @param mesh defines the mesh to check
  27613. * @param subMesh defines which submesh to check
  27614. * @param useInstances specifies that instances should be used
  27615. * @returns a boolean indicating that the submesh is ready or not
  27616. */
  27617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27618. /**
  27619. * Builds the material UBO layouts.
  27620. * Used internally during the effect preparation.
  27621. */
  27622. buildUniformLayout(): void;
  27623. /**
  27624. * Unbinds the material from the mesh
  27625. */
  27626. unbind(): void;
  27627. /**
  27628. * Binds the submesh to this material by preparing the effect and shader to draw
  27629. * @param world defines the world transformation matrix
  27630. * @param mesh defines the mesh containing the submesh
  27631. * @param subMesh defines the submesh to bind the material to
  27632. */
  27633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27634. /**
  27635. * Get the list of animatables in the material.
  27636. * @returns the list of animatables object used in the material
  27637. */
  27638. getAnimatables(): IAnimatable[];
  27639. /**
  27640. * Gets the active textures from the material
  27641. * @returns an array of textures
  27642. */
  27643. getActiveTextures(): BaseTexture[];
  27644. /**
  27645. * Specifies if the material uses a texture
  27646. * @param texture defines the texture to check against the material
  27647. * @returns a boolean specifying if the material uses the texture
  27648. */
  27649. hasTexture(texture: BaseTexture): boolean;
  27650. /**
  27651. * Disposes the material
  27652. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27653. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27654. */
  27655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27656. /**
  27657. * Makes a duplicate of the material, and gives it a new name
  27658. * @param name defines the new name for the duplicated material
  27659. * @returns the cloned material
  27660. */
  27661. clone(name: string): StandardMaterial;
  27662. /**
  27663. * Serializes this material in a JSON representation
  27664. * @returns the serialized material object
  27665. */
  27666. serialize(): any;
  27667. /**
  27668. * Creates a standard material from parsed material data
  27669. * @param source defines the JSON representation of the material
  27670. * @param scene defines the hosting scene
  27671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27672. * @returns a new standard material
  27673. */
  27674. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27675. /**
  27676. * Are diffuse textures enabled in the application.
  27677. */
  27678. static get DiffuseTextureEnabled(): boolean;
  27679. static set DiffuseTextureEnabled(value: boolean);
  27680. /**
  27681. * Are ambient textures enabled in the application.
  27682. */
  27683. static get AmbientTextureEnabled(): boolean;
  27684. static set AmbientTextureEnabled(value: boolean);
  27685. /**
  27686. * Are opacity textures enabled in the application.
  27687. */
  27688. static get OpacityTextureEnabled(): boolean;
  27689. static set OpacityTextureEnabled(value: boolean);
  27690. /**
  27691. * Are reflection textures enabled in the application.
  27692. */
  27693. static get ReflectionTextureEnabled(): boolean;
  27694. static set ReflectionTextureEnabled(value: boolean);
  27695. /**
  27696. * Are emissive textures enabled in the application.
  27697. */
  27698. static get EmissiveTextureEnabled(): boolean;
  27699. static set EmissiveTextureEnabled(value: boolean);
  27700. /**
  27701. * Are specular textures enabled in the application.
  27702. */
  27703. static get SpecularTextureEnabled(): boolean;
  27704. static set SpecularTextureEnabled(value: boolean);
  27705. /**
  27706. * Are bump textures enabled in the application.
  27707. */
  27708. static get BumpTextureEnabled(): boolean;
  27709. static set BumpTextureEnabled(value: boolean);
  27710. /**
  27711. * Are lightmap textures enabled in the application.
  27712. */
  27713. static get LightmapTextureEnabled(): boolean;
  27714. static set LightmapTextureEnabled(value: boolean);
  27715. /**
  27716. * Are refraction textures enabled in the application.
  27717. */
  27718. static get RefractionTextureEnabled(): boolean;
  27719. static set RefractionTextureEnabled(value: boolean);
  27720. /**
  27721. * Are color grading textures enabled in the application.
  27722. */
  27723. static get ColorGradingTextureEnabled(): boolean;
  27724. static set ColorGradingTextureEnabled(value: boolean);
  27725. /**
  27726. * Are fresnels enabled in the application.
  27727. */
  27728. static get FresnelEnabled(): boolean;
  27729. static set FresnelEnabled(value: boolean);
  27730. }
  27731. }
  27732. declare module "babylonjs/Particles/solidParticleSystem" {
  27733. import { Nullable } from "babylonjs/types";
  27734. import { Vector3 } from "babylonjs/Maths/math.vector";
  27735. import { Mesh } from "babylonjs/Meshes/mesh";
  27736. import { Scene, IDisposable } from "babylonjs/scene";
  27737. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27738. import { Material } from "babylonjs/Materials/material";
  27739. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27740. /**
  27741. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27742. *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.
  27743. * The SPS is also a particle system. It provides some methods to manage the particles.
  27744. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27745. *
  27746. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27747. */
  27748. export class SolidParticleSystem implements IDisposable {
  27749. /**
  27750. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27751. * Example : var p = SPS.particles[i];
  27752. */
  27753. particles: SolidParticle[];
  27754. /**
  27755. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27756. */
  27757. nbParticles: number;
  27758. /**
  27759. * If the particles must ever face the camera (default false). Useful for planar particles.
  27760. */
  27761. billboard: boolean;
  27762. /**
  27763. * Recompute normals when adding a shape
  27764. */
  27765. recomputeNormals: boolean;
  27766. /**
  27767. * This a counter ofr your own usage. It's not set by any SPS functions.
  27768. */
  27769. counter: number;
  27770. /**
  27771. * The SPS name. This name is also given to the underlying mesh.
  27772. */
  27773. name: string;
  27774. /**
  27775. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27776. */
  27777. mesh: Mesh;
  27778. /**
  27779. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27780. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27781. */
  27782. vars: any;
  27783. /**
  27784. * This array is populated when the SPS is set as 'pickable'.
  27785. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27786. * Each element of this array is an object `{idx: int, faceId: int}`.
  27787. * `idx` is the picked particle index in the `SPS.particles` array
  27788. * `faceId` is the picked face index counted within this particle.
  27789. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27790. */
  27791. pickedParticles: {
  27792. idx: number;
  27793. faceId: number;
  27794. }[];
  27795. /**
  27796. * This array is populated when `enableDepthSort` is set to true.
  27797. * Each element of this array is an instance of the class DepthSortedParticle.
  27798. */
  27799. depthSortedParticles: DepthSortedParticle[];
  27800. /**
  27801. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27802. * @hidden
  27803. */
  27804. _bSphereOnly: boolean;
  27805. /**
  27806. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27807. * @hidden
  27808. */
  27809. _bSphereRadiusFactor: number;
  27810. private _scene;
  27811. private _positions;
  27812. private _indices;
  27813. private _normals;
  27814. private _colors;
  27815. private _uvs;
  27816. private _indices32;
  27817. private _positions32;
  27818. private _normals32;
  27819. private _fixedNormal32;
  27820. private _colors32;
  27821. private _uvs32;
  27822. private _index;
  27823. private _updatable;
  27824. private _pickable;
  27825. private _isVisibilityBoxLocked;
  27826. private _alwaysVisible;
  27827. private _depthSort;
  27828. private _expandable;
  27829. private _shapeCounter;
  27830. private _copy;
  27831. private _color;
  27832. private _computeParticleColor;
  27833. private _computeParticleTexture;
  27834. private _computeParticleRotation;
  27835. private _computeParticleVertex;
  27836. private _computeBoundingBox;
  27837. private _depthSortParticles;
  27838. private _camera;
  27839. private _mustUnrotateFixedNormals;
  27840. private _particlesIntersect;
  27841. private _needs32Bits;
  27842. private _isNotBuilt;
  27843. private _lastParticleId;
  27844. private _idxOfId;
  27845. private _multimaterialEnabled;
  27846. private _useModelMaterial;
  27847. private _indicesByMaterial;
  27848. private _materialIndexes;
  27849. private _depthSortFunction;
  27850. private _materialSortFunction;
  27851. private _materials;
  27852. private _multimaterial;
  27853. private _materialIndexesById;
  27854. private _defaultMaterial;
  27855. private _autoUpdateSubMeshes;
  27856. /**
  27857. * Creates a SPS (Solid Particle System) object.
  27858. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27859. * @param scene (Scene) is the scene in which the SPS is added.
  27860. * @param options defines the options of the sps e.g.
  27861. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27862. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27863. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27864. * * 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.
  27865. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27866. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27867. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27868. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27869. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27870. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27871. */
  27872. constructor(name: string, scene: Scene, options?: {
  27873. updatable?: boolean;
  27874. isPickable?: boolean;
  27875. enableDepthSort?: boolean;
  27876. particleIntersection?: boolean;
  27877. boundingSphereOnly?: boolean;
  27878. bSphereRadiusFactor?: number;
  27879. expandable?: boolean;
  27880. useModelMaterial?: boolean;
  27881. enableMultiMaterial?: boolean;
  27882. });
  27883. /**
  27884. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27885. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27886. * @returns the created mesh
  27887. */
  27888. buildMesh(): Mesh;
  27889. /**
  27890. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27891. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27892. * Thus the particles generated from `digest()` have their property `position` set yet.
  27893. * @param mesh ( Mesh ) is the mesh to be digested
  27894. * @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
  27895. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27896. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27897. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27898. * @returns the current SPS
  27899. */
  27900. digest(mesh: Mesh, options?: {
  27901. facetNb?: number;
  27902. number?: number;
  27903. delta?: number;
  27904. storage?: [];
  27905. }): SolidParticleSystem;
  27906. /**
  27907. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27908. * @hidden
  27909. */
  27910. private _unrotateFixedNormals;
  27911. /**
  27912. * Resets the temporary working copy particle
  27913. * @hidden
  27914. */
  27915. private _resetCopy;
  27916. /**
  27917. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27918. * @param p the current index in the positions array to be updated
  27919. * @param ind the current index in the indices array
  27920. * @param shape a Vector3 array, the shape geometry
  27921. * @param positions the positions array to be updated
  27922. * @param meshInd the shape indices array
  27923. * @param indices the indices array to be updated
  27924. * @param meshUV the shape uv array
  27925. * @param uvs the uv array to be updated
  27926. * @param meshCol the shape color array
  27927. * @param colors the color array to be updated
  27928. * @param meshNor the shape normals array
  27929. * @param normals the normals array to be updated
  27930. * @param idx the particle index
  27931. * @param idxInShape the particle index in its shape
  27932. * @param options the addShape() method passed options
  27933. * @model the particle model
  27934. * @hidden
  27935. */
  27936. private _meshBuilder;
  27937. /**
  27938. * Returns a shape Vector3 array from positions float array
  27939. * @param positions float array
  27940. * @returns a vector3 array
  27941. * @hidden
  27942. */
  27943. private _posToShape;
  27944. /**
  27945. * Returns a shapeUV array from a float uvs (array deep copy)
  27946. * @param uvs as a float array
  27947. * @returns a shapeUV array
  27948. * @hidden
  27949. */
  27950. private _uvsToShapeUV;
  27951. /**
  27952. * Adds a new particle object in the particles array
  27953. * @param idx particle index in particles array
  27954. * @param id particle id
  27955. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27956. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27957. * @param model particle ModelShape object
  27958. * @param shapeId model shape identifier
  27959. * @param idxInShape index of the particle in the current model
  27960. * @param bInfo model bounding info object
  27961. * @param storage target storage array, if any
  27962. * @hidden
  27963. */
  27964. private _addParticle;
  27965. /**
  27966. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27967. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27968. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27969. * @param nb (positive integer) the number of particles to be created from this model
  27970. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27971. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27972. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27973. * @returns the number of shapes in the system
  27974. */
  27975. addShape(mesh: Mesh, nb: number, options?: {
  27976. positionFunction?: any;
  27977. vertexFunction?: any;
  27978. storage?: [];
  27979. }): number;
  27980. /**
  27981. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27982. * @hidden
  27983. */
  27984. private _rebuildParticle;
  27985. /**
  27986. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27987. * @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.
  27988. * @returns the SPS.
  27989. */
  27990. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27991. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27992. * Returns an array with the removed particles.
  27993. * 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.
  27994. * The SPS can't be empty so at least one particle needs to remain in place.
  27995. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27996. * @param start index of the first particle to remove
  27997. * @param end index of the last particle to remove (included)
  27998. * @returns an array populated with the removed particles
  27999. */
  28000. removeParticles(start: number, end: number): SolidParticle[];
  28001. /**
  28002. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28003. * @param solidParticleArray an array populated with Solid Particles objects
  28004. * @returns the SPS
  28005. */
  28006. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28007. /**
  28008. * Creates a new particle and modifies the SPS mesh geometry :
  28009. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28010. * - calls _addParticle() to populate the particle array
  28011. * factorized code from addShape() and insertParticlesFromArray()
  28012. * @param idx particle index in the particles array
  28013. * @param i particle index in its shape
  28014. * @param modelShape particle ModelShape object
  28015. * @param shape shape vertex array
  28016. * @param meshInd shape indices array
  28017. * @param meshUV shape uv array
  28018. * @param meshCol shape color array
  28019. * @param meshNor shape normals array
  28020. * @param bbInfo shape bounding info
  28021. * @param storage target particle storage
  28022. * @options addShape() passed options
  28023. * @hidden
  28024. */
  28025. private _insertNewParticle;
  28026. /**
  28027. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28028. * This method calls `updateParticle()` for each particle of the SPS.
  28029. * For an animated SPS, it is usually called within the render loop.
  28030. * 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.
  28031. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28032. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28033. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28034. * @returns the SPS.
  28035. */
  28036. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28037. /**
  28038. * Disposes the SPS.
  28039. */
  28040. dispose(): void;
  28041. /**
  28042. * Returns a SolidParticle object from its identifier : particle.id
  28043. * @param id (integer) the particle Id
  28044. * @returns the searched particle or null if not found in the SPS.
  28045. */
  28046. getParticleById(id: number): Nullable<SolidParticle>;
  28047. /**
  28048. * Returns a new array populated with the particles having the passed shapeId.
  28049. * @param shapeId (integer) the shape identifier
  28050. * @returns a new solid particle array
  28051. */
  28052. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28053. /**
  28054. * Populates the passed array "ref" with the particles having the passed shapeId.
  28055. * @param shapeId the shape identifier
  28056. * @returns the SPS
  28057. * @param ref
  28058. */
  28059. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28060. /**
  28061. * Computes the required SubMeshes according the materials assigned to the particles.
  28062. * @returns the solid particle system.
  28063. * Does nothing if called before the SPS mesh is built.
  28064. */
  28065. computeSubMeshes(): SolidParticleSystem;
  28066. /**
  28067. * Sorts the solid particles by material when MultiMaterial is enabled.
  28068. * Updates the indices32 array.
  28069. * Updates the indicesByMaterial array.
  28070. * Updates the mesh indices array.
  28071. * @returns the SPS
  28072. * @hidden
  28073. */
  28074. private _sortParticlesByMaterial;
  28075. /**
  28076. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28077. * @hidden
  28078. */
  28079. private _setMaterialIndexesById;
  28080. /**
  28081. * Returns an array with unique values of Materials from the passed array
  28082. * @param array the material array to be checked and filtered
  28083. * @hidden
  28084. */
  28085. private _filterUniqueMaterialId;
  28086. /**
  28087. * Sets a new Standard Material as _defaultMaterial if not already set.
  28088. * @hidden
  28089. */
  28090. private _setDefaultMaterial;
  28091. /**
  28092. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28094. * @returns the SPS.
  28095. */
  28096. refreshVisibleSize(): SolidParticleSystem;
  28097. /**
  28098. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28099. * @param size the size (float) of the visibility box
  28100. * note : this doesn't lock the SPS mesh bounding box.
  28101. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28102. */
  28103. setVisibilityBox(size: number): void;
  28104. /**
  28105. * Gets whether the SPS as always visible or not
  28106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28107. */
  28108. get isAlwaysVisible(): boolean;
  28109. /**
  28110. * Sets the SPS as always visible or not
  28111. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28112. */
  28113. set isAlwaysVisible(val: boolean);
  28114. /**
  28115. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28116. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28117. */
  28118. set isVisibilityBoxLocked(val: boolean);
  28119. /**
  28120. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28121. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28122. */
  28123. get isVisibilityBoxLocked(): boolean;
  28124. /**
  28125. * Tells to `setParticles()` to compute the particle rotations or not.
  28126. * Default value : true. The SPS is faster when it's set to false.
  28127. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28128. */
  28129. set computeParticleRotation(val: boolean);
  28130. /**
  28131. * Tells to `setParticles()` to compute the particle colors or not.
  28132. * Default value : true. The SPS is faster when it's set to false.
  28133. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28134. */
  28135. set computeParticleColor(val: boolean);
  28136. set computeParticleTexture(val: boolean);
  28137. /**
  28138. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28139. * Default value : false. The SPS is faster when it's set to false.
  28140. * Note : the particle custom vertex positions aren't stored values.
  28141. */
  28142. set computeParticleVertex(val: boolean);
  28143. /**
  28144. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28145. */
  28146. set computeBoundingBox(val: boolean);
  28147. /**
  28148. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28150. * Default : `true`
  28151. */
  28152. set depthSortParticles(val: boolean);
  28153. /**
  28154. * Gets if `setParticles()` computes the particle rotations or not.
  28155. * Default value : true. The SPS is faster when it's set to false.
  28156. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28157. */
  28158. get computeParticleRotation(): boolean;
  28159. /**
  28160. * Gets if `setParticles()` computes the particle colors or not.
  28161. * Default value : true. The SPS is faster when it's set to false.
  28162. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28163. */
  28164. get computeParticleColor(): boolean;
  28165. /**
  28166. * Gets if `setParticles()` computes the particle textures or not.
  28167. * Default value : true. The SPS is faster when it's set to false.
  28168. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28169. */
  28170. get computeParticleTexture(): boolean;
  28171. /**
  28172. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28173. * Default value : false. The SPS is faster when it's set to false.
  28174. * Note : the particle custom vertex positions aren't stored values.
  28175. */
  28176. get computeParticleVertex(): boolean;
  28177. /**
  28178. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28179. */
  28180. get computeBoundingBox(): boolean;
  28181. /**
  28182. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28183. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28184. * Default : `true`
  28185. */
  28186. get depthSortParticles(): boolean;
  28187. /**
  28188. * Gets if the SPS is created as expandable at construction time.
  28189. * Default : `false`
  28190. */
  28191. get expandable(): boolean;
  28192. /**
  28193. * Gets if the SPS supports the Multi Materials
  28194. */
  28195. get multimaterialEnabled(): boolean;
  28196. /**
  28197. * Gets if the SPS uses the model materials for its own multimaterial.
  28198. */
  28199. get useModelMaterial(): boolean;
  28200. /**
  28201. * The SPS used material array.
  28202. */
  28203. get materials(): Material[];
  28204. /**
  28205. * Sets the SPS MultiMaterial from the passed materials.
  28206. * Note : the passed array is internally copied and not used then by reference.
  28207. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28208. */
  28209. setMultiMaterial(materials: Material[]): void;
  28210. /**
  28211. * The SPS computed multimaterial object
  28212. */
  28213. get multimaterial(): MultiMaterial;
  28214. set multimaterial(mm: MultiMaterial);
  28215. /**
  28216. * If the subMeshes must be updated on the next call to setParticles()
  28217. */
  28218. get autoUpdateSubMeshes(): boolean;
  28219. set autoUpdateSubMeshes(val: boolean);
  28220. /**
  28221. * This function does nothing. It may be overwritten to set all the particle first values.
  28222. * The SPS doesn't call this function, you may have to call it by your own.
  28223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28224. */
  28225. initParticles(): void;
  28226. /**
  28227. * This function does nothing. It may be overwritten to recycle a particle.
  28228. * The SPS doesn't call this function, you may have to call it by your own.
  28229. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28230. * @param particle The particle to recycle
  28231. * @returns the recycled particle
  28232. */
  28233. recycleParticle(particle: SolidParticle): SolidParticle;
  28234. /**
  28235. * Updates a particle : this function should be overwritten by the user.
  28236. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28237. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28238. * @example : just set a particle position or velocity and recycle conditions
  28239. * @param particle The particle to update
  28240. * @returns the updated particle
  28241. */
  28242. updateParticle(particle: SolidParticle): SolidParticle;
  28243. /**
  28244. * Updates a vertex of a particle : it can be overwritten by the user.
  28245. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28246. * @param particle the current particle
  28247. * @param vertex the current index of the current particle
  28248. * @param pt the index of the current vertex in the particle shape
  28249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28250. * @example : just set a vertex particle position
  28251. * @returns the updated vertex
  28252. */
  28253. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28254. /**
  28255. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28256. * This does nothing and may be overwritten by the user.
  28257. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28258. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28259. * @param update the boolean update value actually passed to setParticles()
  28260. */
  28261. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28262. /**
  28263. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28264. * This will be passed three parameters.
  28265. * This does nothing and may be overwritten by the user.
  28266. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28267. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28268. * @param update the boolean update value actually passed to setParticles()
  28269. */
  28270. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28271. }
  28272. }
  28273. declare module "babylonjs/Particles/solidParticle" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28276. import { Color4 } from "babylonjs/Maths/math.color";
  28277. import { Mesh } from "babylonjs/Meshes/mesh";
  28278. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28279. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28280. import { Plane } from "babylonjs/Maths/math.plane";
  28281. import { Material } from "babylonjs/Materials/material";
  28282. /**
  28283. * Represents one particle of a solid particle system.
  28284. */
  28285. export class SolidParticle {
  28286. /**
  28287. * particle global index
  28288. */
  28289. idx: number;
  28290. /**
  28291. * particle identifier
  28292. */
  28293. id: number;
  28294. /**
  28295. * The color of the particle
  28296. */
  28297. color: Nullable<Color4>;
  28298. /**
  28299. * The world space position of the particle.
  28300. */
  28301. position: Vector3;
  28302. /**
  28303. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28304. */
  28305. rotation: Vector3;
  28306. /**
  28307. * The world space rotation quaternion of the particle.
  28308. */
  28309. rotationQuaternion: Nullable<Quaternion>;
  28310. /**
  28311. * The scaling of the particle.
  28312. */
  28313. scaling: Vector3;
  28314. /**
  28315. * The uvs of the particle.
  28316. */
  28317. uvs: Vector4;
  28318. /**
  28319. * The current speed of the particle.
  28320. */
  28321. velocity: Vector3;
  28322. /**
  28323. * The pivot point in the particle local space.
  28324. */
  28325. pivot: Vector3;
  28326. /**
  28327. * Must the particle be translated from its pivot point in its local space ?
  28328. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28329. * Default : false
  28330. */
  28331. translateFromPivot: boolean;
  28332. /**
  28333. * Is the particle active or not ?
  28334. */
  28335. alive: boolean;
  28336. /**
  28337. * Is the particle visible or not ?
  28338. */
  28339. isVisible: boolean;
  28340. /**
  28341. * Index of this particle in the global "positions" array (Internal use)
  28342. * @hidden
  28343. */
  28344. _pos: number;
  28345. /**
  28346. * @hidden Index of this particle in the global "indices" array (Internal use)
  28347. */
  28348. _ind: number;
  28349. /**
  28350. * @hidden ModelShape of this particle (Internal use)
  28351. */
  28352. _model: ModelShape;
  28353. /**
  28354. * ModelShape id of this particle
  28355. */
  28356. shapeId: number;
  28357. /**
  28358. * Index of the particle in its shape id
  28359. */
  28360. idxInShape: number;
  28361. /**
  28362. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28363. */
  28364. _modelBoundingInfo: BoundingInfo;
  28365. /**
  28366. * @hidden Particle BoundingInfo object (Internal use)
  28367. */
  28368. _boundingInfo: BoundingInfo;
  28369. /**
  28370. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28371. */
  28372. _sps: SolidParticleSystem;
  28373. /**
  28374. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28375. */
  28376. _stillInvisible: boolean;
  28377. /**
  28378. * @hidden Last computed particle rotation matrix
  28379. */
  28380. _rotationMatrix: number[];
  28381. /**
  28382. * Parent particle Id, if any.
  28383. * Default null.
  28384. */
  28385. parentId: Nullable<number>;
  28386. /**
  28387. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28388. */
  28389. materialIndex: Nullable<number>;
  28390. /**
  28391. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28392. * The possible values are :
  28393. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28394. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28395. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28396. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28397. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28398. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28399. * */
  28400. cullingStrategy: number;
  28401. /**
  28402. * @hidden Internal global position in the SPS.
  28403. */
  28404. _globalPosition: Vector3;
  28405. /**
  28406. * Creates a Solid Particle object.
  28407. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28408. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28409. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28410. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28411. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28412. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28413. * @param shapeId (integer) is the model shape identifier in the SPS.
  28414. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28415. * @param sps defines the sps it is associated to
  28416. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28417. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28418. */
  28419. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28420. /**
  28421. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28422. * @param target the particle target
  28423. * @returns the current particle
  28424. */
  28425. copyToRef(target: SolidParticle): SolidParticle;
  28426. /**
  28427. * Legacy support, changed scale to scaling
  28428. */
  28429. get scale(): Vector3;
  28430. /**
  28431. * Legacy support, changed scale to scaling
  28432. */
  28433. set scale(scale: Vector3);
  28434. /**
  28435. * Legacy support, changed quaternion to rotationQuaternion
  28436. */
  28437. get quaternion(): Nullable<Quaternion>;
  28438. /**
  28439. * Legacy support, changed quaternion to rotationQuaternion
  28440. */
  28441. set quaternion(q: Nullable<Quaternion>);
  28442. /**
  28443. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28444. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28445. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28446. * @returns true if it intersects
  28447. */
  28448. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28449. /**
  28450. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28451. * A particle is in the frustum if its bounding box intersects the frustum
  28452. * @param frustumPlanes defines the frustum to test
  28453. * @returns true if the particle is in the frustum planes
  28454. */
  28455. isInFrustum(frustumPlanes: Plane[]): boolean;
  28456. /**
  28457. * get the rotation matrix of the particle
  28458. * @hidden
  28459. */
  28460. getRotationMatrix(m: Matrix): void;
  28461. }
  28462. /**
  28463. * Represents the shape of the model used by one particle of a solid particle system.
  28464. * SPS internal tool, don't use it manually.
  28465. */
  28466. export class ModelShape {
  28467. /**
  28468. * The shape id
  28469. * @hidden
  28470. */
  28471. shapeID: number;
  28472. /**
  28473. * flat array of model positions (internal use)
  28474. * @hidden
  28475. */
  28476. _shape: Vector3[];
  28477. /**
  28478. * flat array of model UVs (internal use)
  28479. * @hidden
  28480. */
  28481. _shapeUV: number[];
  28482. /**
  28483. * color array of the model
  28484. * @hidden
  28485. */
  28486. _shapeColors: number[];
  28487. /**
  28488. * indices array of the model
  28489. * @hidden
  28490. */
  28491. _indices: number[];
  28492. /**
  28493. * normals array of the model
  28494. * @hidden
  28495. */
  28496. _normals: number[];
  28497. /**
  28498. * length of the shape in the model indices array (internal use)
  28499. * @hidden
  28500. */
  28501. _indicesLength: number;
  28502. /**
  28503. * Custom position function (internal use)
  28504. * @hidden
  28505. */
  28506. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28507. /**
  28508. * Custom vertex function (internal use)
  28509. * @hidden
  28510. */
  28511. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28512. /**
  28513. * Model material (internal use)
  28514. * @hidden
  28515. */
  28516. _material: Nullable<Material>;
  28517. /**
  28518. * 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.
  28519. * SPS internal tool, don't use it manually.
  28520. * @hidden
  28521. */
  28522. 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>);
  28523. }
  28524. /**
  28525. * Represents a Depth Sorted Particle in the solid particle system.
  28526. * @hidden
  28527. */
  28528. export class DepthSortedParticle {
  28529. /**
  28530. * Index of the particle in the "indices" array
  28531. */
  28532. ind: number;
  28533. /**
  28534. * Length of the particle shape in the "indices" array
  28535. */
  28536. indicesLength: number;
  28537. /**
  28538. * Squared distance from the particle to the camera
  28539. */
  28540. sqDistance: number;
  28541. /**
  28542. * Material index when used with MultiMaterials
  28543. */
  28544. materialIndex: number;
  28545. /**
  28546. * Creates a new sorted particle
  28547. * @param materialIndex
  28548. */
  28549. constructor(ind: number, indLength: number, materialIndex: number);
  28550. }
  28551. }
  28552. declare module "babylonjs/Collisions/meshCollisionData" {
  28553. import { Collider } from "babylonjs/Collisions/collider";
  28554. import { Vector3 } from "babylonjs/Maths/math.vector";
  28555. import { Nullable } from "babylonjs/types";
  28556. import { Observer } from "babylonjs/Misc/observable";
  28557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28558. /**
  28559. * @hidden
  28560. */
  28561. export class _MeshCollisionData {
  28562. _checkCollisions: boolean;
  28563. _collisionMask: number;
  28564. _collisionGroup: number;
  28565. _collider: Nullable<Collider>;
  28566. _oldPositionForCollisions: Vector3;
  28567. _diffPositionForCollisions: Vector3;
  28568. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28569. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28570. }
  28571. }
  28572. declare module "babylonjs/Meshes/abstractMesh" {
  28573. import { Observable } from "babylonjs/Misc/observable";
  28574. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28575. import { Camera } from "babylonjs/Cameras/camera";
  28576. import { Scene, IDisposable } from "babylonjs/scene";
  28577. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28578. import { Node } from "babylonjs/node";
  28579. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28582. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28583. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28584. import { Material } from "babylonjs/Materials/material";
  28585. import { Light } from "babylonjs/Lights/light";
  28586. import { Skeleton } from "babylonjs/Bones/skeleton";
  28587. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28588. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28589. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28590. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28591. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28592. import { Plane } from "babylonjs/Maths/math.plane";
  28593. import { Ray } from "babylonjs/Culling/ray";
  28594. import { Collider } from "babylonjs/Collisions/collider";
  28595. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28596. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28597. /** @hidden */
  28598. class _FacetDataStorage {
  28599. facetPositions: Vector3[];
  28600. facetNormals: Vector3[];
  28601. facetPartitioning: number[][];
  28602. facetNb: number;
  28603. partitioningSubdivisions: number;
  28604. partitioningBBoxRatio: number;
  28605. facetDataEnabled: boolean;
  28606. facetParameters: any;
  28607. bbSize: Vector3;
  28608. subDiv: {
  28609. max: number;
  28610. X: number;
  28611. Y: number;
  28612. Z: number;
  28613. };
  28614. facetDepthSort: boolean;
  28615. facetDepthSortEnabled: boolean;
  28616. depthSortedIndices: IndicesArray;
  28617. depthSortedFacets: {
  28618. ind: number;
  28619. sqDistance: number;
  28620. }[];
  28621. facetDepthSortFunction: (f1: {
  28622. ind: number;
  28623. sqDistance: number;
  28624. }, f2: {
  28625. ind: number;
  28626. sqDistance: number;
  28627. }) => number;
  28628. facetDepthSortFrom: Vector3;
  28629. facetDepthSortOrigin: Vector3;
  28630. invertedMatrix: Matrix;
  28631. }
  28632. /**
  28633. * @hidden
  28634. **/
  28635. class _InternalAbstractMeshDataInfo {
  28636. _hasVertexAlpha: boolean;
  28637. _useVertexColors: boolean;
  28638. _numBoneInfluencers: number;
  28639. _applyFog: boolean;
  28640. _receiveShadows: boolean;
  28641. _facetData: _FacetDataStorage;
  28642. _visibility: number;
  28643. _skeleton: Nullable<Skeleton>;
  28644. _layerMask: number;
  28645. _computeBonesUsingShaders: boolean;
  28646. _isActive: boolean;
  28647. _onlyForInstances: boolean;
  28648. _isActiveIntermediate: boolean;
  28649. _onlyForInstancesIntermediate: boolean;
  28650. _actAsRegularMesh: boolean;
  28651. }
  28652. /**
  28653. * Class used to store all common mesh properties
  28654. */
  28655. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28656. /** No occlusion */
  28657. static OCCLUSION_TYPE_NONE: number;
  28658. /** Occlusion set to optimisitic */
  28659. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28660. /** Occlusion set to strict */
  28661. static OCCLUSION_TYPE_STRICT: number;
  28662. /** Use an accurante occlusion algorithm */
  28663. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28664. /** Use a conservative occlusion algorithm */
  28665. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28666. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28667. * Test order :
  28668. * Is the bounding sphere outside the frustum ?
  28669. * If not, are the bounding box vertices outside the frustum ?
  28670. * It not, then the cullable object is in the frustum.
  28671. */
  28672. static readonly CULLINGSTRATEGY_STANDARD: number;
  28673. /** Culling strategy : Bounding Sphere Only.
  28674. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28675. * It's also less accurate than the standard because some not visible objects can still be selected.
  28676. * Test : is the bounding sphere outside the frustum ?
  28677. * If not, then the cullable object is in the frustum.
  28678. */
  28679. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28680. /** Culling strategy : Optimistic Inclusion.
  28681. * This in an inclusion test first, then the standard exclusion test.
  28682. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28683. * 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.
  28684. * Anyway, it's as accurate as the standard strategy.
  28685. * Test :
  28686. * Is the cullable object bounding sphere center in the frustum ?
  28687. * If not, apply the default culling strategy.
  28688. */
  28689. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28690. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28691. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28692. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28693. * 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.
  28694. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28695. * Test :
  28696. * Is the cullable object bounding sphere center in the frustum ?
  28697. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28698. */
  28699. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28700. /**
  28701. * No billboard
  28702. */
  28703. static get BILLBOARDMODE_NONE(): number;
  28704. /** Billboard on X axis */
  28705. static get BILLBOARDMODE_X(): number;
  28706. /** Billboard on Y axis */
  28707. static get BILLBOARDMODE_Y(): number;
  28708. /** Billboard on Z axis */
  28709. static get BILLBOARDMODE_Z(): number;
  28710. /** Billboard on all axes */
  28711. static get BILLBOARDMODE_ALL(): number;
  28712. /** Billboard on using position instead of orientation */
  28713. static get BILLBOARDMODE_USE_POSITION(): number;
  28714. /** @hidden */
  28715. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28716. /**
  28717. * The culling strategy to use to check whether the mesh must be rendered or not.
  28718. * This value can be changed at any time and will be used on the next render mesh selection.
  28719. * The possible values are :
  28720. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28721. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28722. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28723. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28724. * Please read each static variable documentation to get details about the culling process.
  28725. * */
  28726. cullingStrategy: number;
  28727. /**
  28728. * Gets the number of facets in the mesh
  28729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28730. */
  28731. get facetNb(): number;
  28732. /**
  28733. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28735. */
  28736. get partitioningSubdivisions(): number;
  28737. set partitioningSubdivisions(nb: number);
  28738. /**
  28739. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28740. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28742. */
  28743. get partitioningBBoxRatio(): number;
  28744. set partitioningBBoxRatio(ratio: number);
  28745. /**
  28746. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28747. * Works only for updatable meshes.
  28748. * Doesn't work with multi-materials
  28749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28750. */
  28751. get mustDepthSortFacets(): boolean;
  28752. set mustDepthSortFacets(sort: boolean);
  28753. /**
  28754. * The location (Vector3) where the facet depth sort must be computed from.
  28755. * By default, the active camera position.
  28756. * Used only when facet depth sort is enabled
  28757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28758. */
  28759. get facetDepthSortFrom(): Vector3;
  28760. set facetDepthSortFrom(location: Vector3);
  28761. /**
  28762. * gets a boolean indicating if facetData is enabled
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28764. */
  28765. get isFacetDataEnabled(): boolean;
  28766. /** @hidden */
  28767. _updateNonUniformScalingState(value: boolean): boolean;
  28768. /**
  28769. * An event triggered when this mesh collides with another one
  28770. */
  28771. onCollideObservable: Observable<AbstractMesh>;
  28772. /** Set a function to call when this mesh collides with another one */
  28773. set onCollide(callback: () => void);
  28774. /**
  28775. * An event triggered when the collision's position changes
  28776. */
  28777. onCollisionPositionChangeObservable: Observable<Vector3>;
  28778. /** Set a function to call when the collision's position changes */
  28779. set onCollisionPositionChange(callback: () => void);
  28780. /**
  28781. * An event triggered when material is changed
  28782. */
  28783. onMaterialChangedObservable: Observable<AbstractMesh>;
  28784. /**
  28785. * Gets or sets the orientation for POV movement & rotation
  28786. */
  28787. definedFacingForward: boolean;
  28788. /** @hidden */
  28789. _occlusionQuery: Nullable<WebGLQuery>;
  28790. /** @hidden */
  28791. _renderingGroup: Nullable<RenderingGroup>;
  28792. /**
  28793. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28794. */
  28795. get visibility(): number;
  28796. /**
  28797. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28798. */
  28799. set visibility(value: number);
  28800. /** Gets or sets the alpha index used to sort transparent meshes
  28801. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28802. */
  28803. alphaIndex: number;
  28804. /**
  28805. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28806. */
  28807. isVisible: boolean;
  28808. /**
  28809. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28810. */
  28811. isPickable: boolean;
  28812. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28813. showSubMeshesBoundingBox: boolean;
  28814. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28815. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28816. */
  28817. isBlocker: boolean;
  28818. /**
  28819. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28820. */
  28821. enablePointerMoveEvents: boolean;
  28822. /**
  28823. * Specifies the rendering group id for this mesh (0 by default)
  28824. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28825. */
  28826. renderingGroupId: number;
  28827. private _material;
  28828. /** Gets or sets current material */
  28829. get material(): Nullable<Material>;
  28830. set material(value: Nullable<Material>);
  28831. /**
  28832. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28833. * @see http://doc.babylonjs.com/babylon101/shadows
  28834. */
  28835. get receiveShadows(): boolean;
  28836. set receiveShadows(value: boolean);
  28837. /** Defines color to use when rendering outline */
  28838. outlineColor: Color3;
  28839. /** Define width to use when rendering outline */
  28840. outlineWidth: number;
  28841. /** Defines color to use when rendering overlay */
  28842. overlayColor: Color3;
  28843. /** Defines alpha to use when rendering overlay */
  28844. overlayAlpha: number;
  28845. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28846. get hasVertexAlpha(): boolean;
  28847. set hasVertexAlpha(value: boolean);
  28848. /** 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) */
  28849. get useVertexColors(): boolean;
  28850. set useVertexColors(value: boolean);
  28851. /**
  28852. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28853. */
  28854. get computeBonesUsingShaders(): boolean;
  28855. set computeBonesUsingShaders(value: boolean);
  28856. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28857. get numBoneInfluencers(): number;
  28858. set numBoneInfluencers(value: number);
  28859. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28860. get applyFog(): boolean;
  28861. set applyFog(value: boolean);
  28862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28863. useOctreeForRenderingSelection: boolean;
  28864. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28865. useOctreeForPicking: boolean;
  28866. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28867. useOctreeForCollisions: boolean;
  28868. /**
  28869. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28870. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28871. */
  28872. get layerMask(): number;
  28873. set layerMask(value: number);
  28874. /**
  28875. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28876. */
  28877. alwaysSelectAsActiveMesh: boolean;
  28878. /**
  28879. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28880. */
  28881. doNotSyncBoundingInfo: boolean;
  28882. /**
  28883. * Gets or sets the current action manager
  28884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28885. */
  28886. actionManager: Nullable<AbstractActionManager>;
  28887. private _meshCollisionData;
  28888. /**
  28889. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28890. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28891. */
  28892. ellipsoid: Vector3;
  28893. /**
  28894. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28895. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28896. */
  28897. ellipsoidOffset: Vector3;
  28898. /**
  28899. * Gets or sets a collision mask used to mask collisions (default is -1).
  28900. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28901. */
  28902. get collisionMask(): number;
  28903. set collisionMask(mask: number);
  28904. /**
  28905. * Gets or sets the current collision group mask (-1 by default).
  28906. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28907. */
  28908. get collisionGroup(): number;
  28909. set collisionGroup(mask: number);
  28910. /**
  28911. * Defines edge width used when edgesRenderer is enabled
  28912. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28913. */
  28914. edgesWidth: number;
  28915. /**
  28916. * Defines edge color used when edgesRenderer is enabled
  28917. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28918. */
  28919. edgesColor: Color4;
  28920. /** @hidden */
  28921. _edgesRenderer: Nullable<IEdgesRenderer>;
  28922. /** @hidden */
  28923. _masterMesh: Nullable<AbstractMesh>;
  28924. /** @hidden */
  28925. _boundingInfo: Nullable<BoundingInfo>;
  28926. /** @hidden */
  28927. _renderId: number;
  28928. /**
  28929. * Gets or sets the list of subMeshes
  28930. * @see http://doc.babylonjs.com/how_to/multi_materials
  28931. */
  28932. subMeshes: SubMesh[];
  28933. /** @hidden */
  28934. _intersectionsInProgress: AbstractMesh[];
  28935. /** @hidden */
  28936. _unIndexed: boolean;
  28937. /** @hidden */
  28938. _lightSources: Light[];
  28939. /** Gets the list of lights affecting that mesh */
  28940. get lightSources(): Light[];
  28941. /** @hidden */
  28942. get _positions(): Nullable<Vector3[]>;
  28943. /** @hidden */
  28944. _waitingData: {
  28945. lods: Nullable<any>;
  28946. actions: Nullable<any>;
  28947. freezeWorldMatrix: Nullable<boolean>;
  28948. };
  28949. /** @hidden */
  28950. _bonesTransformMatrices: Nullable<Float32Array>;
  28951. /** @hidden */
  28952. _transformMatrixTexture: Nullable<RawTexture>;
  28953. /**
  28954. * Gets or sets a skeleton to apply skining transformations
  28955. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28956. */
  28957. set skeleton(value: Nullable<Skeleton>);
  28958. get skeleton(): Nullable<Skeleton>;
  28959. /**
  28960. * An event triggered when the mesh is rebuilt.
  28961. */
  28962. onRebuildObservable: Observable<AbstractMesh>;
  28963. /**
  28964. * Creates a new AbstractMesh
  28965. * @param name defines the name of the mesh
  28966. * @param scene defines the hosting scene
  28967. */
  28968. constructor(name: string, scene?: Nullable<Scene>);
  28969. /**
  28970. * Returns the string "AbstractMesh"
  28971. * @returns "AbstractMesh"
  28972. */
  28973. getClassName(): string;
  28974. /**
  28975. * Gets a string representation of the current mesh
  28976. * @param fullDetails defines a boolean indicating if full details must be included
  28977. * @returns a string representation of the current mesh
  28978. */
  28979. toString(fullDetails?: boolean): string;
  28980. /**
  28981. * @hidden
  28982. */
  28983. protected _getEffectiveParent(): Nullable<Node>;
  28984. /** @hidden */
  28985. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28986. /** @hidden */
  28987. _rebuild(): void;
  28988. /** @hidden */
  28989. _resyncLightSources(): void;
  28990. /** @hidden */
  28991. _resyncLightSource(light: Light): void;
  28992. /** @hidden */
  28993. _unBindEffect(): void;
  28994. /** @hidden */
  28995. _removeLightSource(light: Light, dispose: boolean): void;
  28996. private _markSubMeshesAsDirty;
  28997. /** @hidden */
  28998. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28999. /** @hidden */
  29000. _markSubMeshesAsAttributesDirty(): void;
  29001. /** @hidden */
  29002. _markSubMeshesAsMiscDirty(): void;
  29003. /**
  29004. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29005. */
  29006. get scaling(): Vector3;
  29007. set scaling(newScaling: Vector3);
  29008. /**
  29009. * Returns true if the mesh is blocked. Implemented by child classes
  29010. */
  29011. get isBlocked(): boolean;
  29012. /**
  29013. * Returns the mesh itself by default. Implemented by child classes
  29014. * @param camera defines the camera to use to pick the right LOD level
  29015. * @returns the currentAbstractMesh
  29016. */
  29017. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29018. /**
  29019. * Returns 0 by default. Implemented by child classes
  29020. * @returns an integer
  29021. */
  29022. getTotalVertices(): number;
  29023. /**
  29024. * Returns a positive integer : the total number of indices in this mesh geometry.
  29025. * @returns the numner of indices or zero if the mesh has no geometry.
  29026. */
  29027. getTotalIndices(): number;
  29028. /**
  29029. * Returns null by default. Implemented by child classes
  29030. * @returns null
  29031. */
  29032. getIndices(): Nullable<IndicesArray>;
  29033. /**
  29034. * Returns the array of the requested vertex data kind. Implemented by child classes
  29035. * @param kind defines the vertex data kind to use
  29036. * @returns null
  29037. */
  29038. getVerticesData(kind: string): Nullable<FloatArray>;
  29039. /**
  29040. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29041. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29042. * Note that a new underlying VertexBuffer object is created each call.
  29043. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29044. * @param kind defines vertex data kind:
  29045. * * VertexBuffer.PositionKind
  29046. * * VertexBuffer.UVKind
  29047. * * VertexBuffer.UV2Kind
  29048. * * VertexBuffer.UV3Kind
  29049. * * VertexBuffer.UV4Kind
  29050. * * VertexBuffer.UV5Kind
  29051. * * VertexBuffer.UV6Kind
  29052. * * VertexBuffer.ColorKind
  29053. * * VertexBuffer.MatricesIndicesKind
  29054. * * VertexBuffer.MatricesIndicesExtraKind
  29055. * * VertexBuffer.MatricesWeightsKind
  29056. * * VertexBuffer.MatricesWeightsExtraKind
  29057. * @param data defines the data source
  29058. * @param updatable defines if the data must be flagged as updatable (or static)
  29059. * @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
  29060. * @returns the current mesh
  29061. */
  29062. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29063. /**
  29064. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29065. * If the mesh has no geometry, it is simply returned as it is.
  29066. * @param kind defines vertex data kind:
  29067. * * VertexBuffer.PositionKind
  29068. * * VertexBuffer.UVKind
  29069. * * VertexBuffer.UV2Kind
  29070. * * VertexBuffer.UV3Kind
  29071. * * VertexBuffer.UV4Kind
  29072. * * VertexBuffer.UV5Kind
  29073. * * VertexBuffer.UV6Kind
  29074. * * VertexBuffer.ColorKind
  29075. * * VertexBuffer.MatricesIndicesKind
  29076. * * VertexBuffer.MatricesIndicesExtraKind
  29077. * * VertexBuffer.MatricesWeightsKind
  29078. * * VertexBuffer.MatricesWeightsExtraKind
  29079. * @param data defines the data source
  29080. * @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
  29081. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29082. * @returns the current mesh
  29083. */
  29084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29085. /**
  29086. * Sets the mesh indices,
  29087. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29088. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29089. * @param totalVertices Defines the total number of vertices
  29090. * @returns the current mesh
  29091. */
  29092. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29093. /**
  29094. * Gets a boolean indicating if specific vertex data is present
  29095. * @param kind defines the vertex data kind to use
  29096. * @returns true is data kind is present
  29097. */
  29098. isVerticesDataPresent(kind: string): boolean;
  29099. /**
  29100. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29101. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29102. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29103. * @returns a BoundingInfo
  29104. */
  29105. getBoundingInfo(): BoundingInfo;
  29106. /**
  29107. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29108. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29109. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29110. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29111. * @returns the current mesh
  29112. */
  29113. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29114. /**
  29115. * Overwrite the current bounding info
  29116. * @param boundingInfo defines the new bounding info
  29117. * @returns the current mesh
  29118. */
  29119. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29120. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29121. get useBones(): boolean;
  29122. /** @hidden */
  29123. _preActivate(): void;
  29124. /** @hidden */
  29125. _preActivateForIntermediateRendering(renderId: number): void;
  29126. /** @hidden */
  29127. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29128. /** @hidden */
  29129. _postActivate(): void;
  29130. /** @hidden */
  29131. _freeze(): void;
  29132. /** @hidden */
  29133. _unFreeze(): void;
  29134. /**
  29135. * Gets the current world matrix
  29136. * @returns a Matrix
  29137. */
  29138. getWorldMatrix(): Matrix;
  29139. /** @hidden */
  29140. _getWorldMatrixDeterminant(): number;
  29141. /**
  29142. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29143. */
  29144. get isAnInstance(): boolean;
  29145. /**
  29146. * Gets a boolean indicating if this mesh has instances
  29147. */
  29148. get hasInstances(): boolean;
  29149. /**
  29150. * Perform relative position change from the point of view of behind the front of the mesh.
  29151. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29152. * Supports definition of mesh facing forward or backward
  29153. * @param amountRight defines the distance on the right axis
  29154. * @param amountUp defines the distance on the up axis
  29155. * @param amountForward defines the distance on the forward axis
  29156. * @returns the current mesh
  29157. */
  29158. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29159. /**
  29160. * Calculate relative position change from the point of view of behind the front of the mesh.
  29161. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29162. * Supports definition of mesh facing forward or backward
  29163. * @param amountRight defines the distance on the right axis
  29164. * @param amountUp defines the distance on the up axis
  29165. * @param amountForward defines the distance on the forward axis
  29166. * @returns the new displacement vector
  29167. */
  29168. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29169. /**
  29170. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29171. * Supports definition of mesh facing forward or backward
  29172. * @param flipBack defines the flip
  29173. * @param twirlClockwise defines the twirl
  29174. * @param tiltRight defines the tilt
  29175. * @returns the current mesh
  29176. */
  29177. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29178. /**
  29179. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29180. * Supports definition of mesh facing forward or backward.
  29181. * @param flipBack defines the flip
  29182. * @param twirlClockwise defines the twirl
  29183. * @param tiltRight defines the tilt
  29184. * @returns the new rotation vector
  29185. */
  29186. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29187. /**
  29188. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29189. * This means the mesh underlying bounding box and sphere are recomputed.
  29190. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29191. * @returns the current mesh
  29192. */
  29193. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29194. /** @hidden */
  29195. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29196. /** @hidden */
  29197. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29198. /** @hidden */
  29199. _updateBoundingInfo(): AbstractMesh;
  29200. /** @hidden */
  29201. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29202. /** @hidden */
  29203. protected _afterComputeWorldMatrix(): void;
  29204. /** @hidden */
  29205. get _effectiveMesh(): AbstractMesh;
  29206. /**
  29207. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29208. * A mesh is in the frustum if its bounding box intersects the frustum
  29209. * @param frustumPlanes defines the frustum to test
  29210. * @returns true if the mesh is in the frustum planes
  29211. */
  29212. isInFrustum(frustumPlanes: Plane[]): boolean;
  29213. /**
  29214. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29215. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29216. * @param frustumPlanes defines the frustum to test
  29217. * @returns true if the mesh is completely in the frustum planes
  29218. */
  29219. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29220. /**
  29221. * True if the mesh intersects another mesh or a SolidParticle object
  29222. * @param mesh defines a target mesh or SolidParticle to test
  29223. * @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)
  29224. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29225. * @returns true if there is an intersection
  29226. */
  29227. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29228. /**
  29229. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29230. * @param point defines the point to test
  29231. * @returns true if there is an intersection
  29232. */
  29233. intersectsPoint(point: Vector3): boolean;
  29234. /**
  29235. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29237. */
  29238. get checkCollisions(): boolean;
  29239. set checkCollisions(collisionEnabled: boolean);
  29240. /**
  29241. * Gets Collider object used to compute collisions (not physics)
  29242. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29243. */
  29244. get collider(): Nullable<Collider>;
  29245. /**
  29246. * Move the mesh using collision engine
  29247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29248. * @param displacement defines the requested displacement vector
  29249. * @returns the current mesh
  29250. */
  29251. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29252. private _onCollisionPositionChange;
  29253. /** @hidden */
  29254. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29255. /** @hidden */
  29256. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29257. /** @hidden */
  29258. _checkCollision(collider: Collider): AbstractMesh;
  29259. /** @hidden */
  29260. _generatePointsArray(): boolean;
  29261. /**
  29262. * Checks if the passed Ray intersects with the mesh
  29263. * @param ray defines the ray to use
  29264. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29265. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29266. * @returns the picking info
  29267. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29268. */
  29269. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29270. /**
  29271. * Clones the current mesh
  29272. * @param name defines the mesh name
  29273. * @param newParent defines the new mesh parent
  29274. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29275. * @returns the new mesh
  29276. */
  29277. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29278. /**
  29279. * Disposes all the submeshes of the current meshnp
  29280. * @returns the current mesh
  29281. */
  29282. releaseSubMeshes(): AbstractMesh;
  29283. /**
  29284. * Releases resources associated with this abstract mesh.
  29285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29287. */
  29288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29289. /**
  29290. * Adds the passed mesh as a child to the current mesh
  29291. * @param mesh defines the child mesh
  29292. * @returns the current mesh
  29293. */
  29294. addChild(mesh: AbstractMesh): AbstractMesh;
  29295. /**
  29296. * Removes the passed mesh from the current mesh children list
  29297. * @param mesh defines the child mesh
  29298. * @returns the current mesh
  29299. */
  29300. removeChild(mesh: AbstractMesh): AbstractMesh;
  29301. /** @hidden */
  29302. private _initFacetData;
  29303. /**
  29304. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29305. * This method can be called within the render loop.
  29306. * 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
  29307. * @returns the current mesh
  29308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29309. */
  29310. updateFacetData(): AbstractMesh;
  29311. /**
  29312. * Returns the facetLocalNormals array.
  29313. * The normals are expressed in the mesh local spac
  29314. * @returns an array of Vector3
  29315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29316. */
  29317. getFacetLocalNormals(): Vector3[];
  29318. /**
  29319. * Returns the facetLocalPositions array.
  29320. * The facet positions are expressed in the mesh local space
  29321. * @returns an array of Vector3
  29322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29323. */
  29324. getFacetLocalPositions(): Vector3[];
  29325. /**
  29326. * Returns the facetLocalPartioning array
  29327. * @returns an array of array of numbers
  29328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29329. */
  29330. getFacetLocalPartitioning(): number[][];
  29331. /**
  29332. * Returns the i-th facet position in the world system.
  29333. * This method allocates a new Vector3 per call
  29334. * @param i defines the facet index
  29335. * @returns a new Vector3
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29337. */
  29338. getFacetPosition(i: number): Vector3;
  29339. /**
  29340. * Sets the reference Vector3 with the i-th facet position in the world system
  29341. * @param i defines the facet index
  29342. * @param ref defines the target vector
  29343. * @returns the current mesh
  29344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29345. */
  29346. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29347. /**
  29348. * Returns the i-th facet normal in the world system.
  29349. * This method allocates a new Vector3 per call
  29350. * @param i defines the facet index
  29351. * @returns a new Vector3
  29352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29353. */
  29354. getFacetNormal(i: number): Vector3;
  29355. /**
  29356. * Sets the reference Vector3 with the i-th facet normal in the world system
  29357. * @param i defines the facet index
  29358. * @param ref defines the target vector
  29359. * @returns the current mesh
  29360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29361. */
  29362. getFacetNormalToRef(i: number, ref: Vector3): this;
  29363. /**
  29364. * 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)
  29365. * @param x defines x coordinate
  29366. * @param y defines y coordinate
  29367. * @param z defines z coordinate
  29368. * @returns the array of facet indexes
  29369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29370. */
  29371. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29372. /**
  29373. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29374. * @param projected sets as the (x,y,z) world projection on the facet
  29375. * @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
  29376. * @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
  29377. * @param x defines x coordinate
  29378. * @param y defines y coordinate
  29379. * @param z defines z coordinate
  29380. * @returns the face index if found (or null instead)
  29381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29382. */
  29383. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29384. /**
  29385. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29386. * @param projected sets as the (x,y,z) local projection on the facet
  29387. * @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
  29388. * @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
  29389. * @param x defines x coordinate
  29390. * @param y defines y coordinate
  29391. * @param z defines z coordinate
  29392. * @returns the face index if found (or null instead)
  29393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29394. */
  29395. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29396. /**
  29397. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29398. * @returns the parameters
  29399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29400. */
  29401. getFacetDataParameters(): any;
  29402. /**
  29403. * Disables the feature FacetData and frees the related memory
  29404. * @returns the current mesh
  29405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29406. */
  29407. disableFacetData(): AbstractMesh;
  29408. /**
  29409. * Updates the AbstractMesh indices array
  29410. * @param indices defines the data source
  29411. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29412. * @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)
  29413. * @returns the current mesh
  29414. */
  29415. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29416. /**
  29417. * Creates new normals data for the mesh
  29418. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29419. * @returns the current mesh
  29420. */
  29421. createNormals(updatable: boolean): AbstractMesh;
  29422. /**
  29423. * Align the mesh with a normal
  29424. * @param normal defines the normal to use
  29425. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29426. * @returns the current mesh
  29427. */
  29428. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29429. /** @hidden */
  29430. _checkOcclusionQuery(): boolean;
  29431. /**
  29432. * Disables the mesh edge rendering mode
  29433. * @returns the currentAbstractMesh
  29434. */
  29435. disableEdgesRendering(): AbstractMesh;
  29436. /**
  29437. * Enables the edge rendering mode on the mesh.
  29438. * This mode makes the mesh edges visible
  29439. * @param epsilon defines the maximal distance between two angles to detect a face
  29440. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29441. * @returns the currentAbstractMesh
  29442. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29443. */
  29444. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29445. }
  29446. }
  29447. declare module "babylonjs/Actions/actionEvent" {
  29448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29449. import { Nullable } from "babylonjs/types";
  29450. import { Sprite } from "babylonjs/Sprites/sprite";
  29451. import { Scene } from "babylonjs/scene";
  29452. import { Vector2 } from "babylonjs/Maths/math.vector";
  29453. /**
  29454. * Interface used to define ActionEvent
  29455. */
  29456. export interface IActionEvent {
  29457. /** The mesh or sprite that triggered the action */
  29458. source: any;
  29459. /** The X mouse cursor position at the time of the event */
  29460. pointerX: number;
  29461. /** The Y mouse cursor position at the time of the event */
  29462. pointerY: number;
  29463. /** The mesh that is currently pointed at (can be null) */
  29464. meshUnderPointer: Nullable<AbstractMesh>;
  29465. /** the original (browser) event that triggered the ActionEvent */
  29466. sourceEvent?: any;
  29467. /** additional data for the event */
  29468. additionalData?: any;
  29469. }
  29470. /**
  29471. * ActionEvent is the event being sent when an action is triggered.
  29472. */
  29473. export class ActionEvent implements IActionEvent {
  29474. /** The mesh or sprite that triggered the action */
  29475. source: any;
  29476. /** The X mouse cursor position at the time of the event */
  29477. pointerX: number;
  29478. /** The Y mouse cursor position at the time of the event */
  29479. pointerY: number;
  29480. /** The mesh that is currently pointed at (can be null) */
  29481. meshUnderPointer: Nullable<AbstractMesh>;
  29482. /** the original (browser) event that triggered the ActionEvent */
  29483. sourceEvent?: any;
  29484. /** additional data for the event */
  29485. additionalData?: any;
  29486. /**
  29487. * Creates a new ActionEvent
  29488. * @param source The mesh or sprite that triggered the action
  29489. * @param pointerX The X mouse cursor position at the time of the event
  29490. * @param pointerY The Y mouse cursor position at the time of the event
  29491. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29492. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29493. * @param additionalData additional data for the event
  29494. */
  29495. constructor(
  29496. /** The mesh or sprite that triggered the action */
  29497. source: any,
  29498. /** The X mouse cursor position at the time of the event */
  29499. pointerX: number,
  29500. /** The Y mouse cursor position at the time of the event */
  29501. pointerY: number,
  29502. /** The mesh that is currently pointed at (can be null) */
  29503. meshUnderPointer: Nullable<AbstractMesh>,
  29504. /** the original (browser) event that triggered the ActionEvent */
  29505. sourceEvent?: any,
  29506. /** additional data for the event */
  29507. additionalData?: any);
  29508. /**
  29509. * Helper function to auto-create an ActionEvent from a source mesh.
  29510. * @param source The source mesh that triggered the event
  29511. * @param evt The original (browser) event
  29512. * @param additionalData additional data for the event
  29513. * @returns the new ActionEvent
  29514. */
  29515. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29516. /**
  29517. * Helper function to auto-create an ActionEvent from a source sprite
  29518. * @param source The source sprite that triggered the event
  29519. * @param scene Scene associated with the sprite
  29520. * @param evt The original (browser) event
  29521. * @param additionalData additional data for the event
  29522. * @returns the new ActionEvent
  29523. */
  29524. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29525. /**
  29526. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29527. * @param scene the scene where the event occurred
  29528. * @param evt The original (browser) event
  29529. * @returns the new ActionEvent
  29530. */
  29531. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29532. /**
  29533. * Helper function to auto-create an ActionEvent from a primitive
  29534. * @param prim defines the target primitive
  29535. * @param pointerPos defines the pointer position
  29536. * @param evt The original (browser) event
  29537. * @param additionalData additional data for the event
  29538. * @returns the new ActionEvent
  29539. */
  29540. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29541. }
  29542. }
  29543. declare module "babylonjs/Actions/abstractActionManager" {
  29544. import { IDisposable } from "babylonjs/scene";
  29545. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29546. import { IAction } from "babylonjs/Actions/action";
  29547. import { Nullable } from "babylonjs/types";
  29548. /**
  29549. * Abstract class used to decouple action Manager from scene and meshes.
  29550. * Do not instantiate.
  29551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29552. */
  29553. export abstract class AbstractActionManager implements IDisposable {
  29554. /** Gets the list of active triggers */
  29555. static Triggers: {
  29556. [key: string]: number;
  29557. };
  29558. /** Gets the cursor to use when hovering items */
  29559. hoverCursor: string;
  29560. /** Gets the list of actions */
  29561. actions: IAction[];
  29562. /**
  29563. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29564. */
  29565. isRecursive: boolean;
  29566. /**
  29567. * Releases all associated resources
  29568. */
  29569. abstract dispose(): void;
  29570. /**
  29571. * Does this action manager has pointer triggers
  29572. */
  29573. abstract get hasPointerTriggers(): boolean;
  29574. /**
  29575. * Does this action manager has pick triggers
  29576. */
  29577. abstract get hasPickTriggers(): boolean;
  29578. /**
  29579. * Process a specific trigger
  29580. * @param trigger defines the trigger to process
  29581. * @param evt defines the event details to be processed
  29582. */
  29583. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29584. /**
  29585. * Does this action manager handles actions of any of the given triggers
  29586. * @param triggers defines the triggers to be tested
  29587. * @return a boolean indicating whether one (or more) of the triggers is handled
  29588. */
  29589. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29590. /**
  29591. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29592. * speed.
  29593. * @param triggerA defines the trigger to be tested
  29594. * @param triggerB defines the trigger to be tested
  29595. * @return a boolean indicating whether one (or more) of the triggers is handled
  29596. */
  29597. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29598. /**
  29599. * Does this action manager handles actions of a given trigger
  29600. * @param trigger defines the trigger to be tested
  29601. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29602. * @return whether the trigger is handled
  29603. */
  29604. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29605. /**
  29606. * Serialize this manager to a JSON object
  29607. * @param name defines the property name to store this manager
  29608. * @returns a JSON representation of this manager
  29609. */
  29610. abstract serialize(name: string): any;
  29611. /**
  29612. * Registers an action to this action manager
  29613. * @param action defines the action to be registered
  29614. * @return the action amended (prepared) after registration
  29615. */
  29616. abstract registerAction(action: IAction): Nullable<IAction>;
  29617. /**
  29618. * Unregisters an action to this action manager
  29619. * @param action defines the action to be unregistered
  29620. * @return a boolean indicating whether the action has been unregistered
  29621. */
  29622. abstract unregisterAction(action: IAction): Boolean;
  29623. /**
  29624. * Does exist one action manager with at least one trigger
  29625. **/
  29626. static get HasTriggers(): boolean;
  29627. /**
  29628. * Does exist one action manager with at least one pick trigger
  29629. **/
  29630. static get HasPickTriggers(): boolean;
  29631. /**
  29632. * Does exist one action manager that handles actions of a given trigger
  29633. * @param trigger defines the trigger to be tested
  29634. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29635. **/
  29636. static HasSpecificTrigger(trigger: number): boolean;
  29637. }
  29638. }
  29639. declare module "babylonjs/node" {
  29640. import { Scene } from "babylonjs/scene";
  29641. import { Nullable } from "babylonjs/types";
  29642. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29643. import { Engine } from "babylonjs/Engines/engine";
  29644. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29645. import { Observable } from "babylonjs/Misc/observable";
  29646. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29647. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29648. import { Animatable } from "babylonjs/Animations/animatable";
  29649. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29650. import { Animation } from "babylonjs/Animations/animation";
  29651. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29653. /**
  29654. * Defines how a node can be built from a string name.
  29655. */
  29656. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29657. /**
  29658. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29659. */
  29660. export class Node implements IBehaviorAware<Node> {
  29661. /** @hidden */
  29662. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29663. private static _NodeConstructors;
  29664. /**
  29665. * Add a new node constructor
  29666. * @param type defines the type name of the node to construct
  29667. * @param constructorFunc defines the constructor function
  29668. */
  29669. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29670. /**
  29671. * Returns a node constructor based on type name
  29672. * @param type defines the type name
  29673. * @param name defines the new node name
  29674. * @param scene defines the hosting scene
  29675. * @param options defines optional options to transmit to constructors
  29676. * @returns the new constructor or null
  29677. */
  29678. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29679. /**
  29680. * Gets or sets the name of the node
  29681. */
  29682. name: string;
  29683. /**
  29684. * Gets or sets the id of the node
  29685. */
  29686. id: string;
  29687. /**
  29688. * Gets or sets the unique id of the node
  29689. */
  29690. uniqueId: number;
  29691. /**
  29692. * Gets or sets a string used to store user defined state for the node
  29693. */
  29694. state: string;
  29695. /**
  29696. * Gets or sets an object used to store user defined information for the node
  29697. */
  29698. metadata: any;
  29699. /**
  29700. * For internal use only. Please do not use.
  29701. */
  29702. reservedDataStore: any;
  29703. /**
  29704. * List of inspectable custom properties (used by the Inspector)
  29705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29706. */
  29707. inspectableCustomProperties: IInspectable[];
  29708. private _doNotSerialize;
  29709. /**
  29710. * Gets or sets a boolean used to define if the node must be serialized
  29711. */
  29712. get doNotSerialize(): boolean;
  29713. set doNotSerialize(value: boolean);
  29714. /** @hidden */
  29715. _isDisposed: boolean;
  29716. /**
  29717. * Gets a list of Animations associated with the node
  29718. */
  29719. animations: import("babylonjs/Animations/animation").Animation[];
  29720. protected _ranges: {
  29721. [name: string]: Nullable<AnimationRange>;
  29722. };
  29723. /**
  29724. * Callback raised when the node is ready to be used
  29725. */
  29726. onReady: Nullable<(node: Node) => void>;
  29727. private _isEnabled;
  29728. private _isParentEnabled;
  29729. private _isReady;
  29730. /** @hidden */
  29731. _currentRenderId: number;
  29732. private _parentUpdateId;
  29733. /** @hidden */
  29734. _childUpdateId: number;
  29735. /** @hidden */
  29736. _waitingParentId: Nullable<string>;
  29737. /** @hidden */
  29738. _scene: Scene;
  29739. /** @hidden */
  29740. _cache: any;
  29741. private _parentNode;
  29742. private _children;
  29743. /** @hidden */
  29744. _worldMatrix: Matrix;
  29745. /** @hidden */
  29746. _worldMatrixDeterminant: number;
  29747. /** @hidden */
  29748. _worldMatrixDeterminantIsDirty: boolean;
  29749. /** @hidden */
  29750. private _sceneRootNodesIndex;
  29751. /**
  29752. * Gets a boolean indicating if the node has been disposed
  29753. * @returns true if the node was disposed
  29754. */
  29755. isDisposed(): boolean;
  29756. /**
  29757. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29758. * @see https://doc.babylonjs.com/how_to/parenting
  29759. */
  29760. set parent(parent: Nullable<Node>);
  29761. get parent(): Nullable<Node>;
  29762. /** @hidden */
  29763. _addToSceneRootNodes(): void;
  29764. /** @hidden */
  29765. _removeFromSceneRootNodes(): void;
  29766. private _animationPropertiesOverride;
  29767. /**
  29768. * Gets or sets the animation properties override
  29769. */
  29770. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29771. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29772. /**
  29773. * Gets a string idenfifying the name of the class
  29774. * @returns "Node" string
  29775. */
  29776. getClassName(): string;
  29777. /** @hidden */
  29778. readonly _isNode: boolean;
  29779. /**
  29780. * An event triggered when the mesh is disposed
  29781. */
  29782. onDisposeObservable: Observable<Node>;
  29783. private _onDisposeObserver;
  29784. /**
  29785. * Sets a callback that will be raised when the node will be disposed
  29786. */
  29787. set onDispose(callback: () => void);
  29788. /**
  29789. * Creates a new Node
  29790. * @param name the name and id to be given to this node
  29791. * @param scene the scene this node will be added to
  29792. */
  29793. constructor(name: string, scene?: Nullable<Scene>);
  29794. /**
  29795. * Gets the scene of the node
  29796. * @returns a scene
  29797. */
  29798. getScene(): Scene;
  29799. /**
  29800. * Gets the engine of the node
  29801. * @returns a Engine
  29802. */
  29803. getEngine(): Engine;
  29804. private _behaviors;
  29805. /**
  29806. * Attach a behavior to the node
  29807. * @see http://doc.babylonjs.com/features/behaviour
  29808. * @param behavior defines the behavior to attach
  29809. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29810. * @returns the current Node
  29811. */
  29812. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29813. /**
  29814. * Remove an attached behavior
  29815. * @see http://doc.babylonjs.com/features/behaviour
  29816. * @param behavior defines the behavior to attach
  29817. * @returns the current Node
  29818. */
  29819. removeBehavior(behavior: Behavior<Node>): Node;
  29820. /**
  29821. * Gets the list of attached behaviors
  29822. * @see http://doc.babylonjs.com/features/behaviour
  29823. */
  29824. get behaviors(): Behavior<Node>[];
  29825. /**
  29826. * Gets an attached behavior by name
  29827. * @param name defines the name of the behavior to look for
  29828. * @see http://doc.babylonjs.com/features/behaviour
  29829. * @returns null if behavior was not found else the requested behavior
  29830. */
  29831. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29832. /**
  29833. * Returns the latest update of the World matrix
  29834. * @returns a Matrix
  29835. */
  29836. getWorldMatrix(): Matrix;
  29837. /** @hidden */
  29838. _getWorldMatrixDeterminant(): number;
  29839. /**
  29840. * Returns directly the latest state of the mesh World matrix.
  29841. * A Matrix is returned.
  29842. */
  29843. get worldMatrixFromCache(): Matrix;
  29844. /** @hidden */
  29845. _initCache(): void;
  29846. /** @hidden */
  29847. updateCache(force?: boolean): void;
  29848. /** @hidden */
  29849. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29850. /** @hidden */
  29851. _updateCache(ignoreParentClass?: boolean): void;
  29852. /** @hidden */
  29853. _isSynchronized(): boolean;
  29854. /** @hidden */
  29855. _markSyncedWithParent(): void;
  29856. /** @hidden */
  29857. isSynchronizedWithParent(): boolean;
  29858. /** @hidden */
  29859. isSynchronized(): boolean;
  29860. /**
  29861. * Is this node ready to be used/rendered
  29862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29863. * @return true if the node is ready
  29864. */
  29865. isReady(completeCheck?: boolean): boolean;
  29866. /**
  29867. * Is this node enabled?
  29868. * 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
  29869. * @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
  29870. * @return whether this node (and its parent) is enabled
  29871. */
  29872. isEnabled(checkAncestors?: boolean): boolean;
  29873. /** @hidden */
  29874. protected _syncParentEnabledState(): void;
  29875. /**
  29876. * Set the enabled state of this node
  29877. * @param value defines the new enabled state
  29878. */
  29879. setEnabled(value: boolean): void;
  29880. /**
  29881. * Is this node a descendant of the given node?
  29882. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29883. * @param ancestor defines the parent node to inspect
  29884. * @returns a boolean indicating if this node is a descendant of the given node
  29885. */
  29886. isDescendantOf(ancestor: Node): boolean;
  29887. /** @hidden */
  29888. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29889. /**
  29890. * Will return all nodes that have this node as ascendant
  29891. * @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
  29892. * @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
  29893. * @return all children nodes of all types
  29894. */
  29895. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29896. /**
  29897. * Get all child-meshes of this node
  29898. * @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)
  29899. * @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
  29900. * @returns an array of AbstractMesh
  29901. */
  29902. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29903. /**
  29904. * Get all direct children of this node
  29905. * @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
  29906. * @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)
  29907. * @returns an array of Node
  29908. */
  29909. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29910. /** @hidden */
  29911. _setReady(state: boolean): void;
  29912. /**
  29913. * Get an animation by name
  29914. * @param name defines the name of the animation to look for
  29915. * @returns null if not found else the requested animation
  29916. */
  29917. getAnimationByName(name: string): Nullable<Animation>;
  29918. /**
  29919. * Creates an animation range for this node
  29920. * @param name defines the name of the range
  29921. * @param from defines the starting key
  29922. * @param to defines the end key
  29923. */
  29924. createAnimationRange(name: string, from: number, to: number): void;
  29925. /**
  29926. * Delete a specific animation range
  29927. * @param name defines the name of the range to delete
  29928. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29929. */
  29930. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29931. /**
  29932. * Get an animation range by name
  29933. * @param name defines the name of the animation range to look for
  29934. * @returns null if not found else the requested animation range
  29935. */
  29936. getAnimationRange(name: string): Nullable<AnimationRange>;
  29937. /**
  29938. * Gets the list of all animation ranges defined on this node
  29939. * @returns an array
  29940. */
  29941. getAnimationRanges(): Nullable<AnimationRange>[];
  29942. /**
  29943. * Will start the animation sequence
  29944. * @param name defines the range frames for animation sequence
  29945. * @param loop defines if the animation should loop (false by default)
  29946. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29947. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29948. * @returns the object created for this animation. If range does not exist, it will return null
  29949. */
  29950. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29951. /**
  29952. * Serialize animation ranges into a JSON compatible object
  29953. * @returns serialization object
  29954. */
  29955. serializeAnimationRanges(): any;
  29956. /**
  29957. * Computes the world matrix of the node
  29958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29959. * @returns the world matrix
  29960. */
  29961. computeWorldMatrix(force?: boolean): Matrix;
  29962. /**
  29963. * Releases resources associated with this node.
  29964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29966. */
  29967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29968. /**
  29969. * Parse animation range data from a serialization object and store them into a given node
  29970. * @param node defines where to store the animation ranges
  29971. * @param parsedNode defines the serialization object to read data from
  29972. * @param scene defines the hosting scene
  29973. */
  29974. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29975. /**
  29976. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29977. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29978. * @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
  29979. * @returns the new bounding vectors
  29980. */
  29981. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29982. min: Vector3;
  29983. max: Vector3;
  29984. };
  29985. }
  29986. }
  29987. declare module "babylonjs/Animations/animation" {
  29988. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29989. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29990. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29991. import { Nullable } from "babylonjs/types";
  29992. import { Scene } from "babylonjs/scene";
  29993. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29994. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29995. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29996. import { Node } from "babylonjs/node";
  29997. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29998. import { Size } from "babylonjs/Maths/math.size";
  29999. import { Animatable } from "babylonjs/Animations/animatable";
  30000. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30001. /**
  30002. * @hidden
  30003. */
  30004. export class _IAnimationState {
  30005. key: number;
  30006. repeatCount: number;
  30007. workValue?: any;
  30008. loopMode?: number;
  30009. offsetValue?: any;
  30010. highLimitValue?: any;
  30011. }
  30012. /**
  30013. * Class used to store any kind of animation
  30014. */
  30015. export class Animation {
  30016. /**Name of the animation */
  30017. name: string;
  30018. /**Property to animate */
  30019. targetProperty: string;
  30020. /**The frames per second of the animation */
  30021. framePerSecond: number;
  30022. /**The data type of the animation */
  30023. dataType: number;
  30024. /**The loop mode of the animation */
  30025. loopMode?: number | undefined;
  30026. /**Specifies if blending should be enabled */
  30027. enableBlending?: boolean | undefined;
  30028. /**
  30029. * Use matrix interpolation instead of using direct key value when animating matrices
  30030. */
  30031. static AllowMatricesInterpolation: boolean;
  30032. /**
  30033. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30034. */
  30035. static AllowMatrixDecomposeForInterpolation: boolean;
  30036. /**
  30037. * Stores the key frames of the animation
  30038. */
  30039. private _keys;
  30040. /**
  30041. * Stores the easing function of the animation
  30042. */
  30043. private _easingFunction;
  30044. /**
  30045. * @hidden Internal use only
  30046. */
  30047. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30048. /**
  30049. * The set of event that will be linked to this animation
  30050. */
  30051. private _events;
  30052. /**
  30053. * Stores an array of target property paths
  30054. */
  30055. targetPropertyPath: string[];
  30056. /**
  30057. * Stores the blending speed of the animation
  30058. */
  30059. blendingSpeed: number;
  30060. /**
  30061. * Stores the animation ranges for the animation
  30062. */
  30063. private _ranges;
  30064. /**
  30065. * @hidden Internal use
  30066. */
  30067. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30068. /**
  30069. * Sets up an animation
  30070. * @param property The property to animate
  30071. * @param animationType The animation type to apply
  30072. * @param framePerSecond The frames per second of the animation
  30073. * @param easingFunction The easing function used in the animation
  30074. * @returns The created animation
  30075. */
  30076. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30077. /**
  30078. * Create and start an animation on a node
  30079. * @param name defines the name of the global animation that will be run on all nodes
  30080. * @param node defines the root node where the animation will take place
  30081. * @param targetProperty defines property to animate
  30082. * @param framePerSecond defines the number of frame per second yo use
  30083. * @param totalFrame defines the number of frames in total
  30084. * @param from defines the initial value
  30085. * @param to defines the final value
  30086. * @param loopMode defines which loop mode you want to use (off by default)
  30087. * @param easingFunction defines the easing function to use (linear by default)
  30088. * @param onAnimationEnd defines the callback to call when animation end
  30089. * @returns the animatable created for this animation
  30090. */
  30091. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30092. /**
  30093. * Create and start an animation on a node and its descendants
  30094. * @param name defines the name of the global animation that will be run on all nodes
  30095. * @param node defines the root node where the animation will take place
  30096. * @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
  30097. * @param targetProperty defines property to animate
  30098. * @param framePerSecond defines the number of frame per second to use
  30099. * @param totalFrame defines the number of frames in total
  30100. * @param from defines the initial value
  30101. * @param to defines the final value
  30102. * @param loopMode defines which loop mode you want to use (off by default)
  30103. * @param easingFunction defines the easing function to use (linear by default)
  30104. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30105. * @returns the list of animatables created for all nodes
  30106. * @example https://www.babylonjs-playground.com/#MH0VLI
  30107. */
  30108. 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[]>;
  30109. /**
  30110. * Creates a new animation, merges it with the existing animations and starts it
  30111. * @param name Name of the animation
  30112. * @param node Node which contains the scene that begins the animations
  30113. * @param targetProperty Specifies which property to animate
  30114. * @param framePerSecond The frames per second of the animation
  30115. * @param totalFrame The total number of frames
  30116. * @param from The frame at the beginning of the animation
  30117. * @param to The frame at the end of the animation
  30118. * @param loopMode Specifies the loop mode of the animation
  30119. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30120. * @param onAnimationEnd Callback to run once the animation is complete
  30121. * @returns Nullable animation
  30122. */
  30123. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30124. /**
  30125. * Transition property of an host to the target Value
  30126. * @param property The property to transition
  30127. * @param targetValue The target Value of the property
  30128. * @param host The object where the property to animate belongs
  30129. * @param scene Scene used to run the animation
  30130. * @param frameRate Framerate (in frame/s) to use
  30131. * @param transition The transition type we want to use
  30132. * @param duration The duration of the animation, in milliseconds
  30133. * @param onAnimationEnd Callback trigger at the end of the animation
  30134. * @returns Nullable animation
  30135. */
  30136. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30137. /**
  30138. * Return the array of runtime animations currently using this animation
  30139. */
  30140. get runtimeAnimations(): RuntimeAnimation[];
  30141. /**
  30142. * Specifies if any of the runtime animations are currently running
  30143. */
  30144. get hasRunningRuntimeAnimations(): boolean;
  30145. /**
  30146. * Initializes the animation
  30147. * @param name Name of the animation
  30148. * @param targetProperty Property to animate
  30149. * @param framePerSecond The frames per second of the animation
  30150. * @param dataType The data type of the animation
  30151. * @param loopMode The loop mode of the animation
  30152. * @param enableBlending Specifies if blending should be enabled
  30153. */
  30154. constructor(
  30155. /**Name of the animation */
  30156. name: string,
  30157. /**Property to animate */
  30158. targetProperty: string,
  30159. /**The frames per second of the animation */
  30160. framePerSecond: number,
  30161. /**The data type of the animation */
  30162. dataType: number,
  30163. /**The loop mode of the animation */
  30164. loopMode?: number | undefined,
  30165. /**Specifies if blending should be enabled */
  30166. enableBlending?: boolean | undefined);
  30167. /**
  30168. * Converts the animation to a string
  30169. * @param fullDetails support for multiple levels of logging within scene loading
  30170. * @returns String form of the animation
  30171. */
  30172. toString(fullDetails?: boolean): string;
  30173. /**
  30174. * Add an event to this animation
  30175. * @param event Event to add
  30176. */
  30177. addEvent(event: AnimationEvent): void;
  30178. /**
  30179. * Remove all events found at the given frame
  30180. * @param frame The frame to remove events from
  30181. */
  30182. removeEvents(frame: number): void;
  30183. /**
  30184. * Retrieves all the events from the animation
  30185. * @returns Events from the animation
  30186. */
  30187. getEvents(): AnimationEvent[];
  30188. /**
  30189. * Creates an animation range
  30190. * @param name Name of the animation range
  30191. * @param from Starting frame of the animation range
  30192. * @param to Ending frame of the animation
  30193. */
  30194. createRange(name: string, from: number, to: number): void;
  30195. /**
  30196. * Deletes an animation range by name
  30197. * @param name Name of the animation range to delete
  30198. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30199. */
  30200. deleteRange(name: string, deleteFrames?: boolean): void;
  30201. /**
  30202. * Gets the animation range by name, or null if not defined
  30203. * @param name Name of the animation range
  30204. * @returns Nullable animation range
  30205. */
  30206. getRange(name: string): Nullable<AnimationRange>;
  30207. /**
  30208. * Gets the key frames from the animation
  30209. * @returns The key frames of the animation
  30210. */
  30211. getKeys(): Array<IAnimationKey>;
  30212. /**
  30213. * Gets the highest frame rate of the animation
  30214. * @returns Highest frame rate of the animation
  30215. */
  30216. getHighestFrame(): number;
  30217. /**
  30218. * Gets the easing function of the animation
  30219. * @returns Easing function of the animation
  30220. */
  30221. getEasingFunction(): IEasingFunction;
  30222. /**
  30223. * Sets the easing function of the animation
  30224. * @param easingFunction A custom mathematical formula for animation
  30225. */
  30226. setEasingFunction(easingFunction: EasingFunction): void;
  30227. /**
  30228. * Interpolates a scalar linearly
  30229. * @param startValue Start value of the animation curve
  30230. * @param endValue End value of the animation curve
  30231. * @param gradient Scalar amount to interpolate
  30232. * @returns Interpolated scalar value
  30233. */
  30234. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30235. /**
  30236. * Interpolates a scalar cubically
  30237. * @param startValue Start value of the animation curve
  30238. * @param outTangent End tangent of the animation
  30239. * @param endValue End value of the animation curve
  30240. * @param inTangent Start tangent of the animation curve
  30241. * @param gradient Scalar amount to interpolate
  30242. * @returns Interpolated scalar value
  30243. */
  30244. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30245. /**
  30246. * Interpolates a quaternion using a spherical linear interpolation
  30247. * @param startValue Start value of the animation curve
  30248. * @param endValue End value of the animation curve
  30249. * @param gradient Scalar amount to interpolate
  30250. * @returns Interpolated quaternion value
  30251. */
  30252. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30253. /**
  30254. * Interpolates a quaternion cubically
  30255. * @param startValue Start value of the animation curve
  30256. * @param outTangent End tangent of the animation curve
  30257. * @param endValue End value of the animation curve
  30258. * @param inTangent Start tangent of the animation curve
  30259. * @param gradient Scalar amount to interpolate
  30260. * @returns Interpolated quaternion value
  30261. */
  30262. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30263. /**
  30264. * Interpolates a Vector3 linearl
  30265. * @param startValue Start value of the animation curve
  30266. * @param endValue End value of the animation curve
  30267. * @param gradient Scalar amount to interpolate
  30268. * @returns Interpolated scalar value
  30269. */
  30270. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30271. /**
  30272. * Interpolates a Vector3 cubically
  30273. * @param startValue Start value of the animation curve
  30274. * @param outTangent End tangent of the animation
  30275. * @param endValue End value of the animation curve
  30276. * @param inTangent Start tangent of the animation curve
  30277. * @param gradient Scalar amount to interpolate
  30278. * @returns InterpolatedVector3 value
  30279. */
  30280. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30281. /**
  30282. * Interpolates a Vector2 linearly
  30283. * @param startValue Start value of the animation curve
  30284. * @param endValue End value of the animation curve
  30285. * @param gradient Scalar amount to interpolate
  30286. * @returns Interpolated Vector2 value
  30287. */
  30288. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30289. /**
  30290. * Interpolates a Vector2 cubically
  30291. * @param startValue Start value of the animation curve
  30292. * @param outTangent End tangent of the animation
  30293. * @param endValue End value of the animation curve
  30294. * @param inTangent Start tangent of the animation curve
  30295. * @param gradient Scalar amount to interpolate
  30296. * @returns Interpolated Vector2 value
  30297. */
  30298. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30299. /**
  30300. * Interpolates a size linearly
  30301. * @param startValue Start value of the animation curve
  30302. * @param endValue End value of the animation curve
  30303. * @param gradient Scalar amount to interpolate
  30304. * @returns Interpolated Size value
  30305. */
  30306. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30307. /**
  30308. * Interpolates a Color3 linearly
  30309. * @param startValue Start value of the animation curve
  30310. * @param endValue End value of the animation curve
  30311. * @param gradient Scalar amount to interpolate
  30312. * @returns Interpolated Color3 value
  30313. */
  30314. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30315. /**
  30316. * Interpolates a Color4 linearly
  30317. * @param startValue Start value of the animation curve
  30318. * @param endValue End value of the animation curve
  30319. * @param gradient Scalar amount to interpolate
  30320. * @returns Interpolated Color3 value
  30321. */
  30322. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30323. /**
  30324. * @hidden Internal use only
  30325. */
  30326. _getKeyValue(value: any): any;
  30327. /**
  30328. * @hidden Internal use only
  30329. */
  30330. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30331. /**
  30332. * Defines the function to use to interpolate matrices
  30333. * @param startValue defines the start matrix
  30334. * @param endValue defines the end matrix
  30335. * @param gradient defines the gradient between both matrices
  30336. * @param result defines an optional target matrix where to store the interpolation
  30337. * @returns the interpolated matrix
  30338. */
  30339. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30340. /**
  30341. * Makes a copy of the animation
  30342. * @returns Cloned animation
  30343. */
  30344. clone(): Animation;
  30345. /**
  30346. * Sets the key frames of the animation
  30347. * @param values The animation key frames to set
  30348. */
  30349. setKeys(values: Array<IAnimationKey>): void;
  30350. /**
  30351. * Serializes the animation to an object
  30352. * @returns Serialized object
  30353. */
  30354. serialize(): any;
  30355. /**
  30356. * Float animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_FLOAT: number;
  30359. /**
  30360. * Vector3 animation type
  30361. */
  30362. static readonly ANIMATIONTYPE_VECTOR3: number;
  30363. /**
  30364. * Quaternion animation type
  30365. */
  30366. static readonly ANIMATIONTYPE_QUATERNION: number;
  30367. /**
  30368. * Matrix animation type
  30369. */
  30370. static readonly ANIMATIONTYPE_MATRIX: number;
  30371. /**
  30372. * Color3 animation type
  30373. */
  30374. static readonly ANIMATIONTYPE_COLOR3: number;
  30375. /**
  30376. * Color3 animation type
  30377. */
  30378. static readonly ANIMATIONTYPE_COLOR4: number;
  30379. /**
  30380. * Vector2 animation type
  30381. */
  30382. static readonly ANIMATIONTYPE_VECTOR2: number;
  30383. /**
  30384. * Size animation type
  30385. */
  30386. static readonly ANIMATIONTYPE_SIZE: number;
  30387. /**
  30388. * Relative Loop Mode
  30389. */
  30390. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30391. /**
  30392. * Cycle Loop Mode
  30393. */
  30394. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30395. /**
  30396. * Constant Loop Mode
  30397. */
  30398. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30399. /** @hidden */
  30400. static _UniversalLerp(left: any, right: any, amount: number): any;
  30401. /**
  30402. * Parses an animation object and creates an animation
  30403. * @param parsedAnimation Parsed animation object
  30404. * @returns Animation object
  30405. */
  30406. static Parse(parsedAnimation: any): Animation;
  30407. /**
  30408. * Appends the serialized animations from the source animations
  30409. * @param source Source containing the animations
  30410. * @param destination Target to store the animations
  30411. */
  30412. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30413. }
  30414. }
  30415. declare module "babylonjs/Animations/animatable.interface" {
  30416. import { Nullable } from "babylonjs/types";
  30417. import { Animation } from "babylonjs/Animations/animation";
  30418. /**
  30419. * Interface containing an array of animations
  30420. */
  30421. export interface IAnimatable {
  30422. /**
  30423. * Array of animations
  30424. */
  30425. animations: Nullable<Array<Animation>>;
  30426. }
  30427. }
  30428. declare module "babylonjs/Misc/decorators" {
  30429. import { Nullable } from "babylonjs/types";
  30430. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30431. import { Scene } from "babylonjs/scene";
  30432. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30433. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30434. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30435. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30436. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30437. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30438. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30439. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30440. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30441. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30442. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30443. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30444. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30445. /**
  30446. * Decorator used to define property that can be serialized as reference to a camera
  30447. * @param sourceName defines the name of the property to decorate
  30448. */
  30449. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30450. /**
  30451. * Class used to help serialization objects
  30452. */
  30453. export class SerializationHelper {
  30454. /** @hidden */
  30455. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30456. /** @hidden */
  30457. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30458. /** @hidden */
  30459. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30460. /** @hidden */
  30461. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30462. /**
  30463. * Appends the serialized animations from the source animations
  30464. * @param source Source containing the animations
  30465. * @param destination Target to store the animations
  30466. */
  30467. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30468. /**
  30469. * Static function used to serialized a specific entity
  30470. * @param entity defines the entity to serialize
  30471. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30472. * @returns a JSON compatible object representing the serialization of the entity
  30473. */
  30474. static Serialize<T>(entity: T, serializationObject?: any): any;
  30475. /**
  30476. * Creates a new entity from a serialization data object
  30477. * @param creationFunction defines a function used to instanciated the new entity
  30478. * @param source defines the source serialization data
  30479. * @param scene defines the hosting scene
  30480. * @param rootUrl defines the root url for resources
  30481. * @returns a new entity
  30482. */
  30483. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30484. /**
  30485. * Clones an object
  30486. * @param creationFunction defines the function used to instanciate the new object
  30487. * @param source defines the source object
  30488. * @returns the cloned object
  30489. */
  30490. static Clone<T>(creationFunction: () => T, source: T): T;
  30491. /**
  30492. * Instanciates a new object based on a source one (some data will be shared between both object)
  30493. * @param creationFunction defines the function used to instanciate the new object
  30494. * @param source defines the source object
  30495. * @returns the new object
  30496. */
  30497. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30498. }
  30499. }
  30500. declare module "babylonjs/Misc/guid" {
  30501. /**
  30502. * Class used to manipulate GUIDs
  30503. */
  30504. export class GUID {
  30505. /**
  30506. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30507. * Be aware Math.random() could cause collisions, but:
  30508. * "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"
  30509. * @returns a pseudo random id
  30510. */
  30511. static RandomId(): string;
  30512. }
  30513. }
  30514. declare module "babylonjs/Materials/Textures/baseTexture" {
  30515. import { Observable } from "babylonjs/Misc/observable";
  30516. import { Nullable } from "babylonjs/types";
  30517. import { Scene } from "babylonjs/scene";
  30518. import { Matrix } from "babylonjs/Maths/math.vector";
  30519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30521. import { ISize } from "babylonjs/Maths/math.size";
  30522. import "babylonjs/Misc/fileTools";
  30523. /**
  30524. * Base class of all the textures in babylon.
  30525. * It groups all the common properties the materials, post process, lights... might need
  30526. * in order to make a correct use of the texture.
  30527. */
  30528. export class BaseTexture implements IAnimatable {
  30529. /**
  30530. * Default anisotropic filtering level for the application.
  30531. * It is set to 4 as a good tradeoff between perf and quality.
  30532. */
  30533. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30534. /**
  30535. * Gets or sets the unique id of the texture
  30536. */
  30537. uniqueId: number;
  30538. /**
  30539. * Define the name of the texture.
  30540. */
  30541. name: string;
  30542. /**
  30543. * Gets or sets an object used to store user defined information.
  30544. */
  30545. metadata: any;
  30546. /**
  30547. * For internal use only. Please do not use.
  30548. */
  30549. reservedDataStore: any;
  30550. private _hasAlpha;
  30551. /**
  30552. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30553. */
  30554. set hasAlpha(value: boolean);
  30555. get hasAlpha(): boolean;
  30556. /**
  30557. * Defines if the alpha value should be determined via the rgb values.
  30558. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30559. */
  30560. getAlphaFromRGB: boolean;
  30561. /**
  30562. * Intensity or strength of the texture.
  30563. * It is commonly used by materials to fine tune the intensity of the texture
  30564. */
  30565. level: number;
  30566. /**
  30567. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30568. * This is part of the texture as textures usually maps to one uv set.
  30569. */
  30570. coordinatesIndex: number;
  30571. private _coordinatesMode;
  30572. /**
  30573. * How a texture is mapped.
  30574. *
  30575. * | Value | Type | Description |
  30576. * | ----- | ----------------------------------- | ----------- |
  30577. * | 0 | EXPLICIT_MODE | |
  30578. * | 1 | SPHERICAL_MODE | |
  30579. * | 2 | PLANAR_MODE | |
  30580. * | 3 | CUBIC_MODE | |
  30581. * | 4 | PROJECTION_MODE | |
  30582. * | 5 | SKYBOX_MODE | |
  30583. * | 6 | INVCUBIC_MODE | |
  30584. * | 7 | EQUIRECTANGULAR_MODE | |
  30585. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30586. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30587. */
  30588. set coordinatesMode(value: number);
  30589. get coordinatesMode(): number;
  30590. /**
  30591. * | Value | Type | Description |
  30592. * | ----- | ------------------ | ----------- |
  30593. * | 0 | CLAMP_ADDRESSMODE | |
  30594. * | 1 | WRAP_ADDRESSMODE | |
  30595. * | 2 | MIRROR_ADDRESSMODE | |
  30596. */
  30597. wrapU: number;
  30598. /**
  30599. * | Value | Type | Description |
  30600. * | ----- | ------------------ | ----------- |
  30601. * | 0 | CLAMP_ADDRESSMODE | |
  30602. * | 1 | WRAP_ADDRESSMODE | |
  30603. * | 2 | MIRROR_ADDRESSMODE | |
  30604. */
  30605. wrapV: number;
  30606. /**
  30607. * | Value | Type | Description |
  30608. * | ----- | ------------------ | ----------- |
  30609. * | 0 | CLAMP_ADDRESSMODE | |
  30610. * | 1 | WRAP_ADDRESSMODE | |
  30611. * | 2 | MIRROR_ADDRESSMODE | |
  30612. */
  30613. wrapR: number;
  30614. /**
  30615. * With compliant hardware and browser (supporting anisotropic filtering)
  30616. * this defines the level of anisotropic filtering in the texture.
  30617. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30618. */
  30619. anisotropicFilteringLevel: number;
  30620. /**
  30621. * Define if the texture is a cube texture or if false a 2d texture.
  30622. */
  30623. get isCube(): boolean;
  30624. set isCube(value: boolean);
  30625. /**
  30626. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30627. */
  30628. get is3D(): boolean;
  30629. set is3D(value: boolean);
  30630. /**
  30631. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30632. */
  30633. get is2DArray(): boolean;
  30634. set is2DArray(value: boolean);
  30635. /**
  30636. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30637. * HDR texture are usually stored in linear space.
  30638. * This only impacts the PBR and Background materials
  30639. */
  30640. gammaSpace: boolean;
  30641. /**
  30642. * Gets or sets whether or not the texture contains RGBD data.
  30643. */
  30644. get isRGBD(): boolean;
  30645. set isRGBD(value: boolean);
  30646. /**
  30647. * Is Z inverted in the texture (useful in a cube texture).
  30648. */
  30649. invertZ: boolean;
  30650. /**
  30651. * Are mip maps generated for this texture or not.
  30652. */
  30653. get noMipmap(): boolean;
  30654. /**
  30655. * @hidden
  30656. */
  30657. lodLevelInAlpha: boolean;
  30658. /**
  30659. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30660. */
  30661. get lodGenerationOffset(): number;
  30662. set lodGenerationOffset(value: number);
  30663. /**
  30664. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30665. */
  30666. get lodGenerationScale(): number;
  30667. set lodGenerationScale(value: number);
  30668. /**
  30669. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30670. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30671. * average roughness values.
  30672. */
  30673. get linearSpecularLOD(): boolean;
  30674. set linearSpecularLOD(value: boolean);
  30675. /**
  30676. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30677. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30678. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30679. */
  30680. get irradianceTexture(): Nullable<BaseTexture>;
  30681. set irradianceTexture(value: Nullable<BaseTexture>);
  30682. /**
  30683. * Define if the texture is a render target.
  30684. */
  30685. isRenderTarget: boolean;
  30686. /**
  30687. * Define the unique id of the texture in the scene.
  30688. */
  30689. get uid(): string;
  30690. /**
  30691. * Return a string representation of the texture.
  30692. * @returns the texture as a string
  30693. */
  30694. toString(): string;
  30695. /**
  30696. * Get the class name of the texture.
  30697. * @returns "BaseTexture"
  30698. */
  30699. getClassName(): string;
  30700. /**
  30701. * Define the list of animation attached to the texture.
  30702. */
  30703. animations: import("babylonjs/Animations/animation").Animation[];
  30704. /**
  30705. * An event triggered when the texture is disposed.
  30706. */
  30707. onDisposeObservable: Observable<BaseTexture>;
  30708. private _onDisposeObserver;
  30709. /**
  30710. * Callback triggered when the texture has been disposed.
  30711. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30712. */
  30713. set onDispose(callback: () => void);
  30714. /**
  30715. * Define the current state of the loading sequence when in delayed load mode.
  30716. */
  30717. delayLoadState: number;
  30718. private _scene;
  30719. /** @hidden */
  30720. _texture: Nullable<InternalTexture>;
  30721. private _uid;
  30722. /**
  30723. * Define if the texture is preventinga material to render or not.
  30724. * If not and the texture is not ready, the engine will use a default black texture instead.
  30725. */
  30726. get isBlocking(): boolean;
  30727. /**
  30728. * Instantiates a new BaseTexture.
  30729. * Base class of all the textures in babylon.
  30730. * It groups all the common properties the materials, post process, lights... might need
  30731. * in order to make a correct use of the texture.
  30732. * @param scene Define the scene the texture blongs to
  30733. */
  30734. constructor(scene: Nullable<Scene>);
  30735. /**
  30736. * Get the scene the texture belongs to.
  30737. * @returns the scene or null if undefined
  30738. */
  30739. getScene(): Nullable<Scene>;
  30740. /**
  30741. * Get the texture transform matrix used to offset tile the texture for istance.
  30742. * @returns the transformation matrix
  30743. */
  30744. getTextureMatrix(): Matrix;
  30745. /**
  30746. * Get the texture reflection matrix used to rotate/transform the reflection.
  30747. * @returns the reflection matrix
  30748. */
  30749. getReflectionTextureMatrix(): Matrix;
  30750. /**
  30751. * Get the underlying lower level texture from Babylon.
  30752. * @returns the insternal texture
  30753. */
  30754. getInternalTexture(): Nullable<InternalTexture>;
  30755. /**
  30756. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30757. * @returns true if ready or not blocking
  30758. */
  30759. isReadyOrNotBlocking(): boolean;
  30760. /**
  30761. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30762. * @returns true if fully ready
  30763. */
  30764. isReady(): boolean;
  30765. private _cachedSize;
  30766. /**
  30767. * Get the size of the texture.
  30768. * @returns the texture size.
  30769. */
  30770. getSize(): ISize;
  30771. /**
  30772. * Get the base size of the texture.
  30773. * It can be different from the size if the texture has been resized for POT for instance
  30774. * @returns the base size
  30775. */
  30776. getBaseSize(): ISize;
  30777. /**
  30778. * Update the sampling mode of the texture.
  30779. * Default is Trilinear mode.
  30780. *
  30781. * | Value | Type | Description |
  30782. * | ----- | ------------------ | ----------- |
  30783. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30784. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30785. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30786. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30787. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30788. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30789. * | 7 | NEAREST_LINEAR | |
  30790. * | 8 | NEAREST_NEAREST | |
  30791. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30792. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30793. * | 11 | LINEAR_LINEAR | |
  30794. * | 12 | LINEAR_NEAREST | |
  30795. *
  30796. * > _mag_: magnification filter (close to the viewer)
  30797. * > _min_: minification filter (far from the viewer)
  30798. * > _mip_: filter used between mip map levels
  30799. *@param samplingMode Define the new sampling mode of the texture
  30800. */
  30801. updateSamplingMode(samplingMode: number): void;
  30802. /**
  30803. * Scales the texture if is `canRescale()`
  30804. * @param ratio the resize factor we want to use to rescale
  30805. */
  30806. scale(ratio: number): void;
  30807. /**
  30808. * Get if the texture can rescale.
  30809. */
  30810. get canRescale(): boolean;
  30811. /** @hidden */
  30812. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30813. /** @hidden */
  30814. _rebuild(): void;
  30815. /**
  30816. * Triggers the load sequence in delayed load mode.
  30817. */
  30818. delayLoad(): void;
  30819. /**
  30820. * Clones the texture.
  30821. * @returns the cloned texture
  30822. */
  30823. clone(): Nullable<BaseTexture>;
  30824. /**
  30825. * Get the texture underlying type (INT, FLOAT...)
  30826. */
  30827. get textureType(): number;
  30828. /**
  30829. * Get the texture underlying format (RGB, RGBA...)
  30830. */
  30831. get textureFormat(): number;
  30832. /**
  30833. * Indicates that textures need to be re-calculated for all materials
  30834. */
  30835. protected _markAllSubMeshesAsTexturesDirty(): void;
  30836. /**
  30837. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30838. * This will returns an RGBA array buffer containing either in values (0-255) or
  30839. * float values (0-1) depending of the underlying buffer type.
  30840. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30841. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30842. * @param buffer defines a user defined buffer to fill with data (can be null)
  30843. * @returns The Array buffer containing the pixels data.
  30844. */
  30845. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30846. /**
  30847. * Release and destroy the underlying lower level texture aka internalTexture.
  30848. */
  30849. releaseInternalTexture(): void;
  30850. /** @hidden */
  30851. get _lodTextureHigh(): Nullable<BaseTexture>;
  30852. /** @hidden */
  30853. get _lodTextureMid(): Nullable<BaseTexture>;
  30854. /** @hidden */
  30855. get _lodTextureLow(): Nullable<BaseTexture>;
  30856. /**
  30857. * Dispose the texture and release its associated resources.
  30858. */
  30859. dispose(): void;
  30860. /**
  30861. * Serialize the texture into a JSON representation that can be parsed later on.
  30862. * @returns the JSON representation of the texture
  30863. */
  30864. serialize(): any;
  30865. /**
  30866. * Helper function to be called back once a list of texture contains only ready textures.
  30867. * @param textures Define the list of textures to wait for
  30868. * @param callback Define the callback triggered once the entire list will be ready
  30869. */
  30870. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30871. }
  30872. }
  30873. declare module "babylonjs/Materials/effect" {
  30874. import { Observable } from "babylonjs/Misc/observable";
  30875. import { Nullable } from "babylonjs/types";
  30876. import { IDisposable } from "babylonjs/scene";
  30877. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30878. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30879. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30881. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30882. import { Engine } from "babylonjs/Engines/engine";
  30883. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30887. /**
  30888. * Options to be used when creating an effect.
  30889. */
  30890. export interface IEffectCreationOptions {
  30891. /**
  30892. * Atrributes that will be used in the shader.
  30893. */
  30894. attributes: string[];
  30895. /**
  30896. * Uniform varible names that will be set in the shader.
  30897. */
  30898. uniformsNames: string[];
  30899. /**
  30900. * Uniform buffer variable names that will be set in the shader.
  30901. */
  30902. uniformBuffersNames: string[];
  30903. /**
  30904. * Sampler texture variable names that will be set in the shader.
  30905. */
  30906. samplers: string[];
  30907. /**
  30908. * Define statements that will be set in the shader.
  30909. */
  30910. defines: any;
  30911. /**
  30912. * Possible fallbacks for this effect to improve performance when needed.
  30913. */
  30914. fallbacks: Nullable<IEffectFallbacks>;
  30915. /**
  30916. * Callback that will be called when the shader is compiled.
  30917. */
  30918. onCompiled: Nullable<(effect: Effect) => void>;
  30919. /**
  30920. * Callback that will be called if an error occurs during shader compilation.
  30921. */
  30922. onError: Nullable<(effect: Effect, errors: string) => void>;
  30923. /**
  30924. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30925. */
  30926. indexParameters?: any;
  30927. /**
  30928. * Max number of lights that can be used in the shader.
  30929. */
  30930. maxSimultaneousLights?: number;
  30931. /**
  30932. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30933. */
  30934. transformFeedbackVaryings?: Nullable<string[]>;
  30935. }
  30936. /**
  30937. * Effect containing vertex and fragment shader that can be executed on an object.
  30938. */
  30939. export class Effect implements IDisposable {
  30940. /**
  30941. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30942. */
  30943. static ShadersRepository: string;
  30944. /**
  30945. * Name of the effect.
  30946. */
  30947. name: any;
  30948. /**
  30949. * String container all the define statements that should be set on the shader.
  30950. */
  30951. defines: string;
  30952. /**
  30953. * Callback that will be called when the shader is compiled.
  30954. */
  30955. onCompiled: Nullable<(effect: Effect) => void>;
  30956. /**
  30957. * Callback that will be called if an error occurs during shader compilation.
  30958. */
  30959. onError: Nullable<(effect: Effect, errors: string) => void>;
  30960. /**
  30961. * Callback that will be called when effect is bound.
  30962. */
  30963. onBind: Nullable<(effect: Effect) => void>;
  30964. /**
  30965. * Unique ID of the effect.
  30966. */
  30967. uniqueId: number;
  30968. /**
  30969. * Observable that will be called when the shader is compiled.
  30970. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30971. */
  30972. onCompileObservable: Observable<Effect>;
  30973. /**
  30974. * Observable that will be called if an error occurs during shader compilation.
  30975. */
  30976. onErrorObservable: Observable<Effect>;
  30977. /** @hidden */
  30978. _onBindObservable: Nullable<Observable<Effect>>;
  30979. /**
  30980. * @hidden
  30981. * Specifies if the effect was previously ready
  30982. */
  30983. _wasPreviouslyReady: boolean;
  30984. /**
  30985. * Observable that will be called when effect is bound.
  30986. */
  30987. get onBindObservable(): Observable<Effect>;
  30988. /** @hidden */
  30989. _bonesComputationForcedToCPU: boolean;
  30990. private static _uniqueIdSeed;
  30991. private _engine;
  30992. private _uniformBuffersNames;
  30993. private _uniformsNames;
  30994. private _samplerList;
  30995. private _samplers;
  30996. private _isReady;
  30997. private _compilationError;
  30998. private _allFallbacksProcessed;
  30999. private _attributesNames;
  31000. private _attributes;
  31001. private _attributeLocationByName;
  31002. private _uniforms;
  31003. /**
  31004. * Key for the effect.
  31005. * @hidden
  31006. */
  31007. _key: string;
  31008. private _indexParameters;
  31009. private _fallbacks;
  31010. private _vertexSourceCode;
  31011. private _fragmentSourceCode;
  31012. private _vertexSourceCodeOverride;
  31013. private _fragmentSourceCodeOverride;
  31014. private _transformFeedbackVaryings;
  31015. /**
  31016. * Compiled shader to webGL program.
  31017. * @hidden
  31018. */
  31019. _pipelineContext: Nullable<IPipelineContext>;
  31020. private _valueCache;
  31021. private static _baseCache;
  31022. /**
  31023. * Instantiates an effect.
  31024. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31025. * @param baseName Name of the effect.
  31026. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31027. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31028. * @param samplers List of sampler variables that will be passed to the shader.
  31029. * @param engine Engine to be used to render the effect
  31030. * @param defines Define statements to be added to the shader.
  31031. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31032. * @param onCompiled Callback that will be called when the shader is compiled.
  31033. * @param onError Callback that will be called if an error occurs during shader compilation.
  31034. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31035. */
  31036. 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);
  31037. private _useFinalCode;
  31038. /**
  31039. * Unique key for this effect
  31040. */
  31041. get key(): string;
  31042. /**
  31043. * If the effect has been compiled and prepared.
  31044. * @returns if the effect is compiled and prepared.
  31045. */
  31046. isReady(): boolean;
  31047. private _isReadyInternal;
  31048. /**
  31049. * The engine the effect was initialized with.
  31050. * @returns the engine.
  31051. */
  31052. getEngine(): Engine;
  31053. /**
  31054. * The pipeline context for this effect
  31055. * @returns the associated pipeline context
  31056. */
  31057. getPipelineContext(): Nullable<IPipelineContext>;
  31058. /**
  31059. * The set of names of attribute variables for the shader.
  31060. * @returns An array of attribute names.
  31061. */
  31062. getAttributesNames(): string[];
  31063. /**
  31064. * Returns the attribute at the given index.
  31065. * @param index The index of the attribute.
  31066. * @returns The location of the attribute.
  31067. */
  31068. getAttributeLocation(index: number): number;
  31069. /**
  31070. * Returns the attribute based on the name of the variable.
  31071. * @param name of the attribute to look up.
  31072. * @returns the attribute location.
  31073. */
  31074. getAttributeLocationByName(name: string): number;
  31075. /**
  31076. * The number of attributes.
  31077. * @returns the numnber of attributes.
  31078. */
  31079. getAttributesCount(): number;
  31080. /**
  31081. * Gets the index of a uniform variable.
  31082. * @param uniformName of the uniform to look up.
  31083. * @returns the index.
  31084. */
  31085. getUniformIndex(uniformName: string): number;
  31086. /**
  31087. * Returns the attribute based on the name of the variable.
  31088. * @param uniformName of the uniform to look up.
  31089. * @returns the location of the uniform.
  31090. */
  31091. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31092. /**
  31093. * Returns an array of sampler variable names
  31094. * @returns The array of sampler variable neames.
  31095. */
  31096. getSamplers(): string[];
  31097. /**
  31098. * The error from the last compilation.
  31099. * @returns the error string.
  31100. */
  31101. getCompilationError(): string;
  31102. /**
  31103. * Gets a boolean indicating that all fallbacks were used during compilation
  31104. * @returns true if all fallbacks were used
  31105. */
  31106. allFallbacksProcessed(): boolean;
  31107. /**
  31108. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31109. * @param func The callback to be used.
  31110. */
  31111. executeWhenCompiled(func: (effect: Effect) => void): void;
  31112. private _checkIsReady;
  31113. private _loadShader;
  31114. /**
  31115. * Recompiles the webGL program
  31116. * @param vertexSourceCode The source code for the vertex shader.
  31117. * @param fragmentSourceCode The source code for the fragment shader.
  31118. * @param onCompiled Callback called when completed.
  31119. * @param onError Callback called on error.
  31120. * @hidden
  31121. */
  31122. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31123. /**
  31124. * Prepares the effect
  31125. * @hidden
  31126. */
  31127. _prepareEffect(): void;
  31128. private _processCompilationErrors;
  31129. /**
  31130. * Checks if the effect is supported. (Must be called after compilation)
  31131. */
  31132. get isSupported(): boolean;
  31133. /**
  31134. * Binds a texture to the engine to be used as output of the shader.
  31135. * @param channel Name of the output variable.
  31136. * @param texture Texture to bind.
  31137. * @hidden
  31138. */
  31139. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31140. /**
  31141. * Sets a texture on the engine to be used in the shader.
  31142. * @param channel Name of the sampler variable.
  31143. * @param texture Texture to set.
  31144. */
  31145. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31146. /**
  31147. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31148. * @param channel Name of the sampler variable.
  31149. * @param texture Texture to set.
  31150. */
  31151. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31152. /**
  31153. * Sets an array of textures on the engine to be used in the shader.
  31154. * @param channel Name of the variable.
  31155. * @param textures Textures to set.
  31156. */
  31157. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31158. /**
  31159. * 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)
  31160. * @param channel Name of the sampler variable.
  31161. * @param postProcess Post process to get the input texture from.
  31162. */
  31163. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31164. /**
  31165. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31166. * 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)
  31167. * @param channel Name of the sampler variable.
  31168. * @param postProcess Post process to get the output texture from.
  31169. */
  31170. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31171. /** @hidden */
  31172. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31173. /** @hidden */
  31174. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31175. /** @hidden */
  31176. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31177. /** @hidden */
  31178. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31179. /**
  31180. * Binds a buffer to a uniform.
  31181. * @param buffer Buffer to bind.
  31182. * @param name Name of the uniform variable to bind to.
  31183. */
  31184. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31185. /**
  31186. * Binds block to a uniform.
  31187. * @param blockName Name of the block to bind.
  31188. * @param index Index to bind.
  31189. */
  31190. bindUniformBlock(blockName: string, index: number): void;
  31191. /**
  31192. * Sets an interger value on a uniform variable.
  31193. * @param uniformName Name of the variable.
  31194. * @param value Value to be set.
  31195. * @returns this effect.
  31196. */
  31197. setInt(uniformName: string, value: number): Effect;
  31198. /**
  31199. * Sets an int array on a uniform variable.
  31200. * @param uniformName Name of the variable.
  31201. * @param array array to be set.
  31202. * @returns this effect.
  31203. */
  31204. setIntArray(uniformName: string, array: Int32Array): Effect;
  31205. /**
  31206. * 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)
  31207. * @param uniformName Name of the variable.
  31208. * @param array array to be set.
  31209. * @returns this effect.
  31210. */
  31211. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31212. /**
  31213. * 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)
  31214. * @param uniformName Name of the variable.
  31215. * @param array array to be set.
  31216. * @returns this effect.
  31217. */
  31218. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31219. /**
  31220. * 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)
  31221. * @param uniformName Name of the variable.
  31222. * @param array array to be set.
  31223. * @returns this effect.
  31224. */
  31225. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31226. /**
  31227. * Sets an float array on a uniform variable.
  31228. * @param uniformName Name of the variable.
  31229. * @param array array to be set.
  31230. * @returns this effect.
  31231. */
  31232. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31233. /**
  31234. * 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)
  31235. * @param uniformName Name of the variable.
  31236. * @param array array to be set.
  31237. * @returns this effect.
  31238. */
  31239. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31240. /**
  31241. * 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)
  31242. * @param uniformName Name of the variable.
  31243. * @param array array to be set.
  31244. * @returns this effect.
  31245. */
  31246. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31247. /**
  31248. * 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)
  31249. * @param uniformName Name of the variable.
  31250. * @param array array to be set.
  31251. * @returns this effect.
  31252. */
  31253. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31254. /**
  31255. * Sets an array on a uniform variable.
  31256. * @param uniformName Name of the variable.
  31257. * @param array array to be set.
  31258. * @returns this effect.
  31259. */
  31260. setArray(uniformName: string, array: number[]): Effect;
  31261. /**
  31262. * 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)
  31263. * @param uniformName Name of the variable.
  31264. * @param array array to be set.
  31265. * @returns this effect.
  31266. */
  31267. setArray2(uniformName: string, array: number[]): Effect;
  31268. /**
  31269. * 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)
  31270. * @param uniformName Name of the variable.
  31271. * @param array array to be set.
  31272. * @returns this effect.
  31273. */
  31274. setArray3(uniformName: string, array: number[]): Effect;
  31275. /**
  31276. * 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)
  31277. * @param uniformName Name of the variable.
  31278. * @param array array to be set.
  31279. * @returns this effect.
  31280. */
  31281. setArray4(uniformName: string, array: number[]): Effect;
  31282. /**
  31283. * Sets matrices on a uniform variable.
  31284. * @param uniformName Name of the variable.
  31285. * @param matrices matrices to be set.
  31286. * @returns this effect.
  31287. */
  31288. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31289. /**
  31290. * Sets matrix on a uniform variable.
  31291. * @param uniformName Name of the variable.
  31292. * @param matrix matrix to be set.
  31293. * @returns this effect.
  31294. */
  31295. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31296. /**
  31297. * 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)
  31298. * @param uniformName Name of the variable.
  31299. * @param matrix matrix to be set.
  31300. * @returns this effect.
  31301. */
  31302. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31303. /**
  31304. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31305. * @param uniformName Name of the variable.
  31306. * @param matrix matrix to be set.
  31307. * @returns this effect.
  31308. */
  31309. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31310. /**
  31311. * Sets a float on a uniform variable.
  31312. * @param uniformName Name of the variable.
  31313. * @param value value to be set.
  31314. * @returns this effect.
  31315. */
  31316. setFloat(uniformName: string, value: number): Effect;
  31317. /**
  31318. * Sets a boolean on a uniform variable.
  31319. * @param uniformName Name of the variable.
  31320. * @param bool value to be set.
  31321. * @returns this effect.
  31322. */
  31323. setBool(uniformName: string, bool: boolean): Effect;
  31324. /**
  31325. * Sets a Vector2 on a uniform variable.
  31326. * @param uniformName Name of the variable.
  31327. * @param vector2 vector2 to be set.
  31328. * @returns this effect.
  31329. */
  31330. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31331. /**
  31332. * Sets a float2 on a uniform variable.
  31333. * @param uniformName Name of the variable.
  31334. * @param x First float in float2.
  31335. * @param y Second float in float2.
  31336. * @returns this effect.
  31337. */
  31338. setFloat2(uniformName: string, x: number, y: number): Effect;
  31339. /**
  31340. * Sets a Vector3 on a uniform variable.
  31341. * @param uniformName Name of the variable.
  31342. * @param vector3 Value to be set.
  31343. * @returns this effect.
  31344. */
  31345. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31346. /**
  31347. * Sets a float3 on a uniform variable.
  31348. * @param uniformName Name of the variable.
  31349. * @param x First float in float3.
  31350. * @param y Second float in float3.
  31351. * @param z Third float in float3.
  31352. * @returns this effect.
  31353. */
  31354. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31355. /**
  31356. * Sets a Vector4 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param vector4 Value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31362. /**
  31363. * Sets a float4 on a uniform variable.
  31364. * @param uniformName Name of the variable.
  31365. * @param x First float in float4.
  31366. * @param y Second float in float4.
  31367. * @param z Third float in float4.
  31368. * @param w Fourth float in float4.
  31369. * @returns this effect.
  31370. */
  31371. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31372. /**
  31373. * Sets a Color3 on a uniform variable.
  31374. * @param uniformName Name of the variable.
  31375. * @param color3 Value to be set.
  31376. * @returns this effect.
  31377. */
  31378. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31379. /**
  31380. * Sets a Color4 on a uniform variable.
  31381. * @param uniformName Name of the variable.
  31382. * @param color3 Value to be set.
  31383. * @param alpha Alpha value to be set.
  31384. * @returns this effect.
  31385. */
  31386. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31387. /**
  31388. * Sets a Color4 on a uniform variable
  31389. * @param uniformName defines the name of the variable
  31390. * @param color4 defines the value to be set
  31391. * @returns this effect.
  31392. */
  31393. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31394. /** Release all associated resources */
  31395. dispose(): void;
  31396. /**
  31397. * This function will add a new shader to the shader store
  31398. * @param name the name of the shader
  31399. * @param pixelShader optional pixel shader content
  31400. * @param vertexShader optional vertex shader content
  31401. */
  31402. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31403. /**
  31404. * Store of each shader (The can be looked up using effect.key)
  31405. */
  31406. static ShadersStore: {
  31407. [key: string]: string;
  31408. };
  31409. /**
  31410. * Store of each included file for a shader (The can be looked up using effect.key)
  31411. */
  31412. static IncludesShadersStore: {
  31413. [key: string]: string;
  31414. };
  31415. /**
  31416. * Resets the cache of effects.
  31417. */
  31418. static ResetCache(): void;
  31419. }
  31420. }
  31421. declare module "babylonjs/Engines/engineCapabilities" {
  31422. /**
  31423. * Interface used to describe the capabilities of the engine relatively to the current browser
  31424. */
  31425. export interface EngineCapabilities {
  31426. /** Maximum textures units per fragment shader */
  31427. maxTexturesImageUnits: number;
  31428. /** Maximum texture units per vertex shader */
  31429. maxVertexTextureImageUnits: number;
  31430. /** Maximum textures units in the entire pipeline */
  31431. maxCombinedTexturesImageUnits: number;
  31432. /** Maximum texture size */
  31433. maxTextureSize: number;
  31434. /** Maximum texture samples */
  31435. maxSamples?: number;
  31436. /** Maximum cube texture size */
  31437. maxCubemapTextureSize: number;
  31438. /** Maximum render texture size */
  31439. maxRenderTextureSize: number;
  31440. /** Maximum number of vertex attributes */
  31441. maxVertexAttribs: number;
  31442. /** Maximum number of varyings */
  31443. maxVaryingVectors: number;
  31444. /** Maximum number of uniforms per vertex shader */
  31445. maxVertexUniformVectors: number;
  31446. /** Maximum number of uniforms per fragment shader */
  31447. maxFragmentUniformVectors: number;
  31448. /** Defines if standard derivates (dx/dy) are supported */
  31449. standardDerivatives: boolean;
  31450. /** Defines if s3tc texture compression is supported */
  31451. s3tc?: WEBGL_compressed_texture_s3tc;
  31452. /** Defines if pvrtc texture compression is supported */
  31453. pvrtc: any;
  31454. /** Defines if etc1 texture compression is supported */
  31455. etc1: any;
  31456. /** Defines if etc2 texture compression is supported */
  31457. etc2: any;
  31458. /** Defines if astc texture compression is supported */
  31459. astc: any;
  31460. /** Defines if float textures are supported */
  31461. textureFloat: boolean;
  31462. /** Defines if vertex array objects are supported */
  31463. vertexArrayObject: boolean;
  31464. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31465. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31466. /** Gets the maximum level of anisotropy supported */
  31467. maxAnisotropy: number;
  31468. /** Defines if instancing is supported */
  31469. instancedArrays: boolean;
  31470. /** Defines if 32 bits indices are supported */
  31471. uintIndices: boolean;
  31472. /** Defines if high precision shaders are supported */
  31473. highPrecisionShaderSupported: boolean;
  31474. /** Defines if depth reading in the fragment shader is supported */
  31475. fragmentDepthSupported: boolean;
  31476. /** Defines if float texture linear filtering is supported*/
  31477. textureFloatLinearFiltering: boolean;
  31478. /** Defines if rendering to float textures is supported */
  31479. textureFloatRender: boolean;
  31480. /** Defines if half float textures are supported*/
  31481. textureHalfFloat: boolean;
  31482. /** Defines if half float texture linear filtering is supported*/
  31483. textureHalfFloatLinearFiltering: boolean;
  31484. /** Defines if rendering to half float textures is supported */
  31485. textureHalfFloatRender: boolean;
  31486. /** Defines if textureLOD shader command is supported */
  31487. textureLOD: boolean;
  31488. /** Defines if draw buffers extension is supported */
  31489. drawBuffersExtension: boolean;
  31490. /** Defines if depth textures are supported */
  31491. depthTextureExtension: boolean;
  31492. /** Defines if float color buffer are supported */
  31493. colorBufferFloat: boolean;
  31494. /** Gets disjoint timer query extension (null if not supported) */
  31495. timerQuery?: EXT_disjoint_timer_query;
  31496. /** Defines if timestamp can be used with timer query */
  31497. canUseTimestampForTimerQuery: boolean;
  31498. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31499. multiview?: any;
  31500. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31501. oculusMultiview?: any;
  31502. /** Function used to let the system compiles shaders in background */
  31503. parallelShaderCompile?: {
  31504. COMPLETION_STATUS_KHR: number;
  31505. };
  31506. /** Max number of texture samples for MSAA */
  31507. maxMSAASamples: number;
  31508. /** Defines if the blend min max extension is supported */
  31509. blendMinMax: boolean;
  31510. }
  31511. }
  31512. declare module "babylonjs/States/depthCullingState" {
  31513. import { Nullable } from "babylonjs/types";
  31514. /**
  31515. * @hidden
  31516. **/
  31517. export class DepthCullingState {
  31518. private _isDepthTestDirty;
  31519. private _isDepthMaskDirty;
  31520. private _isDepthFuncDirty;
  31521. private _isCullFaceDirty;
  31522. private _isCullDirty;
  31523. private _isZOffsetDirty;
  31524. private _isFrontFaceDirty;
  31525. private _depthTest;
  31526. private _depthMask;
  31527. private _depthFunc;
  31528. private _cull;
  31529. private _cullFace;
  31530. private _zOffset;
  31531. private _frontFace;
  31532. /**
  31533. * Initializes the state.
  31534. */
  31535. constructor();
  31536. get isDirty(): boolean;
  31537. get zOffset(): number;
  31538. set zOffset(value: number);
  31539. get cullFace(): Nullable<number>;
  31540. set cullFace(value: Nullable<number>);
  31541. get cull(): Nullable<boolean>;
  31542. set cull(value: Nullable<boolean>);
  31543. get depthFunc(): Nullable<number>;
  31544. set depthFunc(value: Nullable<number>);
  31545. get depthMask(): boolean;
  31546. set depthMask(value: boolean);
  31547. get depthTest(): boolean;
  31548. set depthTest(value: boolean);
  31549. get frontFace(): Nullable<number>;
  31550. set frontFace(value: Nullable<number>);
  31551. reset(): void;
  31552. apply(gl: WebGLRenderingContext): void;
  31553. }
  31554. }
  31555. declare module "babylonjs/States/stencilState" {
  31556. /**
  31557. * @hidden
  31558. **/
  31559. export class StencilState {
  31560. /** 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 */
  31561. static readonly ALWAYS: number;
  31562. /** Passed to stencilOperation to specify that stencil value must be kept */
  31563. static readonly KEEP: number;
  31564. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31565. static readonly REPLACE: number;
  31566. private _isStencilTestDirty;
  31567. private _isStencilMaskDirty;
  31568. private _isStencilFuncDirty;
  31569. private _isStencilOpDirty;
  31570. private _stencilTest;
  31571. private _stencilMask;
  31572. private _stencilFunc;
  31573. private _stencilFuncRef;
  31574. private _stencilFuncMask;
  31575. private _stencilOpStencilFail;
  31576. private _stencilOpDepthFail;
  31577. private _stencilOpStencilDepthPass;
  31578. get isDirty(): boolean;
  31579. get stencilFunc(): number;
  31580. set stencilFunc(value: number);
  31581. get stencilFuncRef(): number;
  31582. set stencilFuncRef(value: number);
  31583. get stencilFuncMask(): number;
  31584. set stencilFuncMask(value: number);
  31585. get stencilOpStencilFail(): number;
  31586. set stencilOpStencilFail(value: number);
  31587. get stencilOpDepthFail(): number;
  31588. set stencilOpDepthFail(value: number);
  31589. get stencilOpStencilDepthPass(): number;
  31590. set stencilOpStencilDepthPass(value: number);
  31591. get stencilMask(): number;
  31592. set stencilMask(value: number);
  31593. get stencilTest(): boolean;
  31594. set stencilTest(value: boolean);
  31595. constructor();
  31596. reset(): void;
  31597. apply(gl: WebGLRenderingContext): void;
  31598. }
  31599. }
  31600. declare module "babylonjs/States/alphaCullingState" {
  31601. /**
  31602. * @hidden
  31603. **/
  31604. export class AlphaState {
  31605. private _isAlphaBlendDirty;
  31606. private _isBlendFunctionParametersDirty;
  31607. private _isBlendEquationParametersDirty;
  31608. private _isBlendConstantsDirty;
  31609. private _alphaBlend;
  31610. private _blendFunctionParameters;
  31611. private _blendEquationParameters;
  31612. private _blendConstants;
  31613. /**
  31614. * Initializes the state.
  31615. */
  31616. constructor();
  31617. get isDirty(): boolean;
  31618. get alphaBlend(): boolean;
  31619. set alphaBlend(value: boolean);
  31620. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31621. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31622. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31623. reset(): void;
  31624. apply(gl: WebGLRenderingContext): void;
  31625. }
  31626. }
  31627. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31628. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31629. /** @hidden */
  31630. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31631. attributeProcessor(attribute: string): string;
  31632. varyingProcessor(varying: string, isFragment: boolean): string;
  31633. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31634. }
  31635. }
  31636. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31637. /**
  31638. * Interface for attribute information associated with buffer instanciation
  31639. */
  31640. export interface InstancingAttributeInfo {
  31641. /**
  31642. * Name of the GLSL attribute
  31643. * if attribute index is not specified, this is used to retrieve the index from the effect
  31644. */
  31645. attributeName: string;
  31646. /**
  31647. * Index/offset of the attribute in the vertex shader
  31648. * if not specified, this will be computes from the name.
  31649. */
  31650. index?: number;
  31651. /**
  31652. * size of the attribute, 1, 2, 3 or 4
  31653. */
  31654. attributeSize: number;
  31655. /**
  31656. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31657. */
  31658. offset: number;
  31659. /**
  31660. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31661. * default to 1
  31662. */
  31663. divisor?: number;
  31664. /**
  31665. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31666. * default is FLOAT
  31667. */
  31668. attributeType?: number;
  31669. /**
  31670. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31671. */
  31672. normalized?: boolean;
  31673. }
  31674. }
  31675. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31677. import { Nullable } from "babylonjs/types";
  31678. module "babylonjs/Engines/thinEngine" {
  31679. interface ThinEngine {
  31680. /**
  31681. * Update a video texture
  31682. * @param texture defines the texture to update
  31683. * @param video defines the video element to use
  31684. * @param invertY defines if data must be stored with Y axis inverted
  31685. */
  31686. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31687. }
  31688. }
  31689. }
  31690. declare module "babylonjs/Materials/Textures/videoTexture" {
  31691. import { Observable } from "babylonjs/Misc/observable";
  31692. import { Nullable } from "babylonjs/types";
  31693. import { Scene } from "babylonjs/scene";
  31694. import { Texture } from "babylonjs/Materials/Textures/texture";
  31695. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31696. /**
  31697. * Settings for finer control over video usage
  31698. */
  31699. export interface VideoTextureSettings {
  31700. /**
  31701. * Applies `autoplay` to video, if specified
  31702. */
  31703. autoPlay?: boolean;
  31704. /**
  31705. * Applies `loop` to video, if specified
  31706. */
  31707. loop?: boolean;
  31708. /**
  31709. * Automatically updates internal texture from video at every frame in the render loop
  31710. */
  31711. autoUpdateTexture: boolean;
  31712. /**
  31713. * Image src displayed during the video loading or until the user interacts with the video.
  31714. */
  31715. poster?: string;
  31716. }
  31717. /**
  31718. * If you want to display a video in your scene, this is the special texture for that.
  31719. * This special texture works similar to other textures, with the exception of a few parameters.
  31720. * @see https://doc.babylonjs.com/how_to/video_texture
  31721. */
  31722. export class VideoTexture extends Texture {
  31723. /**
  31724. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31725. */
  31726. readonly autoUpdateTexture: boolean;
  31727. /**
  31728. * The video instance used by the texture internally
  31729. */
  31730. readonly video: HTMLVideoElement;
  31731. private _onUserActionRequestedObservable;
  31732. /**
  31733. * Event triggerd when a dom action is required by the user to play the video.
  31734. * This happens due to recent changes in browser policies preventing video to auto start.
  31735. */
  31736. get onUserActionRequestedObservable(): Observable<Texture>;
  31737. private _generateMipMaps;
  31738. private _engine;
  31739. private _stillImageCaptured;
  31740. private _displayingPosterTexture;
  31741. private _settings;
  31742. private _createInternalTextureOnEvent;
  31743. private _frameId;
  31744. private _currentSrc;
  31745. /**
  31746. * Creates a video texture.
  31747. * If you want to display a video in your scene, this is the special texture for that.
  31748. * This special texture works similar to other textures, with the exception of a few parameters.
  31749. * @see https://doc.babylonjs.com/how_to/video_texture
  31750. * @param name optional name, will detect from video source, if not defined
  31751. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31752. * @param scene is obviously the current scene.
  31753. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31754. * @param invertY is false by default but can be used to invert video on Y axis
  31755. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31756. * @param settings allows finer control over video usage
  31757. */
  31758. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31759. private _getName;
  31760. private _getVideo;
  31761. private _createInternalTexture;
  31762. private reset;
  31763. /**
  31764. * @hidden Internal method to initiate `update`.
  31765. */
  31766. _rebuild(): void;
  31767. /**
  31768. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31769. */
  31770. update(): void;
  31771. /**
  31772. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31773. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31774. */
  31775. updateTexture(isVisible: boolean): void;
  31776. protected _updateInternalTexture: () => void;
  31777. /**
  31778. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31779. * @param url New url.
  31780. */
  31781. updateURL(url: string): void;
  31782. /**
  31783. * Clones the texture.
  31784. * @returns the cloned texture
  31785. */
  31786. clone(): VideoTexture;
  31787. /**
  31788. * Dispose the texture and release its associated resources.
  31789. */
  31790. dispose(): void;
  31791. /**
  31792. * Creates a video texture straight from a stream.
  31793. * @param scene Define the scene the texture should be created in
  31794. * @param stream Define the stream the texture should be created from
  31795. * @returns The created video texture as a promise
  31796. */
  31797. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31798. /**
  31799. * Creates a video texture straight from your WebCam video feed.
  31800. * @param scene Define the scene the texture should be created in
  31801. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31802. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31803. * @returns The created video texture as a promise
  31804. */
  31805. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31806. minWidth: number;
  31807. maxWidth: number;
  31808. minHeight: number;
  31809. maxHeight: number;
  31810. deviceId: string;
  31811. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31812. /**
  31813. * Creates a video texture straight from your WebCam video feed.
  31814. * @param scene Define the scene the texture should be created in
  31815. * @param onReady Define a callback to triggered once the texture will be ready
  31816. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31817. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31818. */
  31819. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31820. minWidth: number;
  31821. maxWidth: number;
  31822. minHeight: number;
  31823. maxHeight: number;
  31824. deviceId: string;
  31825. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31826. }
  31827. }
  31828. declare module "babylonjs/Engines/thinEngine" {
  31829. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31830. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31831. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31833. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31834. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31835. import { Observable } from "babylonjs/Misc/observable";
  31836. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31837. import { StencilState } from "babylonjs/States/stencilState";
  31838. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31839. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31840. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31841. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31842. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31843. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31844. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31845. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31846. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31848. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31849. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31850. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31851. import { WebRequest } from "babylonjs/Misc/webRequest";
  31852. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31853. /**
  31854. * Defines the interface used by objects working like Scene
  31855. * @hidden
  31856. */
  31857. export interface ISceneLike {
  31858. _addPendingData(data: any): void;
  31859. _removePendingData(data: any): void;
  31860. offlineProvider: IOfflineProvider;
  31861. }
  31862. /** Interface defining initialization parameters for Engine class */
  31863. export interface EngineOptions extends WebGLContextAttributes {
  31864. /**
  31865. * Defines if the engine should no exceed a specified device ratio
  31866. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31867. */
  31868. limitDeviceRatio?: number;
  31869. /**
  31870. * Defines if webvr should be enabled automatically
  31871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31872. */
  31873. autoEnableWebVR?: boolean;
  31874. /**
  31875. * Defines if webgl2 should be turned off even if supported
  31876. * @see http://doc.babylonjs.com/features/webgl2
  31877. */
  31878. disableWebGL2Support?: boolean;
  31879. /**
  31880. * Defines if webaudio should be initialized as well
  31881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31882. */
  31883. audioEngine?: boolean;
  31884. /**
  31885. * Defines if animations should run using a deterministic lock step
  31886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31887. */
  31888. deterministicLockstep?: boolean;
  31889. /** Defines the maximum steps to use with deterministic lock step mode */
  31890. lockstepMaxSteps?: number;
  31891. /** Defines the seconds between each deterministic lock step */
  31892. timeStep?: number;
  31893. /**
  31894. * Defines that engine should ignore context lost events
  31895. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31896. */
  31897. doNotHandleContextLost?: boolean;
  31898. /**
  31899. * Defines that engine should ignore modifying touch action attribute and style
  31900. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31901. */
  31902. doNotHandleTouchAction?: boolean;
  31903. /**
  31904. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31905. */
  31906. useHighPrecisionFloats?: boolean;
  31907. }
  31908. /**
  31909. * The base engine class (root of all engines)
  31910. */
  31911. export class ThinEngine {
  31912. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31913. static ExceptionList: ({
  31914. key: string;
  31915. capture: string;
  31916. captureConstraint: number;
  31917. targets: string[];
  31918. } | {
  31919. key: string;
  31920. capture: null;
  31921. captureConstraint: null;
  31922. targets: string[];
  31923. })[];
  31924. /** @hidden */
  31925. static _TextureLoaders: IInternalTextureLoader[];
  31926. /**
  31927. * Returns the current npm package of the sdk
  31928. */
  31929. static get NpmPackage(): string;
  31930. /**
  31931. * Returns the current version of the framework
  31932. */
  31933. static get Version(): string;
  31934. /**
  31935. * Returns a string describing the current engine
  31936. */
  31937. get description(): string;
  31938. /**
  31939. * Gets or sets the epsilon value used by collision engine
  31940. */
  31941. static CollisionsEpsilon: number;
  31942. /**
  31943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31944. */
  31945. static get ShadersRepository(): string;
  31946. static set ShadersRepository(value: string);
  31947. /** @hidden */
  31948. _shaderProcessor: IShaderProcessor;
  31949. /**
  31950. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31951. */
  31952. forcePOTTextures: boolean;
  31953. /**
  31954. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31955. */
  31956. isFullscreen: boolean;
  31957. /**
  31958. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31959. */
  31960. cullBackFaces: boolean;
  31961. /**
  31962. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31963. */
  31964. renderEvenInBackground: boolean;
  31965. /**
  31966. * Gets or sets a boolean indicating that cache can be kept between frames
  31967. */
  31968. preventCacheWipeBetweenFrames: boolean;
  31969. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31970. validateShaderPrograms: boolean;
  31971. /**
  31972. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31973. * This can provide greater z depth for distant objects.
  31974. */
  31975. useReverseDepthBuffer: boolean;
  31976. /**
  31977. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31978. */
  31979. disableUniformBuffers: boolean;
  31980. /** @hidden */
  31981. _uniformBuffers: UniformBuffer[];
  31982. /**
  31983. * Gets a boolean indicating that the engine supports uniform buffers
  31984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31985. */
  31986. get supportsUniformBuffers(): boolean;
  31987. /** @hidden */
  31988. _gl: WebGLRenderingContext;
  31989. /** @hidden */
  31990. _webGLVersion: number;
  31991. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31992. protected _windowIsBackground: boolean;
  31993. protected _creationOptions: EngineOptions;
  31994. protected _highPrecisionShadersAllowed: boolean;
  31995. /** @hidden */
  31996. get _shouldUseHighPrecisionShader(): boolean;
  31997. /**
  31998. * Gets a boolean indicating that only power of 2 textures are supported
  31999. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32000. */
  32001. get needPOTTextures(): boolean;
  32002. /** @hidden */
  32003. _badOS: boolean;
  32004. /** @hidden */
  32005. _badDesktopOS: boolean;
  32006. private _hardwareScalingLevel;
  32007. /** @hidden */
  32008. _caps: EngineCapabilities;
  32009. private _isStencilEnable;
  32010. private _glVersion;
  32011. private _glRenderer;
  32012. private _glVendor;
  32013. /** @hidden */
  32014. _videoTextureSupported: boolean;
  32015. protected _renderingQueueLaunched: boolean;
  32016. protected _activeRenderLoops: (() => void)[];
  32017. /**
  32018. * Observable signaled when a context lost event is raised
  32019. */
  32020. onContextLostObservable: Observable<ThinEngine>;
  32021. /**
  32022. * Observable signaled when a context restored event is raised
  32023. */
  32024. onContextRestoredObservable: Observable<ThinEngine>;
  32025. private _onContextLost;
  32026. private _onContextRestored;
  32027. protected _contextWasLost: boolean;
  32028. /** @hidden */
  32029. _doNotHandleContextLost: boolean;
  32030. /**
  32031. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32033. */
  32034. get doNotHandleContextLost(): boolean;
  32035. set doNotHandleContextLost(value: boolean);
  32036. /**
  32037. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32038. */
  32039. disableVertexArrayObjects: boolean;
  32040. /** @hidden */
  32041. protected _colorWrite: boolean;
  32042. /** @hidden */
  32043. protected _colorWriteChanged: boolean;
  32044. /** @hidden */
  32045. protected _depthCullingState: DepthCullingState;
  32046. /** @hidden */
  32047. protected _stencilState: StencilState;
  32048. /** @hidden */
  32049. _alphaState: AlphaState;
  32050. /** @hidden */
  32051. _alphaMode: number;
  32052. /** @hidden */
  32053. _alphaEquation: number;
  32054. /** @hidden */
  32055. _internalTexturesCache: InternalTexture[];
  32056. /** @hidden */
  32057. protected _activeChannel: number;
  32058. private _currentTextureChannel;
  32059. /** @hidden */
  32060. protected _boundTexturesCache: {
  32061. [key: string]: Nullable<InternalTexture>;
  32062. };
  32063. /** @hidden */
  32064. protected _currentEffect: Nullable<Effect>;
  32065. /** @hidden */
  32066. protected _currentProgram: Nullable<WebGLProgram>;
  32067. private _compiledEffects;
  32068. private _vertexAttribArraysEnabled;
  32069. /** @hidden */
  32070. protected _cachedViewport: Nullable<IViewportLike>;
  32071. private _cachedVertexArrayObject;
  32072. /** @hidden */
  32073. protected _cachedVertexBuffers: any;
  32074. /** @hidden */
  32075. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32076. /** @hidden */
  32077. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32078. /** @hidden */
  32079. _currentRenderTarget: Nullable<InternalTexture>;
  32080. private _uintIndicesCurrentlySet;
  32081. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32082. /** @hidden */
  32083. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32084. private _currentBufferPointers;
  32085. private _currentInstanceLocations;
  32086. private _currentInstanceBuffers;
  32087. private _textureUnits;
  32088. /** @hidden */
  32089. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32090. /** @hidden */
  32091. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32092. /** @hidden */
  32093. _boundRenderFunction: any;
  32094. private _vaoRecordInProgress;
  32095. private _mustWipeVertexAttributes;
  32096. private _emptyTexture;
  32097. private _emptyCubeTexture;
  32098. private _emptyTexture3D;
  32099. private _emptyTexture2DArray;
  32100. /** @hidden */
  32101. _frameHandler: number;
  32102. private _nextFreeTextureSlots;
  32103. private _maxSimultaneousTextures;
  32104. private _activeRequests;
  32105. protected _texturesSupported: string[];
  32106. /** @hidden */
  32107. _textureFormatInUse: Nullable<string>;
  32108. protected get _supportsHardwareTextureRescaling(): boolean;
  32109. /**
  32110. * Gets the list of texture formats supported
  32111. */
  32112. get texturesSupported(): Array<string>;
  32113. /**
  32114. * Gets the list of texture formats in use
  32115. */
  32116. get textureFormatInUse(): Nullable<string>;
  32117. /**
  32118. * Gets the current viewport
  32119. */
  32120. get currentViewport(): Nullable<IViewportLike>;
  32121. /**
  32122. * Gets the default empty texture
  32123. */
  32124. get emptyTexture(): InternalTexture;
  32125. /**
  32126. * Gets the default empty 3D texture
  32127. */
  32128. get emptyTexture3D(): InternalTexture;
  32129. /**
  32130. * Gets the default empty 2D array texture
  32131. */
  32132. get emptyTexture2DArray(): InternalTexture;
  32133. /**
  32134. * Gets the default empty cube texture
  32135. */
  32136. get emptyCubeTexture(): InternalTexture;
  32137. /**
  32138. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32139. */
  32140. readonly premultipliedAlpha: boolean;
  32141. /**
  32142. * Observable event triggered before each texture is initialized
  32143. */
  32144. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32145. /**
  32146. * Creates a new engine
  32147. * @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
  32148. * @param antialias defines enable antialiasing (default: false)
  32149. * @param options defines further options to be sent to the getContext() function
  32150. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32151. */
  32152. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32153. private _rebuildInternalTextures;
  32154. private _rebuildEffects;
  32155. /**
  32156. * Gets a boolean indicating if all created effects are ready
  32157. * @returns true if all effects are ready
  32158. */
  32159. areAllEffectsReady(): boolean;
  32160. protected _rebuildBuffers(): void;
  32161. private _initGLContext;
  32162. /**
  32163. * Gets version of the current webGL context
  32164. */
  32165. get webGLVersion(): number;
  32166. /**
  32167. * Gets a string idenfifying the name of the class
  32168. * @returns "Engine" string
  32169. */
  32170. getClassName(): string;
  32171. /**
  32172. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32173. */
  32174. get isStencilEnable(): boolean;
  32175. /** @hidden */
  32176. _prepareWorkingCanvas(): void;
  32177. /**
  32178. * Reset the texture cache to empty state
  32179. */
  32180. resetTextureCache(): void;
  32181. /**
  32182. * Gets an object containing information about the current webGL context
  32183. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32184. */
  32185. getGlInfo(): {
  32186. vendor: string;
  32187. renderer: string;
  32188. version: string;
  32189. };
  32190. /**
  32191. * Defines the hardware scaling level.
  32192. * By default the hardware scaling level is computed from the window device ratio.
  32193. * 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.
  32194. * @param level defines the level to use
  32195. */
  32196. setHardwareScalingLevel(level: number): void;
  32197. /**
  32198. * Gets the current hardware scaling level.
  32199. * By default the hardware scaling level is computed from the window device ratio.
  32200. * 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.
  32201. * @returns a number indicating the current hardware scaling level
  32202. */
  32203. getHardwareScalingLevel(): number;
  32204. /**
  32205. * Gets the list of loaded textures
  32206. * @returns an array containing all loaded textures
  32207. */
  32208. getLoadedTexturesCache(): InternalTexture[];
  32209. /**
  32210. * Gets the object containing all engine capabilities
  32211. * @returns the EngineCapabilities object
  32212. */
  32213. getCaps(): EngineCapabilities;
  32214. /**
  32215. * stop executing a render loop function and remove it from the execution array
  32216. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32217. */
  32218. stopRenderLoop(renderFunction?: () => void): void;
  32219. /** @hidden */
  32220. _renderLoop(): void;
  32221. /**
  32222. * Gets the HTML canvas attached with the current webGL context
  32223. * @returns a HTML canvas
  32224. */
  32225. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32226. /**
  32227. * Gets host window
  32228. * @returns the host window object
  32229. */
  32230. getHostWindow(): Nullable<Window>;
  32231. /**
  32232. * Gets the current render width
  32233. * @param useScreen defines if screen size must be used (or the current render target if any)
  32234. * @returns a number defining the current render width
  32235. */
  32236. getRenderWidth(useScreen?: boolean): number;
  32237. /**
  32238. * Gets the current render height
  32239. * @param useScreen defines if screen size must be used (or the current render target if any)
  32240. * @returns a number defining the current render height
  32241. */
  32242. getRenderHeight(useScreen?: boolean): number;
  32243. /**
  32244. * Can be used to override the current requestAnimationFrame requester.
  32245. * @hidden
  32246. */
  32247. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32248. /**
  32249. * Register and execute a render loop. The engine can have more than one render function
  32250. * @param renderFunction defines the function to continuously execute
  32251. */
  32252. runRenderLoop(renderFunction: () => void): void;
  32253. /**
  32254. * Clear the current render buffer or the current render target (if any is set up)
  32255. * @param color defines the color to use
  32256. * @param backBuffer defines if the back buffer must be cleared
  32257. * @param depth defines if the depth buffer must be cleared
  32258. * @param stencil defines if the stencil buffer must be cleared
  32259. */
  32260. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32261. private _viewportCached;
  32262. /** @hidden */
  32263. _viewport(x: number, y: number, width: number, height: number): void;
  32264. /**
  32265. * Set the WebGL's viewport
  32266. * @param viewport defines the viewport element to be used
  32267. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32268. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32269. */
  32270. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32271. /**
  32272. * Begin a new frame
  32273. */
  32274. beginFrame(): void;
  32275. /**
  32276. * Enf the current frame
  32277. */
  32278. endFrame(): void;
  32279. /**
  32280. * Resize the view according to the canvas' size
  32281. */
  32282. resize(): void;
  32283. /**
  32284. * Force a specific size of the canvas
  32285. * @param width defines the new canvas' width
  32286. * @param height defines the new canvas' height
  32287. */
  32288. setSize(width: number, height: number): void;
  32289. /**
  32290. * Binds the frame buffer to the specified texture.
  32291. * @param texture The texture to render to or null for the default canvas
  32292. * @param faceIndex The face of the texture to render to in case of cube texture
  32293. * @param requiredWidth The width of the target to render to
  32294. * @param requiredHeight The height of the target to render to
  32295. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32296. * @param lodLevel defines the lod level to bind to the frame buffer
  32297. * @param layer defines the 2d array index to bind to frame buffer to
  32298. */
  32299. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32300. /** @hidden */
  32301. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32302. /**
  32303. * Unbind the current render target texture from the webGL context
  32304. * @param texture defines the render target texture to unbind
  32305. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32306. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32307. */
  32308. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32309. /**
  32310. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32311. */
  32312. flushFramebuffer(): void;
  32313. /**
  32314. * Unbind the current render target and bind the default framebuffer
  32315. */
  32316. restoreDefaultFramebuffer(): void;
  32317. /** @hidden */
  32318. protected _resetVertexBufferBinding(): void;
  32319. /**
  32320. * Creates a vertex buffer
  32321. * @param data the data for the vertex buffer
  32322. * @returns the new WebGL static buffer
  32323. */
  32324. createVertexBuffer(data: DataArray): DataBuffer;
  32325. private _createVertexBuffer;
  32326. /**
  32327. * Creates a dynamic vertex buffer
  32328. * @param data the data for the dynamic vertex buffer
  32329. * @returns the new WebGL dynamic buffer
  32330. */
  32331. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32332. protected _resetIndexBufferBinding(): void;
  32333. /**
  32334. * Creates a new index buffer
  32335. * @param indices defines the content of the index buffer
  32336. * @param updatable defines if the index buffer must be updatable
  32337. * @returns a new webGL buffer
  32338. */
  32339. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32340. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32341. /**
  32342. * Bind a webGL buffer to the webGL context
  32343. * @param buffer defines the buffer to bind
  32344. */
  32345. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32346. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32347. private bindBuffer;
  32348. /**
  32349. * update the bound buffer with the given data
  32350. * @param data defines the data to update
  32351. */
  32352. updateArrayBuffer(data: Float32Array): void;
  32353. private _vertexAttribPointer;
  32354. /** @hidden */
  32355. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32356. private _bindVertexBuffersAttributes;
  32357. /**
  32358. * Records a vertex array object
  32359. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32360. * @param vertexBuffers defines the list of vertex buffers to store
  32361. * @param indexBuffer defines the index buffer to store
  32362. * @param effect defines the effect to store
  32363. * @returns the new vertex array object
  32364. */
  32365. recordVertexArrayObject(vertexBuffers: {
  32366. [key: string]: VertexBuffer;
  32367. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32368. /**
  32369. * Bind a specific vertex array object
  32370. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32371. * @param vertexArrayObject defines the vertex array object to bind
  32372. * @param indexBuffer defines the index buffer to bind
  32373. */
  32374. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32375. /**
  32376. * Bind webGl buffers directly to the webGL context
  32377. * @param vertexBuffer defines the vertex buffer to bind
  32378. * @param indexBuffer defines the index buffer to bind
  32379. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32380. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32381. * @param effect defines the effect associated with the vertex buffer
  32382. */
  32383. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32384. private _unbindVertexArrayObject;
  32385. /**
  32386. * Bind a list of vertex buffers to the webGL context
  32387. * @param vertexBuffers defines the list of vertex buffers to bind
  32388. * @param indexBuffer defines the index buffer to bind
  32389. * @param effect defines the effect associated with the vertex buffers
  32390. */
  32391. bindBuffers(vertexBuffers: {
  32392. [key: string]: Nullable<VertexBuffer>;
  32393. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32394. /**
  32395. * Unbind all instance attributes
  32396. */
  32397. unbindInstanceAttributes(): void;
  32398. /**
  32399. * Release and free the memory of a vertex array object
  32400. * @param vao defines the vertex array object to delete
  32401. */
  32402. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32403. /** @hidden */
  32404. _releaseBuffer(buffer: DataBuffer): boolean;
  32405. protected _deleteBuffer(buffer: DataBuffer): void;
  32406. /**
  32407. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32408. * @param instancesBuffer defines the webGL buffer to update and bind
  32409. * @param data defines the data to store in the buffer
  32410. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32411. */
  32412. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32413. /**
  32414. * Bind the content of a webGL buffer used with instantiation
  32415. * @param instancesBuffer defines the webGL buffer to bind
  32416. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32417. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32418. */
  32419. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32420. /**
  32421. * Disable the instance attribute corresponding to the name in parameter
  32422. * @param name defines the name of the attribute to disable
  32423. */
  32424. disableInstanceAttributeByName(name: string): void;
  32425. /**
  32426. * Disable the instance attribute corresponding to the location in parameter
  32427. * @param attributeLocation defines the attribute location of the attribute to disable
  32428. */
  32429. disableInstanceAttribute(attributeLocation: number): void;
  32430. /**
  32431. * Disable the attribute corresponding to the location in parameter
  32432. * @param attributeLocation defines the attribute location of the attribute to disable
  32433. */
  32434. disableAttributeByIndex(attributeLocation: number): void;
  32435. /**
  32436. * Send a draw order
  32437. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32438. * @param indexStart defines the starting index
  32439. * @param indexCount defines the number of index to draw
  32440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32441. */
  32442. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32443. /**
  32444. * Draw a list of points
  32445. * @param verticesStart defines the index of first vertex to draw
  32446. * @param verticesCount defines the count of vertices to draw
  32447. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32448. */
  32449. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32450. /**
  32451. * Draw a list of unindexed primitives
  32452. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32453. * @param verticesStart defines the index of first vertex to draw
  32454. * @param verticesCount defines the count of vertices to draw
  32455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32456. */
  32457. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32458. /**
  32459. * Draw a list of indexed primitives
  32460. * @param fillMode defines the primitive to use
  32461. * @param indexStart defines the starting index
  32462. * @param indexCount defines the number of index to draw
  32463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32464. */
  32465. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32466. /**
  32467. * Draw a list of unindexed primitives
  32468. * @param fillMode defines the primitive to use
  32469. * @param verticesStart defines the index of first vertex to draw
  32470. * @param verticesCount defines the count of vertices to draw
  32471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32472. */
  32473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32474. private _drawMode;
  32475. /** @hidden */
  32476. protected _reportDrawCall(): void;
  32477. /** @hidden */
  32478. _releaseEffect(effect: Effect): void;
  32479. /** @hidden */
  32480. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32481. /**
  32482. * Create a new effect (used to store vertex/fragment shaders)
  32483. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32484. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32485. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32486. * @param samplers defines an array of string used to represent textures
  32487. * @param defines defines the string containing the defines to use to compile the shaders
  32488. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32489. * @param onCompiled defines a function to call when the effect creation is successful
  32490. * @param onError defines a function to call when the effect creation has failed
  32491. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32492. * @returns the new Effect
  32493. */
  32494. 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;
  32495. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32496. private _compileShader;
  32497. private _compileRawShader;
  32498. /**
  32499. * Directly creates a webGL program
  32500. * @param pipelineContext defines the pipeline context to attach to
  32501. * @param vertexCode defines the vertex shader code to use
  32502. * @param fragmentCode defines the fragment shader code to use
  32503. * @param context defines the webGL context to use (if not set, the current one will be used)
  32504. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32505. * @returns the new webGL program
  32506. */
  32507. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32508. /**
  32509. * Creates a webGL program
  32510. * @param pipelineContext defines the pipeline context to attach to
  32511. * @param vertexCode defines the vertex shader code to use
  32512. * @param fragmentCode defines the fragment shader code to use
  32513. * @param defines defines the string containing the defines to use to compile the shaders
  32514. * @param context defines the webGL context to use (if not set, the current one will be used)
  32515. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32516. * @returns the new webGL program
  32517. */
  32518. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32519. /**
  32520. * Creates a new pipeline context
  32521. * @returns the new pipeline
  32522. */
  32523. createPipelineContext(): IPipelineContext;
  32524. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32525. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32526. /** @hidden */
  32527. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32528. /** @hidden */
  32529. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32530. /** @hidden */
  32531. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32532. /**
  32533. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32534. * @param pipelineContext defines the pipeline context to use
  32535. * @param uniformsNames defines the list of uniform names
  32536. * @returns an array of webGL uniform locations
  32537. */
  32538. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32539. /**
  32540. * Gets the lsit of active attributes for a given webGL program
  32541. * @param pipelineContext defines the pipeline context to use
  32542. * @param attributesNames defines the list of attribute names to get
  32543. * @returns an array of indices indicating the offset of each attribute
  32544. */
  32545. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32546. /**
  32547. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32548. * @param effect defines the effect to activate
  32549. */
  32550. enableEffect(effect: Nullable<Effect>): void;
  32551. /**
  32552. * Set the value of an uniform to a number (int)
  32553. * @param uniform defines the webGL uniform location where to store the value
  32554. * @param value defines the int number to store
  32555. */
  32556. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32557. /**
  32558. * Set the value of an uniform to an array of int32
  32559. * @param uniform defines the webGL uniform location where to store the value
  32560. * @param array defines the array of int32 to store
  32561. */
  32562. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32563. /**
  32564. * Set the value of an uniform to an array of int32 (stored as vec2)
  32565. * @param uniform defines the webGL uniform location where to store the value
  32566. * @param array defines the array of int32 to store
  32567. */
  32568. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32569. /**
  32570. * Set the value of an uniform to an array of int32 (stored as vec3)
  32571. * @param uniform defines the webGL uniform location where to store the value
  32572. * @param array defines the array of int32 to store
  32573. */
  32574. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32575. /**
  32576. * Set the value of an uniform to an array of int32 (stored as vec4)
  32577. * @param uniform defines the webGL uniform location where to store the value
  32578. * @param array defines the array of int32 to store
  32579. */
  32580. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32581. /**
  32582. * Set the value of an uniform to an array of number
  32583. * @param uniform defines the webGL uniform location where to store the value
  32584. * @param array defines the array of number to store
  32585. */
  32586. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32587. /**
  32588. * Set the value of an uniform to an array of number (stored as vec2)
  32589. * @param uniform defines the webGL uniform location where to store the value
  32590. * @param array defines the array of number to store
  32591. */
  32592. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32593. /**
  32594. * Set the value of an uniform to an array of number (stored as vec3)
  32595. * @param uniform defines the webGL uniform location where to store the value
  32596. * @param array defines the array of number to store
  32597. */
  32598. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32599. /**
  32600. * Set the value of an uniform to an array of number (stored as vec4)
  32601. * @param uniform defines the webGL uniform location where to store the value
  32602. * @param array defines the array of number to store
  32603. */
  32604. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32605. /**
  32606. * Set the value of an uniform to an array of float32 (stored as matrices)
  32607. * @param uniform defines the webGL uniform location where to store the value
  32608. * @param matrices defines the array of float32 to store
  32609. */
  32610. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32611. /**
  32612. * Set the value of an uniform to a matrix (3x3)
  32613. * @param uniform defines the webGL uniform location where to store the value
  32614. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32615. */
  32616. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32617. /**
  32618. * Set the value of an uniform to a matrix (2x2)
  32619. * @param uniform defines the webGL uniform location where to store the value
  32620. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32621. */
  32622. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32623. /**
  32624. * Set the value of an uniform to a number (float)
  32625. * @param uniform defines the webGL uniform location where to store the value
  32626. * @param value defines the float number to store
  32627. */
  32628. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32629. /**
  32630. * Set the value of an uniform to a vec2
  32631. * @param uniform defines the webGL uniform location where to store the value
  32632. * @param x defines the 1st component of the value
  32633. * @param y defines the 2nd component of the value
  32634. */
  32635. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32636. /**
  32637. * Set the value of an uniform to a vec3
  32638. * @param uniform defines the webGL uniform location where to store the value
  32639. * @param x defines the 1st component of the value
  32640. * @param y defines the 2nd component of the value
  32641. * @param z defines the 3rd component of the value
  32642. */
  32643. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32644. /**
  32645. * Set the value of an uniform to a vec4
  32646. * @param uniform defines the webGL uniform location where to store the value
  32647. * @param x defines the 1st component of the value
  32648. * @param y defines the 2nd component of the value
  32649. * @param z defines the 3rd component of the value
  32650. * @param w defines the 4th component of the value
  32651. */
  32652. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32653. /**
  32654. * Apply all cached states (depth, culling, stencil and alpha)
  32655. */
  32656. applyStates(): void;
  32657. /**
  32658. * Enable or disable color writing
  32659. * @param enable defines the state to set
  32660. */
  32661. setColorWrite(enable: boolean): void;
  32662. /**
  32663. * Gets a boolean indicating if color writing is enabled
  32664. * @returns the current color writing state
  32665. */
  32666. getColorWrite(): boolean;
  32667. /**
  32668. * Gets the depth culling state manager
  32669. */
  32670. get depthCullingState(): DepthCullingState;
  32671. /**
  32672. * Gets the alpha state manager
  32673. */
  32674. get alphaState(): AlphaState;
  32675. /**
  32676. * Gets the stencil state manager
  32677. */
  32678. get stencilState(): StencilState;
  32679. /**
  32680. * Clears the list of texture accessible through engine.
  32681. * This can help preventing texture load conflict due to name collision.
  32682. */
  32683. clearInternalTexturesCache(): void;
  32684. /**
  32685. * Force the entire cache to be cleared
  32686. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32687. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32688. */
  32689. wipeCaches(bruteForce?: boolean): void;
  32690. /** @hidden */
  32691. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32692. min: number;
  32693. mag: number;
  32694. };
  32695. /** @hidden */
  32696. _createTexture(): WebGLTexture;
  32697. /**
  32698. * Usually called from Texture.ts.
  32699. * Passed information to create a WebGLTexture
  32700. * @param urlArg defines a value which contains one of the following:
  32701. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32702. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32703. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32704. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32705. * @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)
  32706. * @param scene needed for loading to the correct scene
  32707. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32708. * @param onLoad optional callback to be called upon successful completion
  32709. * @param onError optional callback to be called upon failure
  32710. * @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
  32711. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32712. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32713. * @param forcedExtension defines the extension to use to pick the right loader
  32714. * @param mimeType defines an optional mime type
  32715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32716. */
  32717. 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;
  32718. /**
  32719. * Loads an image as an HTMLImageElement.
  32720. * @param input url string, ArrayBuffer, or Blob to load
  32721. * @param onLoad callback called when the image successfully loads
  32722. * @param onError callback called when the image fails to load
  32723. * @param offlineProvider offline provider for caching
  32724. * @param mimeType optional mime type
  32725. * @returns the HTMLImageElement of the loaded image
  32726. * @hidden
  32727. */
  32728. 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>;
  32729. /**
  32730. * @hidden
  32731. */
  32732. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32733. /**
  32734. * Creates a raw texture
  32735. * @param data defines the data to store in the texture
  32736. * @param width defines the width of the texture
  32737. * @param height defines the height of the texture
  32738. * @param format defines the format of the data
  32739. * @param generateMipMaps defines if the engine should generate the mip levels
  32740. * @param invertY defines if data must be stored with Y axis inverted
  32741. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32742. * @param compression defines the compression used (null by default)
  32743. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32744. * @returns the raw texture inside an InternalTexture
  32745. */
  32746. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32747. /**
  32748. * Creates a new raw cube texture
  32749. * @param data defines the array of data to use to create each face
  32750. * @param size defines the size of the textures
  32751. * @param format defines the format of the data
  32752. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32753. * @param generateMipMaps defines if the engine should generate the mip levels
  32754. * @param invertY defines if data must be stored with Y axis inverted
  32755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32756. * @param compression defines the compression used (null by default)
  32757. * @returns the cube texture as an InternalTexture
  32758. */
  32759. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32760. /**
  32761. * Creates a new raw 3D texture
  32762. * @param data defines the data used to create the texture
  32763. * @param width defines the width of the texture
  32764. * @param height defines the height of the texture
  32765. * @param depth defines the depth of the texture
  32766. * @param format defines the format of the texture
  32767. * @param generateMipMaps defines if the engine must generate mip levels
  32768. * @param invertY defines if data must be stored with Y axis inverted
  32769. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32770. * @param compression defines the compressed used (can be null)
  32771. * @param textureType defines the compressed used (can be null)
  32772. * @returns a new raw 3D texture (stored in an InternalTexture)
  32773. */
  32774. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32775. /**
  32776. * Creates a new raw 2D array texture
  32777. * @param data defines the data used to create the texture
  32778. * @param width defines the width of the texture
  32779. * @param height defines the height of the texture
  32780. * @param depth defines the number of layers of the texture
  32781. * @param format defines the format of the texture
  32782. * @param generateMipMaps defines if the engine must generate mip levels
  32783. * @param invertY defines if data must be stored with Y axis inverted
  32784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32785. * @param compression defines the compressed used (can be null)
  32786. * @param textureType defines the compressed used (can be null)
  32787. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32788. */
  32789. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32790. private _unpackFlipYCached;
  32791. /**
  32792. * In case you are sharing the context with other applications, it might
  32793. * be interested to not cache the unpack flip y state to ensure a consistent
  32794. * value would be set.
  32795. */
  32796. enableUnpackFlipYCached: boolean;
  32797. /** @hidden */
  32798. _unpackFlipY(value: boolean): void;
  32799. /** @hidden */
  32800. _getUnpackAlignement(): number;
  32801. private _getTextureTarget;
  32802. /**
  32803. * Update the sampling mode of a given texture
  32804. * @param samplingMode defines the required sampling mode
  32805. * @param texture defines the texture to update
  32806. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32807. */
  32808. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32809. /**
  32810. * Update the sampling mode of a given texture
  32811. * @param texture defines the texture to update
  32812. * @param wrapU defines the texture wrap mode of the u coordinates
  32813. * @param wrapV defines the texture wrap mode of the v coordinates
  32814. * @param wrapR defines the texture wrap mode of the r coordinates
  32815. */
  32816. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32817. /** @hidden */
  32818. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32819. width: number;
  32820. height: number;
  32821. layers?: number;
  32822. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32823. /** @hidden */
  32824. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32825. /** @hidden */
  32826. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32827. /**
  32828. * Update a portion of an internal texture
  32829. * @param texture defines the texture to update
  32830. * @param imageData defines the data to store into the texture
  32831. * @param xOffset defines the x coordinates of the update rectangle
  32832. * @param yOffset defines the y coordinates of the update rectangle
  32833. * @param width defines the width of the update rectangle
  32834. * @param height defines the height of the update rectangle
  32835. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32836. * @param lod defines the lod level to update (0 by default)
  32837. */
  32838. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32839. /** @hidden */
  32840. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32841. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32842. private _prepareWebGLTexture;
  32843. /** @hidden */
  32844. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32845. private _getDepthStencilBuffer;
  32846. /** @hidden */
  32847. _releaseFramebufferObjects(texture: InternalTexture): void;
  32848. /** @hidden */
  32849. _releaseTexture(texture: InternalTexture): void;
  32850. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32851. protected _setProgram(program: WebGLProgram): void;
  32852. protected _boundUniforms: {
  32853. [key: number]: WebGLUniformLocation;
  32854. };
  32855. /**
  32856. * Binds an effect to the webGL context
  32857. * @param effect defines the effect to bind
  32858. */
  32859. bindSamplers(effect: Effect): void;
  32860. private _activateCurrentTexture;
  32861. /** @hidden */
  32862. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32863. /** @hidden */
  32864. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32865. /**
  32866. * Unbind all textures from the webGL context
  32867. */
  32868. unbindAllTextures(): void;
  32869. /**
  32870. * Sets a texture to the according uniform.
  32871. * @param channel The texture channel
  32872. * @param uniform The uniform to set
  32873. * @param texture The texture to apply
  32874. */
  32875. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32876. private _bindSamplerUniformToChannel;
  32877. private _getTextureWrapMode;
  32878. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32879. /**
  32880. * Sets an array of texture to the webGL context
  32881. * @param channel defines the channel where the texture array must be set
  32882. * @param uniform defines the associated uniform location
  32883. * @param textures defines the array of textures to bind
  32884. */
  32885. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32886. /** @hidden */
  32887. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32888. private _setTextureParameterFloat;
  32889. private _setTextureParameterInteger;
  32890. /**
  32891. * Unbind all vertex attributes from the webGL context
  32892. */
  32893. unbindAllAttributes(): void;
  32894. /**
  32895. * 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
  32896. */
  32897. releaseEffects(): void;
  32898. /**
  32899. * Dispose and release all associated resources
  32900. */
  32901. dispose(): void;
  32902. /**
  32903. * Attach a new callback raised when context lost event is fired
  32904. * @param callback defines the callback to call
  32905. */
  32906. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32907. /**
  32908. * Attach a new callback raised when context restored event is fired
  32909. * @param callback defines the callback to call
  32910. */
  32911. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32912. /**
  32913. * Get the current error code of the webGL context
  32914. * @returns the error code
  32915. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32916. */
  32917. getError(): number;
  32918. private _canRenderToFloatFramebuffer;
  32919. private _canRenderToHalfFloatFramebuffer;
  32920. private _canRenderToFramebuffer;
  32921. /** @hidden */
  32922. _getWebGLTextureType(type: number): number;
  32923. /** @hidden */
  32924. _getInternalFormat(format: number): number;
  32925. /** @hidden */
  32926. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32927. /** @hidden */
  32928. _getRGBAMultiSampleBufferFormat(type: number): number;
  32929. /** @hidden */
  32930. _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;
  32931. /**
  32932. * Loads a file from a url
  32933. * @param url url to load
  32934. * @param onSuccess callback called when the file successfully loads
  32935. * @param onProgress callback called while file is loading (if the server supports this mode)
  32936. * @param offlineProvider defines the offline provider for caching
  32937. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32938. * @param onError callback called when the file fails to load
  32939. * @returns a file request object
  32940. * @hidden
  32941. */
  32942. 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;
  32943. /**
  32944. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32945. * @param x defines the x coordinate of the rectangle where pixels must be read
  32946. * @param y defines the y coordinate of the rectangle where pixels must be read
  32947. * @param width defines the width of the rectangle where pixels must be read
  32948. * @param height defines the height of the rectangle where pixels must be read
  32949. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32950. * @returns a Uint8Array containing RGBA colors
  32951. */
  32952. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32953. private static _isSupported;
  32954. /**
  32955. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32956. * @returns true if the engine can be created
  32957. * @ignorenaming
  32958. */
  32959. static isSupported(): boolean;
  32960. /**
  32961. * Find the next highest power of two.
  32962. * @param x Number to start search from.
  32963. * @return Next highest power of two.
  32964. */
  32965. static CeilingPOT(x: number): number;
  32966. /**
  32967. * Find the next lowest power of two.
  32968. * @param x Number to start search from.
  32969. * @return Next lowest power of two.
  32970. */
  32971. static FloorPOT(x: number): number;
  32972. /**
  32973. * Find the nearest power of two.
  32974. * @param x Number to start search from.
  32975. * @return Next nearest power of two.
  32976. */
  32977. static NearestPOT(x: number): number;
  32978. /**
  32979. * Get the closest exponent of two
  32980. * @param value defines the value to approximate
  32981. * @param max defines the maximum value to return
  32982. * @param mode defines how to define the closest value
  32983. * @returns closest exponent of two of the given value
  32984. */
  32985. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32986. /**
  32987. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32988. * @param func - the function to be called
  32989. * @param requester - the object that will request the next frame. Falls back to window.
  32990. * @returns frame number
  32991. */
  32992. static QueueNewFrame(func: () => void, requester?: any): number;
  32993. /**
  32994. * Gets host document
  32995. * @returns the host document object
  32996. */
  32997. getHostDocument(): Nullable<Document>;
  32998. }
  32999. }
  33000. declare module "babylonjs/Maths/sphericalPolynomial" {
  33001. import { Vector3 } from "babylonjs/Maths/math.vector";
  33002. import { Color3 } from "babylonjs/Maths/math.color";
  33003. /**
  33004. * Class representing spherical harmonics coefficients to the 3rd degree
  33005. */
  33006. export class SphericalHarmonics {
  33007. /**
  33008. * Defines whether or not the harmonics have been prescaled for rendering.
  33009. */
  33010. preScaled: boolean;
  33011. /**
  33012. * The l0,0 coefficients of the spherical harmonics
  33013. */
  33014. l00: Vector3;
  33015. /**
  33016. * The l1,-1 coefficients of the spherical harmonics
  33017. */
  33018. l1_1: Vector3;
  33019. /**
  33020. * The l1,0 coefficients of the spherical harmonics
  33021. */
  33022. l10: Vector3;
  33023. /**
  33024. * The l1,1 coefficients of the spherical harmonics
  33025. */
  33026. l11: Vector3;
  33027. /**
  33028. * The l2,-2 coefficients of the spherical harmonics
  33029. */
  33030. l2_2: Vector3;
  33031. /**
  33032. * The l2,-1 coefficients of the spherical harmonics
  33033. */
  33034. l2_1: Vector3;
  33035. /**
  33036. * The l2,0 coefficients of the spherical harmonics
  33037. */
  33038. l20: Vector3;
  33039. /**
  33040. * The l2,1 coefficients of the spherical harmonics
  33041. */
  33042. l21: Vector3;
  33043. /**
  33044. * The l2,2 coefficients of the spherical harmonics
  33045. */
  33046. l22: Vector3;
  33047. /**
  33048. * Adds a light to the spherical harmonics
  33049. * @param direction the direction of the light
  33050. * @param color the color of the light
  33051. * @param deltaSolidAngle the delta solid angle of the light
  33052. */
  33053. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33054. /**
  33055. * Scales the spherical harmonics by the given amount
  33056. * @param scale the amount to scale
  33057. */
  33058. scaleInPlace(scale: number): void;
  33059. /**
  33060. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33061. *
  33062. * ```
  33063. * E_lm = A_l * L_lm
  33064. * ```
  33065. *
  33066. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33067. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33068. * the scaling factors are given in equation 9.
  33069. */
  33070. convertIncidentRadianceToIrradiance(): void;
  33071. /**
  33072. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33073. *
  33074. * ```
  33075. * L = (1/pi) * E * rho
  33076. * ```
  33077. *
  33078. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33079. */
  33080. convertIrradianceToLambertianRadiance(): void;
  33081. /**
  33082. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33083. * required operations at run time.
  33084. *
  33085. * This is simply done by scaling back the SH with Ylm constants parameter.
  33086. * The trigonometric part being applied by the shader at run time.
  33087. */
  33088. preScaleForRendering(): void;
  33089. /**
  33090. * Constructs a spherical harmonics from an array.
  33091. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33092. * @returns the spherical harmonics
  33093. */
  33094. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33095. /**
  33096. * Gets the spherical harmonics from polynomial
  33097. * @param polynomial the spherical polynomial
  33098. * @returns the spherical harmonics
  33099. */
  33100. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33101. }
  33102. /**
  33103. * Class representing spherical polynomial coefficients to the 3rd degree
  33104. */
  33105. export class SphericalPolynomial {
  33106. private _harmonics;
  33107. /**
  33108. * The spherical harmonics used to create the polynomials.
  33109. */
  33110. get preScaledHarmonics(): SphericalHarmonics;
  33111. /**
  33112. * The x coefficients of the spherical polynomial
  33113. */
  33114. x: Vector3;
  33115. /**
  33116. * The y coefficients of the spherical polynomial
  33117. */
  33118. y: Vector3;
  33119. /**
  33120. * The z coefficients of the spherical polynomial
  33121. */
  33122. z: Vector3;
  33123. /**
  33124. * The xx coefficients of the spherical polynomial
  33125. */
  33126. xx: Vector3;
  33127. /**
  33128. * The yy coefficients of the spherical polynomial
  33129. */
  33130. yy: Vector3;
  33131. /**
  33132. * The zz coefficients of the spherical polynomial
  33133. */
  33134. zz: Vector3;
  33135. /**
  33136. * The xy coefficients of the spherical polynomial
  33137. */
  33138. xy: Vector3;
  33139. /**
  33140. * The yz coefficients of the spherical polynomial
  33141. */
  33142. yz: Vector3;
  33143. /**
  33144. * The zx coefficients of the spherical polynomial
  33145. */
  33146. zx: Vector3;
  33147. /**
  33148. * Adds an ambient color to the spherical polynomial
  33149. * @param color the color to add
  33150. */
  33151. addAmbient(color: Color3): void;
  33152. /**
  33153. * Scales the spherical polynomial by the given amount
  33154. * @param scale the amount to scale
  33155. */
  33156. scaleInPlace(scale: number): void;
  33157. /**
  33158. * Gets the spherical polynomial from harmonics
  33159. * @param harmonics the spherical harmonics
  33160. * @returns the spherical polynomial
  33161. */
  33162. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33163. /**
  33164. * Constructs a spherical polynomial from an array.
  33165. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33166. * @returns the spherical polynomial
  33167. */
  33168. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33169. }
  33170. }
  33171. declare module "babylonjs/Materials/Textures/internalTexture" {
  33172. import { Observable } from "babylonjs/Misc/observable";
  33173. import { Nullable, int } from "babylonjs/types";
  33174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33176. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33177. /**
  33178. * Defines the source of the internal texture
  33179. */
  33180. export enum InternalTextureSource {
  33181. /**
  33182. * The source of the texture data is unknown
  33183. */
  33184. Unknown = 0,
  33185. /**
  33186. * Texture data comes from an URL
  33187. */
  33188. Url = 1,
  33189. /**
  33190. * Texture data is only used for temporary storage
  33191. */
  33192. Temp = 2,
  33193. /**
  33194. * Texture data comes from raw data (ArrayBuffer)
  33195. */
  33196. Raw = 3,
  33197. /**
  33198. * Texture content is dynamic (video or dynamic texture)
  33199. */
  33200. Dynamic = 4,
  33201. /**
  33202. * Texture content is generated by rendering to it
  33203. */
  33204. RenderTarget = 5,
  33205. /**
  33206. * Texture content is part of a multi render target process
  33207. */
  33208. MultiRenderTarget = 6,
  33209. /**
  33210. * Texture data comes from a cube data file
  33211. */
  33212. Cube = 7,
  33213. /**
  33214. * Texture data comes from a raw cube data
  33215. */
  33216. CubeRaw = 8,
  33217. /**
  33218. * Texture data come from a prefiltered cube data file
  33219. */
  33220. CubePrefiltered = 9,
  33221. /**
  33222. * Texture content is raw 3D data
  33223. */
  33224. Raw3D = 10,
  33225. /**
  33226. * Texture content is raw 2D array data
  33227. */
  33228. Raw2DArray = 11,
  33229. /**
  33230. * Texture content is a depth texture
  33231. */
  33232. Depth = 12,
  33233. /**
  33234. * Texture data comes from a raw cube data encoded with RGBD
  33235. */
  33236. CubeRawRGBD = 13
  33237. }
  33238. /**
  33239. * Class used to store data associated with WebGL texture data for the engine
  33240. * This class should not be used directly
  33241. */
  33242. export class InternalTexture {
  33243. /** @hidden */
  33244. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33245. /**
  33246. * Defines if the texture is ready
  33247. */
  33248. isReady: boolean;
  33249. /**
  33250. * Defines if the texture is a cube texture
  33251. */
  33252. isCube: boolean;
  33253. /**
  33254. * Defines if the texture contains 3D data
  33255. */
  33256. is3D: boolean;
  33257. /**
  33258. * Defines if the texture contains 2D array data
  33259. */
  33260. is2DArray: boolean;
  33261. /**
  33262. * Defines if the texture contains multiview data
  33263. */
  33264. isMultiview: boolean;
  33265. /**
  33266. * Gets the URL used to load this texture
  33267. */
  33268. url: string;
  33269. /**
  33270. * Gets the sampling mode of the texture
  33271. */
  33272. samplingMode: number;
  33273. /**
  33274. * Gets a boolean indicating if the texture needs mipmaps generation
  33275. */
  33276. generateMipMaps: boolean;
  33277. /**
  33278. * Gets the number of samples used by the texture (WebGL2+ only)
  33279. */
  33280. samples: number;
  33281. /**
  33282. * Gets the type of the texture (int, float...)
  33283. */
  33284. type: number;
  33285. /**
  33286. * Gets the format of the texture (RGB, RGBA...)
  33287. */
  33288. format: number;
  33289. /**
  33290. * Observable called when the texture is loaded
  33291. */
  33292. onLoadedObservable: Observable<InternalTexture>;
  33293. /**
  33294. * Gets the width of the texture
  33295. */
  33296. width: number;
  33297. /**
  33298. * Gets the height of the texture
  33299. */
  33300. height: number;
  33301. /**
  33302. * Gets the depth of the texture
  33303. */
  33304. depth: number;
  33305. /**
  33306. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33307. */
  33308. baseWidth: number;
  33309. /**
  33310. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33311. */
  33312. baseHeight: number;
  33313. /**
  33314. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33315. */
  33316. baseDepth: number;
  33317. /**
  33318. * Gets a boolean indicating if the texture is inverted on Y axis
  33319. */
  33320. invertY: boolean;
  33321. /** @hidden */
  33322. _invertVScale: boolean;
  33323. /** @hidden */
  33324. _associatedChannel: number;
  33325. /** @hidden */
  33326. _source: InternalTextureSource;
  33327. /** @hidden */
  33328. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33329. /** @hidden */
  33330. _bufferView: Nullable<ArrayBufferView>;
  33331. /** @hidden */
  33332. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33333. /** @hidden */
  33334. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33335. /** @hidden */
  33336. _size: number;
  33337. /** @hidden */
  33338. _extension: string;
  33339. /** @hidden */
  33340. _files: Nullable<string[]>;
  33341. /** @hidden */
  33342. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33343. /** @hidden */
  33344. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33345. /** @hidden */
  33346. _framebuffer: Nullable<WebGLFramebuffer>;
  33347. /** @hidden */
  33348. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33349. /** @hidden */
  33350. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33351. /** @hidden */
  33352. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33353. /** @hidden */
  33354. _attachments: Nullable<number[]>;
  33355. /** @hidden */
  33356. _cachedCoordinatesMode: Nullable<number>;
  33357. /** @hidden */
  33358. _cachedWrapU: Nullable<number>;
  33359. /** @hidden */
  33360. _cachedWrapV: Nullable<number>;
  33361. /** @hidden */
  33362. _cachedWrapR: Nullable<number>;
  33363. /** @hidden */
  33364. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33365. /** @hidden */
  33366. _isDisabled: boolean;
  33367. /** @hidden */
  33368. _compression: Nullable<string>;
  33369. /** @hidden */
  33370. _generateStencilBuffer: boolean;
  33371. /** @hidden */
  33372. _generateDepthBuffer: boolean;
  33373. /** @hidden */
  33374. _comparisonFunction: number;
  33375. /** @hidden */
  33376. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33377. /** @hidden */
  33378. _lodGenerationScale: number;
  33379. /** @hidden */
  33380. _lodGenerationOffset: number;
  33381. /** @hidden */
  33382. _depthStencilTexture: Nullable<InternalTexture>;
  33383. /** @hidden */
  33384. _colorTextureArray: Nullable<WebGLTexture>;
  33385. /** @hidden */
  33386. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33387. /** @hidden */
  33388. _lodTextureHigh: Nullable<BaseTexture>;
  33389. /** @hidden */
  33390. _lodTextureMid: Nullable<BaseTexture>;
  33391. /** @hidden */
  33392. _lodTextureLow: Nullable<BaseTexture>;
  33393. /** @hidden */
  33394. _isRGBD: boolean;
  33395. /** @hidden */
  33396. _linearSpecularLOD: boolean;
  33397. /** @hidden */
  33398. _irradianceTexture: Nullable<BaseTexture>;
  33399. /** @hidden */
  33400. _webGLTexture: Nullable<WebGLTexture>;
  33401. /** @hidden */
  33402. _references: number;
  33403. private _engine;
  33404. /**
  33405. * Gets the Engine the texture belongs to.
  33406. * @returns The babylon engine
  33407. */
  33408. getEngine(): ThinEngine;
  33409. /**
  33410. * Gets the data source type of the texture
  33411. */
  33412. get source(): InternalTextureSource;
  33413. /**
  33414. * Creates a new InternalTexture
  33415. * @param engine defines the engine to use
  33416. * @param source defines the type of data that will be used
  33417. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33418. */
  33419. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33420. /**
  33421. * Increments the number of references (ie. the number of Texture that point to it)
  33422. */
  33423. incrementReferences(): void;
  33424. /**
  33425. * Change the size of the texture (not the size of the content)
  33426. * @param width defines the new width
  33427. * @param height defines the new height
  33428. * @param depth defines the new depth (1 by default)
  33429. */
  33430. updateSize(width: int, height: int, depth?: int): void;
  33431. /** @hidden */
  33432. _rebuild(): void;
  33433. /** @hidden */
  33434. _swapAndDie(target: InternalTexture): void;
  33435. /**
  33436. * Dispose the current allocated resources
  33437. */
  33438. dispose(): void;
  33439. }
  33440. }
  33441. declare module "babylonjs/Audio/analyser" {
  33442. import { Scene } from "babylonjs/scene";
  33443. /**
  33444. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33446. */
  33447. export class Analyser {
  33448. /**
  33449. * Gets or sets the smoothing
  33450. * @ignorenaming
  33451. */
  33452. SMOOTHING: number;
  33453. /**
  33454. * Gets or sets the FFT table size
  33455. * @ignorenaming
  33456. */
  33457. FFT_SIZE: number;
  33458. /**
  33459. * Gets or sets the bar graph amplitude
  33460. * @ignorenaming
  33461. */
  33462. BARGRAPHAMPLITUDE: number;
  33463. /**
  33464. * Gets or sets the position of the debug canvas
  33465. * @ignorenaming
  33466. */
  33467. DEBUGCANVASPOS: {
  33468. x: number;
  33469. y: number;
  33470. };
  33471. /**
  33472. * Gets or sets the debug canvas size
  33473. * @ignorenaming
  33474. */
  33475. DEBUGCANVASSIZE: {
  33476. width: number;
  33477. height: number;
  33478. };
  33479. private _byteFreqs;
  33480. private _byteTime;
  33481. private _floatFreqs;
  33482. private _webAudioAnalyser;
  33483. private _debugCanvas;
  33484. private _debugCanvasContext;
  33485. private _scene;
  33486. private _registerFunc;
  33487. private _audioEngine;
  33488. /**
  33489. * Creates a new analyser
  33490. * @param scene defines hosting scene
  33491. */
  33492. constructor(scene: Scene);
  33493. /**
  33494. * Get the number of data values you will have to play with for the visualization
  33495. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33496. * @returns a number
  33497. */
  33498. getFrequencyBinCount(): number;
  33499. /**
  33500. * Gets the current frequency data as a byte array
  33501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33502. * @returns a Uint8Array
  33503. */
  33504. getByteFrequencyData(): Uint8Array;
  33505. /**
  33506. * Gets the current waveform as a byte array
  33507. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33508. * @returns a Uint8Array
  33509. */
  33510. getByteTimeDomainData(): Uint8Array;
  33511. /**
  33512. * Gets the current frequency data as a float array
  33513. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33514. * @returns a Float32Array
  33515. */
  33516. getFloatFrequencyData(): Float32Array;
  33517. /**
  33518. * Renders the debug canvas
  33519. */
  33520. drawDebugCanvas(): void;
  33521. /**
  33522. * Stops rendering the debug canvas and removes it
  33523. */
  33524. stopDebugCanvas(): void;
  33525. /**
  33526. * Connects two audio nodes
  33527. * @param inputAudioNode defines first node to connect
  33528. * @param outputAudioNode defines second node to connect
  33529. */
  33530. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33531. /**
  33532. * Releases all associated resources
  33533. */
  33534. dispose(): void;
  33535. }
  33536. }
  33537. declare module "babylonjs/Audio/audioEngine" {
  33538. import { IDisposable } from "babylonjs/scene";
  33539. import { Analyser } from "babylonjs/Audio/analyser";
  33540. import { Nullable } from "babylonjs/types";
  33541. import { Observable } from "babylonjs/Misc/observable";
  33542. /**
  33543. * This represents an audio engine and it is responsible
  33544. * to play, synchronize and analyse sounds throughout the application.
  33545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33546. */
  33547. export interface IAudioEngine extends IDisposable {
  33548. /**
  33549. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33550. */
  33551. readonly canUseWebAudio: boolean;
  33552. /**
  33553. * Gets the current AudioContext if available.
  33554. */
  33555. readonly audioContext: Nullable<AudioContext>;
  33556. /**
  33557. * The master gain node defines the global audio volume of your audio engine.
  33558. */
  33559. readonly masterGain: GainNode;
  33560. /**
  33561. * Gets whether or not mp3 are supported by your browser.
  33562. */
  33563. readonly isMP3supported: boolean;
  33564. /**
  33565. * Gets whether or not ogg are supported by your browser.
  33566. */
  33567. readonly isOGGsupported: boolean;
  33568. /**
  33569. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33570. * @ignoreNaming
  33571. */
  33572. WarnedWebAudioUnsupported: boolean;
  33573. /**
  33574. * Defines if the audio engine relies on a custom unlocked button.
  33575. * In this case, the embedded button will not be displayed.
  33576. */
  33577. useCustomUnlockedButton: boolean;
  33578. /**
  33579. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33580. */
  33581. readonly unlocked: boolean;
  33582. /**
  33583. * Event raised when audio has been unlocked on the browser.
  33584. */
  33585. onAudioUnlockedObservable: Observable<AudioEngine>;
  33586. /**
  33587. * Event raised when audio has been locked on the browser.
  33588. */
  33589. onAudioLockedObservable: Observable<AudioEngine>;
  33590. /**
  33591. * Flags the audio engine in Locked state.
  33592. * This happens due to new browser policies preventing audio to autoplay.
  33593. */
  33594. lock(): void;
  33595. /**
  33596. * Unlocks the audio engine once a user action has been done on the dom.
  33597. * This is helpful to resume play once browser policies have been satisfied.
  33598. */
  33599. unlock(): void;
  33600. }
  33601. /**
  33602. * This represents the default audio engine used in babylon.
  33603. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33605. */
  33606. export class AudioEngine implements IAudioEngine {
  33607. private _audioContext;
  33608. private _audioContextInitialized;
  33609. private _muteButton;
  33610. private _hostElement;
  33611. /**
  33612. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33613. */
  33614. canUseWebAudio: boolean;
  33615. /**
  33616. * The master gain node defines the global audio volume of your audio engine.
  33617. */
  33618. masterGain: GainNode;
  33619. /**
  33620. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33621. * @ignoreNaming
  33622. */
  33623. WarnedWebAudioUnsupported: boolean;
  33624. /**
  33625. * Gets whether or not mp3 are supported by your browser.
  33626. */
  33627. isMP3supported: boolean;
  33628. /**
  33629. * Gets whether or not ogg are supported by your browser.
  33630. */
  33631. isOGGsupported: boolean;
  33632. /**
  33633. * Gets whether audio has been unlocked on the device.
  33634. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33635. * a user interaction has happened.
  33636. */
  33637. unlocked: boolean;
  33638. /**
  33639. * Defines if the audio engine relies on a custom unlocked button.
  33640. * In this case, the embedded button will not be displayed.
  33641. */
  33642. useCustomUnlockedButton: boolean;
  33643. /**
  33644. * Event raised when audio has been unlocked on the browser.
  33645. */
  33646. onAudioUnlockedObservable: Observable<AudioEngine>;
  33647. /**
  33648. * Event raised when audio has been locked on the browser.
  33649. */
  33650. onAudioLockedObservable: Observable<AudioEngine>;
  33651. /**
  33652. * Gets the current AudioContext if available.
  33653. */
  33654. get audioContext(): Nullable<AudioContext>;
  33655. private _connectedAnalyser;
  33656. /**
  33657. * Instantiates a new audio engine.
  33658. *
  33659. * There should be only one per page as some browsers restrict the number
  33660. * of audio contexts you can create.
  33661. * @param hostElement defines the host element where to display the mute icon if necessary
  33662. */
  33663. constructor(hostElement?: Nullable<HTMLElement>);
  33664. /**
  33665. * Flags the audio engine in Locked state.
  33666. * This happens due to new browser policies preventing audio to autoplay.
  33667. */
  33668. lock(): void;
  33669. /**
  33670. * Unlocks the audio engine once a user action has been done on the dom.
  33671. * This is helpful to resume play once browser policies have been satisfied.
  33672. */
  33673. unlock(): void;
  33674. private _resumeAudioContext;
  33675. private _initializeAudioContext;
  33676. private _tryToRun;
  33677. private _triggerRunningState;
  33678. private _triggerSuspendedState;
  33679. private _displayMuteButton;
  33680. private _moveButtonToTopLeft;
  33681. private _onResize;
  33682. private _hideMuteButton;
  33683. /**
  33684. * Destroy and release the resources associated with the audio ccontext.
  33685. */
  33686. dispose(): void;
  33687. /**
  33688. * Gets the global volume sets on the master gain.
  33689. * @returns the global volume if set or -1 otherwise
  33690. */
  33691. getGlobalVolume(): number;
  33692. /**
  33693. * Sets the global volume of your experience (sets on the master gain).
  33694. * @param newVolume Defines the new global volume of the application
  33695. */
  33696. setGlobalVolume(newVolume: number): void;
  33697. /**
  33698. * Connect the audio engine to an audio analyser allowing some amazing
  33699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33701. * @param analyser The analyser to connect to the engine
  33702. */
  33703. connectToAnalyser(analyser: Analyser): void;
  33704. }
  33705. }
  33706. declare module "babylonjs/Loading/loadingScreen" {
  33707. /**
  33708. * Interface used to present a loading screen while loading a scene
  33709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33710. */
  33711. export interface ILoadingScreen {
  33712. /**
  33713. * Function called to display the loading screen
  33714. */
  33715. displayLoadingUI: () => void;
  33716. /**
  33717. * Function called to hide the loading screen
  33718. */
  33719. hideLoadingUI: () => void;
  33720. /**
  33721. * Gets or sets the color to use for the background
  33722. */
  33723. loadingUIBackgroundColor: string;
  33724. /**
  33725. * Gets or sets the text to display while loading
  33726. */
  33727. loadingUIText: string;
  33728. }
  33729. /**
  33730. * Class used for the default loading screen
  33731. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33732. */
  33733. export class DefaultLoadingScreen implements ILoadingScreen {
  33734. private _renderingCanvas;
  33735. private _loadingText;
  33736. private _loadingDivBackgroundColor;
  33737. private _loadingDiv;
  33738. private _loadingTextDiv;
  33739. /** Gets or sets the logo url to use for the default loading screen */
  33740. static DefaultLogoUrl: string;
  33741. /** Gets or sets the spinner url to use for the default loading screen */
  33742. static DefaultSpinnerUrl: string;
  33743. /**
  33744. * Creates a new default loading screen
  33745. * @param _renderingCanvas defines the canvas used to render the scene
  33746. * @param _loadingText defines the default text to display
  33747. * @param _loadingDivBackgroundColor defines the default background color
  33748. */
  33749. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33750. /**
  33751. * Function called to display the loading screen
  33752. */
  33753. displayLoadingUI(): void;
  33754. /**
  33755. * Function called to hide the loading screen
  33756. */
  33757. hideLoadingUI(): void;
  33758. /**
  33759. * Gets or sets the text to display while loading
  33760. */
  33761. set loadingUIText(text: string);
  33762. get loadingUIText(): string;
  33763. /**
  33764. * Gets or sets the color to use for the background
  33765. */
  33766. get loadingUIBackgroundColor(): string;
  33767. set loadingUIBackgroundColor(color: string);
  33768. private _resizeLoadingUI;
  33769. }
  33770. }
  33771. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33772. /**
  33773. * Interface for any object that can request an animation frame
  33774. */
  33775. export interface ICustomAnimationFrameRequester {
  33776. /**
  33777. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33778. */
  33779. renderFunction?: Function;
  33780. /**
  33781. * Called to request the next frame to render to
  33782. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33783. */
  33784. requestAnimationFrame: Function;
  33785. /**
  33786. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33787. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33788. */
  33789. requestID?: number;
  33790. }
  33791. }
  33792. declare module "babylonjs/Misc/performanceMonitor" {
  33793. /**
  33794. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33795. */
  33796. export class PerformanceMonitor {
  33797. private _enabled;
  33798. private _rollingFrameTime;
  33799. private _lastFrameTimeMs;
  33800. /**
  33801. * constructor
  33802. * @param frameSampleSize The number of samples required to saturate the sliding window
  33803. */
  33804. constructor(frameSampleSize?: number);
  33805. /**
  33806. * Samples current frame
  33807. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33808. */
  33809. sampleFrame(timeMs?: number): void;
  33810. /**
  33811. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33812. */
  33813. get averageFrameTime(): number;
  33814. /**
  33815. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33816. */
  33817. get averageFrameTimeVariance(): number;
  33818. /**
  33819. * Returns the frame time of the most recent frame
  33820. */
  33821. get instantaneousFrameTime(): number;
  33822. /**
  33823. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33824. */
  33825. get averageFPS(): number;
  33826. /**
  33827. * Returns the average framerate in frames per second using the most recent frame time
  33828. */
  33829. get instantaneousFPS(): number;
  33830. /**
  33831. * Returns true if enough samples have been taken to completely fill the sliding window
  33832. */
  33833. get isSaturated(): boolean;
  33834. /**
  33835. * Enables contributions to the sliding window sample set
  33836. */
  33837. enable(): void;
  33838. /**
  33839. * Disables contributions to the sliding window sample set
  33840. * Samples will not be interpolated over the disabled period
  33841. */
  33842. disable(): void;
  33843. /**
  33844. * Returns true if sampling is enabled
  33845. */
  33846. get isEnabled(): boolean;
  33847. /**
  33848. * Resets performance monitor
  33849. */
  33850. reset(): void;
  33851. }
  33852. /**
  33853. * RollingAverage
  33854. *
  33855. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33856. */
  33857. export class RollingAverage {
  33858. /**
  33859. * Current average
  33860. */
  33861. average: number;
  33862. /**
  33863. * Current variance
  33864. */
  33865. variance: number;
  33866. protected _samples: Array<number>;
  33867. protected _sampleCount: number;
  33868. protected _pos: number;
  33869. protected _m2: number;
  33870. /**
  33871. * constructor
  33872. * @param length The number of samples required to saturate the sliding window
  33873. */
  33874. constructor(length: number);
  33875. /**
  33876. * Adds a sample to the sample set
  33877. * @param v The sample value
  33878. */
  33879. add(v: number): void;
  33880. /**
  33881. * Returns previously added values or null if outside of history or outside the sliding window domain
  33882. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33883. * @return Value previously recorded with add() or null if outside of range
  33884. */
  33885. history(i: number): number;
  33886. /**
  33887. * Returns true if enough samples have been taken to completely fill the sliding window
  33888. * @return true if sample-set saturated
  33889. */
  33890. isSaturated(): boolean;
  33891. /**
  33892. * Resets the rolling average (equivalent to 0 samples taken so far)
  33893. */
  33894. reset(): void;
  33895. /**
  33896. * Wraps a value around the sample range boundaries
  33897. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33898. * @return Wrapped position in sample range
  33899. */
  33900. protected _wrapPosition(i: number): number;
  33901. }
  33902. }
  33903. declare module "babylonjs/Misc/perfCounter" {
  33904. /**
  33905. * This class is used to track a performance counter which is number based.
  33906. * The user has access to many properties which give statistics of different nature.
  33907. *
  33908. * The implementer can track two kinds of Performance Counter: time and count.
  33909. * 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.
  33910. * 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.
  33911. */
  33912. export class PerfCounter {
  33913. /**
  33914. * Gets or sets a global boolean to turn on and off all the counters
  33915. */
  33916. static Enabled: boolean;
  33917. /**
  33918. * Returns the smallest value ever
  33919. */
  33920. get min(): number;
  33921. /**
  33922. * Returns the biggest value ever
  33923. */
  33924. get max(): number;
  33925. /**
  33926. * Returns the average value since the performance counter is running
  33927. */
  33928. get average(): number;
  33929. /**
  33930. * Returns the average value of the last second the counter was monitored
  33931. */
  33932. get lastSecAverage(): number;
  33933. /**
  33934. * Returns the current value
  33935. */
  33936. get current(): number;
  33937. /**
  33938. * Gets the accumulated total
  33939. */
  33940. get total(): number;
  33941. /**
  33942. * Gets the total value count
  33943. */
  33944. get count(): number;
  33945. /**
  33946. * Creates a new counter
  33947. */
  33948. constructor();
  33949. /**
  33950. * Call this method to start monitoring a new frame.
  33951. * 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.
  33952. */
  33953. fetchNewFrame(): void;
  33954. /**
  33955. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33956. * @param newCount the count value to add to the monitored count
  33957. * @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.
  33958. */
  33959. addCount(newCount: number, fetchResult: boolean): void;
  33960. /**
  33961. * Start monitoring this performance counter
  33962. */
  33963. beginMonitoring(): void;
  33964. /**
  33965. * Compute the time lapsed since the previous beginMonitoring() call.
  33966. * @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
  33967. */
  33968. endMonitoring(newFrame?: boolean): void;
  33969. private _fetchResult;
  33970. private _startMonitoringTime;
  33971. private _min;
  33972. private _max;
  33973. private _average;
  33974. private _current;
  33975. private _totalValueCount;
  33976. private _totalAccumulated;
  33977. private _lastSecAverage;
  33978. private _lastSecAccumulated;
  33979. private _lastSecTime;
  33980. private _lastSecValueCount;
  33981. }
  33982. }
  33983. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33984. module "babylonjs/Engines/thinEngine" {
  33985. interface ThinEngine {
  33986. /**
  33987. * Sets alpha constants used by some alpha blending modes
  33988. * @param r defines the red component
  33989. * @param g defines the green component
  33990. * @param b defines the blue component
  33991. * @param a defines the alpha component
  33992. */
  33993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33994. /**
  33995. * Sets the current alpha mode
  33996. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33999. */
  34000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34001. /**
  34002. * Gets the current alpha mode
  34003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34004. * @returns the current alpha mode
  34005. */
  34006. getAlphaMode(): number;
  34007. /**
  34008. * Sets the current alpha equation
  34009. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34010. */
  34011. setAlphaEquation(equation: number): void;
  34012. /**
  34013. * Gets the current alpha equation.
  34014. * @returns the current alpha equation
  34015. */
  34016. getAlphaEquation(): number;
  34017. }
  34018. }
  34019. }
  34020. declare module "babylonjs/Engines/engine" {
  34021. import { Observable } from "babylonjs/Misc/observable";
  34022. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34023. import { Scene } from "babylonjs/scene";
  34024. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34025. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34026. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34027. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34028. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34029. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34030. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34031. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34032. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34034. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34035. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34036. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34037. import "babylonjs/Engines/Extensions/engine.alpha";
  34038. import { Material } from "babylonjs/Materials/material";
  34039. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34040. /**
  34041. * Defines the interface used by display changed events
  34042. */
  34043. export interface IDisplayChangedEventArgs {
  34044. /** Gets the vrDisplay object (if any) */
  34045. vrDisplay: Nullable<any>;
  34046. /** Gets a boolean indicating if webVR is supported */
  34047. vrSupported: boolean;
  34048. }
  34049. /**
  34050. * Defines the interface used by objects containing a viewport (like a camera)
  34051. */
  34052. interface IViewportOwnerLike {
  34053. /**
  34054. * Gets or sets the viewport
  34055. */
  34056. viewport: IViewportLike;
  34057. }
  34058. /**
  34059. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34060. */
  34061. export class Engine extends ThinEngine {
  34062. /** Defines that alpha blending is disabled */
  34063. static readonly ALPHA_DISABLE: number;
  34064. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34065. static readonly ALPHA_ADD: number;
  34066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34067. static readonly ALPHA_COMBINE: number;
  34068. /** Defines that alpha blending to DEST - SRC * DEST */
  34069. static readonly ALPHA_SUBTRACT: number;
  34070. /** Defines that alpha blending to SRC * DEST */
  34071. static readonly ALPHA_MULTIPLY: number;
  34072. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34073. static readonly ALPHA_MAXIMIZED: number;
  34074. /** Defines that alpha blending to SRC + DEST */
  34075. static readonly ALPHA_ONEONE: number;
  34076. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34077. static readonly ALPHA_PREMULTIPLIED: number;
  34078. /**
  34079. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34080. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34081. */
  34082. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34083. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34084. static readonly ALPHA_INTERPOLATE: number;
  34085. /**
  34086. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34087. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34088. */
  34089. static readonly ALPHA_SCREENMODE: number;
  34090. /** Defines that the ressource is not delayed*/
  34091. static readonly DELAYLOADSTATE_NONE: number;
  34092. /** Defines that the ressource was successfully delay loaded */
  34093. static readonly DELAYLOADSTATE_LOADED: number;
  34094. /** Defines that the ressource is currently delay loading */
  34095. static readonly DELAYLOADSTATE_LOADING: number;
  34096. /** Defines that the ressource is delayed and has not started loading */
  34097. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34099. static readonly NEVER: number;
  34100. /** 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 */
  34101. static readonly ALWAYS: number;
  34102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34103. static readonly LESS: number;
  34104. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34105. static readonly EQUAL: number;
  34106. /** 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 */
  34107. static readonly LEQUAL: number;
  34108. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34109. static readonly GREATER: number;
  34110. /** 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 */
  34111. static readonly GEQUAL: number;
  34112. /** 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 */
  34113. static readonly NOTEQUAL: number;
  34114. /** Passed to stencilOperation to specify that stencil value must be kept */
  34115. static readonly KEEP: number;
  34116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34117. static readonly REPLACE: number;
  34118. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34119. static readonly INCR: number;
  34120. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34121. static readonly DECR: number;
  34122. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34123. static readonly INVERT: number;
  34124. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34125. static readonly INCR_WRAP: number;
  34126. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34127. static readonly DECR_WRAP: number;
  34128. /** Texture is not repeating outside of 0..1 UVs */
  34129. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34130. /** Texture is repeating outside of 0..1 UVs */
  34131. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34132. /** Texture is repeating and mirrored */
  34133. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34134. /** ALPHA */
  34135. static readonly TEXTUREFORMAT_ALPHA: number;
  34136. /** LUMINANCE */
  34137. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34138. /** LUMINANCE_ALPHA */
  34139. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34140. /** RGB */
  34141. static readonly TEXTUREFORMAT_RGB: number;
  34142. /** RGBA */
  34143. static readonly TEXTUREFORMAT_RGBA: number;
  34144. /** RED */
  34145. static readonly TEXTUREFORMAT_RED: number;
  34146. /** RED (2nd reference) */
  34147. static readonly TEXTUREFORMAT_R: number;
  34148. /** RG */
  34149. static readonly TEXTUREFORMAT_RG: number;
  34150. /** RED_INTEGER */
  34151. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34152. /** RED_INTEGER (2nd reference) */
  34153. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34154. /** RG_INTEGER */
  34155. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34156. /** RGB_INTEGER */
  34157. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34158. /** RGBA_INTEGER */
  34159. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34160. /** UNSIGNED_BYTE */
  34161. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34162. /** UNSIGNED_BYTE (2nd reference) */
  34163. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34164. /** FLOAT */
  34165. static readonly TEXTURETYPE_FLOAT: number;
  34166. /** HALF_FLOAT */
  34167. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34168. /** BYTE */
  34169. static readonly TEXTURETYPE_BYTE: number;
  34170. /** SHORT */
  34171. static readonly TEXTURETYPE_SHORT: number;
  34172. /** UNSIGNED_SHORT */
  34173. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34174. /** INT */
  34175. static readonly TEXTURETYPE_INT: number;
  34176. /** UNSIGNED_INT */
  34177. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34178. /** UNSIGNED_SHORT_4_4_4_4 */
  34179. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34180. /** UNSIGNED_SHORT_5_5_5_1 */
  34181. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34182. /** UNSIGNED_SHORT_5_6_5 */
  34183. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34184. /** UNSIGNED_INT_2_10_10_10_REV */
  34185. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34186. /** UNSIGNED_INT_24_8 */
  34187. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34188. /** UNSIGNED_INT_10F_11F_11F_REV */
  34189. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34190. /** UNSIGNED_INT_5_9_9_9_REV */
  34191. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34192. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34193. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34194. /** nearest is mag = nearest and min = nearest and mip = linear */
  34195. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34197. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34198. /** Trilinear is mag = linear and min = linear and mip = linear */
  34199. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34200. /** nearest is mag = nearest and min = nearest and mip = linear */
  34201. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34202. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34203. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34204. /** Trilinear is mag = linear and min = linear and mip = linear */
  34205. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34206. /** mag = nearest and min = nearest and mip = nearest */
  34207. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34208. /** mag = nearest and min = linear and mip = nearest */
  34209. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34210. /** mag = nearest and min = linear and mip = linear */
  34211. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34212. /** mag = nearest and min = linear and mip = none */
  34213. static readonly TEXTURE_NEAREST_LINEAR: number;
  34214. /** mag = nearest and min = nearest and mip = none */
  34215. static readonly TEXTURE_NEAREST_NEAREST: number;
  34216. /** mag = linear and min = nearest and mip = nearest */
  34217. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34218. /** mag = linear and min = nearest and mip = linear */
  34219. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34220. /** mag = linear and min = linear and mip = none */
  34221. static readonly TEXTURE_LINEAR_LINEAR: number;
  34222. /** mag = linear and min = nearest and mip = none */
  34223. static readonly TEXTURE_LINEAR_NEAREST: number;
  34224. /** Explicit coordinates mode */
  34225. static readonly TEXTURE_EXPLICIT_MODE: number;
  34226. /** Spherical coordinates mode */
  34227. static readonly TEXTURE_SPHERICAL_MODE: number;
  34228. /** Planar coordinates mode */
  34229. static readonly TEXTURE_PLANAR_MODE: number;
  34230. /** Cubic coordinates mode */
  34231. static readonly TEXTURE_CUBIC_MODE: number;
  34232. /** Projection coordinates mode */
  34233. static readonly TEXTURE_PROJECTION_MODE: number;
  34234. /** Skybox coordinates mode */
  34235. static readonly TEXTURE_SKYBOX_MODE: number;
  34236. /** Inverse Cubic coordinates mode */
  34237. static readonly TEXTURE_INVCUBIC_MODE: number;
  34238. /** Equirectangular coordinates mode */
  34239. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34240. /** Equirectangular Fixed coordinates mode */
  34241. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34242. /** Equirectangular Fixed Mirrored coordinates mode */
  34243. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34244. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34245. static readonly SCALEMODE_FLOOR: number;
  34246. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34247. static readonly SCALEMODE_NEAREST: number;
  34248. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34249. static readonly SCALEMODE_CEILING: number;
  34250. /**
  34251. * Returns the current npm package of the sdk
  34252. */
  34253. static get NpmPackage(): string;
  34254. /**
  34255. * Returns the current version of the framework
  34256. */
  34257. static get Version(): string;
  34258. /** Gets the list of created engines */
  34259. static get Instances(): Engine[];
  34260. /**
  34261. * Gets the latest created engine
  34262. */
  34263. static get LastCreatedEngine(): Nullable<Engine>;
  34264. /**
  34265. * Gets the latest created scene
  34266. */
  34267. static get LastCreatedScene(): Nullable<Scene>;
  34268. /**
  34269. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34270. * @param flag defines which part of the materials must be marked as dirty
  34271. * @param predicate defines a predicate used to filter which materials should be affected
  34272. */
  34273. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34274. /**
  34275. * Method called to create the default loading screen.
  34276. * This can be overriden in your own app.
  34277. * @param canvas The rendering canvas element
  34278. * @returns The loading screen
  34279. */
  34280. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34281. /**
  34282. * Method called to create the default rescale post process on each engine.
  34283. */
  34284. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34285. /**
  34286. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34287. **/
  34288. enableOfflineSupport: boolean;
  34289. /**
  34290. * 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)
  34291. **/
  34292. disableManifestCheck: boolean;
  34293. /**
  34294. * Gets the list of created scenes
  34295. */
  34296. scenes: Scene[];
  34297. /**
  34298. * Event raised when a new scene is created
  34299. */
  34300. onNewSceneAddedObservable: Observable<Scene>;
  34301. /**
  34302. * Gets the list of created postprocesses
  34303. */
  34304. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34305. /**
  34306. * Gets a boolean indicating if the pointer is currently locked
  34307. */
  34308. isPointerLock: boolean;
  34309. /**
  34310. * Observable event triggered each time the rendering canvas is resized
  34311. */
  34312. onResizeObservable: Observable<Engine>;
  34313. /**
  34314. * Observable event triggered each time the canvas loses focus
  34315. */
  34316. onCanvasBlurObservable: Observable<Engine>;
  34317. /**
  34318. * Observable event triggered each time the canvas gains focus
  34319. */
  34320. onCanvasFocusObservable: Observable<Engine>;
  34321. /**
  34322. * Observable event triggered each time the canvas receives pointerout event
  34323. */
  34324. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34325. /**
  34326. * Observable raised when the engine begins a new frame
  34327. */
  34328. onBeginFrameObservable: Observable<Engine>;
  34329. /**
  34330. * If set, will be used to request the next animation frame for the render loop
  34331. */
  34332. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34333. /**
  34334. * Observable raised when the engine ends the current frame
  34335. */
  34336. onEndFrameObservable: Observable<Engine>;
  34337. /**
  34338. * Observable raised when the engine is about to compile a shader
  34339. */
  34340. onBeforeShaderCompilationObservable: Observable<Engine>;
  34341. /**
  34342. * Observable raised when the engine has jsut compiled a shader
  34343. */
  34344. onAfterShaderCompilationObservable: Observable<Engine>;
  34345. /**
  34346. * Gets the audio engine
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34348. * @ignorenaming
  34349. */
  34350. static audioEngine: IAudioEngine;
  34351. /**
  34352. * Default AudioEngine factory responsible of creating the Audio Engine.
  34353. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34354. */
  34355. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34356. /**
  34357. * Default offline support factory responsible of creating a tool used to store data locally.
  34358. * By default, this will create a Database object if the workload has been embedded.
  34359. */
  34360. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34361. private _loadingScreen;
  34362. private _pointerLockRequested;
  34363. private _dummyFramebuffer;
  34364. private _rescalePostProcess;
  34365. private _deterministicLockstep;
  34366. private _lockstepMaxSteps;
  34367. private _timeStep;
  34368. protected get _supportsHardwareTextureRescaling(): boolean;
  34369. private _fps;
  34370. private _deltaTime;
  34371. /** @hidden */
  34372. _drawCalls: PerfCounter;
  34373. /** 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 */
  34374. canvasTabIndex: number;
  34375. /**
  34376. * Turn this value on if you want to pause FPS computation when in background
  34377. */
  34378. disablePerformanceMonitorInBackground: boolean;
  34379. private _performanceMonitor;
  34380. /**
  34381. * Gets the performance monitor attached to this engine
  34382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34383. */
  34384. get performanceMonitor(): PerformanceMonitor;
  34385. private _onFocus;
  34386. private _onBlur;
  34387. private _onCanvasPointerOut;
  34388. private _onCanvasBlur;
  34389. private _onCanvasFocus;
  34390. private _onFullscreenChange;
  34391. private _onPointerLockChange;
  34392. /**
  34393. * Gets the HTML element used to attach event listeners
  34394. * @returns a HTML element
  34395. */
  34396. getInputElement(): Nullable<HTMLElement>;
  34397. /**
  34398. * Creates a new engine
  34399. * @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
  34400. * @param antialias defines enable antialiasing (default: false)
  34401. * @param options defines further options to be sent to the getContext() function
  34402. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34403. */
  34404. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34405. /**
  34406. * Gets current aspect ratio
  34407. * @param viewportOwner defines the camera to use to get the aspect ratio
  34408. * @param useScreen defines if screen size must be used (or the current render target if any)
  34409. * @returns a number defining the aspect ratio
  34410. */
  34411. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34412. /**
  34413. * Gets current screen aspect ratio
  34414. * @returns a number defining the aspect ratio
  34415. */
  34416. getScreenAspectRatio(): number;
  34417. /**
  34418. * Gets the client rect of the HTML canvas attached with the current webGL context
  34419. * @returns a client rectanglee
  34420. */
  34421. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34422. /**
  34423. * Gets the client rect of the HTML element used for events
  34424. * @returns a client rectanglee
  34425. */
  34426. getInputElementClientRect(): Nullable<ClientRect>;
  34427. /**
  34428. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34429. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34430. * @returns true if engine is in deterministic lock step mode
  34431. */
  34432. isDeterministicLockStep(): boolean;
  34433. /**
  34434. * Gets the max steps when engine is running in deterministic lock step
  34435. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34436. * @returns the max steps
  34437. */
  34438. getLockstepMaxSteps(): number;
  34439. /**
  34440. * Returns the time in ms between steps when using deterministic lock step.
  34441. * @returns time step in (ms)
  34442. */
  34443. getTimeStep(): number;
  34444. /**
  34445. * Force the mipmap generation for the given render target texture
  34446. * @param texture defines the render target texture to use
  34447. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34448. */
  34449. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34450. /** States */
  34451. /**
  34452. * Set various states to the webGL context
  34453. * @param culling defines backface culling state
  34454. * @param zOffset defines the value to apply to zOffset (0 by default)
  34455. * @param force defines if states must be applied even if cache is up to date
  34456. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34457. */
  34458. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34459. /**
  34460. * Set the z offset to apply to current rendering
  34461. * @param value defines the offset to apply
  34462. */
  34463. setZOffset(value: number): void;
  34464. /**
  34465. * Gets the current value of the zOffset
  34466. * @returns the current zOffset state
  34467. */
  34468. getZOffset(): number;
  34469. /**
  34470. * Enable or disable depth buffering
  34471. * @param enable defines the state to set
  34472. */
  34473. setDepthBuffer(enable: boolean): void;
  34474. /**
  34475. * Gets a boolean indicating if depth writing is enabled
  34476. * @returns the current depth writing state
  34477. */
  34478. getDepthWrite(): boolean;
  34479. /**
  34480. * Enable or disable depth writing
  34481. * @param enable defines the state to set
  34482. */
  34483. setDepthWrite(enable: boolean): void;
  34484. /**
  34485. * Gets a boolean indicating if stencil buffer is enabled
  34486. * @returns the current stencil buffer state
  34487. */
  34488. getStencilBuffer(): boolean;
  34489. /**
  34490. * Enable or disable the stencil buffer
  34491. * @param enable defines if the stencil buffer must be enabled or disabled
  34492. */
  34493. setStencilBuffer(enable: boolean): void;
  34494. /**
  34495. * Gets the current stencil mask
  34496. * @returns a number defining the new stencil mask to use
  34497. */
  34498. getStencilMask(): number;
  34499. /**
  34500. * Sets the current stencil mask
  34501. * @param mask defines the new stencil mask to use
  34502. */
  34503. setStencilMask(mask: number): void;
  34504. /**
  34505. * Gets the current stencil function
  34506. * @returns a number defining the stencil function to use
  34507. */
  34508. getStencilFunction(): number;
  34509. /**
  34510. * Gets the current stencil reference value
  34511. * @returns a number defining the stencil reference value to use
  34512. */
  34513. getStencilFunctionReference(): number;
  34514. /**
  34515. * Gets the current stencil mask
  34516. * @returns a number defining the stencil mask to use
  34517. */
  34518. getStencilFunctionMask(): number;
  34519. /**
  34520. * Sets the current stencil function
  34521. * @param stencilFunc defines the new stencil function to use
  34522. */
  34523. setStencilFunction(stencilFunc: number): void;
  34524. /**
  34525. * Sets the current stencil reference
  34526. * @param reference defines the new stencil reference to use
  34527. */
  34528. setStencilFunctionReference(reference: number): void;
  34529. /**
  34530. * Sets the current stencil mask
  34531. * @param mask defines the new stencil mask to use
  34532. */
  34533. setStencilFunctionMask(mask: number): void;
  34534. /**
  34535. * Gets the current stencil operation when stencil fails
  34536. * @returns a number defining stencil operation to use when stencil fails
  34537. */
  34538. getStencilOperationFail(): number;
  34539. /**
  34540. * Gets the current stencil operation when depth fails
  34541. * @returns a number defining stencil operation to use when depth fails
  34542. */
  34543. getStencilOperationDepthFail(): number;
  34544. /**
  34545. * Gets the current stencil operation when stencil passes
  34546. * @returns a number defining stencil operation to use when stencil passes
  34547. */
  34548. getStencilOperationPass(): number;
  34549. /**
  34550. * Sets the stencil operation to use when stencil fails
  34551. * @param operation defines the stencil operation to use when stencil fails
  34552. */
  34553. setStencilOperationFail(operation: number): void;
  34554. /**
  34555. * Sets the stencil operation to use when depth fails
  34556. * @param operation defines the stencil operation to use when depth fails
  34557. */
  34558. setStencilOperationDepthFail(operation: number): void;
  34559. /**
  34560. * Sets the stencil operation to use when stencil passes
  34561. * @param operation defines the stencil operation to use when stencil passes
  34562. */
  34563. setStencilOperationPass(operation: number): void;
  34564. /**
  34565. * Sets a boolean indicating if the dithering state is enabled or disabled
  34566. * @param value defines the dithering state
  34567. */
  34568. setDitheringState(value: boolean): void;
  34569. /**
  34570. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34571. * @param value defines the rasterizer state
  34572. */
  34573. setRasterizerState(value: boolean): void;
  34574. /**
  34575. * Gets the current depth function
  34576. * @returns a number defining the depth function
  34577. */
  34578. getDepthFunction(): Nullable<number>;
  34579. /**
  34580. * Sets the current depth function
  34581. * @param depthFunc defines the function to use
  34582. */
  34583. setDepthFunction(depthFunc: number): void;
  34584. /**
  34585. * Sets the current depth function to GREATER
  34586. */
  34587. setDepthFunctionToGreater(): void;
  34588. /**
  34589. * Sets the current depth function to GEQUAL
  34590. */
  34591. setDepthFunctionToGreaterOrEqual(): void;
  34592. /**
  34593. * Sets the current depth function to LESS
  34594. */
  34595. setDepthFunctionToLess(): void;
  34596. /**
  34597. * Sets the current depth function to LEQUAL
  34598. */
  34599. setDepthFunctionToLessOrEqual(): void;
  34600. private _cachedStencilBuffer;
  34601. private _cachedStencilFunction;
  34602. private _cachedStencilMask;
  34603. private _cachedStencilOperationPass;
  34604. private _cachedStencilOperationFail;
  34605. private _cachedStencilOperationDepthFail;
  34606. private _cachedStencilReference;
  34607. /**
  34608. * Caches the the state of the stencil buffer
  34609. */
  34610. cacheStencilState(): void;
  34611. /**
  34612. * Restores the state of the stencil buffer
  34613. */
  34614. restoreStencilState(): void;
  34615. /**
  34616. * Directly set the WebGL Viewport
  34617. * @param x defines the x coordinate of the viewport (in screen space)
  34618. * @param y defines the y coordinate of the viewport (in screen space)
  34619. * @param width defines the width of the viewport (in screen space)
  34620. * @param height defines the height of the viewport (in screen space)
  34621. * @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
  34622. */
  34623. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34624. /**
  34625. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34626. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34627. * @param y defines the y-coordinate of the corner of the clear rectangle
  34628. * @param width defines the width of the clear rectangle
  34629. * @param height defines the height of the clear rectangle
  34630. * @param clearColor defines the clear color
  34631. */
  34632. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34633. /**
  34634. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34635. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34636. * @param y defines the y-coordinate of the corner of the clear rectangle
  34637. * @param width defines the width of the clear rectangle
  34638. * @param height defines the height of the clear rectangle
  34639. */
  34640. enableScissor(x: number, y: number, width: number, height: number): void;
  34641. /**
  34642. * Disable previously set scissor test rectangle
  34643. */
  34644. disableScissor(): void;
  34645. protected _reportDrawCall(): void;
  34646. /**
  34647. * Initializes a webVR display and starts listening to display change events
  34648. * The onVRDisplayChangedObservable will be notified upon these changes
  34649. * @returns The onVRDisplayChangedObservable
  34650. */
  34651. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34652. /** @hidden */
  34653. _prepareVRComponent(): void;
  34654. /** @hidden */
  34655. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34656. /** @hidden */
  34657. _submitVRFrame(): void;
  34658. /**
  34659. * Call this function to leave webVR mode
  34660. * Will do nothing if webVR is not supported or if there is no webVR device
  34661. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34662. */
  34663. disableVR(): void;
  34664. /**
  34665. * Gets a boolean indicating that the system is in VR mode and is presenting
  34666. * @returns true if VR mode is engaged
  34667. */
  34668. isVRPresenting(): boolean;
  34669. /** @hidden */
  34670. _requestVRFrame(): void;
  34671. /** @hidden */
  34672. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34673. /**
  34674. * Gets the source code of the vertex shader associated with a specific webGL program
  34675. * @param program defines the program to use
  34676. * @returns a string containing the source code of the vertex shader associated with the program
  34677. */
  34678. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34679. /**
  34680. * Gets the source code of the fragment shader associated with a specific webGL program
  34681. * @param program defines the program to use
  34682. * @returns a string containing the source code of the fragment shader associated with the program
  34683. */
  34684. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34685. /**
  34686. * Sets a depth stencil texture from a render target to the according uniform.
  34687. * @param channel The texture channel
  34688. * @param uniform The uniform to set
  34689. * @param texture The render target texture containing the depth stencil texture to apply
  34690. */
  34691. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34692. /**
  34693. * Sets a texture to the webGL context from a postprocess
  34694. * @param channel defines the channel to use
  34695. * @param postProcess defines the source postprocess
  34696. */
  34697. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34698. /**
  34699. * Binds the output of the passed in post process to the texture channel specified
  34700. * @param channel The channel the texture should be bound to
  34701. * @param postProcess The post process which's output should be bound
  34702. */
  34703. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34704. /** @hidden */
  34705. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34706. protected _rebuildBuffers(): void;
  34707. /** @hidden */
  34708. _renderFrame(): void;
  34709. _renderLoop(): void;
  34710. /** @hidden */
  34711. _renderViews(): boolean;
  34712. /**
  34713. * Toggle full screen mode
  34714. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34715. */
  34716. switchFullscreen(requestPointerLock: boolean): void;
  34717. /**
  34718. * Enters full screen mode
  34719. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34720. */
  34721. enterFullscreen(requestPointerLock: boolean): void;
  34722. /**
  34723. * Exits full screen mode
  34724. */
  34725. exitFullscreen(): void;
  34726. /**
  34727. * Enters Pointerlock mode
  34728. */
  34729. enterPointerlock(): void;
  34730. /**
  34731. * Exits Pointerlock mode
  34732. */
  34733. exitPointerlock(): void;
  34734. /**
  34735. * Begin a new frame
  34736. */
  34737. beginFrame(): void;
  34738. /**
  34739. * Enf the current frame
  34740. */
  34741. endFrame(): void;
  34742. resize(): void;
  34743. /**
  34744. * Force a specific size of the canvas
  34745. * @param width defines the new canvas' width
  34746. * @param height defines the new canvas' height
  34747. */
  34748. setSize(width: number, height: number): void;
  34749. /**
  34750. * Updates a dynamic vertex buffer.
  34751. * @param vertexBuffer the vertex buffer to update
  34752. * @param data the data used to update the vertex buffer
  34753. * @param byteOffset the byte offset of the data
  34754. * @param byteLength the byte length of the data
  34755. */
  34756. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34757. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34758. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34759. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34760. _releaseTexture(texture: InternalTexture): void;
  34761. /**
  34762. * @hidden
  34763. * Rescales a texture
  34764. * @param source input texutre
  34765. * @param destination destination texture
  34766. * @param scene scene to use to render the resize
  34767. * @param internalFormat format to use when resizing
  34768. * @param onComplete callback to be called when resize has completed
  34769. */
  34770. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34771. /**
  34772. * Gets the current framerate
  34773. * @returns a number representing the framerate
  34774. */
  34775. getFps(): number;
  34776. /**
  34777. * Gets the time spent between current and previous frame
  34778. * @returns a number representing the delta time in ms
  34779. */
  34780. getDeltaTime(): number;
  34781. private _measureFps;
  34782. /** @hidden */
  34783. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34784. /**
  34785. * Update a dynamic index buffer
  34786. * @param indexBuffer defines the target index buffer
  34787. * @param indices defines the data to update
  34788. * @param offset defines the offset in the target index buffer where update should start
  34789. */
  34790. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34791. /**
  34792. * Updates the sample count of a render target texture
  34793. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34794. * @param texture defines the texture to update
  34795. * @param samples defines the sample count to set
  34796. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34797. */
  34798. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34799. /**
  34800. * Updates a depth texture Comparison Mode and Function.
  34801. * If the comparison Function is equal to 0, the mode will be set to none.
  34802. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34803. * @param texture The texture to set the comparison function for
  34804. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34805. */
  34806. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34807. /**
  34808. * Creates a webGL buffer to use with instanciation
  34809. * @param capacity defines the size of the buffer
  34810. * @returns the webGL buffer
  34811. */
  34812. createInstancesBuffer(capacity: number): DataBuffer;
  34813. /**
  34814. * Delete a webGL buffer used with instanciation
  34815. * @param buffer defines the webGL buffer to delete
  34816. */
  34817. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34818. private _clientWaitAsync;
  34819. /** @hidden */
  34820. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34821. /** @hidden */
  34822. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34823. dispose(): void;
  34824. private _disableTouchAction;
  34825. /**
  34826. * Display the loading screen
  34827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34828. */
  34829. displayLoadingUI(): void;
  34830. /**
  34831. * Hide the loading screen
  34832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34833. */
  34834. hideLoadingUI(): void;
  34835. /**
  34836. * Gets the current loading screen object
  34837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34838. */
  34839. get loadingScreen(): ILoadingScreen;
  34840. /**
  34841. * Sets the current loading screen object
  34842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34843. */
  34844. set loadingScreen(loadingScreen: ILoadingScreen);
  34845. /**
  34846. * Sets the current loading screen text
  34847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34848. */
  34849. set loadingUIText(text: string);
  34850. /**
  34851. * Sets the current loading screen background color
  34852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34853. */
  34854. set loadingUIBackgroundColor(color: string);
  34855. /** Pointerlock and fullscreen */
  34856. /**
  34857. * Ask the browser to promote the current element to pointerlock mode
  34858. * @param element defines the DOM element to promote
  34859. */
  34860. static _RequestPointerlock(element: HTMLElement): void;
  34861. /**
  34862. * Asks the browser to exit pointerlock mode
  34863. */
  34864. static _ExitPointerlock(): void;
  34865. /**
  34866. * Ask the browser to promote the current element to fullscreen rendering mode
  34867. * @param element defines the DOM element to promote
  34868. */
  34869. static _RequestFullscreen(element: HTMLElement): void;
  34870. /**
  34871. * Asks the browser to exit fullscreen mode
  34872. */
  34873. static _ExitFullscreen(): void;
  34874. }
  34875. }
  34876. declare module "babylonjs/Engines/engineStore" {
  34877. import { Nullable } from "babylonjs/types";
  34878. import { Engine } from "babylonjs/Engines/engine";
  34879. import { Scene } from "babylonjs/scene";
  34880. /**
  34881. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34882. * during the life time of the application.
  34883. */
  34884. export class EngineStore {
  34885. /** Gets the list of created engines */
  34886. static Instances: import("babylonjs/Engines/engine").Engine[];
  34887. /** @hidden */
  34888. static _LastCreatedScene: Nullable<Scene>;
  34889. /**
  34890. * Gets the latest created engine
  34891. */
  34892. static get LastCreatedEngine(): Nullable<Engine>;
  34893. /**
  34894. * Gets the latest created scene
  34895. */
  34896. static get LastCreatedScene(): Nullable<Scene>;
  34897. /**
  34898. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34899. * @ignorenaming
  34900. */
  34901. static UseFallbackTexture: boolean;
  34902. /**
  34903. * Texture content used if a texture cannot loaded
  34904. * @ignorenaming
  34905. */
  34906. static FallbackTexture: string;
  34907. }
  34908. }
  34909. declare module "babylonjs/Misc/promise" {
  34910. /**
  34911. * Helper class that provides a small promise polyfill
  34912. */
  34913. export class PromisePolyfill {
  34914. /**
  34915. * Static function used to check if the polyfill is required
  34916. * If this is the case then the function will inject the polyfill to window.Promise
  34917. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34918. */
  34919. static Apply(force?: boolean): void;
  34920. }
  34921. }
  34922. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34923. /**
  34924. * Interface for screenshot methods with describe argument called `size` as object with options
  34925. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34926. */
  34927. export interface IScreenshotSize {
  34928. /**
  34929. * number in pixels for canvas height
  34930. */
  34931. height?: number;
  34932. /**
  34933. * multiplier allowing render at a higher or lower resolution
  34934. * If value is defined then height and width will be ignored and taken from camera
  34935. */
  34936. precision?: number;
  34937. /**
  34938. * number in pixels for canvas width
  34939. */
  34940. width?: number;
  34941. }
  34942. }
  34943. declare module "babylonjs/Misc/tools" {
  34944. import { Nullable, float } from "babylonjs/types";
  34945. import { DomManagement } from "babylonjs/Misc/domManagement";
  34946. import { WebRequest } from "babylonjs/Misc/webRequest";
  34947. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34948. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34949. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34950. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34951. import { Camera } from "babylonjs/Cameras/camera";
  34952. import { Engine } from "babylonjs/Engines/engine";
  34953. interface IColor4Like {
  34954. r: float;
  34955. g: float;
  34956. b: float;
  34957. a: float;
  34958. }
  34959. /**
  34960. * Class containing a set of static utilities functions
  34961. */
  34962. export class Tools {
  34963. /**
  34964. * Gets or sets the base URL to use to load assets
  34965. */
  34966. static get BaseUrl(): string;
  34967. static set BaseUrl(value: string);
  34968. /**
  34969. * Enable/Disable Custom HTTP Request Headers globally.
  34970. * default = false
  34971. * @see CustomRequestHeaders
  34972. */
  34973. static UseCustomRequestHeaders: boolean;
  34974. /**
  34975. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34976. * i.e. when loading files, where the server/service expects an Authorization header
  34977. */
  34978. static CustomRequestHeaders: {
  34979. [key: string]: string;
  34980. };
  34981. /**
  34982. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34983. */
  34984. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34985. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34986. /**
  34987. * Default behaviour for cors in the application.
  34988. * It can be a string if the expected behavior is identical in the entire app.
  34989. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34990. */
  34991. static CorsBehavior: string | ((url: string | string[]) => string);
  34992. /**
  34993. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34994. * @ignorenaming
  34995. */
  34996. static get UseFallbackTexture(): boolean;
  34997. static set UseFallbackTexture(value: boolean);
  34998. /**
  34999. * Use this object to register external classes like custom textures or material
  35000. * to allow the laoders to instantiate them
  35001. */
  35002. static get RegisteredExternalClasses(): {
  35003. [key: string]: Object;
  35004. };
  35005. static set RegisteredExternalClasses(classes: {
  35006. [key: string]: Object;
  35007. });
  35008. /**
  35009. * Texture content used if a texture cannot loaded
  35010. * @ignorenaming
  35011. */
  35012. static get fallbackTexture(): string;
  35013. static set fallbackTexture(value: string);
  35014. /**
  35015. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35016. * @param u defines the coordinate on X axis
  35017. * @param v defines the coordinate on Y axis
  35018. * @param width defines the width of the source data
  35019. * @param height defines the height of the source data
  35020. * @param pixels defines the source byte array
  35021. * @param color defines the output color
  35022. */
  35023. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35024. /**
  35025. * Interpolates between a and b via alpha
  35026. * @param a The lower value (returned when alpha = 0)
  35027. * @param b The upper value (returned when alpha = 1)
  35028. * @param alpha The interpolation-factor
  35029. * @return The mixed value
  35030. */
  35031. static Mix(a: number, b: number, alpha: number): number;
  35032. /**
  35033. * Tries to instantiate a new object from a given class name
  35034. * @param className defines the class name to instantiate
  35035. * @returns the new object or null if the system was not able to do the instantiation
  35036. */
  35037. static Instantiate(className: string): any;
  35038. /**
  35039. * Provides a slice function that will work even on IE
  35040. * @param data defines the array to slice
  35041. * @param start defines the start of the data (optional)
  35042. * @param end defines the end of the data (optional)
  35043. * @returns the new sliced array
  35044. */
  35045. static Slice<T>(data: T, start?: number, end?: number): T;
  35046. /**
  35047. * Polyfill for setImmediate
  35048. * @param action defines the action to execute after the current execution block
  35049. */
  35050. static SetImmediate(action: () => void): void;
  35051. /**
  35052. * Function indicating if a number is an exponent of 2
  35053. * @param value defines the value to test
  35054. * @returns true if the value is an exponent of 2
  35055. */
  35056. static IsExponentOfTwo(value: number): boolean;
  35057. private static _tmpFloatArray;
  35058. /**
  35059. * Returns the nearest 32-bit single precision float representation of a Number
  35060. * @param value A Number. If the parameter is of a different type, it will get converted
  35061. * to a number or to NaN if it cannot be converted
  35062. * @returns number
  35063. */
  35064. static FloatRound(value: number): number;
  35065. /**
  35066. * Extracts the filename from a path
  35067. * @param path defines the path to use
  35068. * @returns the filename
  35069. */
  35070. static GetFilename(path: string): string;
  35071. /**
  35072. * Extracts the "folder" part of a path (everything before the filename).
  35073. * @param uri The URI to extract the info from
  35074. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35075. * @returns The "folder" part of the path
  35076. */
  35077. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35078. /**
  35079. * Extracts text content from a DOM element hierarchy
  35080. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35081. */
  35082. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35083. /**
  35084. * Convert an angle in radians to degrees
  35085. * @param angle defines the angle to convert
  35086. * @returns the angle in degrees
  35087. */
  35088. static ToDegrees(angle: number): number;
  35089. /**
  35090. * Convert an angle in degrees to radians
  35091. * @param angle defines the angle to convert
  35092. * @returns the angle in radians
  35093. */
  35094. static ToRadians(angle: number): number;
  35095. /**
  35096. * Returns an array if obj is not an array
  35097. * @param obj defines the object to evaluate as an array
  35098. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35099. * @returns either obj directly if obj is an array or a new array containing obj
  35100. */
  35101. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35102. /**
  35103. * Gets the pointer prefix to use
  35104. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35105. */
  35106. static GetPointerPrefix(): string;
  35107. /**
  35108. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35109. * @param url define the url we are trying
  35110. * @param element define the dom element where to configure the cors policy
  35111. */
  35112. static SetCorsBehavior(url: string | string[], element: {
  35113. crossOrigin: string | null;
  35114. }): void;
  35115. /**
  35116. * Removes unwanted characters from an url
  35117. * @param url defines the url to clean
  35118. * @returns the cleaned url
  35119. */
  35120. static CleanUrl(url: string): string;
  35121. /**
  35122. * Gets or sets a function used to pre-process url before using them to load assets
  35123. */
  35124. static get PreprocessUrl(): (url: string) => string;
  35125. static set PreprocessUrl(processor: (url: string) => string);
  35126. /**
  35127. * Loads an image as an HTMLImageElement.
  35128. * @param input url string, ArrayBuffer, or Blob to load
  35129. * @param onLoad callback called when the image successfully loads
  35130. * @param onError callback called when the image fails to load
  35131. * @param offlineProvider offline provider for caching
  35132. * @param mimeType optional mime type
  35133. * @returns the HTMLImageElement of the loaded image
  35134. */
  35135. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35136. /**
  35137. * Loads a file from a url
  35138. * @param url url string, ArrayBuffer, or Blob to load
  35139. * @param onSuccess callback called when the file successfully loads
  35140. * @param onProgress callback called while file is loading (if the server supports this mode)
  35141. * @param offlineProvider defines the offline provider for caching
  35142. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35143. * @param onError callback called when the file fails to load
  35144. * @returns a file request object
  35145. */
  35146. 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;
  35147. /**
  35148. * Loads a file from a url
  35149. * @param url the file url to load
  35150. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35151. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35152. */
  35153. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35154. /**
  35155. * Load a script (identified by an url). When the url returns, the
  35156. * content of this file is added into a new script element, attached to the DOM (body element)
  35157. * @param scriptUrl defines the url of the script to laod
  35158. * @param onSuccess defines the callback called when the script is loaded
  35159. * @param onError defines the callback to call if an error occurs
  35160. * @param scriptId defines the id of the script element
  35161. */
  35162. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35163. /**
  35164. * Load an asynchronous script (identified by an url). When the url returns, the
  35165. * content of this file is added into a new script element, attached to the DOM (body element)
  35166. * @param scriptUrl defines the url of the script to laod
  35167. * @param scriptId defines the id of the script element
  35168. * @returns a promise request object
  35169. */
  35170. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35171. /**
  35172. * Loads a file from a blob
  35173. * @param fileToLoad defines the blob to use
  35174. * @param callback defines the callback to call when data is loaded
  35175. * @param progressCallback defines the callback to call during loading process
  35176. * @returns a file request object
  35177. */
  35178. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35179. /**
  35180. * Reads a file from a File object
  35181. * @param file defines the file to load
  35182. * @param onSuccess defines the callback to call when data is loaded
  35183. * @param onProgress defines the callback to call during loading process
  35184. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35185. * @param onError defines the callback to call when an error occurs
  35186. * @returns a file request object
  35187. */
  35188. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35189. /**
  35190. * Creates a data url from a given string content
  35191. * @param content defines the content to convert
  35192. * @returns the new data url link
  35193. */
  35194. static FileAsURL(content: string): string;
  35195. /**
  35196. * Format the given number to a specific decimal format
  35197. * @param value defines the number to format
  35198. * @param decimals defines the number of decimals to use
  35199. * @returns the formatted string
  35200. */
  35201. static Format(value: number, decimals?: number): string;
  35202. /**
  35203. * Tries to copy an object by duplicating every property
  35204. * @param source defines the source object
  35205. * @param destination defines the target object
  35206. * @param doNotCopyList defines a list of properties to avoid
  35207. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35208. */
  35209. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35210. /**
  35211. * Gets a boolean indicating if the given object has no own property
  35212. * @param obj defines the object to test
  35213. * @returns true if object has no own property
  35214. */
  35215. static IsEmpty(obj: any): boolean;
  35216. /**
  35217. * Function used to register events at window level
  35218. * @param windowElement defines the Window object to use
  35219. * @param events defines the events to register
  35220. */
  35221. static RegisterTopRootEvents(windowElement: Window, events: {
  35222. name: string;
  35223. handler: Nullable<(e: FocusEvent) => any>;
  35224. }[]): void;
  35225. /**
  35226. * Function used to unregister events from window level
  35227. * @param windowElement defines the Window object to use
  35228. * @param events defines the events to unregister
  35229. */
  35230. static UnregisterTopRootEvents(windowElement: Window, events: {
  35231. name: string;
  35232. handler: Nullable<(e: FocusEvent) => any>;
  35233. }[]): void;
  35234. /**
  35235. * @ignore
  35236. */
  35237. static _ScreenshotCanvas: HTMLCanvasElement;
  35238. /**
  35239. * Dumps the current bound framebuffer
  35240. * @param width defines the rendering width
  35241. * @param height defines the rendering height
  35242. * @param engine defines the hosting engine
  35243. * @param successCallback defines the callback triggered once the data are available
  35244. * @param mimeType defines the mime type of the result
  35245. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35246. */
  35247. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35248. /**
  35249. * Converts the canvas data to blob.
  35250. * This acts as a polyfill for browsers not supporting the to blob function.
  35251. * @param canvas Defines the canvas to extract the data from
  35252. * @param successCallback Defines the callback triggered once the data are available
  35253. * @param mimeType Defines the mime type of the result
  35254. */
  35255. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35256. /**
  35257. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35258. * @param successCallback defines the callback triggered once the data are available
  35259. * @param mimeType defines the mime type of the result
  35260. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35261. */
  35262. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35263. /**
  35264. * Downloads a blob in the browser
  35265. * @param blob defines the blob to download
  35266. * @param fileName defines the name of the downloaded file
  35267. */
  35268. static Download(blob: Blob, fileName: string): void;
  35269. /**
  35270. * Captures a screenshot of the current rendering
  35271. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35272. * @param engine defines the rendering engine
  35273. * @param camera defines the source camera
  35274. * @param size This parameter can be set to a single number or to an object with the
  35275. * following (optional) properties: precision, width, height. If a single number is passed,
  35276. * it will be used for both width and height. If an object is passed, the screenshot size
  35277. * will be derived from the parameters. The precision property is a multiplier allowing
  35278. * rendering at a higher or lower resolution
  35279. * @param successCallback defines the callback receives a single parameter which contains the
  35280. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35281. * src parameter of an <img> to display it
  35282. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35283. * Check your browser for supported MIME types
  35284. */
  35285. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35286. /**
  35287. * Captures a screenshot of the current rendering
  35288. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35289. * @param engine defines the rendering engine
  35290. * @param camera defines the source camera
  35291. * @param size This parameter can be set to a single number or to an object with the
  35292. * following (optional) properties: precision, width, height. If a single number is passed,
  35293. * it will be used for both width and height. If an object is passed, the screenshot size
  35294. * will be derived from the parameters. The precision property is a multiplier allowing
  35295. * rendering at a higher or lower resolution
  35296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35297. * Check your browser for supported MIME types
  35298. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35299. * to the src parameter of an <img> to display it
  35300. */
  35301. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35302. /**
  35303. * Generates an image screenshot from the specified camera.
  35304. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35305. * @param engine The engine to use for rendering
  35306. * @param camera The camera to use for rendering
  35307. * @param size This parameter can be set to a single number or to an object with the
  35308. * following (optional) properties: precision, width, height. If a single number is passed,
  35309. * it will be used for both width and height. If an object is passed, the screenshot size
  35310. * will be derived from the parameters. The precision property is a multiplier allowing
  35311. * rendering at a higher or lower resolution
  35312. * @param successCallback The callback receives a single parameter which contains the
  35313. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35314. * src parameter of an <img> to display it
  35315. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35316. * Check your browser for supported MIME types
  35317. * @param samples Texture samples (default: 1)
  35318. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35319. * @param fileName A name for for the downloaded file.
  35320. */
  35321. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35322. /**
  35323. * Generates an image screenshot from the specified camera.
  35324. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35325. * @param engine The engine to use for rendering
  35326. * @param camera The camera to use for rendering
  35327. * @param size This parameter can be set to a single number or to an object with the
  35328. * following (optional) properties: precision, width, height. If a single number is passed,
  35329. * it will be used for both width and height. If an object is passed, the screenshot size
  35330. * will be derived from the parameters. The precision property is a multiplier allowing
  35331. * rendering at a higher or lower resolution
  35332. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35333. * Check your browser for supported MIME types
  35334. * @param samples Texture samples (default: 1)
  35335. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35336. * @param fileName A name for for the downloaded file.
  35337. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35338. * to the src parameter of an <img> to display it
  35339. */
  35340. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35341. /**
  35342. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35343. * Be aware Math.random() could cause collisions, but:
  35344. * "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"
  35345. * @returns a pseudo random id
  35346. */
  35347. static RandomId(): string;
  35348. /**
  35349. * Test if the given uri is a base64 string
  35350. * @param uri The uri to test
  35351. * @return True if the uri is a base64 string or false otherwise
  35352. */
  35353. static IsBase64(uri: string): boolean;
  35354. /**
  35355. * Decode the given base64 uri.
  35356. * @param uri The uri to decode
  35357. * @return The decoded base64 data.
  35358. */
  35359. static DecodeBase64(uri: string): ArrayBuffer;
  35360. /**
  35361. * Gets the absolute url.
  35362. * @param url the input url
  35363. * @return the absolute url
  35364. */
  35365. static GetAbsoluteUrl(url: string): string;
  35366. /**
  35367. * No log
  35368. */
  35369. static readonly NoneLogLevel: number;
  35370. /**
  35371. * Only message logs
  35372. */
  35373. static readonly MessageLogLevel: number;
  35374. /**
  35375. * Only warning logs
  35376. */
  35377. static readonly WarningLogLevel: number;
  35378. /**
  35379. * Only error logs
  35380. */
  35381. static readonly ErrorLogLevel: number;
  35382. /**
  35383. * All logs
  35384. */
  35385. static readonly AllLogLevel: number;
  35386. /**
  35387. * Gets a value indicating the number of loading errors
  35388. * @ignorenaming
  35389. */
  35390. static get errorsCount(): number;
  35391. /**
  35392. * Callback called when a new log is added
  35393. */
  35394. static OnNewCacheEntry: (entry: string) => void;
  35395. /**
  35396. * Log a message to the console
  35397. * @param message defines the message to log
  35398. */
  35399. static Log(message: string): void;
  35400. /**
  35401. * Write a warning message to the console
  35402. * @param message defines the message to log
  35403. */
  35404. static Warn(message: string): void;
  35405. /**
  35406. * Write an error message to the console
  35407. * @param message defines the message to log
  35408. */
  35409. static Error(message: string): void;
  35410. /**
  35411. * Gets current log cache (list of logs)
  35412. */
  35413. static get LogCache(): string;
  35414. /**
  35415. * Clears the log cache
  35416. */
  35417. static ClearLogCache(): void;
  35418. /**
  35419. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35420. */
  35421. static set LogLevels(level: number);
  35422. /**
  35423. * Checks if the window object exists
  35424. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35425. */
  35426. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35427. /**
  35428. * No performance log
  35429. */
  35430. static readonly PerformanceNoneLogLevel: number;
  35431. /**
  35432. * Use user marks to log performance
  35433. */
  35434. static readonly PerformanceUserMarkLogLevel: number;
  35435. /**
  35436. * Log performance to the console
  35437. */
  35438. static readonly PerformanceConsoleLogLevel: number;
  35439. private static _performance;
  35440. /**
  35441. * Sets the current performance log level
  35442. */
  35443. static set PerformanceLogLevel(level: number);
  35444. private static _StartPerformanceCounterDisabled;
  35445. private static _EndPerformanceCounterDisabled;
  35446. private static _StartUserMark;
  35447. private static _EndUserMark;
  35448. private static _StartPerformanceConsole;
  35449. private static _EndPerformanceConsole;
  35450. /**
  35451. * Starts a performance counter
  35452. */
  35453. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35454. /**
  35455. * Ends a specific performance coutner
  35456. */
  35457. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35458. /**
  35459. * Gets either window.performance.now() if supported or Date.now() else
  35460. */
  35461. static get Now(): number;
  35462. /**
  35463. * This method will return the name of the class used to create the instance of the given object.
  35464. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35465. * @param object the object to get the class name from
  35466. * @param isType defines if the object is actually a type
  35467. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35468. */
  35469. static GetClassName(object: any, isType?: boolean): string;
  35470. /**
  35471. * Gets the first element of an array satisfying a given predicate
  35472. * @param array defines the array to browse
  35473. * @param predicate defines the predicate to use
  35474. * @returns null if not found or the element
  35475. */
  35476. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35477. /**
  35478. * This method will return the name of the full name of the class, including its owning module (if any).
  35479. * 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).
  35480. * @param object the object to get the class name from
  35481. * @param isType defines if the object is actually a type
  35482. * @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.
  35483. * @ignorenaming
  35484. */
  35485. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35486. /**
  35487. * Returns a promise that resolves after the given amount of time.
  35488. * @param delay Number of milliseconds to delay
  35489. * @returns Promise that resolves after the given amount of time
  35490. */
  35491. static DelayAsync(delay: number): Promise<void>;
  35492. /**
  35493. * Utility function to detect if the current user agent is Safari
  35494. * @returns whether or not the current user agent is safari
  35495. */
  35496. static IsSafari(): boolean;
  35497. }
  35498. /**
  35499. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35500. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35501. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35502. * @param name The name of the class, case should be preserved
  35503. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35504. */
  35505. export function className(name: string, module?: string): (target: Object) => void;
  35506. /**
  35507. * An implementation of a loop for asynchronous functions.
  35508. */
  35509. export class AsyncLoop {
  35510. /**
  35511. * Defines the number of iterations for the loop
  35512. */
  35513. iterations: number;
  35514. /**
  35515. * Defines the current index of the loop.
  35516. */
  35517. index: number;
  35518. private _done;
  35519. private _fn;
  35520. private _successCallback;
  35521. /**
  35522. * Constructor.
  35523. * @param iterations the number of iterations.
  35524. * @param func the function to run each iteration
  35525. * @param successCallback the callback that will be called upon succesful execution
  35526. * @param offset starting offset.
  35527. */
  35528. constructor(
  35529. /**
  35530. * Defines the number of iterations for the loop
  35531. */
  35532. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35533. /**
  35534. * Execute the next iteration. Must be called after the last iteration was finished.
  35535. */
  35536. executeNext(): void;
  35537. /**
  35538. * Break the loop and run the success callback.
  35539. */
  35540. breakLoop(): void;
  35541. /**
  35542. * Create and run an async loop.
  35543. * @param iterations the number of iterations.
  35544. * @param fn the function to run each iteration
  35545. * @param successCallback the callback that will be called upon succesful execution
  35546. * @param offset starting offset.
  35547. * @returns the created async loop object
  35548. */
  35549. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35550. /**
  35551. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35552. * @param iterations total number of iterations
  35553. * @param syncedIterations number of synchronous iterations in each async iteration.
  35554. * @param fn the function to call each iteration.
  35555. * @param callback a success call back that will be called when iterating stops.
  35556. * @param breakFunction a break condition (optional)
  35557. * @param timeout timeout settings for the setTimeout function. default - 0.
  35558. * @returns the created async loop object
  35559. */
  35560. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35561. }
  35562. }
  35563. declare module "babylonjs/Misc/stringDictionary" {
  35564. import { Nullable } from "babylonjs/types";
  35565. /**
  35566. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35567. * The underlying implementation relies on an associative array to ensure the best performances.
  35568. * The value can be anything including 'null' but except 'undefined'
  35569. */
  35570. export class StringDictionary<T> {
  35571. /**
  35572. * This will clear this dictionary and copy the content from the 'source' one.
  35573. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35574. * @param source the dictionary to take the content from and copy to this dictionary
  35575. */
  35576. copyFrom(source: StringDictionary<T>): void;
  35577. /**
  35578. * Get a value based from its key
  35579. * @param key the given key to get the matching value from
  35580. * @return the value if found, otherwise undefined is returned
  35581. */
  35582. get(key: string): T | undefined;
  35583. /**
  35584. * Get a value from its key or add it if it doesn't exist.
  35585. * This method will ensure you that a given key/data will be present in the dictionary.
  35586. * @param key the given key to get the matching value from
  35587. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35588. * The factory will only be invoked if there's no data for the given key.
  35589. * @return the value corresponding to the key.
  35590. */
  35591. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35592. /**
  35593. * Get a value from its key if present in the dictionary otherwise add it
  35594. * @param key the key to get the value from
  35595. * @param val if there's no such key/value pair in the dictionary add it with this value
  35596. * @return the value corresponding to the key
  35597. */
  35598. getOrAdd(key: string, val: T): T;
  35599. /**
  35600. * Check if there's a given key in the dictionary
  35601. * @param key the key to check for
  35602. * @return true if the key is present, false otherwise
  35603. */
  35604. contains(key: string): boolean;
  35605. /**
  35606. * Add a new key and its corresponding value
  35607. * @param key the key to add
  35608. * @param value the value corresponding to the key
  35609. * @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
  35610. */
  35611. add(key: string, value: T): boolean;
  35612. /**
  35613. * Update a specific value associated to a key
  35614. * @param key defines the key to use
  35615. * @param value defines the value to store
  35616. * @returns true if the value was updated (or false if the key was not found)
  35617. */
  35618. set(key: string, value: T): boolean;
  35619. /**
  35620. * Get the element of the given key and remove it from the dictionary
  35621. * @param key defines the key to search
  35622. * @returns the value associated with the key or null if not found
  35623. */
  35624. getAndRemove(key: string): Nullable<T>;
  35625. /**
  35626. * Remove a key/value from the dictionary.
  35627. * @param key the key to remove
  35628. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35629. */
  35630. remove(key: string): boolean;
  35631. /**
  35632. * Clear the whole content of the dictionary
  35633. */
  35634. clear(): void;
  35635. /**
  35636. * Gets the current count
  35637. */
  35638. get count(): number;
  35639. /**
  35640. * Execute a callback on each key/val of the dictionary.
  35641. * Note that you can remove any element in this dictionary in the callback implementation
  35642. * @param callback the callback to execute on a given key/value pair
  35643. */
  35644. forEach(callback: (key: string, val: T) => void): void;
  35645. /**
  35646. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35647. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35648. * Note that you can remove any element in this dictionary in the callback implementation
  35649. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35650. * @returns the first item
  35651. */
  35652. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35653. private _count;
  35654. private _data;
  35655. }
  35656. }
  35657. declare module "babylonjs/Collisions/collisionCoordinator" {
  35658. import { Nullable } from "babylonjs/types";
  35659. import { Scene } from "babylonjs/scene";
  35660. import { Vector3 } from "babylonjs/Maths/math.vector";
  35661. import { Collider } from "babylonjs/Collisions/collider";
  35662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35663. /** @hidden */
  35664. export interface ICollisionCoordinator {
  35665. createCollider(): Collider;
  35666. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35667. init(scene: Scene): void;
  35668. }
  35669. /** @hidden */
  35670. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35671. private _scene;
  35672. private _scaledPosition;
  35673. private _scaledVelocity;
  35674. private _finalPosition;
  35675. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35676. createCollider(): Collider;
  35677. init(scene: Scene): void;
  35678. private _collideWithWorld;
  35679. }
  35680. }
  35681. declare module "babylonjs/Inputs/scene.inputManager" {
  35682. import { Nullable } from "babylonjs/types";
  35683. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35684. import { Vector2 } from "babylonjs/Maths/math.vector";
  35685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35686. import { Scene } from "babylonjs/scene";
  35687. /**
  35688. * Class used to manage all inputs for the scene.
  35689. */
  35690. export class InputManager {
  35691. /** The distance in pixel that you have to move to prevent some events */
  35692. static DragMovementThreshold: number;
  35693. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35694. static LongPressDelay: number;
  35695. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35696. static DoubleClickDelay: number;
  35697. /** If you need to check double click without raising a single click at first click, enable this flag */
  35698. static ExclusiveDoubleClickMode: boolean;
  35699. private _wheelEventName;
  35700. private _onPointerMove;
  35701. private _onPointerDown;
  35702. private _onPointerUp;
  35703. private _initClickEvent;
  35704. private _initActionManager;
  35705. private _delayedSimpleClick;
  35706. private _delayedSimpleClickTimeout;
  35707. private _previousDelayedSimpleClickTimeout;
  35708. private _meshPickProceed;
  35709. private _previousButtonPressed;
  35710. private _currentPickResult;
  35711. private _previousPickResult;
  35712. private _totalPointersPressed;
  35713. private _doubleClickOccured;
  35714. private _pointerOverMesh;
  35715. private _pickedDownMesh;
  35716. private _pickedUpMesh;
  35717. private _pointerX;
  35718. private _pointerY;
  35719. private _unTranslatedPointerX;
  35720. private _unTranslatedPointerY;
  35721. private _startingPointerPosition;
  35722. private _previousStartingPointerPosition;
  35723. private _startingPointerTime;
  35724. private _previousStartingPointerTime;
  35725. private _pointerCaptures;
  35726. private _onKeyDown;
  35727. private _onKeyUp;
  35728. private _onCanvasFocusObserver;
  35729. private _onCanvasBlurObserver;
  35730. private _scene;
  35731. /**
  35732. * Creates a new InputManager
  35733. * @param scene defines the hosting scene
  35734. */
  35735. constructor(scene: Scene);
  35736. /**
  35737. * Gets the mesh that is currently under the pointer
  35738. */
  35739. get meshUnderPointer(): Nullable<AbstractMesh>;
  35740. /**
  35741. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35742. */
  35743. get unTranslatedPointer(): Vector2;
  35744. /**
  35745. * Gets or sets the current on-screen X position of the pointer
  35746. */
  35747. get pointerX(): number;
  35748. set pointerX(value: number);
  35749. /**
  35750. * Gets or sets the current on-screen Y position of the pointer
  35751. */
  35752. get pointerY(): number;
  35753. set pointerY(value: number);
  35754. private _updatePointerPosition;
  35755. private _processPointerMove;
  35756. private _setRayOnPointerInfo;
  35757. private _checkPrePointerObservable;
  35758. /**
  35759. * Use this method to simulate a pointer move on a mesh
  35760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35763. */
  35764. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35765. /**
  35766. * Use this method to simulate a pointer down on a mesh
  35767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35770. */
  35771. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35772. private _processPointerDown;
  35773. /** @hidden */
  35774. _isPointerSwiping(): boolean;
  35775. /**
  35776. * Use this method to simulate a pointer up on a mesh
  35777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35780. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35781. */
  35782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35783. private _processPointerUp;
  35784. /**
  35785. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35786. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35787. * @returns true if the pointer was captured
  35788. */
  35789. isPointerCaptured(pointerId?: number): boolean;
  35790. /**
  35791. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35792. * @param attachUp defines if you want to attach events to pointerup
  35793. * @param attachDown defines if you want to attach events to pointerdown
  35794. * @param attachMove defines if you want to attach events to pointermove
  35795. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35796. */
  35797. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35798. /**
  35799. * Detaches all event handlers
  35800. */
  35801. detachControl(): void;
  35802. /**
  35803. * Force the value of meshUnderPointer
  35804. * @param mesh defines the mesh to use
  35805. */
  35806. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35807. /**
  35808. * Gets the mesh under the pointer
  35809. * @returns a Mesh or null if no mesh is under the pointer
  35810. */
  35811. getPointerOverMesh(): Nullable<AbstractMesh>;
  35812. }
  35813. }
  35814. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35815. /**
  35816. * Helper class used to generate session unique ID
  35817. */
  35818. export class UniqueIdGenerator {
  35819. private static _UniqueIdCounter;
  35820. /**
  35821. * Gets an unique (relatively to the current scene) Id
  35822. */
  35823. static get UniqueId(): number;
  35824. }
  35825. }
  35826. declare module "babylonjs/Animations/animationGroup" {
  35827. import { Animatable } from "babylonjs/Animations/animatable";
  35828. import { Animation } from "babylonjs/Animations/animation";
  35829. import { Scene, IDisposable } from "babylonjs/scene";
  35830. import { Observable } from "babylonjs/Misc/observable";
  35831. import { Nullable } from "babylonjs/types";
  35832. import "babylonjs/Animations/animatable";
  35833. /**
  35834. * This class defines the direct association between an animation and a target
  35835. */
  35836. export class TargetedAnimation {
  35837. /**
  35838. * Animation to perform
  35839. */
  35840. animation: Animation;
  35841. /**
  35842. * Target to animate
  35843. */
  35844. target: any;
  35845. /**
  35846. * Serialize the object
  35847. * @returns the JSON object representing the current entity
  35848. */
  35849. serialize(): any;
  35850. }
  35851. /**
  35852. * Use this class to create coordinated animations on multiple targets
  35853. */
  35854. export class AnimationGroup implements IDisposable {
  35855. /** The name of the animation group */
  35856. name: string;
  35857. private _scene;
  35858. private _targetedAnimations;
  35859. private _animatables;
  35860. private _from;
  35861. private _to;
  35862. private _isStarted;
  35863. private _isPaused;
  35864. private _speedRatio;
  35865. private _loopAnimation;
  35866. /**
  35867. * Gets or sets the unique id of the node
  35868. */
  35869. uniqueId: number;
  35870. /**
  35871. * This observable will notify when one animation have ended
  35872. */
  35873. onAnimationEndObservable: Observable<TargetedAnimation>;
  35874. /**
  35875. * Observer raised when one animation loops
  35876. */
  35877. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35878. /**
  35879. * Observer raised when all animations have looped
  35880. */
  35881. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35882. /**
  35883. * This observable will notify when all animations have ended.
  35884. */
  35885. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35886. /**
  35887. * This observable will notify when all animations have paused.
  35888. */
  35889. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35890. /**
  35891. * This observable will notify when all animations are playing.
  35892. */
  35893. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35894. /**
  35895. * Gets the first frame
  35896. */
  35897. get from(): number;
  35898. /**
  35899. * Gets the last frame
  35900. */
  35901. get to(): number;
  35902. /**
  35903. * Define if the animations are started
  35904. */
  35905. get isStarted(): boolean;
  35906. /**
  35907. * Gets a value indicating that the current group is playing
  35908. */
  35909. get isPlaying(): boolean;
  35910. /**
  35911. * Gets or sets the speed ratio to use for all animations
  35912. */
  35913. get speedRatio(): number;
  35914. /**
  35915. * Gets or sets the speed ratio to use for all animations
  35916. */
  35917. set speedRatio(value: number);
  35918. /**
  35919. * Gets or sets if all animations should loop or not
  35920. */
  35921. get loopAnimation(): boolean;
  35922. set loopAnimation(value: boolean);
  35923. /**
  35924. * Gets the targeted animations for this animation group
  35925. */
  35926. get targetedAnimations(): Array<TargetedAnimation>;
  35927. /**
  35928. * returning the list of animatables controlled by this animation group.
  35929. */
  35930. get animatables(): Array<Animatable>;
  35931. /**
  35932. * Instantiates a new Animation Group.
  35933. * This helps managing several animations at once.
  35934. * @see http://doc.babylonjs.com/how_to/group
  35935. * @param name Defines the name of the group
  35936. * @param scene Defines the scene the group belongs to
  35937. */
  35938. constructor(
  35939. /** The name of the animation group */
  35940. name: string, scene?: Nullable<Scene>);
  35941. /**
  35942. * Add an animation (with its target) in the group
  35943. * @param animation defines the animation we want to add
  35944. * @param target defines the target of the animation
  35945. * @returns the TargetedAnimation object
  35946. */
  35947. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35948. /**
  35949. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35950. * It can add constant keys at begin or end
  35951. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35952. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35953. * @returns the animation group
  35954. */
  35955. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35956. private _animationLoopCount;
  35957. private _animationLoopFlags;
  35958. private _processLoop;
  35959. /**
  35960. * Start all animations on given targets
  35961. * @param loop defines if animations must loop
  35962. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35963. * @param from defines the from key (optional)
  35964. * @param to defines the to key (optional)
  35965. * @returns the current animation group
  35966. */
  35967. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35968. /**
  35969. * Pause all animations
  35970. * @returns the animation group
  35971. */
  35972. pause(): AnimationGroup;
  35973. /**
  35974. * Play all animations to initial state
  35975. * This function will start() the animations if they were not started or will restart() them if they were paused
  35976. * @param loop defines if animations must loop
  35977. * @returns the animation group
  35978. */
  35979. play(loop?: boolean): AnimationGroup;
  35980. /**
  35981. * Reset all animations to initial state
  35982. * @returns the animation group
  35983. */
  35984. reset(): AnimationGroup;
  35985. /**
  35986. * Restart animations from key 0
  35987. * @returns the animation group
  35988. */
  35989. restart(): AnimationGroup;
  35990. /**
  35991. * Stop all animations
  35992. * @returns the animation group
  35993. */
  35994. stop(): AnimationGroup;
  35995. /**
  35996. * Set animation weight for all animatables
  35997. * @param weight defines the weight to use
  35998. * @return the animationGroup
  35999. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36000. */
  36001. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36002. /**
  36003. * Synchronize and normalize all animatables with a source animatable
  36004. * @param root defines the root animatable to synchronize with
  36005. * @return the animationGroup
  36006. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36007. */
  36008. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36009. /**
  36010. * Goes to a specific frame in this animation group
  36011. * @param frame the frame number to go to
  36012. * @return the animationGroup
  36013. */
  36014. goToFrame(frame: number): AnimationGroup;
  36015. /**
  36016. * Dispose all associated resources
  36017. */
  36018. dispose(): void;
  36019. private _checkAnimationGroupEnded;
  36020. /**
  36021. * Clone the current animation group and returns a copy
  36022. * @param newName defines the name of the new group
  36023. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36024. * @returns the new aniamtion group
  36025. */
  36026. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36027. /**
  36028. * Serializes the animationGroup to an object
  36029. * @returns Serialized object
  36030. */
  36031. serialize(): any;
  36032. /**
  36033. * Returns a new AnimationGroup object parsed from the source provided.
  36034. * @param parsedAnimationGroup defines the source
  36035. * @param scene defines the scene that will receive the animationGroup
  36036. * @returns a new AnimationGroup
  36037. */
  36038. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36039. /**
  36040. * Returns the string "AnimationGroup"
  36041. * @returns "AnimationGroup"
  36042. */
  36043. getClassName(): string;
  36044. /**
  36045. * Creates a detailled string about the object
  36046. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36047. * @returns a string representing the object
  36048. */
  36049. toString(fullDetails?: boolean): string;
  36050. }
  36051. }
  36052. declare module "babylonjs/scene" {
  36053. import { Nullable } from "babylonjs/types";
  36054. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36055. import { Observable } from "babylonjs/Misc/observable";
  36056. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36057. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36058. import { Geometry } from "babylonjs/Meshes/geometry";
  36059. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36062. import { Mesh } from "babylonjs/Meshes/mesh";
  36063. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36064. import { Bone } from "babylonjs/Bones/bone";
  36065. import { Skeleton } from "babylonjs/Bones/skeleton";
  36066. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36067. import { Camera } from "babylonjs/Cameras/camera";
  36068. import { AbstractScene } from "babylonjs/abstractScene";
  36069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36071. import { Material } from "babylonjs/Materials/material";
  36072. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36073. import { Effect } from "babylonjs/Materials/effect";
  36074. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36075. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36076. import { Light } from "babylonjs/Lights/light";
  36077. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36078. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36079. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36080. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36081. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36082. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36083. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36084. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36085. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36086. import { Engine } from "babylonjs/Engines/engine";
  36087. import { Node } from "babylonjs/node";
  36088. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36089. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36090. import { WebRequest } from "babylonjs/Misc/webRequest";
  36091. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36092. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36093. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36094. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36095. import { Plane } from "babylonjs/Maths/math.plane";
  36096. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36097. import { Ray } from "babylonjs/Culling/ray";
  36098. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36099. import { Animation } from "babylonjs/Animations/animation";
  36100. import { Animatable } from "babylonjs/Animations/animatable";
  36101. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36102. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36103. import { Collider } from "babylonjs/Collisions/collider";
  36104. /**
  36105. * Define an interface for all classes that will hold resources
  36106. */
  36107. export interface IDisposable {
  36108. /**
  36109. * Releases all held resources
  36110. */
  36111. dispose(): void;
  36112. }
  36113. /** Interface defining initialization parameters for Scene class */
  36114. export interface SceneOptions {
  36115. /**
  36116. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36117. * It will improve performance when the number of geometries becomes important.
  36118. */
  36119. useGeometryUniqueIdsMap?: boolean;
  36120. /**
  36121. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36122. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36123. */
  36124. useMaterialMeshMap?: boolean;
  36125. /**
  36126. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36127. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36128. */
  36129. useClonedMeshMap?: boolean;
  36130. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36131. virtual?: boolean;
  36132. }
  36133. /**
  36134. * Represents a scene to be rendered by the engine.
  36135. * @see http://doc.babylonjs.com/features/scene
  36136. */
  36137. export class Scene extends AbstractScene implements IAnimatable {
  36138. /** The fog is deactivated */
  36139. static readonly FOGMODE_NONE: number;
  36140. /** The fog density is following an exponential function */
  36141. static readonly FOGMODE_EXP: number;
  36142. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36143. static readonly FOGMODE_EXP2: number;
  36144. /** The fog density is following a linear function. */
  36145. static readonly FOGMODE_LINEAR: number;
  36146. /**
  36147. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36148. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36149. */
  36150. static MinDeltaTime: number;
  36151. /**
  36152. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36153. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36154. */
  36155. static MaxDeltaTime: number;
  36156. /**
  36157. * Factory used to create the default material.
  36158. * @param name The name of the material to create
  36159. * @param scene The scene to create the material for
  36160. * @returns The default material
  36161. */
  36162. static DefaultMaterialFactory(scene: Scene): Material;
  36163. /**
  36164. * Factory used to create the a collision coordinator.
  36165. * @returns The collision coordinator
  36166. */
  36167. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36168. /** @hidden */
  36169. _inputManager: InputManager;
  36170. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36171. cameraToUseForPointers: Nullable<Camera>;
  36172. /** @hidden */
  36173. readonly _isScene: boolean;
  36174. /** @hidden */
  36175. _blockEntityCollection: boolean;
  36176. /**
  36177. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36178. */
  36179. autoClear: boolean;
  36180. /**
  36181. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36182. */
  36183. autoClearDepthAndStencil: boolean;
  36184. /**
  36185. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36186. */
  36187. clearColor: Color4;
  36188. /**
  36189. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36190. */
  36191. ambientColor: Color3;
  36192. /**
  36193. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36194. * It should only be one of the following (if not the default embedded one):
  36195. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36196. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36197. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36198. * The material properties need to be setup according to the type of texture in use.
  36199. */
  36200. environmentBRDFTexture: BaseTexture;
  36201. /** @hidden */
  36202. protected _environmentTexture: Nullable<BaseTexture>;
  36203. /**
  36204. * Texture used in all pbr material as the reflection texture.
  36205. * As in the majority of the scene they are the same (exception for multi room and so on),
  36206. * this is easier to reference from here than from all the materials.
  36207. */
  36208. get environmentTexture(): Nullable<BaseTexture>;
  36209. /**
  36210. * Texture used in all pbr material as the reflection texture.
  36211. * As in the majority of the scene they are the same (exception for multi room and so on),
  36212. * this is easier to set here than in all the materials.
  36213. */
  36214. set environmentTexture(value: Nullable<BaseTexture>);
  36215. /** @hidden */
  36216. protected _environmentIntensity: number;
  36217. /**
  36218. * Intensity of the environment in all pbr material.
  36219. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36220. * As in the majority of the scene they are the same (exception for multi room and so on),
  36221. * this is easier to reference from here than from all the materials.
  36222. */
  36223. get environmentIntensity(): number;
  36224. /**
  36225. * Intensity of the environment in all pbr material.
  36226. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36227. * As in the majority of the scene they are the same (exception for multi room and so on),
  36228. * this is easier to set here than in all the materials.
  36229. */
  36230. set environmentIntensity(value: number);
  36231. /** @hidden */
  36232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36233. /**
  36234. * Default image processing configuration used either in the rendering
  36235. * Forward main pass or through the imageProcessingPostProcess if present.
  36236. * As in the majority of the scene they are the same (exception for multi camera),
  36237. * this is easier to reference from here than from all the materials and post process.
  36238. *
  36239. * No setter as we it is a shared configuration, you can set the values instead.
  36240. */
  36241. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36242. private _forceWireframe;
  36243. /**
  36244. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36245. */
  36246. set forceWireframe(value: boolean);
  36247. get forceWireframe(): boolean;
  36248. private _skipFrustumClipping;
  36249. /**
  36250. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36251. */
  36252. set skipFrustumClipping(value: boolean);
  36253. get skipFrustumClipping(): boolean;
  36254. private _forcePointsCloud;
  36255. /**
  36256. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36257. */
  36258. set forcePointsCloud(value: boolean);
  36259. get forcePointsCloud(): boolean;
  36260. /**
  36261. * Gets or sets the active clipplane 1
  36262. */
  36263. clipPlane: Nullable<Plane>;
  36264. /**
  36265. * Gets or sets the active clipplane 2
  36266. */
  36267. clipPlane2: Nullable<Plane>;
  36268. /**
  36269. * Gets or sets the active clipplane 3
  36270. */
  36271. clipPlane3: Nullable<Plane>;
  36272. /**
  36273. * Gets or sets the active clipplane 4
  36274. */
  36275. clipPlane4: Nullable<Plane>;
  36276. /**
  36277. * Gets or sets the active clipplane 5
  36278. */
  36279. clipPlane5: Nullable<Plane>;
  36280. /**
  36281. * Gets or sets the active clipplane 6
  36282. */
  36283. clipPlane6: Nullable<Plane>;
  36284. /**
  36285. * Gets or sets a boolean indicating if animations are enabled
  36286. */
  36287. animationsEnabled: boolean;
  36288. private _animationPropertiesOverride;
  36289. /**
  36290. * Gets or sets the animation properties override
  36291. */
  36292. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36293. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36294. /**
  36295. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36296. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36297. */
  36298. useConstantAnimationDeltaTime: boolean;
  36299. /**
  36300. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36301. * Please note that it requires to run a ray cast through the scene on every frame
  36302. */
  36303. constantlyUpdateMeshUnderPointer: boolean;
  36304. /**
  36305. * Defines the HTML cursor to use when hovering over interactive elements
  36306. */
  36307. hoverCursor: string;
  36308. /**
  36309. * Defines the HTML default cursor to use (empty by default)
  36310. */
  36311. defaultCursor: string;
  36312. /**
  36313. * Defines whether cursors are handled by the scene.
  36314. */
  36315. doNotHandleCursors: boolean;
  36316. /**
  36317. * This is used to call preventDefault() on pointer down
  36318. * in order to block unwanted artifacts like system double clicks
  36319. */
  36320. preventDefaultOnPointerDown: boolean;
  36321. /**
  36322. * This is used to call preventDefault() on pointer up
  36323. * in order to block unwanted artifacts like system double clicks
  36324. */
  36325. preventDefaultOnPointerUp: boolean;
  36326. /**
  36327. * Gets or sets user defined metadata
  36328. */
  36329. metadata: any;
  36330. /**
  36331. * For internal use only. Please do not use.
  36332. */
  36333. reservedDataStore: any;
  36334. /**
  36335. * Gets the name of the plugin used to load this scene (null by default)
  36336. */
  36337. loadingPluginName: string;
  36338. /**
  36339. * Use this array to add regular expressions used to disable offline support for specific urls
  36340. */
  36341. disableOfflineSupportExceptionRules: RegExp[];
  36342. /**
  36343. * An event triggered when the scene is disposed.
  36344. */
  36345. onDisposeObservable: Observable<Scene>;
  36346. private _onDisposeObserver;
  36347. /** Sets a function to be executed when this scene is disposed. */
  36348. set onDispose(callback: () => void);
  36349. /**
  36350. * An event triggered before rendering the scene (right after animations and physics)
  36351. */
  36352. onBeforeRenderObservable: Observable<Scene>;
  36353. private _onBeforeRenderObserver;
  36354. /** Sets a function to be executed before rendering this scene */
  36355. set beforeRender(callback: Nullable<() => void>);
  36356. /**
  36357. * An event triggered after rendering the scene
  36358. */
  36359. onAfterRenderObservable: Observable<Scene>;
  36360. /**
  36361. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36362. */
  36363. onAfterRenderCameraObservable: Observable<Camera>;
  36364. private _onAfterRenderObserver;
  36365. /** Sets a function to be executed after rendering this scene */
  36366. set afterRender(callback: Nullable<() => void>);
  36367. /**
  36368. * An event triggered before animating the scene
  36369. */
  36370. onBeforeAnimationsObservable: Observable<Scene>;
  36371. /**
  36372. * An event triggered after animations processing
  36373. */
  36374. onAfterAnimationsObservable: Observable<Scene>;
  36375. /**
  36376. * An event triggered before draw calls are ready to be sent
  36377. */
  36378. onBeforeDrawPhaseObservable: Observable<Scene>;
  36379. /**
  36380. * An event triggered after draw calls have been sent
  36381. */
  36382. onAfterDrawPhaseObservable: Observable<Scene>;
  36383. /**
  36384. * An event triggered when the scene is ready
  36385. */
  36386. onReadyObservable: Observable<Scene>;
  36387. /**
  36388. * An event triggered before rendering a camera
  36389. */
  36390. onBeforeCameraRenderObservable: Observable<Camera>;
  36391. private _onBeforeCameraRenderObserver;
  36392. /** Sets a function to be executed before rendering a camera*/
  36393. set beforeCameraRender(callback: () => void);
  36394. /**
  36395. * An event triggered after rendering a camera
  36396. */
  36397. onAfterCameraRenderObservable: Observable<Camera>;
  36398. private _onAfterCameraRenderObserver;
  36399. /** Sets a function to be executed after rendering a camera*/
  36400. set afterCameraRender(callback: () => void);
  36401. /**
  36402. * An event triggered when active meshes evaluation is about to start
  36403. */
  36404. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36405. /**
  36406. * An event triggered when active meshes evaluation is done
  36407. */
  36408. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36409. /**
  36410. * An event triggered when particles rendering is about to start
  36411. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36412. */
  36413. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36414. /**
  36415. * An event triggered when particles rendering is done
  36416. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36417. */
  36418. onAfterParticlesRenderingObservable: Observable<Scene>;
  36419. /**
  36420. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36421. */
  36422. onDataLoadedObservable: Observable<Scene>;
  36423. /**
  36424. * An event triggered when a camera is created
  36425. */
  36426. onNewCameraAddedObservable: Observable<Camera>;
  36427. /**
  36428. * An event triggered when a camera is removed
  36429. */
  36430. onCameraRemovedObservable: Observable<Camera>;
  36431. /**
  36432. * An event triggered when a light is created
  36433. */
  36434. onNewLightAddedObservable: Observable<Light>;
  36435. /**
  36436. * An event triggered when a light is removed
  36437. */
  36438. onLightRemovedObservable: Observable<Light>;
  36439. /**
  36440. * An event triggered when a geometry is created
  36441. */
  36442. onNewGeometryAddedObservable: Observable<Geometry>;
  36443. /**
  36444. * An event triggered when a geometry is removed
  36445. */
  36446. onGeometryRemovedObservable: Observable<Geometry>;
  36447. /**
  36448. * An event triggered when a transform node is created
  36449. */
  36450. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36451. /**
  36452. * An event triggered when a transform node is removed
  36453. */
  36454. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36455. /**
  36456. * An event triggered when a mesh is created
  36457. */
  36458. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36459. /**
  36460. * An event triggered when a mesh is removed
  36461. */
  36462. onMeshRemovedObservable: Observable<AbstractMesh>;
  36463. /**
  36464. * An event triggered when a skeleton is created
  36465. */
  36466. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36467. /**
  36468. * An event triggered when a skeleton is removed
  36469. */
  36470. onSkeletonRemovedObservable: Observable<Skeleton>;
  36471. /**
  36472. * An event triggered when a material is created
  36473. */
  36474. onNewMaterialAddedObservable: Observable<Material>;
  36475. /**
  36476. * An event triggered when a material is removed
  36477. */
  36478. onMaterialRemovedObservable: Observable<Material>;
  36479. /**
  36480. * An event triggered when a texture is created
  36481. */
  36482. onNewTextureAddedObservable: Observable<BaseTexture>;
  36483. /**
  36484. * An event triggered when a texture is removed
  36485. */
  36486. onTextureRemovedObservable: Observable<BaseTexture>;
  36487. /**
  36488. * An event triggered when render targets are about to be rendered
  36489. * Can happen multiple times per frame.
  36490. */
  36491. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36492. /**
  36493. * An event triggered when render targets were rendered.
  36494. * Can happen multiple times per frame.
  36495. */
  36496. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36497. /**
  36498. * An event triggered before calculating deterministic simulation step
  36499. */
  36500. onBeforeStepObservable: Observable<Scene>;
  36501. /**
  36502. * An event triggered after calculating deterministic simulation step
  36503. */
  36504. onAfterStepObservable: Observable<Scene>;
  36505. /**
  36506. * An event triggered when the activeCamera property is updated
  36507. */
  36508. onActiveCameraChanged: Observable<Scene>;
  36509. /**
  36510. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36511. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36512. * 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)
  36513. */
  36514. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36515. /**
  36516. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36517. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36518. * 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)
  36519. */
  36520. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36521. /**
  36522. * This Observable will when a mesh has been imported into the scene.
  36523. */
  36524. onMeshImportedObservable: Observable<AbstractMesh>;
  36525. /**
  36526. * This Observable will when an animation file has been imported into the scene.
  36527. */
  36528. onAnimationFileImportedObservable: Observable<Scene>;
  36529. /**
  36530. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36531. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36532. */
  36533. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36534. /** @hidden */
  36535. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36536. /**
  36537. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36538. */
  36539. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36540. /**
  36541. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36542. */
  36543. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36544. /**
  36545. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36546. */
  36547. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36548. /** Callback called when a pointer move is detected */
  36549. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36550. /** Callback called when a pointer down is detected */
  36551. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36552. /** Callback called when a pointer up is detected */
  36553. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36554. /** Callback called when a pointer pick is detected */
  36555. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36556. /**
  36557. * 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).
  36558. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36559. */
  36560. onPrePointerObservable: Observable<PointerInfoPre>;
  36561. /**
  36562. * Observable event triggered each time an input event is received from the rendering canvas
  36563. */
  36564. onPointerObservable: Observable<PointerInfo>;
  36565. /**
  36566. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36567. */
  36568. get unTranslatedPointer(): Vector2;
  36569. /**
  36570. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36571. */
  36572. static get DragMovementThreshold(): number;
  36573. static set DragMovementThreshold(value: number);
  36574. /**
  36575. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36576. */
  36577. static get LongPressDelay(): number;
  36578. static set LongPressDelay(value: number);
  36579. /**
  36580. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36581. */
  36582. static get DoubleClickDelay(): number;
  36583. static set DoubleClickDelay(value: number);
  36584. /** If you need to check double click without raising a single click at first click, enable this flag */
  36585. static get ExclusiveDoubleClickMode(): boolean;
  36586. static set ExclusiveDoubleClickMode(value: boolean);
  36587. /** @hidden */
  36588. _mirroredCameraPosition: Nullable<Vector3>;
  36589. /**
  36590. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36591. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36592. */
  36593. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36594. /**
  36595. * Observable event triggered each time an keyboard event is received from the hosting window
  36596. */
  36597. onKeyboardObservable: Observable<KeyboardInfo>;
  36598. private _useRightHandedSystem;
  36599. /**
  36600. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36601. */
  36602. set useRightHandedSystem(value: boolean);
  36603. get useRightHandedSystem(): boolean;
  36604. private _timeAccumulator;
  36605. private _currentStepId;
  36606. private _currentInternalStep;
  36607. /**
  36608. * Sets the step Id used by deterministic lock step
  36609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36610. * @param newStepId defines the step Id
  36611. */
  36612. setStepId(newStepId: number): void;
  36613. /**
  36614. * Gets the step Id used by deterministic lock step
  36615. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36616. * @returns the step Id
  36617. */
  36618. getStepId(): number;
  36619. /**
  36620. * Gets the internal step used by deterministic lock step
  36621. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36622. * @returns the internal step
  36623. */
  36624. getInternalStep(): number;
  36625. private _fogEnabled;
  36626. /**
  36627. * Gets or sets a boolean indicating if fog is enabled on this scene
  36628. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36629. * (Default is true)
  36630. */
  36631. set fogEnabled(value: boolean);
  36632. get fogEnabled(): boolean;
  36633. private _fogMode;
  36634. /**
  36635. * Gets or sets the fog mode to use
  36636. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36637. * | mode | value |
  36638. * | --- | --- |
  36639. * | FOGMODE_NONE | 0 |
  36640. * | FOGMODE_EXP | 1 |
  36641. * | FOGMODE_EXP2 | 2 |
  36642. * | FOGMODE_LINEAR | 3 |
  36643. */
  36644. set fogMode(value: number);
  36645. get fogMode(): number;
  36646. /**
  36647. * Gets or sets the fog color to use
  36648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36649. * (Default is Color3(0.2, 0.2, 0.3))
  36650. */
  36651. fogColor: Color3;
  36652. /**
  36653. * Gets or sets the fog density to use
  36654. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36655. * (Default is 0.1)
  36656. */
  36657. fogDensity: number;
  36658. /**
  36659. * Gets or sets the fog start distance to use
  36660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36661. * (Default is 0)
  36662. */
  36663. fogStart: number;
  36664. /**
  36665. * Gets or sets the fog end distance to use
  36666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36667. * (Default is 1000)
  36668. */
  36669. fogEnd: number;
  36670. private _shadowsEnabled;
  36671. /**
  36672. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36673. */
  36674. set shadowsEnabled(value: boolean);
  36675. get shadowsEnabled(): boolean;
  36676. private _lightsEnabled;
  36677. /**
  36678. * Gets or sets a boolean indicating if lights are enabled on this scene
  36679. */
  36680. set lightsEnabled(value: boolean);
  36681. get lightsEnabled(): boolean;
  36682. /** All of the active cameras added to this scene. */
  36683. activeCameras: Camera[];
  36684. /** @hidden */
  36685. _activeCamera: Nullable<Camera>;
  36686. /** Gets or sets the current active camera */
  36687. get activeCamera(): Nullable<Camera>;
  36688. set activeCamera(value: Nullable<Camera>);
  36689. private _defaultMaterial;
  36690. /** The default material used on meshes when no material is affected */
  36691. get defaultMaterial(): Material;
  36692. /** The default material used on meshes when no material is affected */
  36693. set defaultMaterial(value: Material);
  36694. private _texturesEnabled;
  36695. /**
  36696. * Gets or sets a boolean indicating if textures are enabled on this scene
  36697. */
  36698. set texturesEnabled(value: boolean);
  36699. get texturesEnabled(): boolean;
  36700. /**
  36701. * Gets or sets a boolean indicating if particles are enabled on this scene
  36702. */
  36703. particlesEnabled: boolean;
  36704. /**
  36705. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36706. */
  36707. spritesEnabled: boolean;
  36708. private _skeletonsEnabled;
  36709. /**
  36710. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36711. */
  36712. set skeletonsEnabled(value: boolean);
  36713. get skeletonsEnabled(): boolean;
  36714. /**
  36715. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36716. */
  36717. lensFlaresEnabled: boolean;
  36718. /**
  36719. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36720. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36721. */
  36722. collisionsEnabled: boolean;
  36723. private _collisionCoordinator;
  36724. /** @hidden */
  36725. get collisionCoordinator(): ICollisionCoordinator;
  36726. /**
  36727. * Defines the gravity applied to this scene (used only for collisions)
  36728. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36729. */
  36730. gravity: Vector3;
  36731. /**
  36732. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36733. */
  36734. postProcessesEnabled: boolean;
  36735. /**
  36736. * The list of postprocesses added to the scene
  36737. */
  36738. postProcesses: PostProcess[];
  36739. /**
  36740. * Gets the current postprocess manager
  36741. */
  36742. postProcessManager: PostProcessManager;
  36743. /**
  36744. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36745. */
  36746. renderTargetsEnabled: boolean;
  36747. /**
  36748. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36749. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36750. */
  36751. dumpNextRenderTargets: boolean;
  36752. /**
  36753. * The list of user defined render targets added to the scene
  36754. */
  36755. customRenderTargets: RenderTargetTexture[];
  36756. /**
  36757. * Defines if texture loading must be delayed
  36758. * If true, textures will only be loaded when they need to be rendered
  36759. */
  36760. useDelayedTextureLoading: boolean;
  36761. /**
  36762. * Gets the list of meshes imported to the scene through SceneLoader
  36763. */
  36764. importedMeshesFiles: String[];
  36765. /**
  36766. * Gets or sets a boolean indicating if probes are enabled on this scene
  36767. */
  36768. probesEnabled: boolean;
  36769. /**
  36770. * Gets or sets the current offline provider to use to store scene data
  36771. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36772. */
  36773. offlineProvider: IOfflineProvider;
  36774. /**
  36775. * Gets or sets the action manager associated with the scene
  36776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36777. */
  36778. actionManager: AbstractActionManager;
  36779. private _meshesForIntersections;
  36780. /**
  36781. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36782. */
  36783. proceduralTexturesEnabled: boolean;
  36784. private _engine;
  36785. private _totalVertices;
  36786. /** @hidden */
  36787. _activeIndices: PerfCounter;
  36788. /** @hidden */
  36789. _activeParticles: PerfCounter;
  36790. /** @hidden */
  36791. _activeBones: PerfCounter;
  36792. private _animationRatio;
  36793. /** @hidden */
  36794. _animationTimeLast: number;
  36795. /** @hidden */
  36796. _animationTime: number;
  36797. /**
  36798. * Gets or sets a general scale for animation speed
  36799. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36800. */
  36801. animationTimeScale: number;
  36802. /** @hidden */
  36803. _cachedMaterial: Nullable<Material>;
  36804. /** @hidden */
  36805. _cachedEffect: Nullable<Effect>;
  36806. /** @hidden */
  36807. _cachedVisibility: Nullable<number>;
  36808. private _renderId;
  36809. private _frameId;
  36810. private _executeWhenReadyTimeoutId;
  36811. private _intermediateRendering;
  36812. private _viewUpdateFlag;
  36813. private _projectionUpdateFlag;
  36814. /** @hidden */
  36815. _toBeDisposed: Nullable<IDisposable>[];
  36816. private _activeRequests;
  36817. /** @hidden */
  36818. _pendingData: any[];
  36819. private _isDisposed;
  36820. /**
  36821. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36822. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36823. */
  36824. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36825. private _activeMeshes;
  36826. private _processedMaterials;
  36827. private _renderTargets;
  36828. /** @hidden */
  36829. _activeParticleSystems: SmartArray<IParticleSystem>;
  36830. private _activeSkeletons;
  36831. private _softwareSkinnedMeshes;
  36832. private _renderingManager;
  36833. /** @hidden */
  36834. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36835. private _transformMatrix;
  36836. private _sceneUbo;
  36837. /** @hidden */
  36838. _viewMatrix: Matrix;
  36839. private _projectionMatrix;
  36840. /** @hidden */
  36841. _forcedViewPosition: Nullable<Vector3>;
  36842. /** @hidden */
  36843. _frustumPlanes: Plane[];
  36844. /**
  36845. * Gets the list of frustum planes (built from the active camera)
  36846. */
  36847. get frustumPlanes(): Plane[];
  36848. /**
  36849. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36850. * This is useful if there are more lights that the maximum simulteanous authorized
  36851. */
  36852. requireLightSorting: boolean;
  36853. /** @hidden */
  36854. readonly useMaterialMeshMap: boolean;
  36855. /** @hidden */
  36856. readonly useClonedMeshMap: boolean;
  36857. private _externalData;
  36858. private _uid;
  36859. /**
  36860. * @hidden
  36861. * Backing store of defined scene components.
  36862. */
  36863. _components: ISceneComponent[];
  36864. /**
  36865. * @hidden
  36866. * Backing store of defined scene components.
  36867. */
  36868. _serializableComponents: ISceneSerializableComponent[];
  36869. /**
  36870. * List of components to register on the next registration step.
  36871. */
  36872. private _transientComponents;
  36873. /**
  36874. * Registers the transient components if needed.
  36875. */
  36876. private _registerTransientComponents;
  36877. /**
  36878. * @hidden
  36879. * Add a component to the scene.
  36880. * Note that the ccomponent could be registered on th next frame if this is called after
  36881. * the register component stage.
  36882. * @param component Defines the component to add to the scene
  36883. */
  36884. _addComponent(component: ISceneComponent): void;
  36885. /**
  36886. * @hidden
  36887. * Gets a component from the scene.
  36888. * @param name defines the name of the component to retrieve
  36889. * @returns the component or null if not present
  36890. */
  36891. _getComponent(name: string): Nullable<ISceneComponent>;
  36892. /**
  36893. * @hidden
  36894. * Defines the actions happening before camera updates.
  36895. */
  36896. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36897. /**
  36898. * @hidden
  36899. * Defines the actions happening before clear the canvas.
  36900. */
  36901. _beforeClearStage: Stage<SimpleStageAction>;
  36902. /**
  36903. * @hidden
  36904. * Defines the actions when collecting render targets for the frame.
  36905. */
  36906. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36907. /**
  36908. * @hidden
  36909. * Defines the actions happening for one camera in the frame.
  36910. */
  36911. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36912. /**
  36913. * @hidden
  36914. * Defines the actions happening during the per mesh ready checks.
  36915. */
  36916. _isReadyForMeshStage: Stage<MeshStageAction>;
  36917. /**
  36918. * @hidden
  36919. * Defines the actions happening before evaluate active mesh checks.
  36920. */
  36921. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36922. /**
  36923. * @hidden
  36924. * Defines the actions happening during the evaluate sub mesh checks.
  36925. */
  36926. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36927. /**
  36928. * @hidden
  36929. * Defines the actions happening during the active mesh stage.
  36930. */
  36931. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36932. /**
  36933. * @hidden
  36934. * Defines the actions happening during the per camera render target step.
  36935. */
  36936. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36937. /**
  36938. * @hidden
  36939. * Defines the actions happening just before the active camera is drawing.
  36940. */
  36941. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36942. /**
  36943. * @hidden
  36944. * Defines the actions happening just before a render target is drawing.
  36945. */
  36946. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36947. /**
  36948. * @hidden
  36949. * Defines the actions happening just before a rendering group is drawing.
  36950. */
  36951. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36952. /**
  36953. * @hidden
  36954. * Defines the actions happening just before a mesh is drawing.
  36955. */
  36956. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36957. /**
  36958. * @hidden
  36959. * Defines the actions happening just after a mesh has been drawn.
  36960. */
  36961. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36962. /**
  36963. * @hidden
  36964. * Defines the actions happening just after a rendering group has been drawn.
  36965. */
  36966. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36967. /**
  36968. * @hidden
  36969. * Defines the actions happening just after the active camera has been drawn.
  36970. */
  36971. _afterCameraDrawStage: Stage<CameraStageAction>;
  36972. /**
  36973. * @hidden
  36974. * Defines the actions happening just after a render target has been drawn.
  36975. */
  36976. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36977. /**
  36978. * @hidden
  36979. * Defines the actions happening just after rendering all cameras and computing intersections.
  36980. */
  36981. _afterRenderStage: Stage<SimpleStageAction>;
  36982. /**
  36983. * @hidden
  36984. * Defines the actions happening when a pointer move event happens.
  36985. */
  36986. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36987. /**
  36988. * @hidden
  36989. * Defines the actions happening when a pointer down event happens.
  36990. */
  36991. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36992. /**
  36993. * @hidden
  36994. * Defines the actions happening when a pointer up event happens.
  36995. */
  36996. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36997. /**
  36998. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36999. */
  37000. private geometriesByUniqueId;
  37001. /**
  37002. * Creates a new Scene
  37003. * @param engine defines the engine to use to render this scene
  37004. * @param options defines the scene options
  37005. */
  37006. constructor(engine: Engine, options?: SceneOptions);
  37007. /**
  37008. * Gets a string idenfifying the name of the class
  37009. * @returns "Scene" string
  37010. */
  37011. getClassName(): string;
  37012. private _defaultMeshCandidates;
  37013. /**
  37014. * @hidden
  37015. */
  37016. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37017. private _defaultSubMeshCandidates;
  37018. /**
  37019. * @hidden
  37020. */
  37021. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37022. /**
  37023. * Sets the default candidate providers for the scene.
  37024. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37025. * and getCollidingSubMeshCandidates to their default function
  37026. */
  37027. setDefaultCandidateProviders(): void;
  37028. /**
  37029. * Gets the mesh that is currently under the pointer
  37030. */
  37031. get meshUnderPointer(): Nullable<AbstractMesh>;
  37032. /**
  37033. * Gets or sets the current on-screen X position of the pointer
  37034. */
  37035. get pointerX(): number;
  37036. set pointerX(value: number);
  37037. /**
  37038. * Gets or sets the current on-screen Y position of the pointer
  37039. */
  37040. get pointerY(): number;
  37041. set pointerY(value: number);
  37042. /**
  37043. * Gets the cached material (ie. the latest rendered one)
  37044. * @returns the cached material
  37045. */
  37046. getCachedMaterial(): Nullable<Material>;
  37047. /**
  37048. * Gets the cached effect (ie. the latest rendered one)
  37049. * @returns the cached effect
  37050. */
  37051. getCachedEffect(): Nullable<Effect>;
  37052. /**
  37053. * Gets the cached visibility state (ie. the latest rendered one)
  37054. * @returns the cached visibility state
  37055. */
  37056. getCachedVisibility(): Nullable<number>;
  37057. /**
  37058. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37059. * @param material defines the current material
  37060. * @param effect defines the current effect
  37061. * @param visibility defines the current visibility state
  37062. * @returns true if one parameter is not cached
  37063. */
  37064. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37065. /**
  37066. * Gets the engine associated with the scene
  37067. * @returns an Engine
  37068. */
  37069. getEngine(): Engine;
  37070. /**
  37071. * Gets the total number of vertices rendered per frame
  37072. * @returns the total number of vertices rendered per frame
  37073. */
  37074. getTotalVertices(): number;
  37075. /**
  37076. * Gets the performance counter for total vertices
  37077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37078. */
  37079. get totalVerticesPerfCounter(): PerfCounter;
  37080. /**
  37081. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37082. * @returns the total number of active indices rendered per frame
  37083. */
  37084. getActiveIndices(): number;
  37085. /**
  37086. * Gets the performance counter for active indices
  37087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37088. */
  37089. get totalActiveIndicesPerfCounter(): PerfCounter;
  37090. /**
  37091. * Gets the total number of active particles rendered per frame
  37092. * @returns the total number of active particles rendered per frame
  37093. */
  37094. getActiveParticles(): number;
  37095. /**
  37096. * Gets the performance counter for active particles
  37097. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37098. */
  37099. get activeParticlesPerfCounter(): PerfCounter;
  37100. /**
  37101. * Gets the total number of active bones rendered per frame
  37102. * @returns the total number of active bones rendered per frame
  37103. */
  37104. getActiveBones(): number;
  37105. /**
  37106. * Gets the performance counter for active bones
  37107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37108. */
  37109. get activeBonesPerfCounter(): PerfCounter;
  37110. /**
  37111. * Gets the array of active meshes
  37112. * @returns an array of AbstractMesh
  37113. */
  37114. getActiveMeshes(): SmartArray<AbstractMesh>;
  37115. /**
  37116. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37117. * @returns a number
  37118. */
  37119. getAnimationRatio(): number;
  37120. /**
  37121. * Gets an unique Id for the current render phase
  37122. * @returns a number
  37123. */
  37124. getRenderId(): number;
  37125. /**
  37126. * Gets an unique Id for the current frame
  37127. * @returns a number
  37128. */
  37129. getFrameId(): number;
  37130. /** Call this function if you want to manually increment the render Id*/
  37131. incrementRenderId(): void;
  37132. private _createUbo;
  37133. /**
  37134. * Use this method to simulate a pointer move on a mesh
  37135. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37136. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37137. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37138. * @returns the current scene
  37139. */
  37140. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37141. /**
  37142. * Use this method to simulate a pointer down on a mesh
  37143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37146. * @returns the current scene
  37147. */
  37148. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37149. /**
  37150. * Use this method to simulate a pointer up on a mesh
  37151. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37152. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37153. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37154. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37155. * @returns the current scene
  37156. */
  37157. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37158. /**
  37159. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37160. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37161. * @returns true if the pointer was captured
  37162. */
  37163. isPointerCaptured(pointerId?: number): boolean;
  37164. /**
  37165. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37166. * @param attachUp defines if you want to attach events to pointerup
  37167. * @param attachDown defines if you want to attach events to pointerdown
  37168. * @param attachMove defines if you want to attach events to pointermove
  37169. */
  37170. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37171. /** Detaches all event handlers*/
  37172. detachControl(): void;
  37173. /**
  37174. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37175. * Delay loaded resources are not taking in account
  37176. * @return true if all required resources are ready
  37177. */
  37178. isReady(): boolean;
  37179. /** Resets all cached information relative to material (including effect and visibility) */
  37180. resetCachedMaterial(): void;
  37181. /**
  37182. * Registers a function to be called before every frame render
  37183. * @param func defines the function to register
  37184. */
  37185. registerBeforeRender(func: () => void): void;
  37186. /**
  37187. * Unregisters a function called before every frame render
  37188. * @param func defines the function to unregister
  37189. */
  37190. unregisterBeforeRender(func: () => void): void;
  37191. /**
  37192. * Registers a function to be called after every frame render
  37193. * @param func defines the function to register
  37194. */
  37195. registerAfterRender(func: () => void): void;
  37196. /**
  37197. * Unregisters a function called after every frame render
  37198. * @param func defines the function to unregister
  37199. */
  37200. unregisterAfterRender(func: () => void): void;
  37201. private _executeOnceBeforeRender;
  37202. /**
  37203. * The provided function will run before render once and will be disposed afterwards.
  37204. * A timeout delay can be provided so that the function will be executed in N ms.
  37205. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37206. * @param func The function to be executed.
  37207. * @param timeout optional delay in ms
  37208. */
  37209. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37210. /** @hidden */
  37211. _addPendingData(data: any): void;
  37212. /** @hidden */
  37213. _removePendingData(data: any): void;
  37214. /**
  37215. * Returns the number of items waiting to be loaded
  37216. * @returns the number of items waiting to be loaded
  37217. */
  37218. getWaitingItemsCount(): number;
  37219. /**
  37220. * Returns a boolean indicating if the scene is still loading data
  37221. */
  37222. get isLoading(): boolean;
  37223. /**
  37224. * Registers a function to be executed when the scene is ready
  37225. * @param {Function} func - the function to be executed
  37226. */
  37227. executeWhenReady(func: () => void): void;
  37228. /**
  37229. * Returns a promise that resolves when the scene is ready
  37230. * @returns A promise that resolves when the scene is ready
  37231. */
  37232. whenReadyAsync(): Promise<void>;
  37233. /** @hidden */
  37234. _checkIsReady(): void;
  37235. /**
  37236. * Gets all animatable attached to the scene
  37237. */
  37238. get animatables(): Animatable[];
  37239. /**
  37240. * Resets the last animation time frame.
  37241. * Useful to override when animations start running when loading a scene for the first time.
  37242. */
  37243. resetLastAnimationTimeFrame(): void;
  37244. /**
  37245. * Gets the current view matrix
  37246. * @returns a Matrix
  37247. */
  37248. getViewMatrix(): Matrix;
  37249. /**
  37250. * Gets the current projection matrix
  37251. * @returns a Matrix
  37252. */
  37253. getProjectionMatrix(): Matrix;
  37254. /**
  37255. * Gets the current transform matrix
  37256. * @returns a Matrix made of View * Projection
  37257. */
  37258. getTransformMatrix(): Matrix;
  37259. /**
  37260. * Sets the current transform matrix
  37261. * @param viewL defines the View matrix to use
  37262. * @param projectionL defines the Projection matrix to use
  37263. * @param viewR defines the right View matrix to use (if provided)
  37264. * @param projectionR defines the right Projection matrix to use (if provided)
  37265. */
  37266. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37267. /**
  37268. * Gets the uniform buffer used to store scene data
  37269. * @returns a UniformBuffer
  37270. */
  37271. getSceneUniformBuffer(): UniformBuffer;
  37272. /**
  37273. * Gets an unique (relatively to the current scene) Id
  37274. * @returns an unique number for the scene
  37275. */
  37276. getUniqueId(): number;
  37277. /**
  37278. * Add a mesh to the list of scene's meshes
  37279. * @param newMesh defines the mesh to add
  37280. * @param recursive if all child meshes should also be added to the scene
  37281. */
  37282. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37283. /**
  37284. * Remove a mesh for the list of scene's meshes
  37285. * @param toRemove defines the mesh to remove
  37286. * @param recursive if all child meshes should also be removed from the scene
  37287. * @returns the index where the mesh was in the mesh list
  37288. */
  37289. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37290. /**
  37291. * Add a transform node to the list of scene's transform nodes
  37292. * @param newTransformNode defines the transform node to add
  37293. */
  37294. addTransformNode(newTransformNode: TransformNode): void;
  37295. /**
  37296. * Remove a transform node for the list of scene's transform nodes
  37297. * @param toRemove defines the transform node to remove
  37298. * @returns the index where the transform node was in the transform node list
  37299. */
  37300. removeTransformNode(toRemove: TransformNode): number;
  37301. /**
  37302. * Remove a skeleton for the list of scene's skeletons
  37303. * @param toRemove defines the skeleton to remove
  37304. * @returns the index where the skeleton was in the skeleton list
  37305. */
  37306. removeSkeleton(toRemove: Skeleton): number;
  37307. /**
  37308. * Remove a morph target for the list of scene's morph targets
  37309. * @param toRemove defines the morph target to remove
  37310. * @returns the index where the morph target was in the morph target list
  37311. */
  37312. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37313. /**
  37314. * Remove a light for the list of scene's lights
  37315. * @param toRemove defines the light to remove
  37316. * @returns the index where the light was in the light list
  37317. */
  37318. removeLight(toRemove: Light): number;
  37319. /**
  37320. * Remove a camera for the list of scene's cameras
  37321. * @param toRemove defines the camera to remove
  37322. * @returns the index where the camera was in the camera list
  37323. */
  37324. removeCamera(toRemove: Camera): number;
  37325. /**
  37326. * Remove a particle system for the list of scene's particle systems
  37327. * @param toRemove defines the particle system to remove
  37328. * @returns the index where the particle system was in the particle system list
  37329. */
  37330. removeParticleSystem(toRemove: IParticleSystem): number;
  37331. /**
  37332. * Remove a animation for the list of scene's animations
  37333. * @param toRemove defines the animation to remove
  37334. * @returns the index where the animation was in the animation list
  37335. */
  37336. removeAnimation(toRemove: Animation): number;
  37337. /**
  37338. * Will stop the animation of the given target
  37339. * @param target - the target
  37340. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37341. * @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)
  37342. */
  37343. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37344. /**
  37345. * Removes the given animation group from this scene.
  37346. * @param toRemove The animation group to remove
  37347. * @returns The index of the removed animation group
  37348. */
  37349. removeAnimationGroup(toRemove: AnimationGroup): number;
  37350. /**
  37351. * Removes the given multi-material from this scene.
  37352. * @param toRemove The multi-material to remove
  37353. * @returns The index of the removed multi-material
  37354. */
  37355. removeMultiMaterial(toRemove: MultiMaterial): number;
  37356. /**
  37357. * Removes the given material from this scene.
  37358. * @param toRemove The material to remove
  37359. * @returns The index of the removed material
  37360. */
  37361. removeMaterial(toRemove: Material): number;
  37362. /**
  37363. * Removes the given action manager from this scene.
  37364. * @param toRemove The action manager to remove
  37365. * @returns The index of the removed action manager
  37366. */
  37367. removeActionManager(toRemove: AbstractActionManager): number;
  37368. /**
  37369. * Removes the given texture from this scene.
  37370. * @param toRemove The texture to remove
  37371. * @returns The index of the removed texture
  37372. */
  37373. removeTexture(toRemove: BaseTexture): number;
  37374. /**
  37375. * Adds the given light to this scene
  37376. * @param newLight The light to add
  37377. */
  37378. addLight(newLight: Light): void;
  37379. /**
  37380. * Sorts the list list based on light priorities
  37381. */
  37382. sortLightsByPriority(): void;
  37383. /**
  37384. * Adds the given camera to this scene
  37385. * @param newCamera The camera to add
  37386. */
  37387. addCamera(newCamera: Camera): void;
  37388. /**
  37389. * Adds the given skeleton to this scene
  37390. * @param newSkeleton The skeleton to add
  37391. */
  37392. addSkeleton(newSkeleton: Skeleton): void;
  37393. /**
  37394. * Adds the given particle system to this scene
  37395. * @param newParticleSystem The particle system to add
  37396. */
  37397. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37398. /**
  37399. * Adds the given animation to this scene
  37400. * @param newAnimation The animation to add
  37401. */
  37402. addAnimation(newAnimation: Animation): void;
  37403. /**
  37404. * Adds the given animation group to this scene.
  37405. * @param newAnimationGroup The animation group to add
  37406. */
  37407. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37408. /**
  37409. * Adds the given multi-material to this scene
  37410. * @param newMultiMaterial The multi-material to add
  37411. */
  37412. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37413. /**
  37414. * Adds the given material to this scene
  37415. * @param newMaterial The material to add
  37416. */
  37417. addMaterial(newMaterial: Material): void;
  37418. /**
  37419. * Adds the given morph target to this scene
  37420. * @param newMorphTargetManager The morph target to add
  37421. */
  37422. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37423. /**
  37424. * Adds the given geometry to this scene
  37425. * @param newGeometry The geometry to add
  37426. */
  37427. addGeometry(newGeometry: Geometry): void;
  37428. /**
  37429. * Adds the given action manager to this scene
  37430. * @param newActionManager The action manager to add
  37431. */
  37432. addActionManager(newActionManager: AbstractActionManager): void;
  37433. /**
  37434. * Adds the given texture to this scene.
  37435. * @param newTexture The texture to add
  37436. */
  37437. addTexture(newTexture: BaseTexture): void;
  37438. /**
  37439. * Switch active camera
  37440. * @param newCamera defines the new active camera
  37441. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37442. */
  37443. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37444. /**
  37445. * sets the active camera of the scene using its ID
  37446. * @param id defines the camera's ID
  37447. * @return the new active camera or null if none found.
  37448. */
  37449. setActiveCameraByID(id: string): Nullable<Camera>;
  37450. /**
  37451. * sets the active camera of the scene using its name
  37452. * @param name defines the camera's name
  37453. * @returns the new active camera or null if none found.
  37454. */
  37455. setActiveCameraByName(name: string): Nullable<Camera>;
  37456. /**
  37457. * get an animation group using its name
  37458. * @param name defines the material's name
  37459. * @return the animation group or null if none found.
  37460. */
  37461. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37462. /**
  37463. * Get a material using its unique id
  37464. * @param uniqueId defines the material's unique id
  37465. * @return the material or null if none found.
  37466. */
  37467. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37468. /**
  37469. * get a material using its id
  37470. * @param id defines the material's ID
  37471. * @return the material or null if none found.
  37472. */
  37473. getMaterialByID(id: string): Nullable<Material>;
  37474. /**
  37475. * Gets a the last added material using a given id
  37476. * @param id defines the material's ID
  37477. * @return the last material with the given id or null if none found.
  37478. */
  37479. getLastMaterialByID(id: string): Nullable<Material>;
  37480. /**
  37481. * Gets a material using its name
  37482. * @param name defines the material's name
  37483. * @return the material or null if none found.
  37484. */
  37485. getMaterialByName(name: string): Nullable<Material>;
  37486. /**
  37487. * Get a texture using its unique id
  37488. * @param uniqueId defines the texture's unique id
  37489. * @return the texture or null if none found.
  37490. */
  37491. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37492. /**
  37493. * Gets a camera using its id
  37494. * @param id defines the id to look for
  37495. * @returns the camera or null if not found
  37496. */
  37497. getCameraByID(id: string): Nullable<Camera>;
  37498. /**
  37499. * Gets a camera using its unique id
  37500. * @param uniqueId defines the unique id to look for
  37501. * @returns the camera or null if not found
  37502. */
  37503. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37504. /**
  37505. * Gets a camera using its name
  37506. * @param name defines the camera's name
  37507. * @return the camera or null if none found.
  37508. */
  37509. getCameraByName(name: string): Nullable<Camera>;
  37510. /**
  37511. * Gets a bone using its id
  37512. * @param id defines the bone's id
  37513. * @return the bone or null if not found
  37514. */
  37515. getBoneByID(id: string): Nullable<Bone>;
  37516. /**
  37517. * Gets a bone using its id
  37518. * @param name defines the bone's name
  37519. * @return the bone or null if not found
  37520. */
  37521. getBoneByName(name: string): Nullable<Bone>;
  37522. /**
  37523. * Gets a light node using its name
  37524. * @param name defines the the light's name
  37525. * @return the light or null if none found.
  37526. */
  37527. getLightByName(name: string): Nullable<Light>;
  37528. /**
  37529. * Gets a light node using its id
  37530. * @param id defines the light's id
  37531. * @return the light or null if none found.
  37532. */
  37533. getLightByID(id: string): Nullable<Light>;
  37534. /**
  37535. * Gets a light node using its scene-generated unique ID
  37536. * @param uniqueId defines the light's unique id
  37537. * @return the light or null if none found.
  37538. */
  37539. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37540. /**
  37541. * Gets a particle system by id
  37542. * @param id defines the particle system id
  37543. * @return the corresponding system or null if none found
  37544. */
  37545. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37546. /**
  37547. * Gets a geometry using its ID
  37548. * @param id defines the geometry's id
  37549. * @return the geometry or null if none found.
  37550. */
  37551. getGeometryByID(id: string): Nullable<Geometry>;
  37552. private _getGeometryByUniqueID;
  37553. /**
  37554. * Add a new geometry to this scene
  37555. * @param geometry defines the geometry to be added to the scene.
  37556. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37557. * @return a boolean defining if the geometry was added or not
  37558. */
  37559. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37560. /**
  37561. * Removes an existing geometry
  37562. * @param geometry defines the geometry to be removed from the scene
  37563. * @return a boolean defining if the geometry was removed or not
  37564. */
  37565. removeGeometry(geometry: Geometry): boolean;
  37566. /**
  37567. * Gets the list of geometries attached to the scene
  37568. * @returns an array of Geometry
  37569. */
  37570. getGeometries(): Geometry[];
  37571. /**
  37572. * Gets the first added mesh found of a given ID
  37573. * @param id defines the id to search for
  37574. * @return the mesh found or null if not found at all
  37575. */
  37576. getMeshByID(id: string): Nullable<AbstractMesh>;
  37577. /**
  37578. * Gets a list of meshes using their id
  37579. * @param id defines the id to search for
  37580. * @returns a list of meshes
  37581. */
  37582. getMeshesByID(id: string): Array<AbstractMesh>;
  37583. /**
  37584. * Gets the first added transform node found of a given ID
  37585. * @param id defines the id to search for
  37586. * @return the found transform node or null if not found at all.
  37587. */
  37588. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37589. /**
  37590. * Gets a transform node with its auto-generated unique id
  37591. * @param uniqueId efines the unique id to search for
  37592. * @return the found transform node or null if not found at all.
  37593. */
  37594. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37595. /**
  37596. * Gets a list of transform nodes using their id
  37597. * @param id defines the id to search for
  37598. * @returns a list of transform nodes
  37599. */
  37600. getTransformNodesByID(id: string): Array<TransformNode>;
  37601. /**
  37602. * Gets a mesh with its auto-generated unique id
  37603. * @param uniqueId defines the unique id to search for
  37604. * @return the found mesh or null if not found at all.
  37605. */
  37606. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37607. /**
  37608. * Gets a the last added mesh using a given id
  37609. * @param id defines the id to search for
  37610. * @return the found mesh or null if not found at all.
  37611. */
  37612. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37613. /**
  37614. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37615. * @param id defines the id to search for
  37616. * @return the found node or null if not found at all
  37617. */
  37618. getLastEntryByID(id: string): Nullable<Node>;
  37619. /**
  37620. * Gets a node (Mesh, Camera, Light) using a given id
  37621. * @param id defines the id to search for
  37622. * @return the found node or null if not found at all
  37623. */
  37624. getNodeByID(id: string): Nullable<Node>;
  37625. /**
  37626. * Gets a node (Mesh, Camera, Light) using a given name
  37627. * @param name defines the name to search for
  37628. * @return the found node or null if not found at all.
  37629. */
  37630. getNodeByName(name: string): Nullable<Node>;
  37631. /**
  37632. * Gets a mesh using a given name
  37633. * @param name defines the name to search for
  37634. * @return the found mesh or null if not found at all.
  37635. */
  37636. getMeshByName(name: string): Nullable<AbstractMesh>;
  37637. /**
  37638. * Gets a transform node using a given name
  37639. * @param name defines the name to search for
  37640. * @return the found transform node or null if not found at all.
  37641. */
  37642. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37643. /**
  37644. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37645. * @param id defines the id to search for
  37646. * @return the found skeleton or null if not found at all.
  37647. */
  37648. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37649. /**
  37650. * Gets a skeleton using a given auto generated unique id
  37651. * @param uniqueId defines the unique id to search for
  37652. * @return the found skeleton or null if not found at all.
  37653. */
  37654. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37655. /**
  37656. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37657. * @param id defines the id to search for
  37658. * @return the found skeleton or null if not found at all.
  37659. */
  37660. getSkeletonById(id: string): Nullable<Skeleton>;
  37661. /**
  37662. * Gets a skeleton using a given name
  37663. * @param name defines the name to search for
  37664. * @return the found skeleton or null if not found at all.
  37665. */
  37666. getSkeletonByName(name: string): Nullable<Skeleton>;
  37667. /**
  37668. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37669. * @param id defines the id to search for
  37670. * @return the found morph target manager or null if not found at all.
  37671. */
  37672. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37673. /**
  37674. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37675. * @param id defines the id to search for
  37676. * @return the found morph target or null if not found at all.
  37677. */
  37678. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37679. /**
  37680. * Gets a boolean indicating if the given mesh is active
  37681. * @param mesh defines the mesh to look for
  37682. * @returns true if the mesh is in the active list
  37683. */
  37684. isActiveMesh(mesh: AbstractMesh): boolean;
  37685. /**
  37686. * Return a unique id as a string which can serve as an identifier for the scene
  37687. */
  37688. get uid(): string;
  37689. /**
  37690. * Add an externaly attached data from its key.
  37691. * This method call will fail and return false, if such key already exists.
  37692. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37693. * @param key the unique key that identifies the data
  37694. * @param data the data object to associate to the key for this Engine instance
  37695. * @return true if no such key were already present and the data was added successfully, false otherwise
  37696. */
  37697. addExternalData<T>(key: string, data: T): boolean;
  37698. /**
  37699. * Get an externaly attached data from its key
  37700. * @param key the unique key that identifies the data
  37701. * @return the associated data, if present (can be null), or undefined if not present
  37702. */
  37703. getExternalData<T>(key: string): Nullable<T>;
  37704. /**
  37705. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37706. * @param key the unique key that identifies the data
  37707. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37708. * @return the associated data, can be null if the factory returned null.
  37709. */
  37710. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37711. /**
  37712. * Remove an externaly attached data from the Engine instance
  37713. * @param key the unique key that identifies the data
  37714. * @return true if the data was successfully removed, false if it doesn't exist
  37715. */
  37716. removeExternalData(key: string): boolean;
  37717. private _evaluateSubMesh;
  37718. /**
  37719. * Clear the processed materials smart array preventing retention point in material dispose.
  37720. */
  37721. freeProcessedMaterials(): void;
  37722. private _preventFreeActiveMeshesAndRenderingGroups;
  37723. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37724. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37725. * when disposing several meshes in a row or a hierarchy of meshes.
  37726. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37727. */
  37728. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37729. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37730. /**
  37731. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37732. */
  37733. freeActiveMeshes(): void;
  37734. /**
  37735. * Clear the info related to rendering groups preventing retention points during dispose.
  37736. */
  37737. freeRenderingGroups(): void;
  37738. /** @hidden */
  37739. _isInIntermediateRendering(): boolean;
  37740. /**
  37741. * Lambda returning the list of potentially active meshes.
  37742. */
  37743. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37744. /**
  37745. * Lambda returning the list of potentially active sub meshes.
  37746. */
  37747. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37748. /**
  37749. * Lambda returning the list of potentially intersecting sub meshes.
  37750. */
  37751. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37752. /**
  37753. * Lambda returning the list of potentially colliding sub meshes.
  37754. */
  37755. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37756. private _activeMeshesFrozen;
  37757. private _skipEvaluateActiveMeshesCompletely;
  37758. /**
  37759. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37760. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37761. * @returns the current scene
  37762. */
  37763. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37764. /**
  37765. * Use this function to restart evaluating active meshes on every frame
  37766. * @returns the current scene
  37767. */
  37768. unfreezeActiveMeshes(): Scene;
  37769. private _evaluateActiveMeshes;
  37770. private _activeMesh;
  37771. /**
  37772. * Update the transform matrix to update from the current active camera
  37773. * @param force defines a boolean used to force the update even if cache is up to date
  37774. */
  37775. updateTransformMatrix(force?: boolean): void;
  37776. private _bindFrameBuffer;
  37777. /** @hidden */
  37778. _allowPostProcessClearColor: boolean;
  37779. /** @hidden */
  37780. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37781. private _processSubCameras;
  37782. private _checkIntersections;
  37783. /** @hidden */
  37784. _advancePhysicsEngineStep(step: number): void;
  37785. /**
  37786. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37787. */
  37788. getDeterministicFrameTime: () => number;
  37789. /** @hidden */
  37790. _animate(): void;
  37791. /** Execute all animations (for a frame) */
  37792. animate(): void;
  37793. /**
  37794. * Render the scene
  37795. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37796. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37797. */
  37798. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37799. /**
  37800. * Freeze all materials
  37801. * A frozen material will not be updatable but should be faster to render
  37802. */
  37803. freezeMaterials(): void;
  37804. /**
  37805. * Unfreeze all materials
  37806. * A frozen material will not be updatable but should be faster to render
  37807. */
  37808. unfreezeMaterials(): void;
  37809. /**
  37810. * Releases all held ressources
  37811. */
  37812. dispose(): void;
  37813. /**
  37814. * Gets if the scene is already disposed
  37815. */
  37816. get isDisposed(): boolean;
  37817. /**
  37818. * Call this function to reduce memory footprint of the scene.
  37819. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37820. */
  37821. clearCachedVertexData(): void;
  37822. /**
  37823. * This function will remove the local cached buffer data from texture.
  37824. * It will save memory but will prevent the texture from being rebuilt
  37825. */
  37826. cleanCachedTextureBuffer(): void;
  37827. /**
  37828. * Get the world extend vectors with an optional filter
  37829. *
  37830. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37831. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37832. */
  37833. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37834. min: Vector3;
  37835. max: Vector3;
  37836. };
  37837. /**
  37838. * Creates a ray that can be used to pick in the scene
  37839. * @param x defines the x coordinate of the origin (on-screen)
  37840. * @param y defines the y coordinate of the origin (on-screen)
  37841. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37842. * @param camera defines the camera to use for the picking
  37843. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37844. * @returns a Ray
  37845. */
  37846. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37847. /**
  37848. * Creates a ray that can be used to pick in the scene
  37849. * @param x defines the x coordinate of the origin (on-screen)
  37850. * @param y defines the y coordinate of the origin (on-screen)
  37851. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37852. * @param result defines the ray where to store the picking ray
  37853. * @param camera defines the camera to use for the picking
  37854. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37855. * @returns the current scene
  37856. */
  37857. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37858. /**
  37859. * Creates a ray that can be used to pick in the scene
  37860. * @param x defines the x coordinate of the origin (on-screen)
  37861. * @param y defines the y coordinate of the origin (on-screen)
  37862. * @param camera defines the camera to use for the picking
  37863. * @returns a Ray
  37864. */
  37865. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37866. /**
  37867. * Creates a ray that can be used to pick in the scene
  37868. * @param x defines the x coordinate of the origin (on-screen)
  37869. * @param y defines the y coordinate of the origin (on-screen)
  37870. * @param result defines the ray where to store the picking ray
  37871. * @param camera defines the camera to use for the picking
  37872. * @returns the current scene
  37873. */
  37874. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37875. /** Launch a ray to try to pick a mesh in the scene
  37876. * @param x position on screen
  37877. * @param y position on screen
  37878. * @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
  37879. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37880. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37881. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37882. * @returns a PickingInfo
  37883. */
  37884. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37885. /** Use the given ray to pick a mesh in the scene
  37886. * @param ray The ray to use to pick meshes
  37887. * @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
  37888. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37890. * @returns a PickingInfo
  37891. */
  37892. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37893. /**
  37894. * Launch a ray to try to pick a mesh in the scene
  37895. * @param x X position on screen
  37896. * @param y Y position on screen
  37897. * @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
  37898. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37899. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37900. * @returns an array of PickingInfo
  37901. */
  37902. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37903. /**
  37904. * Launch a ray to try to pick a mesh in the scene
  37905. * @param ray Ray to use
  37906. * @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
  37907. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37908. * @returns an array of PickingInfo
  37909. */
  37910. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37911. /**
  37912. * Force the value of meshUnderPointer
  37913. * @param mesh defines the mesh to use
  37914. */
  37915. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37916. /**
  37917. * Gets the mesh under the pointer
  37918. * @returns a Mesh or null if no mesh is under the pointer
  37919. */
  37920. getPointerOverMesh(): Nullable<AbstractMesh>;
  37921. /** @hidden */
  37922. _rebuildGeometries(): void;
  37923. /** @hidden */
  37924. _rebuildTextures(): void;
  37925. private _getByTags;
  37926. /**
  37927. * Get a list of meshes by tags
  37928. * @param tagsQuery defines the tags query to use
  37929. * @param forEach defines a predicate used to filter results
  37930. * @returns an array of Mesh
  37931. */
  37932. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37933. /**
  37934. * Get a list of cameras by tags
  37935. * @param tagsQuery defines the tags query to use
  37936. * @param forEach defines a predicate used to filter results
  37937. * @returns an array of Camera
  37938. */
  37939. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37940. /**
  37941. * Get a list of lights by tags
  37942. * @param tagsQuery defines the tags query to use
  37943. * @param forEach defines a predicate used to filter results
  37944. * @returns an array of Light
  37945. */
  37946. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37947. /**
  37948. * Get a list of materials by tags
  37949. * @param tagsQuery defines the tags query to use
  37950. * @param forEach defines a predicate used to filter results
  37951. * @returns an array of Material
  37952. */
  37953. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37954. /**
  37955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37956. * This allowed control for front to back rendering or reversly depending of the special needs.
  37957. *
  37958. * @param renderingGroupId The rendering group id corresponding to its index
  37959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37962. */
  37963. 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;
  37964. /**
  37965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37966. *
  37967. * @param renderingGroupId The rendering group id corresponding to its index
  37968. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37969. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37970. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37971. */
  37972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37973. /**
  37974. * Gets the current auto clear configuration for one rendering group of the rendering
  37975. * manager.
  37976. * @param index the rendering group index to get the information for
  37977. * @returns The auto clear setup for the requested rendering group
  37978. */
  37979. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37980. private _blockMaterialDirtyMechanism;
  37981. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37982. get blockMaterialDirtyMechanism(): boolean;
  37983. set blockMaterialDirtyMechanism(value: boolean);
  37984. /**
  37985. * Will flag all materials as dirty to trigger new shader compilation
  37986. * @param flag defines the flag used to specify which material part must be marked as dirty
  37987. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37988. */
  37989. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37990. /** @hidden */
  37991. _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;
  37992. /** @hidden */
  37993. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37994. /** @hidden */
  37995. _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;
  37996. /** @hidden */
  37997. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37998. /** @hidden */
  37999. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38000. /** @hidden */
  38001. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38002. }
  38003. }
  38004. declare module "babylonjs/assetContainer" {
  38005. import { AbstractScene } from "babylonjs/abstractScene";
  38006. import { Scene } from "babylonjs/scene";
  38007. import { Mesh } from "babylonjs/Meshes/mesh";
  38008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38009. import { Skeleton } from "babylonjs/Bones/skeleton";
  38010. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38011. import { Animatable } from "babylonjs/Animations/animatable";
  38012. import { Nullable } from "babylonjs/types";
  38013. import { Node } from "babylonjs/node";
  38014. /**
  38015. * Set of assets to keep when moving a scene into an asset container.
  38016. */
  38017. export class KeepAssets extends AbstractScene {
  38018. }
  38019. /**
  38020. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38021. */
  38022. export class InstantiatedEntries {
  38023. /**
  38024. * List of new root nodes (eg. nodes with no parent)
  38025. */
  38026. rootNodes: TransformNode[];
  38027. /**
  38028. * List of new skeletons
  38029. */
  38030. skeletons: Skeleton[];
  38031. /**
  38032. * List of new animation groups
  38033. */
  38034. animationGroups: AnimationGroup[];
  38035. }
  38036. /**
  38037. * Container with a set of assets that can be added or removed from a scene.
  38038. */
  38039. export class AssetContainer extends AbstractScene {
  38040. private _wasAddedToScene;
  38041. /**
  38042. * The scene the AssetContainer belongs to.
  38043. */
  38044. scene: Scene;
  38045. /**
  38046. * Instantiates an AssetContainer.
  38047. * @param scene The scene the AssetContainer belongs to.
  38048. */
  38049. constructor(scene: Scene);
  38050. /**
  38051. * Instantiate or clone all meshes and add the new ones to the scene.
  38052. * Skeletons and animation groups will all be cloned
  38053. * @param nameFunction defines an optional function used to get new names for clones
  38054. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38055. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38056. */
  38057. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38058. /**
  38059. * Adds all the assets from the container to the scene.
  38060. */
  38061. addAllToScene(): void;
  38062. /**
  38063. * Removes all the assets in the container from the scene
  38064. */
  38065. removeAllFromScene(): void;
  38066. /**
  38067. * Disposes all the assets in the container
  38068. */
  38069. dispose(): void;
  38070. private _moveAssets;
  38071. /**
  38072. * Removes all the assets contained in the scene and adds them to the container.
  38073. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38074. */
  38075. moveAllFromScene(keepAssets?: KeepAssets): void;
  38076. /**
  38077. * 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.
  38078. * @returns the root mesh
  38079. */
  38080. createRootMesh(): Mesh;
  38081. /**
  38082. * Merge animations from this asset container into a scene
  38083. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38084. * @param animatables set of animatables to retarget to a node from the scene
  38085. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38086. */
  38087. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38088. }
  38089. }
  38090. declare module "babylonjs/abstractScene" {
  38091. import { Scene } from "babylonjs/scene";
  38092. import { Nullable } from "babylonjs/types";
  38093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38094. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38095. import { Geometry } from "babylonjs/Meshes/geometry";
  38096. import { Skeleton } from "babylonjs/Bones/skeleton";
  38097. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38098. import { AssetContainer } from "babylonjs/assetContainer";
  38099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38100. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38102. import { Material } from "babylonjs/Materials/material";
  38103. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38104. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38105. import { Camera } from "babylonjs/Cameras/camera";
  38106. import { Light } from "babylonjs/Lights/light";
  38107. import { Node } from "babylonjs/node";
  38108. import { Animation } from "babylonjs/Animations/animation";
  38109. /**
  38110. * Defines how the parser contract is defined.
  38111. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38112. */
  38113. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38114. /**
  38115. * Defines how the individual parser contract is defined.
  38116. * These parser can parse an individual asset
  38117. */
  38118. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38119. /**
  38120. * Base class of the scene acting as a container for the different elements composing a scene.
  38121. * This class is dynamically extended by the different components of the scene increasing
  38122. * flexibility and reducing coupling
  38123. */
  38124. export abstract class AbstractScene {
  38125. /**
  38126. * Stores the list of available parsers in the application.
  38127. */
  38128. private static _BabylonFileParsers;
  38129. /**
  38130. * Stores the list of available individual parsers in the application.
  38131. */
  38132. private static _IndividualBabylonFileParsers;
  38133. /**
  38134. * Adds a parser in the list of available ones
  38135. * @param name Defines the name of the parser
  38136. * @param parser Defines the parser to add
  38137. */
  38138. static AddParser(name: string, parser: BabylonFileParser): void;
  38139. /**
  38140. * Gets a general parser from the list of avaialble ones
  38141. * @param name Defines the name of the parser
  38142. * @returns the requested parser or null
  38143. */
  38144. static GetParser(name: string): Nullable<BabylonFileParser>;
  38145. /**
  38146. * Adds n individual parser in the list of available ones
  38147. * @param name Defines the name of the parser
  38148. * @param parser Defines the parser to add
  38149. */
  38150. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38151. /**
  38152. * Gets an individual parser from the list of avaialble ones
  38153. * @param name Defines the name of the parser
  38154. * @returns the requested parser or null
  38155. */
  38156. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38157. /**
  38158. * Parser json data and populate both a scene and its associated container object
  38159. * @param jsonData Defines the data to parse
  38160. * @param scene Defines the scene to parse the data for
  38161. * @param container Defines the container attached to the parsing sequence
  38162. * @param rootUrl Defines the root url of the data
  38163. */
  38164. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38165. /**
  38166. * Gets the list of root nodes (ie. nodes with no parent)
  38167. */
  38168. rootNodes: Node[];
  38169. /** All of the cameras added to this scene
  38170. * @see http://doc.babylonjs.com/babylon101/cameras
  38171. */
  38172. cameras: Camera[];
  38173. /**
  38174. * All of the lights added to this scene
  38175. * @see http://doc.babylonjs.com/babylon101/lights
  38176. */
  38177. lights: Light[];
  38178. /**
  38179. * All of the (abstract) meshes added to this scene
  38180. */
  38181. meshes: AbstractMesh[];
  38182. /**
  38183. * The list of skeletons added to the scene
  38184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38185. */
  38186. skeletons: Skeleton[];
  38187. /**
  38188. * All of the particle systems added to this scene
  38189. * @see http://doc.babylonjs.com/babylon101/particles
  38190. */
  38191. particleSystems: IParticleSystem[];
  38192. /**
  38193. * Gets a list of Animations associated with the scene
  38194. */
  38195. animations: Animation[];
  38196. /**
  38197. * All of the animation groups added to this scene
  38198. * @see http://doc.babylonjs.com/how_to/group
  38199. */
  38200. animationGroups: AnimationGroup[];
  38201. /**
  38202. * All of the multi-materials added to this scene
  38203. * @see http://doc.babylonjs.com/how_to/multi_materials
  38204. */
  38205. multiMaterials: MultiMaterial[];
  38206. /**
  38207. * All of the materials added to this scene
  38208. * In the context of a Scene, it is not supposed to be modified manually.
  38209. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38210. * Note also that the order of the Material within the array is not significant and might change.
  38211. * @see http://doc.babylonjs.com/babylon101/materials
  38212. */
  38213. materials: Material[];
  38214. /**
  38215. * The list of morph target managers added to the scene
  38216. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38217. */
  38218. morphTargetManagers: MorphTargetManager[];
  38219. /**
  38220. * The list of geometries used in the scene.
  38221. */
  38222. geometries: Geometry[];
  38223. /**
  38224. * All of the tranform nodes added to this scene
  38225. * In the context of a Scene, it is not supposed to be modified manually.
  38226. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38227. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38228. * @see http://doc.babylonjs.com/how_to/transformnode
  38229. */
  38230. transformNodes: TransformNode[];
  38231. /**
  38232. * ActionManagers available on the scene.
  38233. */
  38234. actionManagers: AbstractActionManager[];
  38235. /**
  38236. * Textures to keep.
  38237. */
  38238. textures: BaseTexture[];
  38239. /**
  38240. * Environment texture for the scene
  38241. */
  38242. environmentTexture: Nullable<BaseTexture>;
  38243. /**
  38244. * @returns all meshes, lights, cameras, transformNodes and bones
  38245. */
  38246. getNodes(): Array<Node>;
  38247. }
  38248. }
  38249. declare module "babylonjs/Audio/sound" {
  38250. import { Observable } from "babylonjs/Misc/observable";
  38251. import { Vector3 } from "babylonjs/Maths/math.vector";
  38252. import { Nullable } from "babylonjs/types";
  38253. import { Scene } from "babylonjs/scene";
  38254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38255. /**
  38256. * Interface used to define options for Sound class
  38257. */
  38258. export interface ISoundOptions {
  38259. /**
  38260. * Does the sound autoplay once loaded.
  38261. */
  38262. autoplay?: boolean;
  38263. /**
  38264. * Does the sound loop after it finishes playing once.
  38265. */
  38266. loop?: boolean;
  38267. /**
  38268. * Sound's volume
  38269. */
  38270. volume?: number;
  38271. /**
  38272. * Is it a spatial sound?
  38273. */
  38274. spatialSound?: boolean;
  38275. /**
  38276. * Maximum distance to hear that sound
  38277. */
  38278. maxDistance?: number;
  38279. /**
  38280. * Uses user defined attenuation function
  38281. */
  38282. useCustomAttenuation?: boolean;
  38283. /**
  38284. * Define the roll off factor of spatial sounds.
  38285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38286. */
  38287. rolloffFactor?: number;
  38288. /**
  38289. * Define the reference distance the sound should be heard perfectly.
  38290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38291. */
  38292. refDistance?: number;
  38293. /**
  38294. * Define the distance attenuation model the sound will follow.
  38295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38296. */
  38297. distanceModel?: string;
  38298. /**
  38299. * Defines the playback speed (1 by default)
  38300. */
  38301. playbackRate?: number;
  38302. /**
  38303. * Defines if the sound is from a streaming source
  38304. */
  38305. streaming?: boolean;
  38306. /**
  38307. * Defines an optional length (in seconds) inside the sound file
  38308. */
  38309. length?: number;
  38310. /**
  38311. * Defines an optional offset (in seconds) inside the sound file
  38312. */
  38313. offset?: number;
  38314. /**
  38315. * If true, URLs will not be required to state the audio file codec to use.
  38316. */
  38317. skipCodecCheck?: boolean;
  38318. }
  38319. /**
  38320. * Defines a sound that can be played in the application.
  38321. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38323. */
  38324. export class Sound {
  38325. /**
  38326. * The name of the sound in the scene.
  38327. */
  38328. name: string;
  38329. /**
  38330. * Does the sound autoplay once loaded.
  38331. */
  38332. autoplay: boolean;
  38333. /**
  38334. * Does the sound loop after it finishes playing once.
  38335. */
  38336. loop: boolean;
  38337. /**
  38338. * Does the sound use a custom attenuation curve to simulate the falloff
  38339. * happening when the source gets further away from the camera.
  38340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38341. */
  38342. useCustomAttenuation: boolean;
  38343. /**
  38344. * The sound track id this sound belongs to.
  38345. */
  38346. soundTrackId: number;
  38347. /**
  38348. * Is this sound currently played.
  38349. */
  38350. isPlaying: boolean;
  38351. /**
  38352. * Is this sound currently paused.
  38353. */
  38354. isPaused: boolean;
  38355. /**
  38356. * Does this sound enables spatial sound.
  38357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38358. */
  38359. spatialSound: boolean;
  38360. /**
  38361. * Define the reference distance the sound should be heard perfectly.
  38362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38363. */
  38364. refDistance: number;
  38365. /**
  38366. * Define the roll off factor of spatial sounds.
  38367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38368. */
  38369. rolloffFactor: number;
  38370. /**
  38371. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38373. */
  38374. maxDistance: number;
  38375. /**
  38376. * Define the distance attenuation model the sound will follow.
  38377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38378. */
  38379. distanceModel: string;
  38380. /**
  38381. * @hidden
  38382. * Back Compat
  38383. **/
  38384. onended: () => any;
  38385. /**
  38386. * Observable event when the current playing sound finishes.
  38387. */
  38388. onEndedObservable: Observable<Sound>;
  38389. private _panningModel;
  38390. private _playbackRate;
  38391. private _streaming;
  38392. private _startTime;
  38393. private _startOffset;
  38394. private _position;
  38395. /** @hidden */
  38396. _positionInEmitterSpace: boolean;
  38397. private _localDirection;
  38398. private _volume;
  38399. private _isReadyToPlay;
  38400. private _isDirectional;
  38401. private _readyToPlayCallback;
  38402. private _audioBuffer;
  38403. private _soundSource;
  38404. private _streamingSource;
  38405. private _soundPanner;
  38406. private _soundGain;
  38407. private _inputAudioNode;
  38408. private _outputAudioNode;
  38409. private _coneInnerAngle;
  38410. private _coneOuterAngle;
  38411. private _coneOuterGain;
  38412. private _scene;
  38413. private _connectedTransformNode;
  38414. private _customAttenuationFunction;
  38415. private _registerFunc;
  38416. private _isOutputConnected;
  38417. private _htmlAudioElement;
  38418. private _urlType;
  38419. private _length?;
  38420. private _offset?;
  38421. /** @hidden */
  38422. static _SceneComponentInitialization: (scene: Scene) => void;
  38423. /**
  38424. * Create a sound and attach it to a scene
  38425. * @param name Name of your sound
  38426. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38427. * @param scene defines the scene the sound belongs to
  38428. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38429. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38430. */
  38431. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38432. /**
  38433. * Release the sound and its associated resources
  38434. */
  38435. dispose(): void;
  38436. /**
  38437. * Gets if the sounds is ready to be played or not.
  38438. * @returns true if ready, otherwise false
  38439. */
  38440. isReady(): boolean;
  38441. private _soundLoaded;
  38442. /**
  38443. * Sets the data of the sound from an audiobuffer
  38444. * @param audioBuffer The audioBuffer containing the data
  38445. */
  38446. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38447. /**
  38448. * Updates the current sounds options such as maxdistance, loop...
  38449. * @param options A JSON object containing values named as the object properties
  38450. */
  38451. updateOptions(options: ISoundOptions): void;
  38452. private _createSpatialParameters;
  38453. private _updateSpatialParameters;
  38454. /**
  38455. * Switch the panning model to HRTF:
  38456. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38458. */
  38459. switchPanningModelToHRTF(): void;
  38460. /**
  38461. * Switch the panning model to Equal Power:
  38462. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38464. */
  38465. switchPanningModelToEqualPower(): void;
  38466. private _switchPanningModel;
  38467. /**
  38468. * Connect this sound to a sound track audio node like gain...
  38469. * @param soundTrackAudioNode the sound track audio node to connect to
  38470. */
  38471. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38472. /**
  38473. * Transform this sound into a directional source
  38474. * @param coneInnerAngle Size of the inner cone in degree
  38475. * @param coneOuterAngle Size of the outer cone in degree
  38476. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38477. */
  38478. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38479. /**
  38480. * Gets or sets the inner angle for the directional cone.
  38481. */
  38482. get directionalConeInnerAngle(): number;
  38483. /**
  38484. * Gets or sets the inner angle for the directional cone.
  38485. */
  38486. set directionalConeInnerAngle(value: number);
  38487. /**
  38488. * Gets or sets the outer angle for the directional cone.
  38489. */
  38490. get directionalConeOuterAngle(): number;
  38491. /**
  38492. * Gets or sets the outer angle for the directional cone.
  38493. */
  38494. set directionalConeOuterAngle(value: number);
  38495. /**
  38496. * Sets the position of the emitter if spatial sound is enabled
  38497. * @param newPosition Defines the new posisiton
  38498. */
  38499. setPosition(newPosition: Vector3): void;
  38500. /**
  38501. * Sets the local direction of the emitter if spatial sound is enabled
  38502. * @param newLocalDirection Defines the new local direction
  38503. */
  38504. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38505. private _updateDirection;
  38506. /** @hidden */
  38507. updateDistanceFromListener(): void;
  38508. /**
  38509. * Sets a new custom attenuation function for the sound.
  38510. * @param callback Defines the function used for the attenuation
  38511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38512. */
  38513. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38514. /**
  38515. * Play the sound
  38516. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38517. * @param offset (optional) Start the sound at a specific time in seconds
  38518. * @param length (optional) Sound duration (in seconds)
  38519. */
  38520. play(time?: number, offset?: number, length?: number): void;
  38521. private _onended;
  38522. /**
  38523. * Stop the sound
  38524. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38525. */
  38526. stop(time?: number): void;
  38527. /**
  38528. * Put the sound in pause
  38529. */
  38530. pause(): void;
  38531. /**
  38532. * Sets a dedicated volume for this sounds
  38533. * @param newVolume Define the new volume of the sound
  38534. * @param time Define time for gradual change to new volume
  38535. */
  38536. setVolume(newVolume: number, time?: number): void;
  38537. /**
  38538. * Set the sound play back rate
  38539. * @param newPlaybackRate Define the playback rate the sound should be played at
  38540. */
  38541. setPlaybackRate(newPlaybackRate: number): void;
  38542. /**
  38543. * Gets the volume of the sound.
  38544. * @returns the volume of the sound
  38545. */
  38546. getVolume(): number;
  38547. /**
  38548. * Attach the sound to a dedicated mesh
  38549. * @param transformNode The transform node to connect the sound with
  38550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38551. */
  38552. attachToMesh(transformNode: TransformNode): void;
  38553. /**
  38554. * Detach the sound from the previously attached mesh
  38555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38556. */
  38557. detachFromMesh(): void;
  38558. private _onRegisterAfterWorldMatrixUpdate;
  38559. /**
  38560. * Clone the current sound in the scene.
  38561. * @returns the new sound clone
  38562. */
  38563. clone(): Nullable<Sound>;
  38564. /**
  38565. * Gets the current underlying audio buffer containing the data
  38566. * @returns the audio buffer
  38567. */
  38568. getAudioBuffer(): Nullable<AudioBuffer>;
  38569. /**
  38570. * Serializes the Sound in a JSON representation
  38571. * @returns the JSON representation of the sound
  38572. */
  38573. serialize(): any;
  38574. /**
  38575. * Parse a JSON representation of a sound to innstantiate in a given scene
  38576. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38577. * @param scene Define the scene the new parsed sound should be created in
  38578. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38579. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38580. * @returns the newly parsed sound
  38581. */
  38582. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38583. }
  38584. }
  38585. declare module "babylonjs/Actions/directAudioActions" {
  38586. import { Action } from "babylonjs/Actions/action";
  38587. import { Condition } from "babylonjs/Actions/condition";
  38588. import { Sound } from "babylonjs/Audio/sound";
  38589. /**
  38590. * This defines an action helpful to play a defined sound on a triggered action.
  38591. */
  38592. export class PlaySoundAction extends Action {
  38593. private _sound;
  38594. /**
  38595. * Instantiate the action
  38596. * @param triggerOptions defines the trigger options
  38597. * @param sound defines the sound to play
  38598. * @param condition defines the trigger related conditions
  38599. */
  38600. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38601. /** @hidden */
  38602. _prepare(): void;
  38603. /**
  38604. * Execute the action and play the sound.
  38605. */
  38606. execute(): void;
  38607. /**
  38608. * Serializes the actions and its related information.
  38609. * @param parent defines the object to serialize in
  38610. * @returns the serialized object
  38611. */
  38612. serialize(parent: any): any;
  38613. }
  38614. /**
  38615. * This defines an action helpful to stop a defined sound on a triggered action.
  38616. */
  38617. export class StopSoundAction extends Action {
  38618. private _sound;
  38619. /**
  38620. * Instantiate the action
  38621. * @param triggerOptions defines the trigger options
  38622. * @param sound defines the sound to stop
  38623. * @param condition defines the trigger related conditions
  38624. */
  38625. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38626. /** @hidden */
  38627. _prepare(): void;
  38628. /**
  38629. * Execute the action and stop the sound.
  38630. */
  38631. execute(): void;
  38632. /**
  38633. * Serializes the actions and its related information.
  38634. * @param parent defines the object to serialize in
  38635. * @returns the serialized object
  38636. */
  38637. serialize(parent: any): any;
  38638. }
  38639. }
  38640. declare module "babylonjs/Actions/interpolateValueAction" {
  38641. import { Action } from "babylonjs/Actions/action";
  38642. import { Condition } from "babylonjs/Actions/condition";
  38643. import { Observable } from "babylonjs/Misc/observable";
  38644. /**
  38645. * This defines an action responsible to change the value of a property
  38646. * by interpolating between its current value and the newly set one once triggered.
  38647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38648. */
  38649. export class InterpolateValueAction extends Action {
  38650. /**
  38651. * Defines the path of the property where the value should be interpolated
  38652. */
  38653. propertyPath: string;
  38654. /**
  38655. * Defines the target value at the end of the interpolation.
  38656. */
  38657. value: any;
  38658. /**
  38659. * Defines the time it will take for the property to interpolate to the value.
  38660. */
  38661. duration: number;
  38662. /**
  38663. * Defines if the other scene animations should be stopped when the action has been triggered
  38664. */
  38665. stopOtherAnimations?: boolean;
  38666. /**
  38667. * Defines a callback raised once the interpolation animation has been done.
  38668. */
  38669. onInterpolationDone?: () => void;
  38670. /**
  38671. * Observable triggered once the interpolation animation has been done.
  38672. */
  38673. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38674. private _target;
  38675. private _effectiveTarget;
  38676. private _property;
  38677. /**
  38678. * Instantiate the action
  38679. * @param triggerOptions defines the trigger options
  38680. * @param target defines the object containing the value to interpolate
  38681. * @param propertyPath defines the path to the property in the target object
  38682. * @param value defines the target value at the end of the interpolation
  38683. * @param duration deines the time it will take for the property to interpolate to the value.
  38684. * @param condition defines the trigger related conditions
  38685. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38686. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38687. */
  38688. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38689. /** @hidden */
  38690. _prepare(): void;
  38691. /**
  38692. * Execute the action starts the value interpolation.
  38693. */
  38694. execute(): void;
  38695. /**
  38696. * Serializes the actions and its related information.
  38697. * @param parent defines the object to serialize in
  38698. * @returns the serialized object
  38699. */
  38700. serialize(parent: any): any;
  38701. }
  38702. }
  38703. declare module "babylonjs/Actions/index" {
  38704. export * from "babylonjs/Actions/abstractActionManager";
  38705. export * from "babylonjs/Actions/action";
  38706. export * from "babylonjs/Actions/actionEvent";
  38707. export * from "babylonjs/Actions/actionManager";
  38708. export * from "babylonjs/Actions/condition";
  38709. export * from "babylonjs/Actions/directActions";
  38710. export * from "babylonjs/Actions/directAudioActions";
  38711. export * from "babylonjs/Actions/interpolateValueAction";
  38712. }
  38713. declare module "babylonjs/Animations/index" {
  38714. export * from "babylonjs/Animations/animatable";
  38715. export * from "babylonjs/Animations/animation";
  38716. export * from "babylonjs/Animations/animationGroup";
  38717. export * from "babylonjs/Animations/animationPropertiesOverride";
  38718. export * from "babylonjs/Animations/easing";
  38719. export * from "babylonjs/Animations/runtimeAnimation";
  38720. export * from "babylonjs/Animations/animationEvent";
  38721. export * from "babylonjs/Animations/animationGroup";
  38722. export * from "babylonjs/Animations/animationKey";
  38723. export * from "babylonjs/Animations/animationRange";
  38724. export * from "babylonjs/Animations/animatable.interface";
  38725. }
  38726. declare module "babylonjs/Audio/soundTrack" {
  38727. import { Sound } from "babylonjs/Audio/sound";
  38728. import { Analyser } from "babylonjs/Audio/analyser";
  38729. import { Scene } from "babylonjs/scene";
  38730. /**
  38731. * Options allowed during the creation of a sound track.
  38732. */
  38733. export interface ISoundTrackOptions {
  38734. /**
  38735. * The volume the sound track should take during creation
  38736. */
  38737. volume?: number;
  38738. /**
  38739. * Define if the sound track is the main sound track of the scene
  38740. */
  38741. mainTrack?: boolean;
  38742. }
  38743. /**
  38744. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38745. * It will be also used in a future release to apply effects on a specific track.
  38746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38747. */
  38748. export class SoundTrack {
  38749. /**
  38750. * The unique identifier of the sound track in the scene.
  38751. */
  38752. id: number;
  38753. /**
  38754. * The list of sounds included in the sound track.
  38755. */
  38756. soundCollection: Array<Sound>;
  38757. private _outputAudioNode;
  38758. private _scene;
  38759. private _connectedAnalyser;
  38760. private _options;
  38761. private _isInitialized;
  38762. /**
  38763. * Creates a new sound track.
  38764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38765. * @param scene Define the scene the sound track belongs to
  38766. * @param options
  38767. */
  38768. constructor(scene: Scene, options?: ISoundTrackOptions);
  38769. private _initializeSoundTrackAudioGraph;
  38770. /**
  38771. * Release the sound track and its associated resources
  38772. */
  38773. dispose(): void;
  38774. /**
  38775. * Adds a sound to this sound track
  38776. * @param sound define the cound to add
  38777. * @ignoreNaming
  38778. */
  38779. AddSound(sound: Sound): void;
  38780. /**
  38781. * Removes a sound to this sound track
  38782. * @param sound define the cound to remove
  38783. * @ignoreNaming
  38784. */
  38785. RemoveSound(sound: Sound): void;
  38786. /**
  38787. * Set a global volume for the full sound track.
  38788. * @param newVolume Define the new volume of the sound track
  38789. */
  38790. setVolume(newVolume: number): void;
  38791. /**
  38792. * Switch the panning model to HRTF:
  38793. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38795. */
  38796. switchPanningModelToHRTF(): void;
  38797. /**
  38798. * Switch the panning model to Equal Power:
  38799. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38801. */
  38802. switchPanningModelToEqualPower(): void;
  38803. /**
  38804. * Connect the sound track to an audio analyser allowing some amazing
  38805. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38807. * @param analyser The analyser to connect to the engine
  38808. */
  38809. connectToAnalyser(analyser: Analyser): void;
  38810. }
  38811. }
  38812. declare module "babylonjs/Audio/audioSceneComponent" {
  38813. import { Sound } from "babylonjs/Audio/sound";
  38814. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38815. import { Nullable } from "babylonjs/types";
  38816. import { Vector3 } from "babylonjs/Maths/math.vector";
  38817. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38818. import { Scene } from "babylonjs/scene";
  38819. import { AbstractScene } from "babylonjs/abstractScene";
  38820. import "babylonjs/Audio/audioEngine";
  38821. module "babylonjs/abstractScene" {
  38822. interface AbstractScene {
  38823. /**
  38824. * The list of sounds used in the scene.
  38825. */
  38826. sounds: Nullable<Array<Sound>>;
  38827. }
  38828. }
  38829. module "babylonjs/scene" {
  38830. interface Scene {
  38831. /**
  38832. * @hidden
  38833. * Backing field
  38834. */
  38835. _mainSoundTrack: SoundTrack;
  38836. /**
  38837. * The main sound track played by the scene.
  38838. * It cotains your primary collection of sounds.
  38839. */
  38840. mainSoundTrack: SoundTrack;
  38841. /**
  38842. * The list of sound tracks added to the scene
  38843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38844. */
  38845. soundTracks: Nullable<Array<SoundTrack>>;
  38846. /**
  38847. * Gets a sound using a given name
  38848. * @param name defines the name to search for
  38849. * @return the found sound or null if not found at all.
  38850. */
  38851. getSoundByName(name: string): Nullable<Sound>;
  38852. /**
  38853. * Gets or sets if audio support is enabled
  38854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38855. */
  38856. audioEnabled: boolean;
  38857. /**
  38858. * Gets or sets if audio will be output to headphones
  38859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38860. */
  38861. headphone: boolean;
  38862. /**
  38863. * Gets or sets custom audio listener position provider
  38864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38865. */
  38866. audioListenerPositionProvider: Nullable<() => Vector3>;
  38867. /**
  38868. * Gets or sets a refresh rate when using 3D audio positioning
  38869. */
  38870. audioPositioningRefreshRate: number;
  38871. }
  38872. }
  38873. /**
  38874. * Defines the sound scene component responsible to manage any sounds
  38875. * in a given scene.
  38876. */
  38877. export class AudioSceneComponent implements ISceneSerializableComponent {
  38878. /**
  38879. * The component name helpfull to identify the component in the list of scene components.
  38880. */
  38881. readonly name: string;
  38882. /**
  38883. * The scene the component belongs to.
  38884. */
  38885. scene: Scene;
  38886. private _audioEnabled;
  38887. /**
  38888. * Gets whether audio is enabled or not.
  38889. * Please use related enable/disable method to switch state.
  38890. */
  38891. get audioEnabled(): boolean;
  38892. private _headphone;
  38893. /**
  38894. * Gets whether audio is outputing to headphone or not.
  38895. * Please use the according Switch methods to change output.
  38896. */
  38897. get headphone(): boolean;
  38898. /**
  38899. * Gets or sets a refresh rate when using 3D audio positioning
  38900. */
  38901. audioPositioningRefreshRate: number;
  38902. private _audioListenerPositionProvider;
  38903. /**
  38904. * Gets the current audio listener position provider
  38905. */
  38906. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38907. /**
  38908. * Sets a custom listener position for all sounds in the scene
  38909. * By default, this is the position of the first active camera
  38910. */
  38911. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38912. /**
  38913. * Creates a new instance of the component for the given scene
  38914. * @param scene Defines the scene to register the component in
  38915. */
  38916. constructor(scene: Scene);
  38917. /**
  38918. * Registers the component in a given scene
  38919. */
  38920. register(): void;
  38921. /**
  38922. * Rebuilds the elements related to this component in case of
  38923. * context lost for instance.
  38924. */
  38925. rebuild(): void;
  38926. /**
  38927. * Serializes the component data to the specified json object
  38928. * @param serializationObject The object to serialize to
  38929. */
  38930. serialize(serializationObject: any): void;
  38931. /**
  38932. * Adds all the elements from the container to the scene
  38933. * @param container the container holding the elements
  38934. */
  38935. addFromContainer(container: AbstractScene): void;
  38936. /**
  38937. * Removes all the elements in the container from the scene
  38938. * @param container contains the elements to remove
  38939. * @param dispose if the removed element should be disposed (default: false)
  38940. */
  38941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38942. /**
  38943. * Disposes the component and the associated ressources.
  38944. */
  38945. dispose(): void;
  38946. /**
  38947. * Disables audio in the associated scene.
  38948. */
  38949. disableAudio(): void;
  38950. /**
  38951. * Enables audio in the associated scene.
  38952. */
  38953. enableAudio(): void;
  38954. /**
  38955. * Switch audio to headphone output.
  38956. */
  38957. switchAudioModeForHeadphones(): void;
  38958. /**
  38959. * Switch audio to normal speakers.
  38960. */
  38961. switchAudioModeForNormalSpeakers(): void;
  38962. private _cachedCameraDirection;
  38963. private _cachedCameraPosition;
  38964. private _lastCheck;
  38965. private _afterRender;
  38966. }
  38967. }
  38968. declare module "babylonjs/Audio/weightedsound" {
  38969. import { Sound } from "babylonjs/Audio/sound";
  38970. /**
  38971. * Wraps one or more Sound objects and selects one with random weight for playback.
  38972. */
  38973. export class WeightedSound {
  38974. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38975. loop: boolean;
  38976. private _coneInnerAngle;
  38977. private _coneOuterAngle;
  38978. private _volume;
  38979. /** A Sound is currently playing. */
  38980. isPlaying: boolean;
  38981. /** A Sound is currently paused. */
  38982. isPaused: boolean;
  38983. private _sounds;
  38984. private _weights;
  38985. private _currentIndex?;
  38986. /**
  38987. * Creates a new WeightedSound from the list of sounds given.
  38988. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38989. * @param sounds Array of Sounds that will be selected from.
  38990. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38991. */
  38992. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38993. /**
  38994. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38995. */
  38996. get directionalConeInnerAngle(): number;
  38997. /**
  38998. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38999. */
  39000. set directionalConeInnerAngle(value: number);
  39001. /**
  39002. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39003. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39004. */
  39005. get directionalConeOuterAngle(): number;
  39006. /**
  39007. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39008. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39009. */
  39010. set directionalConeOuterAngle(value: number);
  39011. /**
  39012. * Playback volume.
  39013. */
  39014. get volume(): number;
  39015. /**
  39016. * Playback volume.
  39017. */
  39018. set volume(value: number);
  39019. private _onended;
  39020. /**
  39021. * Suspend playback
  39022. */
  39023. pause(): void;
  39024. /**
  39025. * Stop playback
  39026. */
  39027. stop(): void;
  39028. /**
  39029. * Start playback.
  39030. * @param startOffset Position the clip head at a specific time in seconds.
  39031. */
  39032. play(startOffset?: number): void;
  39033. }
  39034. }
  39035. declare module "babylonjs/Audio/index" {
  39036. export * from "babylonjs/Audio/analyser";
  39037. export * from "babylonjs/Audio/audioEngine";
  39038. export * from "babylonjs/Audio/audioSceneComponent";
  39039. export * from "babylonjs/Audio/sound";
  39040. export * from "babylonjs/Audio/soundTrack";
  39041. export * from "babylonjs/Audio/weightedsound";
  39042. }
  39043. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39044. import { Behavior } from "babylonjs/Behaviors/behavior";
  39045. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39046. import { BackEase } from "babylonjs/Animations/easing";
  39047. /**
  39048. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39049. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39050. */
  39051. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39052. /**
  39053. * Gets the name of the behavior.
  39054. */
  39055. get name(): string;
  39056. /**
  39057. * The easing function used by animations
  39058. */
  39059. static EasingFunction: BackEase;
  39060. /**
  39061. * The easing mode used by animations
  39062. */
  39063. static EasingMode: number;
  39064. /**
  39065. * The duration of the animation, in milliseconds
  39066. */
  39067. transitionDuration: number;
  39068. /**
  39069. * Length of the distance animated by the transition when lower radius is reached
  39070. */
  39071. lowerRadiusTransitionRange: number;
  39072. /**
  39073. * Length of the distance animated by the transition when upper radius is reached
  39074. */
  39075. upperRadiusTransitionRange: number;
  39076. private _autoTransitionRange;
  39077. /**
  39078. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39079. */
  39080. get autoTransitionRange(): boolean;
  39081. /**
  39082. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39083. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39084. */
  39085. set autoTransitionRange(value: boolean);
  39086. private _attachedCamera;
  39087. private _onAfterCheckInputsObserver;
  39088. private _onMeshTargetChangedObserver;
  39089. /**
  39090. * Initializes the behavior.
  39091. */
  39092. init(): void;
  39093. /**
  39094. * Attaches the behavior to its arc rotate camera.
  39095. * @param camera Defines the camera to attach the behavior to
  39096. */
  39097. attach(camera: ArcRotateCamera): void;
  39098. /**
  39099. * Detaches the behavior from its current arc rotate camera.
  39100. */
  39101. detach(): void;
  39102. private _radiusIsAnimating;
  39103. private _radiusBounceTransition;
  39104. private _animatables;
  39105. private _cachedWheelPrecision;
  39106. /**
  39107. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39108. * @param radiusLimit The limit to check against.
  39109. * @return Bool to indicate if at limit.
  39110. */
  39111. private _isRadiusAtLimit;
  39112. /**
  39113. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39114. * @param radiusDelta The delta by which to animate to. Can be negative.
  39115. */
  39116. private _applyBoundRadiusAnimation;
  39117. /**
  39118. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39119. */
  39120. protected _clearAnimationLocks(): void;
  39121. /**
  39122. * Stops and removes all animations that have been applied to the camera
  39123. */
  39124. stopAllAnimations(): void;
  39125. }
  39126. }
  39127. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39128. import { Behavior } from "babylonjs/Behaviors/behavior";
  39129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39130. import { ExponentialEase } from "babylonjs/Animations/easing";
  39131. import { Nullable } from "babylonjs/types";
  39132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39133. import { Vector3 } from "babylonjs/Maths/math.vector";
  39134. /**
  39135. * 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.
  39136. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39137. */
  39138. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39139. /**
  39140. * Gets the name of the behavior.
  39141. */
  39142. get name(): string;
  39143. private _mode;
  39144. private _radiusScale;
  39145. private _positionScale;
  39146. private _defaultElevation;
  39147. private _elevationReturnTime;
  39148. private _elevationReturnWaitTime;
  39149. private _zoomStopsAnimation;
  39150. private _framingTime;
  39151. /**
  39152. * The easing function used by animations
  39153. */
  39154. static EasingFunction: ExponentialEase;
  39155. /**
  39156. * The easing mode used by animations
  39157. */
  39158. static EasingMode: number;
  39159. /**
  39160. * Sets the current mode used by the behavior
  39161. */
  39162. set mode(mode: number);
  39163. /**
  39164. * Gets current mode used by the behavior.
  39165. */
  39166. get mode(): number;
  39167. /**
  39168. * Sets the scale applied to the radius (1 by default)
  39169. */
  39170. set radiusScale(radius: number);
  39171. /**
  39172. * Gets the scale applied to the radius
  39173. */
  39174. get radiusScale(): number;
  39175. /**
  39176. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39177. */
  39178. set positionScale(scale: number);
  39179. /**
  39180. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39181. */
  39182. get positionScale(): number;
  39183. /**
  39184. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39185. * behaviour is triggered, in radians.
  39186. */
  39187. set defaultElevation(elevation: number);
  39188. /**
  39189. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39190. * behaviour is triggered, in radians.
  39191. */
  39192. get defaultElevation(): number;
  39193. /**
  39194. * Sets the time (in milliseconds) taken to return to the default beta position.
  39195. * Negative value indicates camera should not return to default.
  39196. */
  39197. set elevationReturnTime(speed: number);
  39198. /**
  39199. * Gets the time (in milliseconds) taken to return to the default beta position.
  39200. * Negative value indicates camera should not return to default.
  39201. */
  39202. get elevationReturnTime(): number;
  39203. /**
  39204. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39205. */
  39206. set elevationReturnWaitTime(time: number);
  39207. /**
  39208. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39209. */
  39210. get elevationReturnWaitTime(): number;
  39211. /**
  39212. * Sets the flag that indicates if user zooming should stop animation.
  39213. */
  39214. set zoomStopsAnimation(flag: boolean);
  39215. /**
  39216. * Gets the flag that indicates if user zooming should stop animation.
  39217. */
  39218. get zoomStopsAnimation(): boolean;
  39219. /**
  39220. * Sets the transition time when framing the mesh, in milliseconds
  39221. */
  39222. set framingTime(time: number);
  39223. /**
  39224. * Gets the transition time when framing the mesh, in milliseconds
  39225. */
  39226. get framingTime(): number;
  39227. /**
  39228. * Define if the behavior should automatically change the configured
  39229. * camera limits and sensibilities.
  39230. */
  39231. autoCorrectCameraLimitsAndSensibility: boolean;
  39232. private _onPrePointerObservableObserver;
  39233. private _onAfterCheckInputsObserver;
  39234. private _onMeshTargetChangedObserver;
  39235. private _attachedCamera;
  39236. private _isPointerDown;
  39237. private _lastInteractionTime;
  39238. /**
  39239. * Initializes the behavior.
  39240. */
  39241. init(): void;
  39242. /**
  39243. * Attaches the behavior to its arc rotate camera.
  39244. * @param camera Defines the camera to attach the behavior to
  39245. */
  39246. attach(camera: ArcRotateCamera): void;
  39247. /**
  39248. * Detaches the behavior from its current arc rotate camera.
  39249. */
  39250. detach(): void;
  39251. private _animatables;
  39252. private _betaIsAnimating;
  39253. private _betaTransition;
  39254. private _radiusTransition;
  39255. private _vectorTransition;
  39256. /**
  39257. * Targets the given mesh and updates zoom level accordingly.
  39258. * @param mesh The mesh to target.
  39259. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39260. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39261. */
  39262. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39263. /**
  39264. * Targets the given mesh with its children and updates zoom level accordingly.
  39265. * @param mesh The mesh to target.
  39266. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39267. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39268. */
  39269. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39270. /**
  39271. * Targets the given meshes with their children and updates zoom level accordingly.
  39272. * @param meshes The mesh to target.
  39273. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39274. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39275. */
  39276. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39277. /**
  39278. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39279. * @param minimumWorld Determines the smaller position of the bounding box extend
  39280. * @param maximumWorld Determines the bigger position of the bounding box extend
  39281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39283. */
  39284. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39285. /**
  39286. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39287. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39288. * frustum width.
  39289. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39290. * to fully enclose the mesh in the viewing frustum.
  39291. */
  39292. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39293. /**
  39294. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39295. * is automatically returned to its default position (expected to be above ground plane).
  39296. */
  39297. private _maintainCameraAboveGround;
  39298. /**
  39299. * Returns the frustum slope based on the canvas ratio and camera FOV
  39300. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39301. */
  39302. private _getFrustumSlope;
  39303. /**
  39304. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39305. */
  39306. private _clearAnimationLocks;
  39307. /**
  39308. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39309. */
  39310. private _applyUserInteraction;
  39311. /**
  39312. * Stops and removes all animations that have been applied to the camera
  39313. */
  39314. stopAllAnimations(): void;
  39315. /**
  39316. * Gets a value indicating if the user is moving the camera
  39317. */
  39318. get isUserIsMoving(): boolean;
  39319. /**
  39320. * The camera can move all the way towards the mesh.
  39321. */
  39322. static IgnoreBoundsSizeMode: number;
  39323. /**
  39324. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39325. */
  39326. static FitFrustumSidesMode: number;
  39327. }
  39328. }
  39329. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39330. import { Nullable } from "babylonjs/types";
  39331. import { Camera } from "babylonjs/Cameras/camera";
  39332. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39333. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39334. /**
  39335. * Base class for Camera Pointer Inputs.
  39336. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39337. * for example usage.
  39338. */
  39339. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39340. /**
  39341. * Defines the camera the input is attached to.
  39342. */
  39343. abstract camera: Camera;
  39344. /**
  39345. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39346. */
  39347. protected _altKey: boolean;
  39348. protected _ctrlKey: boolean;
  39349. protected _metaKey: boolean;
  39350. protected _shiftKey: boolean;
  39351. /**
  39352. * Which mouse buttons were pressed at time of last mouse event.
  39353. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39354. */
  39355. protected _buttonsPressed: number;
  39356. /**
  39357. * Defines the buttons associated with the input to handle camera move.
  39358. */
  39359. buttons: number[];
  39360. /**
  39361. * Attach the input controls to a specific dom element to get the input from.
  39362. * @param element Defines the element the controls should be listened from
  39363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39364. */
  39365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39366. /**
  39367. * Detach the current controls from the specified dom element.
  39368. * @param element Defines the element to stop listening the inputs from
  39369. */
  39370. detachControl(element: Nullable<HTMLElement>): void;
  39371. /**
  39372. * Gets the class name of the current input.
  39373. * @returns the class name
  39374. */
  39375. getClassName(): string;
  39376. /**
  39377. * Get the friendly name associated with the input class.
  39378. * @returns the input friendly name
  39379. */
  39380. getSimpleName(): string;
  39381. /**
  39382. * Called on pointer POINTERDOUBLETAP event.
  39383. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39384. */
  39385. protected onDoubleTap(type: string): void;
  39386. /**
  39387. * Called on pointer POINTERMOVE event if only a single touch is active.
  39388. * Override this method to provide functionality.
  39389. */
  39390. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39391. /**
  39392. * Called on pointer POINTERMOVE event if multiple touches are active.
  39393. * Override this method to provide functionality.
  39394. */
  39395. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39396. /**
  39397. * Called on JS contextmenu event.
  39398. * Override this method to provide functionality.
  39399. */
  39400. protected onContextMenu(evt: PointerEvent): void;
  39401. /**
  39402. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39403. * press.
  39404. * Override this method to provide functionality.
  39405. */
  39406. protected onButtonDown(evt: PointerEvent): void;
  39407. /**
  39408. * Called each time a new POINTERUP event occurs. Ie, for each button
  39409. * release.
  39410. * Override this method to provide functionality.
  39411. */
  39412. protected onButtonUp(evt: PointerEvent): void;
  39413. /**
  39414. * Called when window becomes inactive.
  39415. * Override this method to provide functionality.
  39416. */
  39417. protected onLostFocus(): void;
  39418. private _pointerInput;
  39419. private _observer;
  39420. private _onLostFocus;
  39421. private pointA;
  39422. private pointB;
  39423. }
  39424. }
  39425. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39426. import { Nullable } from "babylonjs/types";
  39427. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39428. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39429. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39430. /**
  39431. * Manage the pointers inputs to control an arc rotate camera.
  39432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39433. */
  39434. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39435. /**
  39436. * Defines the camera the input is attached to.
  39437. */
  39438. camera: ArcRotateCamera;
  39439. /**
  39440. * Gets the class name of the current input.
  39441. * @returns the class name
  39442. */
  39443. getClassName(): string;
  39444. /**
  39445. * Defines the buttons associated with the input to handle camera move.
  39446. */
  39447. buttons: number[];
  39448. /**
  39449. * Defines the pointer angular sensibility along the X axis or how fast is
  39450. * the camera rotating.
  39451. */
  39452. angularSensibilityX: number;
  39453. /**
  39454. * Defines the pointer angular sensibility along the Y axis or how fast is
  39455. * the camera rotating.
  39456. */
  39457. angularSensibilityY: number;
  39458. /**
  39459. * Defines the pointer pinch precision or how fast is the camera zooming.
  39460. */
  39461. pinchPrecision: number;
  39462. /**
  39463. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39464. * from 0.
  39465. * It defines the percentage of current camera.radius to use as delta when
  39466. * pinch zoom is used.
  39467. */
  39468. pinchDeltaPercentage: number;
  39469. /**
  39470. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39471. * that any object in the plane at the camera's target point will scale
  39472. * perfectly with finger motion.
  39473. * Overrides pinchDeltaPercentage and pinchPrecision.
  39474. */
  39475. useNaturalPinchZoom: boolean;
  39476. /**
  39477. * Defines the pointer panning sensibility or how fast is the camera moving.
  39478. */
  39479. panningSensibility: number;
  39480. /**
  39481. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39482. */
  39483. multiTouchPanning: boolean;
  39484. /**
  39485. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39486. * zoom (pinch) through multitouch.
  39487. */
  39488. multiTouchPanAndZoom: boolean;
  39489. /**
  39490. * Revers pinch action direction.
  39491. */
  39492. pinchInwards: boolean;
  39493. private _isPanClick;
  39494. private _twoFingerActivityCount;
  39495. private _isPinching;
  39496. /**
  39497. * Called on pointer POINTERMOVE event if only a single touch is active.
  39498. */
  39499. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39500. /**
  39501. * Called on pointer POINTERDOUBLETAP event.
  39502. */
  39503. protected onDoubleTap(type: string): void;
  39504. /**
  39505. * Called on pointer POINTERMOVE event if multiple touches are active.
  39506. */
  39507. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39508. /**
  39509. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39510. * press.
  39511. */
  39512. protected onButtonDown(evt: PointerEvent): void;
  39513. /**
  39514. * Called each time a new POINTERUP event occurs. Ie, for each button
  39515. * release.
  39516. */
  39517. protected onButtonUp(evt: PointerEvent): void;
  39518. /**
  39519. * Called when window becomes inactive.
  39520. */
  39521. protected onLostFocus(): void;
  39522. }
  39523. }
  39524. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39525. import { Nullable } from "babylonjs/types";
  39526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39527. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39528. /**
  39529. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39531. */
  39532. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39533. /**
  39534. * Defines the camera the input is attached to.
  39535. */
  39536. camera: ArcRotateCamera;
  39537. /**
  39538. * Defines the list of key codes associated with the up action (increase alpha)
  39539. */
  39540. keysUp: number[];
  39541. /**
  39542. * Defines the list of key codes associated with the down action (decrease alpha)
  39543. */
  39544. keysDown: number[];
  39545. /**
  39546. * Defines the list of key codes associated with the left action (increase beta)
  39547. */
  39548. keysLeft: number[];
  39549. /**
  39550. * Defines the list of key codes associated with the right action (decrease beta)
  39551. */
  39552. keysRight: number[];
  39553. /**
  39554. * Defines the list of key codes associated with the reset action.
  39555. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39556. */
  39557. keysReset: number[];
  39558. /**
  39559. * Defines the panning sensibility of the inputs.
  39560. * (How fast is the camera panning)
  39561. */
  39562. panningSensibility: number;
  39563. /**
  39564. * Defines the zooming sensibility of the inputs.
  39565. * (How fast is the camera zooming)
  39566. */
  39567. zoomingSensibility: number;
  39568. /**
  39569. * Defines whether maintaining the alt key down switch the movement mode from
  39570. * orientation to zoom.
  39571. */
  39572. useAltToZoom: boolean;
  39573. /**
  39574. * Rotation speed of the camera
  39575. */
  39576. angularSpeed: number;
  39577. private _keys;
  39578. private _ctrlPressed;
  39579. private _altPressed;
  39580. private _onCanvasBlurObserver;
  39581. private _onKeyboardObserver;
  39582. private _engine;
  39583. private _scene;
  39584. /**
  39585. * Attach the input controls to a specific dom element to get the input from.
  39586. * @param element Defines the element the controls should be listened from
  39587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39588. */
  39589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39590. /**
  39591. * Detach the current controls from the specified dom element.
  39592. * @param element Defines the element to stop listening the inputs from
  39593. */
  39594. detachControl(element: Nullable<HTMLElement>): void;
  39595. /**
  39596. * Update the current camera state depending on the inputs that have been used this frame.
  39597. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39598. */
  39599. checkInputs(): void;
  39600. /**
  39601. * Gets the class name of the current intput.
  39602. * @returns the class name
  39603. */
  39604. getClassName(): string;
  39605. /**
  39606. * Get the friendly name associated with the input class.
  39607. * @returns the input friendly name
  39608. */
  39609. getSimpleName(): string;
  39610. }
  39611. }
  39612. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39613. import { Nullable } from "babylonjs/types";
  39614. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39616. /**
  39617. * Manage the mouse wheel inputs to control an arc rotate camera.
  39618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39619. */
  39620. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39621. /**
  39622. * Defines the camera the input is attached to.
  39623. */
  39624. camera: ArcRotateCamera;
  39625. /**
  39626. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39627. */
  39628. wheelPrecision: number;
  39629. /**
  39630. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39631. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39632. */
  39633. wheelDeltaPercentage: number;
  39634. private _wheel;
  39635. private _observer;
  39636. private computeDeltaFromMouseWheelLegacyEvent;
  39637. /**
  39638. * Attach the input controls to a specific dom element to get the input from.
  39639. * @param element Defines the element the controls should be listened from
  39640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39641. */
  39642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39643. /**
  39644. * Detach the current controls from the specified dom element.
  39645. * @param element Defines the element to stop listening the inputs from
  39646. */
  39647. detachControl(element: Nullable<HTMLElement>): void;
  39648. /**
  39649. * Gets the class name of the current intput.
  39650. * @returns the class name
  39651. */
  39652. getClassName(): string;
  39653. /**
  39654. * Get the friendly name associated with the input class.
  39655. * @returns the input friendly name
  39656. */
  39657. getSimpleName(): string;
  39658. }
  39659. }
  39660. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39661. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39662. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39663. /**
  39664. * Default Inputs manager for the ArcRotateCamera.
  39665. * It groups all the default supported inputs for ease of use.
  39666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39667. */
  39668. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39669. /**
  39670. * Instantiates a new ArcRotateCameraInputsManager.
  39671. * @param camera Defines the camera the inputs belong to
  39672. */
  39673. constructor(camera: ArcRotateCamera);
  39674. /**
  39675. * Add mouse wheel input support to the input manager.
  39676. * @returns the current input manager
  39677. */
  39678. addMouseWheel(): ArcRotateCameraInputsManager;
  39679. /**
  39680. * Add pointers input support to the input manager.
  39681. * @returns the current input manager
  39682. */
  39683. addPointers(): ArcRotateCameraInputsManager;
  39684. /**
  39685. * Add keyboard input support to the input manager.
  39686. * @returns the current input manager
  39687. */
  39688. addKeyboard(): ArcRotateCameraInputsManager;
  39689. }
  39690. }
  39691. declare module "babylonjs/Cameras/arcRotateCamera" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Nullable } from "babylonjs/types";
  39694. import { Scene } from "babylonjs/scene";
  39695. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39697. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39698. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39699. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39700. import { Camera } from "babylonjs/Cameras/camera";
  39701. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39702. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39703. import { Collider } from "babylonjs/Collisions/collider";
  39704. /**
  39705. * This represents an orbital type of camera.
  39706. *
  39707. * 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.
  39708. * 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.
  39709. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39710. */
  39711. export class ArcRotateCamera extends TargetCamera {
  39712. /**
  39713. * Defines the rotation angle of the camera along the longitudinal axis.
  39714. */
  39715. alpha: number;
  39716. /**
  39717. * Defines the rotation angle of the camera along the latitudinal axis.
  39718. */
  39719. beta: number;
  39720. /**
  39721. * Defines the radius of the camera from it s target point.
  39722. */
  39723. radius: number;
  39724. protected _target: Vector3;
  39725. protected _targetHost: Nullable<AbstractMesh>;
  39726. /**
  39727. * Defines the target point of the camera.
  39728. * The camera looks towards it form the radius distance.
  39729. */
  39730. get target(): Vector3;
  39731. set target(value: Vector3);
  39732. /**
  39733. * Define the current local position of the camera in the scene
  39734. */
  39735. get position(): Vector3;
  39736. set position(newPosition: Vector3);
  39737. protected _upVector: Vector3;
  39738. protected _upToYMatrix: Matrix;
  39739. protected _YToUpMatrix: Matrix;
  39740. /**
  39741. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39742. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39743. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39744. */
  39745. set upVector(vec: Vector3);
  39746. get upVector(): Vector3;
  39747. /**
  39748. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39749. */
  39750. setMatUp(): void;
  39751. /**
  39752. * Current inertia value on the longitudinal axis.
  39753. * The bigger this number the longer it will take for the camera to stop.
  39754. */
  39755. inertialAlphaOffset: number;
  39756. /**
  39757. * Current inertia value on the latitudinal axis.
  39758. * The bigger this number the longer it will take for the camera to stop.
  39759. */
  39760. inertialBetaOffset: number;
  39761. /**
  39762. * Current inertia value on the radius axis.
  39763. * The bigger this number the longer it will take for the camera to stop.
  39764. */
  39765. inertialRadiusOffset: number;
  39766. /**
  39767. * Minimum allowed angle on the longitudinal axis.
  39768. * This can help limiting how the Camera is able to move in the scene.
  39769. */
  39770. lowerAlphaLimit: Nullable<number>;
  39771. /**
  39772. * Maximum allowed angle on the longitudinal axis.
  39773. * This can help limiting how the Camera is able to move in the scene.
  39774. */
  39775. upperAlphaLimit: Nullable<number>;
  39776. /**
  39777. * Minimum allowed angle on the latitudinal axis.
  39778. * This can help limiting how the Camera is able to move in the scene.
  39779. */
  39780. lowerBetaLimit: number;
  39781. /**
  39782. * Maximum allowed angle on the latitudinal axis.
  39783. * This can help limiting how the Camera is able to move in the scene.
  39784. */
  39785. upperBetaLimit: number;
  39786. /**
  39787. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39788. * This can help limiting how the Camera is able to move in the scene.
  39789. */
  39790. lowerRadiusLimit: Nullable<number>;
  39791. /**
  39792. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39793. * This can help limiting how the Camera is able to move in the scene.
  39794. */
  39795. upperRadiusLimit: Nullable<number>;
  39796. /**
  39797. * Defines the current inertia value used during panning of the camera along the X axis.
  39798. */
  39799. inertialPanningX: number;
  39800. /**
  39801. * Defines the current inertia value used during panning of the camera along the Y axis.
  39802. */
  39803. inertialPanningY: number;
  39804. /**
  39805. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39806. * Basically if your fingers moves away from more than this distance you will be considered
  39807. * in pinch mode.
  39808. */
  39809. pinchToPanMaxDistance: number;
  39810. /**
  39811. * Defines the maximum distance the camera can pan.
  39812. * This could help keeping the cammera always in your scene.
  39813. */
  39814. panningDistanceLimit: Nullable<number>;
  39815. /**
  39816. * Defines the target of the camera before paning.
  39817. */
  39818. panningOriginTarget: Vector3;
  39819. /**
  39820. * Defines the value of the inertia used during panning.
  39821. * 0 would mean stop inertia and one would mean no decelleration at all.
  39822. */
  39823. panningInertia: number;
  39824. /**
  39825. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39826. */
  39827. get angularSensibilityX(): number;
  39828. set angularSensibilityX(value: number);
  39829. /**
  39830. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39831. */
  39832. get angularSensibilityY(): number;
  39833. set angularSensibilityY(value: number);
  39834. /**
  39835. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39836. */
  39837. get pinchPrecision(): number;
  39838. set pinchPrecision(value: number);
  39839. /**
  39840. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39841. * It will be used instead of pinchDeltaPrecision if different from 0.
  39842. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39843. */
  39844. get pinchDeltaPercentage(): number;
  39845. set pinchDeltaPercentage(value: number);
  39846. /**
  39847. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39848. * and pinch delta percentage.
  39849. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39850. * that any object in the plane at the camera's target point will scale
  39851. * perfectly with finger motion.
  39852. */
  39853. get useNaturalPinchZoom(): boolean;
  39854. set useNaturalPinchZoom(value: boolean);
  39855. /**
  39856. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39857. */
  39858. get panningSensibility(): number;
  39859. set panningSensibility(value: number);
  39860. /**
  39861. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39862. */
  39863. get keysUp(): number[];
  39864. set keysUp(value: number[]);
  39865. /**
  39866. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39867. */
  39868. get keysDown(): number[];
  39869. set keysDown(value: number[]);
  39870. /**
  39871. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39872. */
  39873. get keysLeft(): number[];
  39874. set keysLeft(value: number[]);
  39875. /**
  39876. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39877. */
  39878. get keysRight(): number[];
  39879. set keysRight(value: number[]);
  39880. /**
  39881. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39882. */
  39883. get wheelPrecision(): number;
  39884. set wheelPrecision(value: number);
  39885. /**
  39886. * Gets or Set the mouse wheel 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 wheelDeltaPercentage(): number;
  39891. set wheelDeltaPercentage(value: number);
  39892. /**
  39893. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39894. */
  39895. zoomOnFactor: number;
  39896. /**
  39897. * Defines a screen offset for the camera position.
  39898. */
  39899. targetScreenOffset: Vector2;
  39900. /**
  39901. * Allows the camera to be completely reversed.
  39902. * If false the camera can not arrive upside down.
  39903. */
  39904. allowUpsideDown: boolean;
  39905. /**
  39906. * Define if double tap/click is used to restore the previously saved state of the camera.
  39907. */
  39908. useInputToRestoreState: boolean;
  39909. /** @hidden */
  39910. _viewMatrix: Matrix;
  39911. /** @hidden */
  39912. _useCtrlForPanning: boolean;
  39913. /** @hidden */
  39914. _panningMouseButton: number;
  39915. /**
  39916. * Defines the input associated to the camera.
  39917. */
  39918. inputs: ArcRotateCameraInputsManager;
  39919. /** @hidden */
  39920. _reset: () => void;
  39921. /**
  39922. * Defines the allowed panning axis.
  39923. */
  39924. panningAxis: Vector3;
  39925. protected _localDirection: Vector3;
  39926. protected _transformedDirection: Vector3;
  39927. private _bouncingBehavior;
  39928. /**
  39929. * Gets the bouncing behavior of the camera if it has been enabled.
  39930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39931. */
  39932. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39933. /**
  39934. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39935. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39936. */
  39937. get useBouncingBehavior(): boolean;
  39938. set useBouncingBehavior(value: boolean);
  39939. private _framingBehavior;
  39940. /**
  39941. * Gets the framing behavior of the camera if it has been enabled.
  39942. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39943. */
  39944. get framingBehavior(): Nullable<FramingBehavior>;
  39945. /**
  39946. * Defines if the framing behavior of the camera is enabled on the camera.
  39947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39948. */
  39949. get useFramingBehavior(): boolean;
  39950. set useFramingBehavior(value: boolean);
  39951. private _autoRotationBehavior;
  39952. /**
  39953. * Gets the auto rotation behavior of the camera if it has been enabled.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39955. */
  39956. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39957. /**
  39958. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39960. */
  39961. get useAutoRotationBehavior(): boolean;
  39962. set useAutoRotationBehavior(value: boolean);
  39963. /**
  39964. * Observable triggered when the mesh target has been changed on the camera.
  39965. */
  39966. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39967. /**
  39968. * Event raised when the camera is colliding with a mesh.
  39969. */
  39970. onCollide: (collidedMesh: AbstractMesh) => void;
  39971. /**
  39972. * Defines whether the camera should check collision with the objects oh the scene.
  39973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39974. */
  39975. checkCollisions: boolean;
  39976. /**
  39977. * Defines the collision radius of the camera.
  39978. * This simulates a sphere around the camera.
  39979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39980. */
  39981. collisionRadius: Vector3;
  39982. protected _collider: Collider;
  39983. protected _previousPosition: Vector3;
  39984. protected _collisionVelocity: Vector3;
  39985. protected _newPosition: Vector3;
  39986. protected _previousAlpha: number;
  39987. protected _previousBeta: number;
  39988. protected _previousRadius: number;
  39989. protected _collisionTriggered: boolean;
  39990. protected _targetBoundingCenter: Nullable<Vector3>;
  39991. private _computationVector;
  39992. /**
  39993. * Instantiates a new ArcRotateCamera in a given scene
  39994. * @param name Defines the name of the camera
  39995. * @param alpha Defines the camera rotation along the logitudinal axis
  39996. * @param beta Defines the camera rotation along the latitudinal axis
  39997. * @param radius Defines the camera distance from its target
  39998. * @param target Defines the camera target
  39999. * @param scene Defines the scene the camera belongs to
  40000. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40001. */
  40002. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40003. /** @hidden */
  40004. _initCache(): void;
  40005. /** @hidden */
  40006. _updateCache(ignoreParentClass?: boolean): void;
  40007. protected _getTargetPosition(): Vector3;
  40008. private _storedAlpha;
  40009. private _storedBeta;
  40010. private _storedRadius;
  40011. private _storedTarget;
  40012. private _storedTargetScreenOffset;
  40013. /**
  40014. * Stores the current state of the camera (alpha, beta, radius and target)
  40015. * @returns the camera itself
  40016. */
  40017. storeState(): Camera;
  40018. /**
  40019. * @hidden
  40020. * Restored camera state. You must call storeState() first
  40021. */
  40022. _restoreStateValues(): boolean;
  40023. /** @hidden */
  40024. _isSynchronizedViewMatrix(): boolean;
  40025. /**
  40026. * Attached controls to the current camera.
  40027. * @param element Defines the element the controls should be listened from
  40028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40029. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40030. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40031. */
  40032. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40033. /**
  40034. * Detach the current controls from the camera.
  40035. * The camera will stop reacting to inputs.
  40036. * @param element Defines the element to stop listening the inputs from
  40037. */
  40038. detachControl(element: HTMLElement): void;
  40039. /** @hidden */
  40040. _checkInputs(): void;
  40041. protected _checkLimits(): void;
  40042. /**
  40043. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40044. */
  40045. rebuildAnglesAndRadius(): void;
  40046. /**
  40047. * Use a position to define the current camera related information like alpha, beta and radius
  40048. * @param position Defines the position to set the camera at
  40049. */
  40050. setPosition(position: Vector3): void;
  40051. /**
  40052. * Defines the target the camera should look at.
  40053. * This will automatically adapt alpha beta and radius to fit within the new target.
  40054. * @param target Defines the new target as a Vector or a mesh
  40055. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40056. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40057. */
  40058. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40059. /** @hidden */
  40060. _getViewMatrix(): Matrix;
  40061. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40062. /**
  40063. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40064. * @param meshes Defines the mesh to zoom on
  40065. * @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)
  40066. */
  40067. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40068. /**
  40069. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40070. * The target will be changed but the radius
  40071. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40072. * @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)
  40073. */
  40074. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40075. min: Vector3;
  40076. max: Vector3;
  40077. distance: number;
  40078. }, doNotUpdateMaxZ?: boolean): void;
  40079. /**
  40080. * @override
  40081. * Override Camera.createRigCamera
  40082. */
  40083. createRigCamera(name: string, cameraIndex: number): Camera;
  40084. /**
  40085. * @hidden
  40086. * @override
  40087. * Override Camera._updateRigCameras
  40088. */
  40089. _updateRigCameras(): void;
  40090. /**
  40091. * Destroy the camera and release the current resources hold by it.
  40092. */
  40093. dispose(): void;
  40094. /**
  40095. * Gets the current object class name.
  40096. * @return the class name
  40097. */
  40098. getClassName(): string;
  40099. }
  40100. }
  40101. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40102. import { Behavior } from "babylonjs/Behaviors/behavior";
  40103. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40104. /**
  40105. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40107. */
  40108. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40109. /**
  40110. * Gets the name of the behavior.
  40111. */
  40112. get name(): string;
  40113. private _zoomStopsAnimation;
  40114. private _idleRotationSpeed;
  40115. private _idleRotationWaitTime;
  40116. private _idleRotationSpinupTime;
  40117. /**
  40118. * Sets the flag that indicates if user zooming should stop animation.
  40119. */
  40120. set zoomStopsAnimation(flag: boolean);
  40121. /**
  40122. * Gets the flag that indicates if user zooming should stop animation.
  40123. */
  40124. get zoomStopsAnimation(): boolean;
  40125. /**
  40126. * Sets the default speed at which the camera rotates around the model.
  40127. */
  40128. set idleRotationSpeed(speed: number);
  40129. /**
  40130. * Gets the default speed at which the camera rotates around the model.
  40131. */
  40132. get idleRotationSpeed(): number;
  40133. /**
  40134. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40135. */
  40136. set idleRotationWaitTime(time: number);
  40137. /**
  40138. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40139. */
  40140. get idleRotationWaitTime(): number;
  40141. /**
  40142. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40143. */
  40144. set idleRotationSpinupTime(time: number);
  40145. /**
  40146. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40147. */
  40148. get idleRotationSpinupTime(): number;
  40149. /**
  40150. * Gets a value indicating if the camera is currently rotating because of this behavior
  40151. */
  40152. get rotationInProgress(): boolean;
  40153. private _onPrePointerObservableObserver;
  40154. private _onAfterCheckInputsObserver;
  40155. private _attachedCamera;
  40156. private _isPointerDown;
  40157. private _lastFrameTime;
  40158. private _lastInteractionTime;
  40159. private _cameraRotationSpeed;
  40160. /**
  40161. * Initializes the behavior.
  40162. */
  40163. init(): void;
  40164. /**
  40165. * Attaches the behavior to its arc rotate camera.
  40166. * @param camera Defines the camera to attach the behavior to
  40167. */
  40168. attach(camera: ArcRotateCamera): void;
  40169. /**
  40170. * Detaches the behavior from its current arc rotate camera.
  40171. */
  40172. detach(): void;
  40173. /**
  40174. * Returns true if user is scrolling.
  40175. * @return true if user is scrolling.
  40176. */
  40177. private _userIsZooming;
  40178. private _lastFrameRadius;
  40179. private _shouldAnimationStopForInteraction;
  40180. /**
  40181. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40182. */
  40183. private _applyUserInteraction;
  40184. private _userIsMoving;
  40185. }
  40186. }
  40187. declare module "babylonjs/Behaviors/Cameras/index" {
  40188. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40189. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40190. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40191. }
  40192. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40193. import { Mesh } from "babylonjs/Meshes/mesh";
  40194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40195. import { Behavior } from "babylonjs/Behaviors/behavior";
  40196. /**
  40197. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40198. */
  40199. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40200. private ui;
  40201. /**
  40202. * The name of the behavior
  40203. */
  40204. name: string;
  40205. /**
  40206. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40207. */
  40208. distanceAwayFromFace: number;
  40209. /**
  40210. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40211. */
  40212. distanceAwayFromBottomOfFace: number;
  40213. private _faceVectors;
  40214. private _target;
  40215. private _scene;
  40216. private _onRenderObserver;
  40217. private _tmpMatrix;
  40218. private _tmpVector;
  40219. /**
  40220. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40221. * @param ui The transform node that should be attched to the mesh
  40222. */
  40223. constructor(ui: TransformNode);
  40224. /**
  40225. * Initializes the behavior
  40226. */
  40227. init(): void;
  40228. private _closestFace;
  40229. private _zeroVector;
  40230. private _lookAtTmpMatrix;
  40231. private _lookAtToRef;
  40232. /**
  40233. * Attaches the AttachToBoxBehavior to the passed in mesh
  40234. * @param target The mesh that the specified node will be attached to
  40235. */
  40236. attach(target: Mesh): void;
  40237. /**
  40238. * Detaches the behavior from the mesh
  40239. */
  40240. detach(): void;
  40241. }
  40242. }
  40243. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40244. import { Behavior } from "babylonjs/Behaviors/behavior";
  40245. import { Mesh } from "babylonjs/Meshes/mesh";
  40246. /**
  40247. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40248. */
  40249. export class FadeInOutBehavior implements Behavior<Mesh> {
  40250. /**
  40251. * Time in milliseconds to delay before fading in (Default: 0)
  40252. */
  40253. delay: number;
  40254. /**
  40255. * Time in milliseconds for the mesh to fade in (Default: 300)
  40256. */
  40257. fadeInTime: number;
  40258. private _millisecondsPerFrame;
  40259. private _hovered;
  40260. private _hoverValue;
  40261. private _ownerNode;
  40262. /**
  40263. * Instatiates the FadeInOutBehavior
  40264. */
  40265. constructor();
  40266. /**
  40267. * The name of the behavior
  40268. */
  40269. get name(): string;
  40270. /**
  40271. * Initializes the behavior
  40272. */
  40273. init(): void;
  40274. /**
  40275. * Attaches the fade behavior on the passed in mesh
  40276. * @param ownerNode The mesh that will be faded in/out once attached
  40277. */
  40278. attach(ownerNode: Mesh): void;
  40279. /**
  40280. * Detaches the behavior from the mesh
  40281. */
  40282. detach(): void;
  40283. /**
  40284. * Triggers the mesh to begin fading in or out
  40285. * @param value if the object should fade in or out (true to fade in)
  40286. */
  40287. fadeIn(value: boolean): void;
  40288. private _update;
  40289. private _setAllVisibility;
  40290. }
  40291. }
  40292. declare module "babylonjs/Misc/pivotTools" {
  40293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40294. /**
  40295. * Class containing a set of static utilities functions for managing Pivots
  40296. * @hidden
  40297. */
  40298. export class PivotTools {
  40299. private static _PivotCached;
  40300. private static _OldPivotPoint;
  40301. private static _PivotTranslation;
  40302. private static _PivotTmpVector;
  40303. /** @hidden */
  40304. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40305. /** @hidden */
  40306. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40307. }
  40308. }
  40309. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40310. import { Scene } from "babylonjs/scene";
  40311. import { Vector4 } from "babylonjs/Maths/math.vector";
  40312. import { Mesh } from "babylonjs/Meshes/mesh";
  40313. import { Nullable } from "babylonjs/types";
  40314. import { Plane } from "babylonjs/Maths/math.plane";
  40315. /**
  40316. * Class containing static functions to help procedurally build meshes
  40317. */
  40318. export class PlaneBuilder {
  40319. /**
  40320. * Creates a plane mesh
  40321. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40322. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40323. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40327. * @param name defines the name of the mesh
  40328. * @param options defines the options used to create the mesh
  40329. * @param scene defines the hosting scene
  40330. * @returns the plane mesh
  40331. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40332. */
  40333. static CreatePlane(name: string, options: {
  40334. size?: number;
  40335. width?: number;
  40336. height?: number;
  40337. sideOrientation?: number;
  40338. frontUVs?: Vector4;
  40339. backUVs?: Vector4;
  40340. updatable?: boolean;
  40341. sourcePlane?: Plane;
  40342. }, scene?: Nullable<Scene>): Mesh;
  40343. }
  40344. }
  40345. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40346. import { Behavior } from "babylonjs/Behaviors/behavior";
  40347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40348. import { Observable } from "babylonjs/Misc/observable";
  40349. import { Vector3 } from "babylonjs/Maths/math.vector";
  40350. import { Ray } from "babylonjs/Culling/ray";
  40351. import "babylonjs/Meshes/Builders/planeBuilder";
  40352. /**
  40353. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40354. */
  40355. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40356. private static _AnyMouseID;
  40357. /**
  40358. * Abstract mesh the behavior is set on
  40359. */
  40360. attachedNode: AbstractMesh;
  40361. private _dragPlane;
  40362. private _scene;
  40363. private _pointerObserver;
  40364. private _beforeRenderObserver;
  40365. private static _planeScene;
  40366. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40367. /**
  40368. * 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)
  40369. */
  40370. maxDragAngle: number;
  40371. /**
  40372. * @hidden
  40373. */
  40374. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40375. /**
  40376. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40377. */
  40378. currentDraggingPointerID: number;
  40379. /**
  40380. * The last position where the pointer hit the drag plane in world space
  40381. */
  40382. lastDragPosition: Vector3;
  40383. /**
  40384. * If the behavior is currently in a dragging state
  40385. */
  40386. dragging: boolean;
  40387. /**
  40388. * 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)
  40389. */
  40390. dragDeltaRatio: number;
  40391. /**
  40392. * If the drag plane orientation should be updated during the dragging (Default: true)
  40393. */
  40394. updateDragPlane: boolean;
  40395. private _debugMode;
  40396. private _moving;
  40397. /**
  40398. * Fires each time the attached mesh is dragged with the pointer
  40399. * * delta between last drag position and current drag position in world space
  40400. * * dragDistance along the drag axis
  40401. * * dragPlaneNormal normal of the current drag plane used during the drag
  40402. * * dragPlanePoint in world space where the drag intersects the drag plane
  40403. */
  40404. onDragObservable: Observable<{
  40405. delta: Vector3;
  40406. dragPlanePoint: Vector3;
  40407. dragPlaneNormal: Vector3;
  40408. dragDistance: number;
  40409. pointerId: number;
  40410. }>;
  40411. /**
  40412. * Fires each time a drag begins (eg. mouse down on mesh)
  40413. */
  40414. onDragStartObservable: Observable<{
  40415. dragPlanePoint: Vector3;
  40416. pointerId: number;
  40417. }>;
  40418. /**
  40419. * Fires each time a drag ends (eg. mouse release after drag)
  40420. */
  40421. onDragEndObservable: Observable<{
  40422. dragPlanePoint: Vector3;
  40423. pointerId: number;
  40424. }>;
  40425. /**
  40426. * If the attached mesh should be moved when dragged
  40427. */
  40428. moveAttached: boolean;
  40429. /**
  40430. * If the drag behavior will react to drag events (Default: true)
  40431. */
  40432. enabled: boolean;
  40433. /**
  40434. * If pointer events should start and release the drag (Default: true)
  40435. */
  40436. startAndReleaseDragOnPointerEvents: boolean;
  40437. /**
  40438. * If camera controls should be detached during the drag
  40439. */
  40440. detachCameraControls: boolean;
  40441. /**
  40442. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40443. */
  40444. useObjectOrientationForDragging: boolean;
  40445. private _options;
  40446. /**
  40447. * Gets the options used by the behavior
  40448. */
  40449. get options(): {
  40450. dragAxis?: Vector3;
  40451. dragPlaneNormal?: Vector3;
  40452. };
  40453. /**
  40454. * Sets the options used by the behavior
  40455. */
  40456. set options(options: {
  40457. dragAxis?: Vector3;
  40458. dragPlaneNormal?: Vector3;
  40459. });
  40460. /**
  40461. * Creates a pointer drag behavior that can be attached to a mesh
  40462. * @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)
  40463. */
  40464. constructor(options?: {
  40465. dragAxis?: Vector3;
  40466. dragPlaneNormal?: Vector3;
  40467. });
  40468. /**
  40469. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40470. */
  40471. validateDrag: (targetPosition: Vector3) => boolean;
  40472. /**
  40473. * The name of the behavior
  40474. */
  40475. get name(): string;
  40476. /**
  40477. * Initializes the behavior
  40478. */
  40479. init(): void;
  40480. private _tmpVector;
  40481. private _alternatePickedPoint;
  40482. private _worldDragAxis;
  40483. private _targetPosition;
  40484. private _attachedElement;
  40485. /**
  40486. * Attaches the drag behavior the passed in mesh
  40487. * @param ownerNode The mesh that will be dragged around once attached
  40488. * @param predicate Predicate to use for pick filtering
  40489. */
  40490. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40491. /**
  40492. * Force relase the drag action by code.
  40493. */
  40494. releaseDrag(): void;
  40495. private _startDragRay;
  40496. private _lastPointerRay;
  40497. /**
  40498. * Simulates the start of a pointer drag event on the behavior
  40499. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40500. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40501. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40502. */
  40503. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40504. private _startDrag;
  40505. private _dragDelta;
  40506. private _moveDrag;
  40507. private _pickWithRayOnDragPlane;
  40508. private _pointA;
  40509. private _pointB;
  40510. private _pointC;
  40511. private _lineA;
  40512. private _lineB;
  40513. private _localAxis;
  40514. private _lookAt;
  40515. private _updateDragPlanePosition;
  40516. /**
  40517. * Detaches the behavior from the mesh
  40518. */
  40519. detach(): void;
  40520. }
  40521. }
  40522. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40523. import { Mesh } from "babylonjs/Meshes/mesh";
  40524. import { Behavior } from "babylonjs/Behaviors/behavior";
  40525. /**
  40526. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40527. */
  40528. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40529. private _dragBehaviorA;
  40530. private _dragBehaviorB;
  40531. private _startDistance;
  40532. private _initialScale;
  40533. private _targetScale;
  40534. private _ownerNode;
  40535. private _sceneRenderObserver;
  40536. /**
  40537. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40538. */
  40539. constructor();
  40540. /**
  40541. * The name of the behavior
  40542. */
  40543. get name(): string;
  40544. /**
  40545. * Initializes the behavior
  40546. */
  40547. init(): void;
  40548. private _getCurrentDistance;
  40549. /**
  40550. * Attaches the scale behavior the passed in mesh
  40551. * @param ownerNode The mesh that will be scaled around once attached
  40552. */
  40553. attach(ownerNode: Mesh): void;
  40554. /**
  40555. * Detaches the behavior from the mesh
  40556. */
  40557. detach(): void;
  40558. }
  40559. }
  40560. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40561. import { Behavior } from "babylonjs/Behaviors/behavior";
  40562. import { Mesh } from "babylonjs/Meshes/mesh";
  40563. import { Observable } from "babylonjs/Misc/observable";
  40564. /**
  40565. * 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
  40566. */
  40567. export class SixDofDragBehavior implements Behavior<Mesh> {
  40568. private static _virtualScene;
  40569. private _ownerNode;
  40570. private _sceneRenderObserver;
  40571. private _scene;
  40572. private _targetPosition;
  40573. private _virtualOriginMesh;
  40574. private _virtualDragMesh;
  40575. private _pointerObserver;
  40576. private _moving;
  40577. private _startingOrientation;
  40578. /**
  40579. * 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)
  40580. */
  40581. private zDragFactor;
  40582. /**
  40583. * If the object should rotate to face the drag origin
  40584. */
  40585. rotateDraggedObject: boolean;
  40586. /**
  40587. * If the behavior is currently in a dragging state
  40588. */
  40589. dragging: boolean;
  40590. /**
  40591. * 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)
  40592. */
  40593. dragDeltaRatio: number;
  40594. /**
  40595. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40596. */
  40597. currentDraggingPointerID: number;
  40598. /**
  40599. * If camera controls should be detached during the drag
  40600. */
  40601. detachCameraControls: boolean;
  40602. /**
  40603. * Fires each time a drag starts
  40604. */
  40605. onDragStartObservable: Observable<{}>;
  40606. /**
  40607. * Fires each time a drag ends (eg. mouse release after drag)
  40608. */
  40609. onDragEndObservable: Observable<{}>;
  40610. /**
  40611. * 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
  40612. */
  40613. constructor();
  40614. /**
  40615. * The name of the behavior
  40616. */
  40617. get name(): string;
  40618. /**
  40619. * Initializes the behavior
  40620. */
  40621. init(): void;
  40622. /**
  40623. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40624. */
  40625. private get _pointerCamera();
  40626. /**
  40627. * Attaches the scale behavior the passed in mesh
  40628. * @param ownerNode The mesh that will be scaled around once attached
  40629. */
  40630. attach(ownerNode: Mesh): void;
  40631. /**
  40632. * Detaches the behavior from the mesh
  40633. */
  40634. detach(): void;
  40635. }
  40636. }
  40637. declare module "babylonjs/Behaviors/Meshes/index" {
  40638. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40639. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40640. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40641. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40642. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40643. }
  40644. declare module "babylonjs/Behaviors/index" {
  40645. export * from "babylonjs/Behaviors/behavior";
  40646. export * from "babylonjs/Behaviors/Cameras/index";
  40647. export * from "babylonjs/Behaviors/Meshes/index";
  40648. }
  40649. declare module "babylonjs/Bones/boneIKController" {
  40650. import { Bone } from "babylonjs/Bones/bone";
  40651. import { Vector3 } from "babylonjs/Maths/math.vector";
  40652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40653. import { Nullable } from "babylonjs/types";
  40654. /**
  40655. * Class used to apply inverse kinematics to bones
  40656. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40657. */
  40658. export class BoneIKController {
  40659. private static _tmpVecs;
  40660. private static _tmpQuat;
  40661. private static _tmpMats;
  40662. /**
  40663. * Gets or sets the target mesh
  40664. */
  40665. targetMesh: AbstractMesh;
  40666. /** Gets or sets the mesh used as pole */
  40667. poleTargetMesh: AbstractMesh;
  40668. /**
  40669. * Gets or sets the bone used as pole
  40670. */
  40671. poleTargetBone: Nullable<Bone>;
  40672. /**
  40673. * Gets or sets the target position
  40674. */
  40675. targetPosition: Vector3;
  40676. /**
  40677. * Gets or sets the pole target position
  40678. */
  40679. poleTargetPosition: Vector3;
  40680. /**
  40681. * Gets or sets the pole target local offset
  40682. */
  40683. poleTargetLocalOffset: Vector3;
  40684. /**
  40685. * Gets or sets the pole angle
  40686. */
  40687. poleAngle: number;
  40688. /**
  40689. * Gets or sets the mesh associated with the controller
  40690. */
  40691. mesh: AbstractMesh;
  40692. /**
  40693. * 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)
  40694. */
  40695. slerpAmount: number;
  40696. private _bone1Quat;
  40697. private _bone1Mat;
  40698. private _bone2Ang;
  40699. private _bone1;
  40700. private _bone2;
  40701. private _bone1Length;
  40702. private _bone2Length;
  40703. private _maxAngle;
  40704. private _maxReach;
  40705. private _rightHandedSystem;
  40706. private _bendAxis;
  40707. private _slerping;
  40708. private _adjustRoll;
  40709. /**
  40710. * Gets or sets maximum allowed angle
  40711. */
  40712. get maxAngle(): number;
  40713. set maxAngle(value: number);
  40714. /**
  40715. * Creates a new BoneIKController
  40716. * @param mesh defines the mesh to control
  40717. * @param bone defines the bone to control
  40718. * @param options defines options to set up the controller
  40719. */
  40720. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40721. targetMesh?: AbstractMesh;
  40722. poleTargetMesh?: AbstractMesh;
  40723. poleTargetBone?: Bone;
  40724. poleTargetLocalOffset?: Vector3;
  40725. poleAngle?: number;
  40726. bendAxis?: Vector3;
  40727. maxAngle?: number;
  40728. slerpAmount?: number;
  40729. });
  40730. private _setMaxAngle;
  40731. /**
  40732. * Force the controller to update the bones
  40733. */
  40734. update(): void;
  40735. }
  40736. }
  40737. declare module "babylonjs/Bones/boneLookController" {
  40738. import { Vector3 } from "babylonjs/Maths/math.vector";
  40739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40740. import { Bone } from "babylonjs/Bones/bone";
  40741. import { Space } from "babylonjs/Maths/math.axis";
  40742. /**
  40743. * Class used to make a bone look toward a point in space
  40744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40745. */
  40746. export class BoneLookController {
  40747. private static _tmpVecs;
  40748. private static _tmpQuat;
  40749. private static _tmpMats;
  40750. /**
  40751. * The target Vector3 that the bone will look at
  40752. */
  40753. target: Vector3;
  40754. /**
  40755. * The mesh that the bone is attached to
  40756. */
  40757. mesh: AbstractMesh;
  40758. /**
  40759. * The bone that will be looking to the target
  40760. */
  40761. bone: Bone;
  40762. /**
  40763. * The up axis of the coordinate system that is used when the bone is rotated
  40764. */
  40765. upAxis: Vector3;
  40766. /**
  40767. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40768. */
  40769. upAxisSpace: Space;
  40770. /**
  40771. * Used to make an adjustment to the yaw of the bone
  40772. */
  40773. adjustYaw: number;
  40774. /**
  40775. * Used to make an adjustment to the pitch of the bone
  40776. */
  40777. adjustPitch: number;
  40778. /**
  40779. * Used to make an adjustment to the roll of the bone
  40780. */
  40781. adjustRoll: number;
  40782. /**
  40783. * 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)
  40784. */
  40785. slerpAmount: number;
  40786. private _minYaw;
  40787. private _maxYaw;
  40788. private _minPitch;
  40789. private _maxPitch;
  40790. private _minYawSin;
  40791. private _minYawCos;
  40792. private _maxYawSin;
  40793. private _maxYawCos;
  40794. private _midYawConstraint;
  40795. private _minPitchTan;
  40796. private _maxPitchTan;
  40797. private _boneQuat;
  40798. private _slerping;
  40799. private _transformYawPitch;
  40800. private _transformYawPitchInv;
  40801. private _firstFrameSkipped;
  40802. private _yawRange;
  40803. private _fowardAxis;
  40804. /**
  40805. * Gets or sets the minimum yaw angle that the bone can look to
  40806. */
  40807. get minYaw(): number;
  40808. set minYaw(value: number);
  40809. /**
  40810. * Gets or sets the maximum yaw angle that the bone can look to
  40811. */
  40812. get maxYaw(): number;
  40813. set maxYaw(value: number);
  40814. /**
  40815. * Gets or sets the minimum pitch angle that the bone can look to
  40816. */
  40817. get minPitch(): number;
  40818. set minPitch(value: number);
  40819. /**
  40820. * Gets or sets the maximum pitch angle that the bone can look to
  40821. */
  40822. get maxPitch(): number;
  40823. set maxPitch(value: number);
  40824. /**
  40825. * Create a BoneLookController
  40826. * @param mesh the mesh that the bone belongs to
  40827. * @param bone the bone that will be looking to the target
  40828. * @param target the target Vector3 to look at
  40829. * @param options optional settings:
  40830. * * maxYaw: the maximum angle the bone will yaw to
  40831. * * minYaw: the minimum angle the bone will yaw to
  40832. * * maxPitch: the maximum angle the bone will pitch to
  40833. * * minPitch: the minimum angle the bone will yaw to
  40834. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40835. * * upAxis: the up axis of the coordinate system
  40836. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40837. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40838. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40839. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40840. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40841. * * adjustRoll: used to make an adjustment to the roll of the bone
  40842. **/
  40843. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40844. maxYaw?: number;
  40845. minYaw?: number;
  40846. maxPitch?: number;
  40847. minPitch?: number;
  40848. slerpAmount?: number;
  40849. upAxis?: Vector3;
  40850. upAxisSpace?: Space;
  40851. yawAxis?: Vector3;
  40852. pitchAxis?: Vector3;
  40853. adjustYaw?: number;
  40854. adjustPitch?: number;
  40855. adjustRoll?: number;
  40856. });
  40857. /**
  40858. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40859. */
  40860. update(): void;
  40861. private _getAngleDiff;
  40862. private _getAngleBetween;
  40863. private _isAngleBetween;
  40864. }
  40865. }
  40866. declare module "babylonjs/Bones/index" {
  40867. export * from "babylonjs/Bones/bone";
  40868. export * from "babylonjs/Bones/boneIKController";
  40869. export * from "babylonjs/Bones/boneLookController";
  40870. export * from "babylonjs/Bones/skeleton";
  40871. }
  40872. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40873. import { Nullable } from "babylonjs/types";
  40874. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40875. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40876. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40877. /**
  40878. * Manage the gamepad inputs to control an arc rotate camera.
  40879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40880. */
  40881. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40882. /**
  40883. * Defines the camera the input is attached to.
  40884. */
  40885. camera: ArcRotateCamera;
  40886. /**
  40887. * Defines the gamepad the input is gathering event from.
  40888. */
  40889. gamepad: Nullable<Gamepad>;
  40890. /**
  40891. * Defines the gamepad rotation sensiblity.
  40892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40893. */
  40894. gamepadRotationSensibility: number;
  40895. /**
  40896. * Defines the gamepad move sensiblity.
  40897. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40898. */
  40899. gamepadMoveSensibility: number;
  40900. private _yAxisScale;
  40901. /**
  40902. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40903. */
  40904. get invertYAxis(): boolean;
  40905. set invertYAxis(value: boolean);
  40906. private _onGamepadConnectedObserver;
  40907. private _onGamepadDisconnectedObserver;
  40908. /**
  40909. * Attach the input controls to a specific dom element to get the input from.
  40910. * @param element Defines the element the controls should be listened from
  40911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40912. */
  40913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40914. /**
  40915. * Detach the current controls from the specified dom element.
  40916. * @param element Defines the element to stop listening the inputs from
  40917. */
  40918. detachControl(element: Nullable<HTMLElement>): void;
  40919. /**
  40920. * Update the current camera state depending on the inputs that have been used this frame.
  40921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40922. */
  40923. checkInputs(): void;
  40924. /**
  40925. * Gets the class name of the current intput.
  40926. * @returns the class name
  40927. */
  40928. getClassName(): string;
  40929. /**
  40930. * Get the friendly name associated with the input class.
  40931. * @returns the input friendly name
  40932. */
  40933. getSimpleName(): string;
  40934. }
  40935. }
  40936. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40937. import { Nullable } from "babylonjs/types";
  40938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40940. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40941. interface ArcRotateCameraInputsManager {
  40942. /**
  40943. * Add orientation input support to the input manager.
  40944. * @returns the current input manager
  40945. */
  40946. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40947. }
  40948. }
  40949. /**
  40950. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40952. */
  40953. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40954. /**
  40955. * Defines the camera the input is attached to.
  40956. */
  40957. camera: ArcRotateCamera;
  40958. /**
  40959. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40960. */
  40961. alphaCorrection: number;
  40962. /**
  40963. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40964. */
  40965. gammaCorrection: number;
  40966. private _alpha;
  40967. private _gamma;
  40968. private _dirty;
  40969. private _deviceOrientationHandler;
  40970. /**
  40971. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40972. */
  40973. constructor();
  40974. /**
  40975. * Attach the input controls to a specific dom element to get the input from.
  40976. * @param element Defines the element the controls should be listened from
  40977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40978. */
  40979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40980. /** @hidden */
  40981. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40982. /**
  40983. * Update the current camera state depending on the inputs that have been used this frame.
  40984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40985. */
  40986. checkInputs(): void;
  40987. /**
  40988. * Detach the current controls from the specified dom element.
  40989. * @param element Defines the element to stop listening the inputs from
  40990. */
  40991. detachControl(element: Nullable<HTMLElement>): void;
  40992. /**
  40993. * Gets the class name of the current intput.
  40994. * @returns the class name
  40995. */
  40996. getClassName(): string;
  40997. /**
  40998. * Get the friendly name associated with the input class.
  40999. * @returns the input friendly name
  41000. */
  41001. getSimpleName(): string;
  41002. }
  41003. }
  41004. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41005. import { Nullable } from "babylonjs/types";
  41006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41007. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41008. /**
  41009. * Listen to mouse events to control the camera.
  41010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41011. */
  41012. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41013. /**
  41014. * Defines the camera the input is attached to.
  41015. */
  41016. camera: FlyCamera;
  41017. /**
  41018. * Defines if touch is enabled. (Default is true.)
  41019. */
  41020. touchEnabled: boolean;
  41021. /**
  41022. * Defines the buttons associated with the input to handle camera rotation.
  41023. */
  41024. buttons: number[];
  41025. /**
  41026. * Assign buttons for Yaw control.
  41027. */
  41028. buttonsYaw: number[];
  41029. /**
  41030. * Assign buttons for Pitch control.
  41031. */
  41032. buttonsPitch: number[];
  41033. /**
  41034. * Assign buttons for Roll control.
  41035. */
  41036. buttonsRoll: number[];
  41037. /**
  41038. * Detect if any button is being pressed while mouse is moved.
  41039. * -1 = Mouse locked.
  41040. * 0 = Left button.
  41041. * 1 = Middle Button.
  41042. * 2 = Right Button.
  41043. */
  41044. activeButton: number;
  41045. /**
  41046. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41047. * Higher values reduce its sensitivity.
  41048. */
  41049. angularSensibility: number;
  41050. private _mousemoveCallback;
  41051. private _observer;
  41052. private _rollObserver;
  41053. private previousPosition;
  41054. private noPreventDefault;
  41055. private element;
  41056. /**
  41057. * Listen to mouse events to control the camera.
  41058. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41060. */
  41061. constructor(touchEnabled?: boolean);
  41062. /**
  41063. * Attach the mouse control to the HTML DOM element.
  41064. * @param element Defines the element that listens to the input events.
  41065. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41066. */
  41067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41068. /**
  41069. * Detach the current controls from the specified dom element.
  41070. * @param element Defines the element to stop listening the inputs from
  41071. */
  41072. detachControl(element: Nullable<HTMLElement>): void;
  41073. /**
  41074. * Gets the class name of the current input.
  41075. * @returns the class name.
  41076. */
  41077. getClassName(): string;
  41078. /**
  41079. * Get the friendly name associated with the input class.
  41080. * @returns the input's friendly name.
  41081. */
  41082. getSimpleName(): string;
  41083. private _pointerInput;
  41084. private _onMouseMove;
  41085. /**
  41086. * Rotate camera by mouse offset.
  41087. */
  41088. private rotateCamera;
  41089. }
  41090. }
  41091. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41092. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41093. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41094. /**
  41095. * Default Inputs manager for the FlyCamera.
  41096. * It groups all the default supported inputs for ease of use.
  41097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41098. */
  41099. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41100. /**
  41101. * Instantiates a new FlyCameraInputsManager.
  41102. * @param camera Defines the camera the inputs belong to.
  41103. */
  41104. constructor(camera: FlyCamera);
  41105. /**
  41106. * Add keyboard input support to the input manager.
  41107. * @returns the new FlyCameraKeyboardMoveInput().
  41108. */
  41109. addKeyboard(): FlyCameraInputsManager;
  41110. /**
  41111. * Add mouse input support to the input manager.
  41112. * @param touchEnabled Enable touch screen support.
  41113. * @returns the new FlyCameraMouseInput().
  41114. */
  41115. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41116. }
  41117. }
  41118. declare module "babylonjs/Cameras/flyCamera" {
  41119. import { Scene } from "babylonjs/scene";
  41120. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41122. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41123. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41124. /**
  41125. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41126. * such as in a 3D Space Shooter or a Flight Simulator.
  41127. */
  41128. export class FlyCamera extends TargetCamera {
  41129. /**
  41130. * Define the collision ellipsoid of the camera.
  41131. * This is helpful for simulating a camera body, like a player's body.
  41132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41133. */
  41134. ellipsoid: Vector3;
  41135. /**
  41136. * Define an offset for the position of the ellipsoid around the camera.
  41137. * This can be helpful if the camera is attached away from the player's body center,
  41138. * such as at its head.
  41139. */
  41140. ellipsoidOffset: Vector3;
  41141. /**
  41142. * Enable or disable collisions of the camera with the rest of the scene objects.
  41143. */
  41144. checkCollisions: boolean;
  41145. /**
  41146. * Enable or disable gravity on the camera.
  41147. */
  41148. applyGravity: boolean;
  41149. /**
  41150. * Define the current direction the camera is moving to.
  41151. */
  41152. cameraDirection: Vector3;
  41153. /**
  41154. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41155. * This overrides and empties cameraRotation.
  41156. */
  41157. rotationQuaternion: Quaternion;
  41158. /**
  41159. * Track Roll to maintain the wanted Rolling when looking around.
  41160. */
  41161. _trackRoll: number;
  41162. /**
  41163. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41164. */
  41165. rollCorrect: number;
  41166. /**
  41167. * Mimic a banked turn, Rolling the camera when Yawing.
  41168. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41169. */
  41170. bankedTurn: boolean;
  41171. /**
  41172. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41173. */
  41174. bankedTurnLimit: number;
  41175. /**
  41176. * Value of 0 disables the banked Roll.
  41177. * Value of 1 is equal to the Yaw angle in radians.
  41178. */
  41179. bankedTurnMultiplier: number;
  41180. /**
  41181. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41182. */
  41183. inputs: FlyCameraInputsManager;
  41184. /**
  41185. * Gets the input sensibility for mouse input.
  41186. * Higher values reduce sensitivity.
  41187. */
  41188. get angularSensibility(): number;
  41189. /**
  41190. * Sets the input sensibility for a mouse input.
  41191. * Higher values reduce sensitivity.
  41192. */
  41193. set angularSensibility(value: number);
  41194. /**
  41195. * Get the keys for camera movement forward.
  41196. */
  41197. get keysForward(): number[];
  41198. /**
  41199. * Set the keys for camera movement forward.
  41200. */
  41201. set keysForward(value: number[]);
  41202. /**
  41203. * Get the keys for camera movement backward.
  41204. */
  41205. get keysBackward(): number[];
  41206. set keysBackward(value: number[]);
  41207. /**
  41208. * Get the keys for camera movement up.
  41209. */
  41210. get keysUp(): number[];
  41211. /**
  41212. * Set the keys for camera movement up.
  41213. */
  41214. set keysUp(value: number[]);
  41215. /**
  41216. * Get the keys for camera movement down.
  41217. */
  41218. get keysDown(): number[];
  41219. /**
  41220. * Set the keys for camera movement down.
  41221. */
  41222. set keysDown(value: number[]);
  41223. /**
  41224. * Get the keys for camera movement left.
  41225. */
  41226. get keysLeft(): number[];
  41227. /**
  41228. * Set the keys for camera movement left.
  41229. */
  41230. set keysLeft(value: number[]);
  41231. /**
  41232. * Set the keys for camera movement right.
  41233. */
  41234. get keysRight(): number[];
  41235. /**
  41236. * Set the keys for camera movement right.
  41237. */
  41238. set keysRight(value: number[]);
  41239. /**
  41240. * Event raised when the camera collides with a mesh in the scene.
  41241. */
  41242. onCollide: (collidedMesh: AbstractMesh) => void;
  41243. private _collider;
  41244. private _needMoveForGravity;
  41245. private _oldPosition;
  41246. private _diffPosition;
  41247. private _newPosition;
  41248. /** @hidden */
  41249. _localDirection: Vector3;
  41250. /** @hidden */
  41251. _transformedDirection: Vector3;
  41252. /**
  41253. * Instantiates a FlyCamera.
  41254. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41255. * such as in a 3D Space Shooter or a Flight Simulator.
  41256. * @param name Define the name of the camera in the scene.
  41257. * @param position Define the starting position of the camera in the scene.
  41258. * @param scene Define the scene the camera belongs to.
  41259. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41260. */
  41261. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41262. /**
  41263. * Attach a control to the HTML DOM element.
  41264. * @param element Defines the element that listens to the input events.
  41265. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41266. */
  41267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41268. /**
  41269. * Detach a control from the HTML DOM element.
  41270. * The camera will stop reacting to that input.
  41271. * @param element Defines the element that listens to the input events.
  41272. */
  41273. detachControl(element: HTMLElement): void;
  41274. private _collisionMask;
  41275. /**
  41276. * Get the mask that the camera ignores in collision events.
  41277. */
  41278. get collisionMask(): number;
  41279. /**
  41280. * Set the mask that the camera ignores in collision events.
  41281. */
  41282. set collisionMask(mask: number);
  41283. /** @hidden */
  41284. _collideWithWorld(displacement: Vector3): void;
  41285. /** @hidden */
  41286. private _onCollisionPositionChange;
  41287. /** @hidden */
  41288. _checkInputs(): void;
  41289. /** @hidden */
  41290. _decideIfNeedsToMove(): boolean;
  41291. /** @hidden */
  41292. _updatePosition(): void;
  41293. /**
  41294. * Restore the Roll to its target value at the rate specified.
  41295. * @param rate - Higher means slower restoring.
  41296. * @hidden
  41297. */
  41298. restoreRoll(rate: number): void;
  41299. /**
  41300. * Destroy the camera and release the current resources held by it.
  41301. */
  41302. dispose(): void;
  41303. /**
  41304. * Get the current object class name.
  41305. * @returns the class name.
  41306. */
  41307. getClassName(): string;
  41308. }
  41309. }
  41310. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41311. import { Nullable } from "babylonjs/types";
  41312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41313. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41314. /**
  41315. * Listen to keyboard events to control the camera.
  41316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41317. */
  41318. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41319. /**
  41320. * Defines the camera the input is attached to.
  41321. */
  41322. camera: FlyCamera;
  41323. /**
  41324. * The list of keyboard keys used to control the forward move of the camera.
  41325. */
  41326. keysForward: number[];
  41327. /**
  41328. * The list of keyboard keys used to control the backward move of the camera.
  41329. */
  41330. keysBackward: number[];
  41331. /**
  41332. * The list of keyboard keys used to control the forward move of the camera.
  41333. */
  41334. keysUp: number[];
  41335. /**
  41336. * The list of keyboard keys used to control the backward move of the camera.
  41337. */
  41338. keysDown: number[];
  41339. /**
  41340. * The list of keyboard keys used to control the right strafe move of the camera.
  41341. */
  41342. keysRight: number[];
  41343. /**
  41344. * The list of keyboard keys used to control the left strafe move of the camera.
  41345. */
  41346. keysLeft: number[];
  41347. private _keys;
  41348. private _onCanvasBlurObserver;
  41349. private _onKeyboardObserver;
  41350. private _engine;
  41351. private _scene;
  41352. /**
  41353. * Attach the input controls to a specific dom element to get the input from.
  41354. * @param element Defines the element the controls should be listened from
  41355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41356. */
  41357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41358. /**
  41359. * Detach the current controls from the specified dom element.
  41360. * @param element Defines the element to stop listening the inputs from
  41361. */
  41362. detachControl(element: Nullable<HTMLElement>): void;
  41363. /**
  41364. * Gets the class name of the current intput.
  41365. * @returns the class name
  41366. */
  41367. getClassName(): string;
  41368. /** @hidden */
  41369. _onLostFocus(e: FocusEvent): void;
  41370. /**
  41371. * Get the friendly name associated with the input class.
  41372. * @returns the input friendly name
  41373. */
  41374. getSimpleName(): string;
  41375. /**
  41376. * Update the current camera state depending on the inputs that have been used this frame.
  41377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41378. */
  41379. checkInputs(): void;
  41380. }
  41381. }
  41382. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41383. import { Nullable } from "babylonjs/types";
  41384. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41385. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41386. /**
  41387. * Manage the mouse wheel inputs to control a follow camera.
  41388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41389. */
  41390. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41391. /**
  41392. * Defines the camera the input is attached to.
  41393. */
  41394. camera: FollowCamera;
  41395. /**
  41396. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41397. */
  41398. axisControlRadius: boolean;
  41399. /**
  41400. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41401. */
  41402. axisControlHeight: boolean;
  41403. /**
  41404. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41405. */
  41406. axisControlRotation: boolean;
  41407. /**
  41408. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41409. * relation to mouseWheel events.
  41410. */
  41411. wheelPrecision: number;
  41412. /**
  41413. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41414. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41415. */
  41416. wheelDeltaPercentage: number;
  41417. private _wheel;
  41418. private _observer;
  41419. /**
  41420. * Attach the input controls to a specific dom element to get the input from.
  41421. * @param element Defines the element the controls should be listened from
  41422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41423. */
  41424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41425. /**
  41426. * Detach the current controls from the specified dom element.
  41427. * @param element Defines the element to stop listening the inputs from
  41428. */
  41429. detachControl(element: Nullable<HTMLElement>): void;
  41430. /**
  41431. * Gets the class name of the current intput.
  41432. * @returns the class name
  41433. */
  41434. getClassName(): string;
  41435. /**
  41436. * Get the friendly name associated with the input class.
  41437. * @returns the input friendly name
  41438. */
  41439. getSimpleName(): string;
  41440. }
  41441. }
  41442. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41443. import { Nullable } from "babylonjs/types";
  41444. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41445. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41446. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41447. /**
  41448. * Manage the pointers inputs to control an follow camera.
  41449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41450. */
  41451. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41452. /**
  41453. * Defines the camera the input is attached to.
  41454. */
  41455. camera: FollowCamera;
  41456. /**
  41457. * Gets the class name of the current input.
  41458. * @returns the class name
  41459. */
  41460. getClassName(): string;
  41461. /**
  41462. * Defines the pointer angular sensibility along the X axis or how fast is
  41463. * the camera rotating.
  41464. * A negative number will reverse the axis direction.
  41465. */
  41466. angularSensibilityX: number;
  41467. /**
  41468. * Defines the pointer angular sensibility along the Y axis or how fast is
  41469. * the camera rotating.
  41470. * A negative number will reverse the axis direction.
  41471. */
  41472. angularSensibilityY: number;
  41473. /**
  41474. * Defines the pointer pinch precision or how fast is the camera zooming.
  41475. * A negative number will reverse the axis direction.
  41476. */
  41477. pinchPrecision: number;
  41478. /**
  41479. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41480. * from 0.
  41481. * It defines the percentage of current camera.radius to use as delta when
  41482. * pinch zoom is used.
  41483. */
  41484. pinchDeltaPercentage: number;
  41485. /**
  41486. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41487. */
  41488. axisXControlRadius: boolean;
  41489. /**
  41490. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41491. */
  41492. axisXControlHeight: boolean;
  41493. /**
  41494. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41495. */
  41496. axisXControlRotation: boolean;
  41497. /**
  41498. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41499. */
  41500. axisYControlRadius: boolean;
  41501. /**
  41502. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41503. */
  41504. axisYControlHeight: boolean;
  41505. /**
  41506. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41507. */
  41508. axisYControlRotation: boolean;
  41509. /**
  41510. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41511. */
  41512. axisPinchControlRadius: boolean;
  41513. /**
  41514. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41515. */
  41516. axisPinchControlHeight: boolean;
  41517. /**
  41518. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41519. */
  41520. axisPinchControlRotation: boolean;
  41521. /**
  41522. * Log error messages if basic misconfiguration has occurred.
  41523. */
  41524. warningEnable: boolean;
  41525. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41526. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41527. private _warningCounter;
  41528. private _warning;
  41529. }
  41530. }
  41531. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41532. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41533. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41534. /**
  41535. * Default Inputs manager for the FollowCamera.
  41536. * It groups all the default supported inputs for ease of use.
  41537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41538. */
  41539. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41540. /**
  41541. * Instantiates a new FollowCameraInputsManager.
  41542. * @param camera Defines the camera the inputs belong to
  41543. */
  41544. constructor(camera: FollowCamera);
  41545. /**
  41546. * Add keyboard input support to the input manager.
  41547. * @returns the current input manager
  41548. */
  41549. addKeyboard(): FollowCameraInputsManager;
  41550. /**
  41551. * Add mouse wheel input support to the input manager.
  41552. * @returns the current input manager
  41553. */
  41554. addMouseWheel(): FollowCameraInputsManager;
  41555. /**
  41556. * Add pointers input support to the input manager.
  41557. * @returns the current input manager
  41558. */
  41559. addPointers(): FollowCameraInputsManager;
  41560. /**
  41561. * Add orientation input support to the input manager.
  41562. * @returns the current input manager
  41563. */
  41564. addVRDeviceOrientation(): FollowCameraInputsManager;
  41565. }
  41566. }
  41567. declare module "babylonjs/Cameras/followCamera" {
  41568. import { Nullable } from "babylonjs/types";
  41569. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41570. import { Scene } from "babylonjs/scene";
  41571. import { Vector3 } from "babylonjs/Maths/math.vector";
  41572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41573. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41574. /**
  41575. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41576. * an arc rotate version arcFollowCamera are available.
  41577. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41578. */
  41579. export class FollowCamera extends TargetCamera {
  41580. /**
  41581. * Distance the follow camera should follow an object at
  41582. */
  41583. radius: number;
  41584. /**
  41585. * Minimum allowed distance of the camera to the axis of rotation
  41586. * (The camera can not get closer).
  41587. * This can help limiting how the Camera is able to move in the scene.
  41588. */
  41589. lowerRadiusLimit: Nullable<number>;
  41590. /**
  41591. * Maximum allowed distance of the camera to the axis of rotation
  41592. * (The camera can not get further).
  41593. * This can help limiting how the Camera is able to move in the scene.
  41594. */
  41595. upperRadiusLimit: Nullable<number>;
  41596. /**
  41597. * Define a rotation offset between the camera and the object it follows
  41598. */
  41599. rotationOffset: number;
  41600. /**
  41601. * Minimum allowed angle to camera position relative to target object.
  41602. * This can help limiting how the Camera is able to move in the scene.
  41603. */
  41604. lowerRotationOffsetLimit: Nullable<number>;
  41605. /**
  41606. * Maximum allowed angle to camera position relative to target object.
  41607. * This can help limiting how the Camera is able to move in the scene.
  41608. */
  41609. upperRotationOffsetLimit: Nullable<number>;
  41610. /**
  41611. * Define a height offset between the camera and the object it follows.
  41612. * It can help following an object from the top (like a car chaing a plane)
  41613. */
  41614. heightOffset: number;
  41615. /**
  41616. * Minimum allowed height of camera position relative to target object.
  41617. * This can help limiting how the Camera is able to move in the scene.
  41618. */
  41619. lowerHeightOffsetLimit: Nullable<number>;
  41620. /**
  41621. * Maximum allowed height of camera position relative to target object.
  41622. * This can help limiting how the Camera is able to move in the scene.
  41623. */
  41624. upperHeightOffsetLimit: Nullable<number>;
  41625. /**
  41626. * Define how fast the camera can accelerate to follow it s target.
  41627. */
  41628. cameraAcceleration: number;
  41629. /**
  41630. * Define the speed limit of the camera following an object.
  41631. */
  41632. maxCameraSpeed: number;
  41633. /**
  41634. * Define the target of the camera.
  41635. */
  41636. lockedTarget: Nullable<AbstractMesh>;
  41637. /**
  41638. * Defines the input associated with the camera.
  41639. */
  41640. inputs: FollowCameraInputsManager;
  41641. /**
  41642. * Instantiates the follow camera.
  41643. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41644. * @param name Define the name of the camera in the scene
  41645. * @param position Define the position of the camera
  41646. * @param scene Define the scene the camera belong to
  41647. * @param lockedTarget Define the target of the camera
  41648. */
  41649. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41650. private _follow;
  41651. /**
  41652. * Attached controls to the current camera.
  41653. * @param element Defines the element the controls should be listened from
  41654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41655. */
  41656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41657. /**
  41658. * Detach the current controls from the camera.
  41659. * The camera will stop reacting to inputs.
  41660. * @param element Defines the element to stop listening the inputs from
  41661. */
  41662. detachControl(element: HTMLElement): void;
  41663. /** @hidden */
  41664. _checkInputs(): void;
  41665. private _checkLimits;
  41666. /**
  41667. * Gets the camera class name.
  41668. * @returns the class name
  41669. */
  41670. getClassName(): string;
  41671. }
  41672. /**
  41673. * Arc Rotate version of the follow camera.
  41674. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41675. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41676. */
  41677. export class ArcFollowCamera extends TargetCamera {
  41678. /** The longitudinal angle of the camera */
  41679. alpha: number;
  41680. /** The latitudinal angle of the camera */
  41681. beta: number;
  41682. /** The radius of the camera from its target */
  41683. radius: number;
  41684. /** Define the camera target (the messh it should follow) */
  41685. target: Nullable<AbstractMesh>;
  41686. private _cartesianCoordinates;
  41687. /**
  41688. * Instantiates a new ArcFollowCamera
  41689. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41690. * @param name Define the name of the camera
  41691. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41692. * @param beta Define the rotation angle of the camera around the elevation axis
  41693. * @param radius Define the radius of the camera from its target point
  41694. * @param target Define the target of the camera
  41695. * @param scene Define the scene the camera belongs to
  41696. */
  41697. constructor(name: string,
  41698. /** The longitudinal angle of the camera */
  41699. alpha: number,
  41700. /** The latitudinal angle of the camera */
  41701. beta: number,
  41702. /** The radius of the camera from its target */
  41703. radius: number,
  41704. /** Define the camera target (the messh it should follow) */
  41705. target: Nullable<AbstractMesh>, scene: Scene);
  41706. private _follow;
  41707. /** @hidden */
  41708. _checkInputs(): void;
  41709. /**
  41710. * Returns the class name of the object.
  41711. * It is mostly used internally for serialization purposes.
  41712. */
  41713. getClassName(): string;
  41714. }
  41715. }
  41716. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41717. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41718. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41719. import { Nullable } from "babylonjs/types";
  41720. /**
  41721. * Manage the keyboard inputs to control the movement of a follow camera.
  41722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41723. */
  41724. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41725. /**
  41726. * Defines the camera the input is attached to.
  41727. */
  41728. camera: FollowCamera;
  41729. /**
  41730. * Defines the list of key codes associated with the up action (increase heightOffset)
  41731. */
  41732. keysHeightOffsetIncr: number[];
  41733. /**
  41734. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41735. */
  41736. keysHeightOffsetDecr: number[];
  41737. /**
  41738. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41739. */
  41740. keysHeightOffsetModifierAlt: boolean;
  41741. /**
  41742. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41743. */
  41744. keysHeightOffsetModifierCtrl: boolean;
  41745. /**
  41746. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41747. */
  41748. keysHeightOffsetModifierShift: boolean;
  41749. /**
  41750. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41751. */
  41752. keysRotationOffsetIncr: number[];
  41753. /**
  41754. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41755. */
  41756. keysRotationOffsetDecr: number[];
  41757. /**
  41758. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41759. */
  41760. keysRotationOffsetModifierAlt: boolean;
  41761. /**
  41762. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41763. */
  41764. keysRotationOffsetModifierCtrl: boolean;
  41765. /**
  41766. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41767. */
  41768. keysRotationOffsetModifierShift: boolean;
  41769. /**
  41770. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41771. */
  41772. keysRadiusIncr: number[];
  41773. /**
  41774. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41775. */
  41776. keysRadiusDecr: number[];
  41777. /**
  41778. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41779. */
  41780. keysRadiusModifierAlt: boolean;
  41781. /**
  41782. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41783. */
  41784. keysRadiusModifierCtrl: boolean;
  41785. /**
  41786. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41787. */
  41788. keysRadiusModifierShift: boolean;
  41789. /**
  41790. * Defines the rate of change of heightOffset.
  41791. */
  41792. heightSensibility: number;
  41793. /**
  41794. * Defines the rate of change of rotationOffset.
  41795. */
  41796. rotationSensibility: number;
  41797. /**
  41798. * Defines the rate of change of radius.
  41799. */
  41800. radiusSensibility: number;
  41801. private _keys;
  41802. private _ctrlPressed;
  41803. private _altPressed;
  41804. private _shiftPressed;
  41805. private _onCanvasBlurObserver;
  41806. private _onKeyboardObserver;
  41807. private _engine;
  41808. private _scene;
  41809. /**
  41810. * Attach the input controls to a specific dom element to get the input from.
  41811. * @param element Defines the element the controls should be listened from
  41812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41813. */
  41814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41815. /**
  41816. * Detach the current controls from the specified dom element.
  41817. * @param element Defines the element to stop listening the inputs from
  41818. */
  41819. detachControl(element: Nullable<HTMLElement>): void;
  41820. /**
  41821. * Update the current camera state depending on the inputs that have been used this frame.
  41822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41823. */
  41824. checkInputs(): void;
  41825. /**
  41826. * Gets the class name of the current input.
  41827. * @returns the class name
  41828. */
  41829. getClassName(): string;
  41830. /**
  41831. * Get the friendly name associated with the input class.
  41832. * @returns the input friendly name
  41833. */
  41834. getSimpleName(): string;
  41835. /**
  41836. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41837. * allow modification of the heightOffset value.
  41838. */
  41839. private _modifierHeightOffset;
  41840. /**
  41841. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41842. * allow modification of the rotationOffset value.
  41843. */
  41844. private _modifierRotationOffset;
  41845. /**
  41846. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41847. * allow modification of the radius value.
  41848. */
  41849. private _modifierRadius;
  41850. }
  41851. }
  41852. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41853. import { Nullable } from "babylonjs/types";
  41854. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41855. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41856. import { Observable } from "babylonjs/Misc/observable";
  41857. module "babylonjs/Cameras/freeCameraInputsManager" {
  41858. interface FreeCameraInputsManager {
  41859. /**
  41860. * @hidden
  41861. */
  41862. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41863. /**
  41864. * Add orientation input support to the input manager.
  41865. * @returns the current input manager
  41866. */
  41867. addDeviceOrientation(): FreeCameraInputsManager;
  41868. }
  41869. }
  41870. /**
  41871. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41872. * Screen rotation is taken into account.
  41873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41874. */
  41875. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41876. private _camera;
  41877. private _screenOrientationAngle;
  41878. private _constantTranform;
  41879. private _screenQuaternion;
  41880. private _alpha;
  41881. private _beta;
  41882. private _gamma;
  41883. /**
  41884. * Can be used to detect if a device orientation sensor is available on a device
  41885. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41886. * @returns a promise that will resolve on orientation change
  41887. */
  41888. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41889. /**
  41890. * @hidden
  41891. */
  41892. _onDeviceOrientationChangedObservable: Observable<void>;
  41893. /**
  41894. * Instantiates a new input
  41895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41896. */
  41897. constructor();
  41898. /**
  41899. * Define the camera controlled by the input.
  41900. */
  41901. get camera(): FreeCamera;
  41902. set camera(camera: FreeCamera);
  41903. /**
  41904. * Attach the input controls to a specific dom element to get the input from.
  41905. * @param element Defines the element the controls should be listened from
  41906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41907. */
  41908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41909. private _orientationChanged;
  41910. private _deviceOrientation;
  41911. /**
  41912. * Detach the current controls from the specified dom element.
  41913. * @param element Defines the element to stop listening the inputs from
  41914. */
  41915. detachControl(element: Nullable<HTMLElement>): void;
  41916. /**
  41917. * Update the current camera state depending on the inputs that have been used this frame.
  41918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41919. */
  41920. checkInputs(): void;
  41921. /**
  41922. * Gets the class name of the current intput.
  41923. * @returns the class name
  41924. */
  41925. getClassName(): string;
  41926. /**
  41927. * Get the friendly name associated with the input class.
  41928. * @returns the input friendly name
  41929. */
  41930. getSimpleName(): string;
  41931. }
  41932. }
  41933. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41934. import { Nullable } from "babylonjs/types";
  41935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41937. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41938. /**
  41939. * Manage the gamepad inputs to control a free camera.
  41940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41941. */
  41942. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41943. /**
  41944. * Define the camera the input is attached to.
  41945. */
  41946. camera: FreeCamera;
  41947. /**
  41948. * Define the Gamepad controlling the input
  41949. */
  41950. gamepad: Nullable<Gamepad>;
  41951. /**
  41952. * Defines the gamepad rotation sensiblity.
  41953. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41954. */
  41955. gamepadAngularSensibility: number;
  41956. /**
  41957. * Defines the gamepad move sensiblity.
  41958. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41959. */
  41960. gamepadMoveSensibility: number;
  41961. private _yAxisScale;
  41962. /**
  41963. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41964. */
  41965. get invertYAxis(): boolean;
  41966. set invertYAxis(value: boolean);
  41967. private _onGamepadConnectedObserver;
  41968. private _onGamepadDisconnectedObserver;
  41969. private _cameraTransform;
  41970. private _deltaTransform;
  41971. private _vector3;
  41972. private _vector2;
  41973. /**
  41974. * Attach the input controls to a specific dom element to get the input from.
  41975. * @param element Defines the element the controls should be listened from
  41976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41977. */
  41978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41979. /**
  41980. * Detach the current controls from the specified dom element.
  41981. * @param element Defines the element to stop listening the inputs from
  41982. */
  41983. detachControl(element: Nullable<HTMLElement>): void;
  41984. /**
  41985. * Update the current camera state depending on the inputs that have been used this frame.
  41986. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41987. */
  41988. checkInputs(): void;
  41989. /**
  41990. * Gets the class name of the current intput.
  41991. * @returns the class name
  41992. */
  41993. getClassName(): string;
  41994. /**
  41995. * Get the friendly name associated with the input class.
  41996. * @returns the input friendly name
  41997. */
  41998. getSimpleName(): string;
  41999. }
  42000. }
  42001. declare module "babylonjs/Misc/virtualJoystick" {
  42002. import { Nullable } from "babylonjs/types";
  42003. import { Vector3 } from "babylonjs/Maths/math.vector";
  42004. /**
  42005. * Defines the potential axis of a Joystick
  42006. */
  42007. export enum JoystickAxis {
  42008. /** X axis */
  42009. X = 0,
  42010. /** Y axis */
  42011. Y = 1,
  42012. /** Z axis */
  42013. Z = 2
  42014. }
  42015. /**
  42016. * Class used to define virtual joystick (used in touch mode)
  42017. */
  42018. export class VirtualJoystick {
  42019. /**
  42020. * Gets or sets a boolean indicating that left and right values must be inverted
  42021. */
  42022. reverseLeftRight: boolean;
  42023. /**
  42024. * Gets or sets a boolean indicating that up and down values must be inverted
  42025. */
  42026. reverseUpDown: boolean;
  42027. /**
  42028. * Gets the offset value for the position (ie. the change of the position value)
  42029. */
  42030. deltaPosition: Vector3;
  42031. /**
  42032. * Gets a boolean indicating if the virtual joystick was pressed
  42033. */
  42034. pressed: boolean;
  42035. /**
  42036. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42037. */
  42038. static Canvas: Nullable<HTMLCanvasElement>;
  42039. private static _globalJoystickIndex;
  42040. private static vjCanvasContext;
  42041. private static vjCanvasWidth;
  42042. private static vjCanvasHeight;
  42043. private static halfWidth;
  42044. private _action;
  42045. private _axisTargetedByLeftAndRight;
  42046. private _axisTargetedByUpAndDown;
  42047. private _joystickSensibility;
  42048. private _inversedSensibility;
  42049. private _joystickPointerID;
  42050. private _joystickColor;
  42051. private _joystickPointerPos;
  42052. private _joystickPreviousPointerPos;
  42053. private _joystickPointerStartPos;
  42054. private _deltaJoystickVector;
  42055. private _leftJoystick;
  42056. private _touches;
  42057. private _onPointerDownHandlerRef;
  42058. private _onPointerMoveHandlerRef;
  42059. private _onPointerUpHandlerRef;
  42060. private _onResize;
  42061. /**
  42062. * Creates a new virtual joystick
  42063. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42064. */
  42065. constructor(leftJoystick?: boolean);
  42066. /**
  42067. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42068. * @param newJoystickSensibility defines the new sensibility
  42069. */
  42070. setJoystickSensibility(newJoystickSensibility: number): void;
  42071. private _onPointerDown;
  42072. private _onPointerMove;
  42073. private _onPointerUp;
  42074. /**
  42075. * Change the color of the virtual joystick
  42076. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42077. */
  42078. setJoystickColor(newColor: string): void;
  42079. /**
  42080. * Defines a callback to call when the joystick is touched
  42081. * @param action defines the callback
  42082. */
  42083. setActionOnTouch(action: () => any): void;
  42084. /**
  42085. * Defines which axis you'd like to control for left & right
  42086. * @param axis defines the axis to use
  42087. */
  42088. setAxisForLeftRight(axis: JoystickAxis): void;
  42089. /**
  42090. * Defines which axis you'd like to control for up & down
  42091. * @param axis defines the axis to use
  42092. */
  42093. setAxisForUpDown(axis: JoystickAxis): void;
  42094. private _drawVirtualJoystick;
  42095. /**
  42096. * Release internal HTML canvas
  42097. */
  42098. releaseCanvas(): void;
  42099. }
  42100. }
  42101. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42102. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42103. import { Nullable } from "babylonjs/types";
  42104. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42105. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42106. module "babylonjs/Cameras/freeCameraInputsManager" {
  42107. interface FreeCameraInputsManager {
  42108. /**
  42109. * Add virtual joystick input support to the input manager.
  42110. * @returns the current input manager
  42111. */
  42112. addVirtualJoystick(): FreeCameraInputsManager;
  42113. }
  42114. }
  42115. /**
  42116. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42118. */
  42119. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42120. /**
  42121. * Defines the camera the input is attached to.
  42122. */
  42123. camera: FreeCamera;
  42124. private _leftjoystick;
  42125. private _rightjoystick;
  42126. /**
  42127. * Gets the left stick of the virtual joystick.
  42128. * @returns The virtual Joystick
  42129. */
  42130. getLeftJoystick(): VirtualJoystick;
  42131. /**
  42132. * Gets the right stick of the virtual joystick.
  42133. * @returns The virtual Joystick
  42134. */
  42135. getRightJoystick(): VirtualJoystick;
  42136. /**
  42137. * Update the current camera state depending on the inputs that have been used this frame.
  42138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42139. */
  42140. checkInputs(): void;
  42141. /**
  42142. * Attach the input controls to a specific dom element to get the input from.
  42143. * @param element Defines the element the controls should be listened from
  42144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42145. */
  42146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42147. /**
  42148. * Detach the current controls from the specified dom element.
  42149. * @param element Defines the element to stop listening the inputs from
  42150. */
  42151. detachControl(element: Nullable<HTMLElement>): void;
  42152. /**
  42153. * Gets the class name of the current intput.
  42154. * @returns the class name
  42155. */
  42156. getClassName(): string;
  42157. /**
  42158. * Get the friendly name associated with the input class.
  42159. * @returns the input friendly name
  42160. */
  42161. getSimpleName(): string;
  42162. }
  42163. }
  42164. declare module "babylonjs/Cameras/Inputs/index" {
  42165. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42166. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42167. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42168. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42169. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42170. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42171. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42172. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42173. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42174. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42175. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42176. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42177. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42178. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42179. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42180. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42181. }
  42182. declare module "babylonjs/Cameras/touchCamera" {
  42183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42184. import { Scene } from "babylonjs/scene";
  42185. import { Vector3 } from "babylonjs/Maths/math.vector";
  42186. /**
  42187. * This represents a FPS type of camera controlled by touch.
  42188. * This is like a universal camera minus the Gamepad controls.
  42189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42190. */
  42191. export class TouchCamera extends FreeCamera {
  42192. /**
  42193. * Defines the touch sensibility for rotation.
  42194. * The higher the faster.
  42195. */
  42196. get touchAngularSensibility(): number;
  42197. set touchAngularSensibility(value: number);
  42198. /**
  42199. * Defines the touch sensibility for move.
  42200. * The higher the faster.
  42201. */
  42202. get touchMoveSensibility(): number;
  42203. set touchMoveSensibility(value: number);
  42204. /**
  42205. * Instantiates a new touch camera.
  42206. * This represents a FPS type of camera controlled by touch.
  42207. * This is like a universal camera minus the Gamepad controls.
  42208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42209. * @param name Define the name of the camera in the scene
  42210. * @param position Define the start position of the camera in the scene
  42211. * @param scene Define the scene the camera belongs to
  42212. */
  42213. constructor(name: string, position: Vector3, scene: Scene);
  42214. /**
  42215. * Gets the current object class name.
  42216. * @return the class name
  42217. */
  42218. getClassName(): string;
  42219. /** @hidden */
  42220. _setupInputs(): void;
  42221. }
  42222. }
  42223. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42224. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42225. import { Scene } from "babylonjs/scene";
  42226. import { Vector3 } from "babylonjs/Maths/math.vector";
  42227. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42228. import { Axis } from "babylonjs/Maths/math.axis";
  42229. /**
  42230. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42231. * being tilted forward or back and left or right.
  42232. */
  42233. export class DeviceOrientationCamera extends FreeCamera {
  42234. private _initialQuaternion;
  42235. private _quaternionCache;
  42236. private _tmpDragQuaternion;
  42237. private _disablePointerInputWhenUsingDeviceOrientation;
  42238. /**
  42239. * Creates a new device orientation camera
  42240. * @param name The name of the camera
  42241. * @param position The start position camera
  42242. * @param scene The scene the camera belongs to
  42243. */
  42244. constructor(name: string, position: Vector3, scene: Scene);
  42245. /**
  42246. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42247. */
  42248. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42249. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42250. private _dragFactor;
  42251. /**
  42252. * Enabled turning on the y axis when the orientation sensor is active
  42253. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42254. */
  42255. enableHorizontalDragging(dragFactor?: number): void;
  42256. /**
  42257. * Gets the current instance class name ("DeviceOrientationCamera").
  42258. * This helps avoiding instanceof at run time.
  42259. * @returns the class name
  42260. */
  42261. getClassName(): string;
  42262. /**
  42263. * @hidden
  42264. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42265. */
  42266. _checkInputs(): void;
  42267. /**
  42268. * Reset the camera to its default orientation on the specified axis only.
  42269. * @param axis The axis to reset
  42270. */
  42271. resetToCurrentRotation(axis?: Axis): void;
  42272. }
  42273. }
  42274. declare module "babylonjs/Gamepads/xboxGamepad" {
  42275. import { Observable } from "babylonjs/Misc/observable";
  42276. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42277. /**
  42278. * Defines supported buttons for XBox360 compatible gamepads
  42279. */
  42280. export enum Xbox360Button {
  42281. /** A */
  42282. A = 0,
  42283. /** B */
  42284. B = 1,
  42285. /** X */
  42286. X = 2,
  42287. /** Y */
  42288. Y = 3,
  42289. /** Start */
  42290. Start = 4,
  42291. /** Back */
  42292. Back = 5,
  42293. /** Left button */
  42294. LB = 6,
  42295. /** Right button */
  42296. RB = 7,
  42297. /** Left stick */
  42298. LeftStick = 8,
  42299. /** Right stick */
  42300. RightStick = 9
  42301. }
  42302. /** Defines values for XBox360 DPad */
  42303. export enum Xbox360Dpad {
  42304. /** Up */
  42305. Up = 0,
  42306. /** Down */
  42307. Down = 1,
  42308. /** Left */
  42309. Left = 2,
  42310. /** Right */
  42311. Right = 3
  42312. }
  42313. /**
  42314. * Defines a XBox360 gamepad
  42315. */
  42316. export class Xbox360Pad extends Gamepad {
  42317. private _leftTrigger;
  42318. private _rightTrigger;
  42319. private _onlefttriggerchanged;
  42320. private _onrighttriggerchanged;
  42321. private _onbuttondown;
  42322. private _onbuttonup;
  42323. private _ondpaddown;
  42324. private _ondpadup;
  42325. /** Observable raised when a button is pressed */
  42326. onButtonDownObservable: Observable<Xbox360Button>;
  42327. /** Observable raised when a button is released */
  42328. onButtonUpObservable: Observable<Xbox360Button>;
  42329. /** Observable raised when a pad is pressed */
  42330. onPadDownObservable: Observable<Xbox360Dpad>;
  42331. /** Observable raised when a pad is released */
  42332. onPadUpObservable: Observable<Xbox360Dpad>;
  42333. private _buttonA;
  42334. private _buttonB;
  42335. private _buttonX;
  42336. private _buttonY;
  42337. private _buttonBack;
  42338. private _buttonStart;
  42339. private _buttonLB;
  42340. private _buttonRB;
  42341. private _buttonLeftStick;
  42342. private _buttonRightStick;
  42343. private _dPadUp;
  42344. private _dPadDown;
  42345. private _dPadLeft;
  42346. private _dPadRight;
  42347. private _isXboxOnePad;
  42348. /**
  42349. * Creates a new XBox360 gamepad object
  42350. * @param id defines the id of this gamepad
  42351. * @param index defines its index
  42352. * @param gamepad defines the internal HTML gamepad object
  42353. * @param xboxOne defines if it is a XBox One gamepad
  42354. */
  42355. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42356. /**
  42357. * Defines the callback to call when left trigger is pressed
  42358. * @param callback defines the callback to use
  42359. */
  42360. onlefttriggerchanged(callback: (value: number) => void): void;
  42361. /**
  42362. * Defines the callback to call when right trigger is pressed
  42363. * @param callback defines the callback to use
  42364. */
  42365. onrighttriggerchanged(callback: (value: number) => void): void;
  42366. /**
  42367. * Gets the left trigger value
  42368. */
  42369. get leftTrigger(): number;
  42370. /**
  42371. * Sets the left trigger value
  42372. */
  42373. set leftTrigger(newValue: number);
  42374. /**
  42375. * Gets the right trigger value
  42376. */
  42377. get rightTrigger(): number;
  42378. /**
  42379. * Sets the right trigger value
  42380. */
  42381. set rightTrigger(newValue: number);
  42382. /**
  42383. * Defines the callback to call when a button is pressed
  42384. * @param callback defines the callback to use
  42385. */
  42386. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42387. /**
  42388. * Defines the callback to call when a button is released
  42389. * @param callback defines the callback to use
  42390. */
  42391. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42392. /**
  42393. * Defines the callback to call when a pad is pressed
  42394. * @param callback defines the callback to use
  42395. */
  42396. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42397. /**
  42398. * Defines the callback to call when a pad is released
  42399. * @param callback defines the callback to use
  42400. */
  42401. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42402. private _setButtonValue;
  42403. private _setDPadValue;
  42404. /**
  42405. * Gets the value of the `A` button
  42406. */
  42407. get buttonA(): number;
  42408. /**
  42409. * Sets the value of the `A` button
  42410. */
  42411. set buttonA(value: number);
  42412. /**
  42413. * Gets the value of the `B` button
  42414. */
  42415. get buttonB(): number;
  42416. /**
  42417. * Sets the value of the `B` button
  42418. */
  42419. set buttonB(value: number);
  42420. /**
  42421. * Gets the value of the `X` button
  42422. */
  42423. get buttonX(): number;
  42424. /**
  42425. * Sets the value of the `X` button
  42426. */
  42427. set buttonX(value: number);
  42428. /**
  42429. * Gets the value of the `Y` button
  42430. */
  42431. get buttonY(): number;
  42432. /**
  42433. * Sets the value of the `Y` button
  42434. */
  42435. set buttonY(value: number);
  42436. /**
  42437. * Gets the value of the `Start` button
  42438. */
  42439. get buttonStart(): number;
  42440. /**
  42441. * Sets the value of the `Start` button
  42442. */
  42443. set buttonStart(value: number);
  42444. /**
  42445. * Gets the value of the `Back` button
  42446. */
  42447. get buttonBack(): number;
  42448. /**
  42449. * Sets the value of the `Back` button
  42450. */
  42451. set buttonBack(value: number);
  42452. /**
  42453. * Gets the value of the `Left` button
  42454. */
  42455. get buttonLB(): number;
  42456. /**
  42457. * Sets the value of the `Left` button
  42458. */
  42459. set buttonLB(value: number);
  42460. /**
  42461. * Gets the value of the `Right` button
  42462. */
  42463. get buttonRB(): number;
  42464. /**
  42465. * Sets the value of the `Right` button
  42466. */
  42467. set buttonRB(value: number);
  42468. /**
  42469. * Gets the value of the Left joystick
  42470. */
  42471. get buttonLeftStick(): number;
  42472. /**
  42473. * Sets the value of the Left joystick
  42474. */
  42475. set buttonLeftStick(value: number);
  42476. /**
  42477. * Gets the value of the Right joystick
  42478. */
  42479. get buttonRightStick(): number;
  42480. /**
  42481. * Sets the value of the Right joystick
  42482. */
  42483. set buttonRightStick(value: number);
  42484. /**
  42485. * Gets the value of D-pad up
  42486. */
  42487. get dPadUp(): number;
  42488. /**
  42489. * Sets the value of D-pad up
  42490. */
  42491. set dPadUp(value: number);
  42492. /**
  42493. * Gets the value of D-pad down
  42494. */
  42495. get dPadDown(): number;
  42496. /**
  42497. * Sets the value of D-pad down
  42498. */
  42499. set dPadDown(value: number);
  42500. /**
  42501. * Gets the value of D-pad left
  42502. */
  42503. get dPadLeft(): number;
  42504. /**
  42505. * Sets the value of D-pad left
  42506. */
  42507. set dPadLeft(value: number);
  42508. /**
  42509. * Gets the value of D-pad right
  42510. */
  42511. get dPadRight(): number;
  42512. /**
  42513. * Sets the value of D-pad right
  42514. */
  42515. set dPadRight(value: number);
  42516. /**
  42517. * Force the gamepad to synchronize with device values
  42518. */
  42519. update(): void;
  42520. /**
  42521. * Disposes the gamepad
  42522. */
  42523. dispose(): void;
  42524. }
  42525. }
  42526. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42527. import { Observable } from "babylonjs/Misc/observable";
  42528. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42529. /**
  42530. * Defines supported buttons for DualShock compatible gamepads
  42531. */
  42532. export enum DualShockButton {
  42533. /** Cross */
  42534. Cross = 0,
  42535. /** Circle */
  42536. Circle = 1,
  42537. /** Square */
  42538. Square = 2,
  42539. /** Triangle */
  42540. Triangle = 3,
  42541. /** Options */
  42542. Options = 4,
  42543. /** Share */
  42544. Share = 5,
  42545. /** L1 */
  42546. L1 = 6,
  42547. /** R1 */
  42548. R1 = 7,
  42549. /** Left stick */
  42550. LeftStick = 8,
  42551. /** Right stick */
  42552. RightStick = 9
  42553. }
  42554. /** Defines values for DualShock DPad */
  42555. export enum DualShockDpad {
  42556. /** Up */
  42557. Up = 0,
  42558. /** Down */
  42559. Down = 1,
  42560. /** Left */
  42561. Left = 2,
  42562. /** Right */
  42563. Right = 3
  42564. }
  42565. /**
  42566. * Defines a DualShock gamepad
  42567. */
  42568. export class DualShockPad extends Gamepad {
  42569. private _leftTrigger;
  42570. private _rightTrigger;
  42571. private _onlefttriggerchanged;
  42572. private _onrighttriggerchanged;
  42573. private _onbuttondown;
  42574. private _onbuttonup;
  42575. private _ondpaddown;
  42576. private _ondpadup;
  42577. /** Observable raised when a button is pressed */
  42578. onButtonDownObservable: Observable<DualShockButton>;
  42579. /** Observable raised when a button is released */
  42580. onButtonUpObservable: Observable<DualShockButton>;
  42581. /** Observable raised when a pad is pressed */
  42582. onPadDownObservable: Observable<DualShockDpad>;
  42583. /** Observable raised when a pad is released */
  42584. onPadUpObservable: Observable<DualShockDpad>;
  42585. private _buttonCross;
  42586. private _buttonCircle;
  42587. private _buttonSquare;
  42588. private _buttonTriangle;
  42589. private _buttonShare;
  42590. private _buttonOptions;
  42591. private _buttonL1;
  42592. private _buttonR1;
  42593. private _buttonLeftStick;
  42594. private _buttonRightStick;
  42595. private _dPadUp;
  42596. private _dPadDown;
  42597. private _dPadLeft;
  42598. private _dPadRight;
  42599. /**
  42600. * Creates a new DualShock gamepad object
  42601. * @param id defines the id of this gamepad
  42602. * @param index defines its index
  42603. * @param gamepad defines the internal HTML gamepad object
  42604. */
  42605. constructor(id: string, index: number, gamepad: any);
  42606. /**
  42607. * Defines the callback to call when left trigger is pressed
  42608. * @param callback defines the callback to use
  42609. */
  42610. onlefttriggerchanged(callback: (value: number) => void): void;
  42611. /**
  42612. * Defines the callback to call when right trigger is pressed
  42613. * @param callback defines the callback to use
  42614. */
  42615. onrighttriggerchanged(callback: (value: number) => void): void;
  42616. /**
  42617. * Gets the left trigger value
  42618. */
  42619. get leftTrigger(): number;
  42620. /**
  42621. * Sets the left trigger value
  42622. */
  42623. set leftTrigger(newValue: number);
  42624. /**
  42625. * Gets the right trigger value
  42626. */
  42627. get rightTrigger(): number;
  42628. /**
  42629. * Sets the right trigger value
  42630. */
  42631. set rightTrigger(newValue: number);
  42632. /**
  42633. * Defines the callback to call when a button is pressed
  42634. * @param callback defines the callback to use
  42635. */
  42636. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42637. /**
  42638. * Defines the callback to call when a button is released
  42639. * @param callback defines the callback to use
  42640. */
  42641. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42642. /**
  42643. * Defines the callback to call when a pad is pressed
  42644. * @param callback defines the callback to use
  42645. */
  42646. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42647. /**
  42648. * Defines the callback to call when a pad is released
  42649. * @param callback defines the callback to use
  42650. */
  42651. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42652. private _setButtonValue;
  42653. private _setDPadValue;
  42654. /**
  42655. * Gets the value of the `Cross` button
  42656. */
  42657. get buttonCross(): number;
  42658. /**
  42659. * Sets the value of the `Cross` button
  42660. */
  42661. set buttonCross(value: number);
  42662. /**
  42663. * Gets the value of the `Circle` button
  42664. */
  42665. get buttonCircle(): number;
  42666. /**
  42667. * Sets the value of the `Circle` button
  42668. */
  42669. set buttonCircle(value: number);
  42670. /**
  42671. * Gets the value of the `Square` button
  42672. */
  42673. get buttonSquare(): number;
  42674. /**
  42675. * Sets the value of the `Square` button
  42676. */
  42677. set buttonSquare(value: number);
  42678. /**
  42679. * Gets the value of the `Triangle` button
  42680. */
  42681. get buttonTriangle(): number;
  42682. /**
  42683. * Sets the value of the `Triangle` button
  42684. */
  42685. set buttonTriangle(value: number);
  42686. /**
  42687. * Gets the value of the `Options` button
  42688. */
  42689. get buttonOptions(): number;
  42690. /**
  42691. * Sets the value of the `Options` button
  42692. */
  42693. set buttonOptions(value: number);
  42694. /**
  42695. * Gets the value of the `Share` button
  42696. */
  42697. get buttonShare(): number;
  42698. /**
  42699. * Sets the value of the `Share` button
  42700. */
  42701. set buttonShare(value: number);
  42702. /**
  42703. * Gets the value of the `L1` button
  42704. */
  42705. get buttonL1(): number;
  42706. /**
  42707. * Sets the value of the `L1` button
  42708. */
  42709. set buttonL1(value: number);
  42710. /**
  42711. * Gets the value of the `R1` button
  42712. */
  42713. get buttonR1(): number;
  42714. /**
  42715. * Sets the value of the `R1` button
  42716. */
  42717. set buttonR1(value: number);
  42718. /**
  42719. * Gets the value of the Left joystick
  42720. */
  42721. get buttonLeftStick(): number;
  42722. /**
  42723. * Sets the value of the Left joystick
  42724. */
  42725. set buttonLeftStick(value: number);
  42726. /**
  42727. * Gets the value of the Right joystick
  42728. */
  42729. get buttonRightStick(): number;
  42730. /**
  42731. * Sets the value of the Right joystick
  42732. */
  42733. set buttonRightStick(value: number);
  42734. /**
  42735. * Gets the value of D-pad up
  42736. */
  42737. get dPadUp(): number;
  42738. /**
  42739. * Sets the value of D-pad up
  42740. */
  42741. set dPadUp(value: number);
  42742. /**
  42743. * Gets the value of D-pad down
  42744. */
  42745. get dPadDown(): number;
  42746. /**
  42747. * Sets the value of D-pad down
  42748. */
  42749. set dPadDown(value: number);
  42750. /**
  42751. * Gets the value of D-pad left
  42752. */
  42753. get dPadLeft(): number;
  42754. /**
  42755. * Sets the value of D-pad left
  42756. */
  42757. set dPadLeft(value: number);
  42758. /**
  42759. * Gets the value of D-pad right
  42760. */
  42761. get dPadRight(): number;
  42762. /**
  42763. * Sets the value of D-pad right
  42764. */
  42765. set dPadRight(value: number);
  42766. /**
  42767. * Force the gamepad to synchronize with device values
  42768. */
  42769. update(): void;
  42770. /**
  42771. * Disposes the gamepad
  42772. */
  42773. dispose(): void;
  42774. }
  42775. }
  42776. declare module "babylonjs/Gamepads/gamepadManager" {
  42777. import { Observable } from "babylonjs/Misc/observable";
  42778. import { Nullable } from "babylonjs/types";
  42779. import { Scene } from "babylonjs/scene";
  42780. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42781. /**
  42782. * Manager for handling gamepads
  42783. */
  42784. export class GamepadManager {
  42785. private _scene?;
  42786. private _babylonGamepads;
  42787. private _oneGamepadConnected;
  42788. /** @hidden */
  42789. _isMonitoring: boolean;
  42790. private _gamepadEventSupported;
  42791. private _gamepadSupport?;
  42792. /**
  42793. * observable to be triggered when the gamepad controller has been connected
  42794. */
  42795. onGamepadConnectedObservable: Observable<Gamepad>;
  42796. /**
  42797. * observable to be triggered when the gamepad controller has been disconnected
  42798. */
  42799. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42800. private _onGamepadConnectedEvent;
  42801. private _onGamepadDisconnectedEvent;
  42802. /**
  42803. * Initializes the gamepad manager
  42804. * @param _scene BabylonJS scene
  42805. */
  42806. constructor(_scene?: Scene | undefined);
  42807. /**
  42808. * The gamepads in the game pad manager
  42809. */
  42810. get gamepads(): Gamepad[];
  42811. /**
  42812. * Get the gamepad controllers based on type
  42813. * @param type The type of gamepad controller
  42814. * @returns Nullable gamepad
  42815. */
  42816. getGamepadByType(type?: number): Nullable<Gamepad>;
  42817. /**
  42818. * Disposes the gamepad manager
  42819. */
  42820. dispose(): void;
  42821. private _addNewGamepad;
  42822. private _startMonitoringGamepads;
  42823. private _stopMonitoringGamepads;
  42824. /** @hidden */
  42825. _checkGamepadsStatus(): void;
  42826. private _updateGamepadObjects;
  42827. }
  42828. }
  42829. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42830. import { Nullable } from "babylonjs/types";
  42831. import { Scene } from "babylonjs/scene";
  42832. import { ISceneComponent } from "babylonjs/sceneComponent";
  42833. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42834. module "babylonjs/scene" {
  42835. interface Scene {
  42836. /** @hidden */
  42837. _gamepadManager: Nullable<GamepadManager>;
  42838. /**
  42839. * Gets the gamepad manager associated with the scene
  42840. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42841. */
  42842. gamepadManager: GamepadManager;
  42843. }
  42844. }
  42845. module "babylonjs/Cameras/freeCameraInputsManager" {
  42846. /**
  42847. * Interface representing a free camera inputs manager
  42848. */
  42849. interface FreeCameraInputsManager {
  42850. /**
  42851. * Adds gamepad input support to the FreeCameraInputsManager.
  42852. * @returns the FreeCameraInputsManager
  42853. */
  42854. addGamepad(): FreeCameraInputsManager;
  42855. }
  42856. }
  42857. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42858. /**
  42859. * Interface representing an arc rotate camera inputs manager
  42860. */
  42861. interface ArcRotateCameraInputsManager {
  42862. /**
  42863. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42864. * @returns the camera inputs manager
  42865. */
  42866. addGamepad(): ArcRotateCameraInputsManager;
  42867. }
  42868. }
  42869. /**
  42870. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42871. */
  42872. export class GamepadSystemSceneComponent implements ISceneComponent {
  42873. /**
  42874. * The component name helpfull to identify the component in the list of scene components.
  42875. */
  42876. readonly name: string;
  42877. /**
  42878. * The scene the component belongs to.
  42879. */
  42880. scene: Scene;
  42881. /**
  42882. * Creates a new instance of the component for the given scene
  42883. * @param scene Defines the scene to register the component in
  42884. */
  42885. constructor(scene: Scene);
  42886. /**
  42887. * Registers the component in a given scene
  42888. */
  42889. register(): void;
  42890. /**
  42891. * Rebuilds the elements related to this component in case of
  42892. * context lost for instance.
  42893. */
  42894. rebuild(): void;
  42895. /**
  42896. * Disposes the component and the associated ressources
  42897. */
  42898. dispose(): void;
  42899. private _beforeCameraUpdate;
  42900. }
  42901. }
  42902. declare module "babylonjs/Cameras/universalCamera" {
  42903. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42904. import { Scene } from "babylonjs/scene";
  42905. import { Vector3 } from "babylonjs/Maths/math.vector";
  42906. import "babylonjs/Gamepads/gamepadSceneComponent";
  42907. /**
  42908. * 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,
  42909. * which still works and will still be found in many Playgrounds.
  42910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42911. */
  42912. export class UniversalCamera extends TouchCamera {
  42913. /**
  42914. * Defines the gamepad rotation sensiblity.
  42915. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42916. */
  42917. get gamepadAngularSensibility(): number;
  42918. set gamepadAngularSensibility(value: number);
  42919. /**
  42920. * Defines the gamepad move sensiblity.
  42921. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42922. */
  42923. get gamepadMoveSensibility(): number;
  42924. set gamepadMoveSensibility(value: number);
  42925. /**
  42926. * 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,
  42927. * which still works and will still be found in many Playgrounds.
  42928. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42929. * @param name Define the name of the camera in the scene
  42930. * @param position Define the start position of the camera in the scene
  42931. * @param scene Define the scene the camera belongs to
  42932. */
  42933. constructor(name: string, position: Vector3, scene: Scene);
  42934. /**
  42935. * Gets the current object class name.
  42936. * @return the class name
  42937. */
  42938. getClassName(): string;
  42939. }
  42940. }
  42941. declare module "babylonjs/Cameras/gamepadCamera" {
  42942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42943. import { Scene } from "babylonjs/scene";
  42944. import { Vector3 } from "babylonjs/Maths/math.vector";
  42945. /**
  42946. * This represents a FPS type of camera. This is only here for back compat purpose.
  42947. * Please use the UniversalCamera instead as both are identical.
  42948. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42949. */
  42950. export class GamepadCamera extends UniversalCamera {
  42951. /**
  42952. * Instantiates a new Gamepad Camera
  42953. * This represents a FPS type of camera. This is only here for back compat purpose.
  42954. * Please use the UniversalCamera instead as both are identical.
  42955. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42956. * @param name Define the name of the camera in the scene
  42957. * @param position Define the start position of the camera in the scene
  42958. * @param scene Define the scene the camera belongs to
  42959. */
  42960. constructor(name: string, position: Vector3, scene: Scene);
  42961. /**
  42962. * Gets the current object class name.
  42963. * @return the class name
  42964. */
  42965. getClassName(): string;
  42966. }
  42967. }
  42968. declare module "babylonjs/Shaders/pass.fragment" {
  42969. /** @hidden */
  42970. export var passPixelShader: {
  42971. name: string;
  42972. shader: string;
  42973. };
  42974. }
  42975. declare module "babylonjs/Shaders/passCube.fragment" {
  42976. /** @hidden */
  42977. export var passCubePixelShader: {
  42978. name: string;
  42979. shader: string;
  42980. };
  42981. }
  42982. declare module "babylonjs/PostProcesses/passPostProcess" {
  42983. import { Nullable } from "babylonjs/types";
  42984. import { Camera } from "babylonjs/Cameras/camera";
  42985. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42986. import { Engine } from "babylonjs/Engines/engine";
  42987. import "babylonjs/Shaders/pass.fragment";
  42988. import "babylonjs/Shaders/passCube.fragment";
  42989. /**
  42990. * PassPostProcess which produces an output the same as it's input
  42991. */
  42992. export class PassPostProcess extends PostProcess {
  42993. /**
  42994. * Creates the PassPostProcess
  42995. * @param name The name of the effect.
  42996. * @param options The required width/height ratio to downsize to before computing the render pass.
  42997. * @param camera The camera to apply the render pass to.
  42998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42999. * @param engine The engine which the post process will be applied. (default: current engine)
  43000. * @param reusable If the post process can be reused on the same frame. (default: false)
  43001. * @param textureType The type of texture to be used when performing the post processing.
  43002. * @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)
  43003. */
  43004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43005. }
  43006. /**
  43007. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43008. */
  43009. export class PassCubePostProcess extends PostProcess {
  43010. private _face;
  43011. /**
  43012. * Gets or sets the cube face to display.
  43013. * * 0 is +X
  43014. * * 1 is -X
  43015. * * 2 is +Y
  43016. * * 3 is -Y
  43017. * * 4 is +Z
  43018. * * 5 is -Z
  43019. */
  43020. get face(): number;
  43021. set face(value: number);
  43022. /**
  43023. * Creates the PassCubePostProcess
  43024. * @param name The name of the effect.
  43025. * @param options The required width/height ratio to downsize to before computing the render pass.
  43026. * @param camera The camera to apply the render pass to.
  43027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43028. * @param engine The engine which the post process will be applied. (default: current engine)
  43029. * @param reusable If the post process can be reused on the same frame. (default: false)
  43030. * @param textureType The type of texture to be used when performing the post processing.
  43031. * @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)
  43032. */
  43033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43034. }
  43035. }
  43036. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43037. /** @hidden */
  43038. export var anaglyphPixelShader: {
  43039. name: string;
  43040. shader: string;
  43041. };
  43042. }
  43043. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43044. import { Engine } from "babylonjs/Engines/engine";
  43045. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43046. import { Camera } from "babylonjs/Cameras/camera";
  43047. import "babylonjs/Shaders/anaglyph.fragment";
  43048. /**
  43049. * Postprocess used to generate anaglyphic rendering
  43050. */
  43051. export class AnaglyphPostProcess extends PostProcess {
  43052. private _passedProcess;
  43053. /**
  43054. * Creates a new AnaglyphPostProcess
  43055. * @param name defines postprocess name
  43056. * @param options defines creation options or target ratio scale
  43057. * @param rigCameras defines cameras using this postprocess
  43058. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43059. * @param engine defines hosting engine
  43060. * @param reusable defines if the postprocess will be reused multiple times per frame
  43061. */
  43062. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43063. }
  43064. }
  43065. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43066. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43067. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43068. import { Scene } from "babylonjs/scene";
  43069. import { Vector3 } from "babylonjs/Maths/math.vector";
  43070. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43071. /**
  43072. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43074. */
  43075. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43076. /**
  43077. * Creates a new AnaglyphArcRotateCamera
  43078. * @param name defines camera name
  43079. * @param alpha defines alpha angle (in radians)
  43080. * @param beta defines beta angle (in radians)
  43081. * @param radius defines radius
  43082. * @param target defines camera target
  43083. * @param interaxialDistance defines distance between each color axis
  43084. * @param scene defines the hosting scene
  43085. */
  43086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43087. /**
  43088. * Gets camera class name
  43089. * @returns AnaglyphArcRotateCamera
  43090. */
  43091. getClassName(): string;
  43092. }
  43093. }
  43094. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43095. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43096. import { Scene } from "babylonjs/scene";
  43097. import { Vector3 } from "babylonjs/Maths/math.vector";
  43098. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43099. /**
  43100. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43101. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43102. */
  43103. export class AnaglyphFreeCamera extends FreeCamera {
  43104. /**
  43105. * Creates a new AnaglyphFreeCamera
  43106. * @param name defines camera name
  43107. * @param position defines initial position
  43108. * @param interaxialDistance defines distance between each color axis
  43109. * @param scene defines the hosting scene
  43110. */
  43111. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43112. /**
  43113. * Gets camera class name
  43114. * @returns AnaglyphFreeCamera
  43115. */
  43116. getClassName(): string;
  43117. }
  43118. }
  43119. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43120. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43121. import { Scene } from "babylonjs/scene";
  43122. import { Vector3 } from "babylonjs/Maths/math.vector";
  43123. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43124. /**
  43125. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43126. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43127. */
  43128. export class AnaglyphGamepadCamera extends GamepadCamera {
  43129. /**
  43130. * Creates a new AnaglyphGamepadCamera
  43131. * @param name defines camera name
  43132. * @param position defines initial position
  43133. * @param interaxialDistance defines distance between each color axis
  43134. * @param scene defines the hosting scene
  43135. */
  43136. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43137. /**
  43138. * Gets camera class name
  43139. * @returns AnaglyphGamepadCamera
  43140. */
  43141. getClassName(): string;
  43142. }
  43143. }
  43144. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43145. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43146. import { Scene } from "babylonjs/scene";
  43147. import { Vector3 } from "babylonjs/Maths/math.vector";
  43148. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43149. /**
  43150. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43151. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43152. */
  43153. export class AnaglyphUniversalCamera extends UniversalCamera {
  43154. /**
  43155. * Creates a new AnaglyphUniversalCamera
  43156. * @param name defines camera name
  43157. * @param position defines initial position
  43158. * @param interaxialDistance defines distance between each color axis
  43159. * @param scene defines the hosting scene
  43160. */
  43161. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43162. /**
  43163. * Gets camera class name
  43164. * @returns AnaglyphUniversalCamera
  43165. */
  43166. getClassName(): string;
  43167. }
  43168. }
  43169. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43170. /** @hidden */
  43171. export var stereoscopicInterlacePixelShader: {
  43172. name: string;
  43173. shader: string;
  43174. };
  43175. }
  43176. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43177. import { Camera } from "babylonjs/Cameras/camera";
  43178. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43179. import { Engine } from "babylonjs/Engines/engine";
  43180. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43181. /**
  43182. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43183. */
  43184. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43185. private _stepSize;
  43186. private _passedProcess;
  43187. /**
  43188. * Initializes a StereoscopicInterlacePostProcessI
  43189. * @param name The name of the effect.
  43190. * @param rigCameras The rig cameras to be appled to the post process
  43191. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43192. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43194. * @param engine The engine which the post process will be applied. (default: current engine)
  43195. * @param reusable If the post process can be reused on the same frame. (default: false)
  43196. */
  43197. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43198. }
  43199. /**
  43200. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43201. */
  43202. export class StereoscopicInterlacePostProcess extends PostProcess {
  43203. private _stepSize;
  43204. private _passedProcess;
  43205. /**
  43206. * Initializes a StereoscopicInterlacePostProcess
  43207. * @param name The name of the effect.
  43208. * @param rigCameras The rig cameras to be appled to the post process
  43209. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43211. * @param engine The engine which the post process will be applied. (default: current engine)
  43212. * @param reusable If the post process can be reused on the same frame. (default: false)
  43213. */
  43214. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43215. }
  43216. }
  43217. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43218. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43219. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43220. import { Scene } from "babylonjs/scene";
  43221. import { Vector3 } from "babylonjs/Maths/math.vector";
  43222. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43223. /**
  43224. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43225. * @see http://doc.babylonjs.com/features/cameras
  43226. */
  43227. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43228. /**
  43229. * Creates a new StereoscopicArcRotateCamera
  43230. * @param name defines camera name
  43231. * @param alpha defines alpha angle (in radians)
  43232. * @param beta defines beta angle (in radians)
  43233. * @param radius defines radius
  43234. * @param target defines camera target
  43235. * @param interaxialDistance defines distance between each color axis
  43236. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43237. * @param scene defines the hosting scene
  43238. */
  43239. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43240. /**
  43241. * Gets camera class name
  43242. * @returns StereoscopicArcRotateCamera
  43243. */
  43244. getClassName(): string;
  43245. }
  43246. }
  43247. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43249. import { Scene } from "babylonjs/scene";
  43250. import { Vector3 } from "babylonjs/Maths/math.vector";
  43251. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43252. /**
  43253. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43254. * @see http://doc.babylonjs.com/features/cameras
  43255. */
  43256. export class StereoscopicFreeCamera extends FreeCamera {
  43257. /**
  43258. * Creates a new StereoscopicFreeCamera
  43259. * @param name defines camera name
  43260. * @param position defines initial position
  43261. * @param interaxialDistance defines distance between each color axis
  43262. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43263. * @param scene defines the hosting scene
  43264. */
  43265. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43266. /**
  43267. * Gets camera class name
  43268. * @returns StereoscopicFreeCamera
  43269. */
  43270. getClassName(): string;
  43271. }
  43272. }
  43273. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43274. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43275. import { Scene } from "babylonjs/scene";
  43276. import { Vector3 } from "babylonjs/Maths/math.vector";
  43277. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43278. /**
  43279. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43280. * @see http://doc.babylonjs.com/features/cameras
  43281. */
  43282. export class StereoscopicGamepadCamera extends GamepadCamera {
  43283. /**
  43284. * Creates a new StereoscopicGamepadCamera
  43285. * @param name defines camera name
  43286. * @param position defines initial position
  43287. * @param interaxialDistance defines distance between each color axis
  43288. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43289. * @param scene defines the hosting scene
  43290. */
  43291. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43292. /**
  43293. * Gets camera class name
  43294. * @returns StereoscopicGamepadCamera
  43295. */
  43296. getClassName(): string;
  43297. }
  43298. }
  43299. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43300. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43301. import { Scene } from "babylonjs/scene";
  43302. import { Vector3 } from "babylonjs/Maths/math.vector";
  43303. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43304. /**
  43305. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43306. * @see http://doc.babylonjs.com/features/cameras
  43307. */
  43308. export class StereoscopicUniversalCamera extends UniversalCamera {
  43309. /**
  43310. * Creates a new StereoscopicUniversalCamera
  43311. * @param name defines camera name
  43312. * @param position defines initial position
  43313. * @param interaxialDistance defines distance between each color axis
  43314. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43315. * @param scene defines the hosting scene
  43316. */
  43317. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43318. /**
  43319. * Gets camera class name
  43320. * @returns StereoscopicUniversalCamera
  43321. */
  43322. getClassName(): string;
  43323. }
  43324. }
  43325. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43326. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43327. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43328. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43329. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43330. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43331. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43332. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43333. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43334. }
  43335. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43336. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43337. import { Scene } from "babylonjs/scene";
  43338. import { Vector3 } from "babylonjs/Maths/math.vector";
  43339. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43340. /**
  43341. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43342. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43343. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43344. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43345. */
  43346. export class VirtualJoysticksCamera extends FreeCamera {
  43347. /**
  43348. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43349. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43350. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43351. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43352. * @param name Define the name of the camera in the scene
  43353. * @param position Define the start position of the camera in the scene
  43354. * @param scene Define the scene the camera belongs to
  43355. */
  43356. constructor(name: string, position: Vector3, scene: Scene);
  43357. /**
  43358. * Gets the current object class name.
  43359. * @return the class name
  43360. */
  43361. getClassName(): string;
  43362. }
  43363. }
  43364. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43365. import { Matrix } from "babylonjs/Maths/math.vector";
  43366. /**
  43367. * This represents all the required metrics to create a VR camera.
  43368. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43369. */
  43370. export class VRCameraMetrics {
  43371. /**
  43372. * Define the horizontal resolution off the screen.
  43373. */
  43374. hResolution: number;
  43375. /**
  43376. * Define the vertical resolution off the screen.
  43377. */
  43378. vResolution: number;
  43379. /**
  43380. * Define the horizontal screen size.
  43381. */
  43382. hScreenSize: number;
  43383. /**
  43384. * Define the vertical screen size.
  43385. */
  43386. vScreenSize: number;
  43387. /**
  43388. * Define the vertical screen center position.
  43389. */
  43390. vScreenCenter: number;
  43391. /**
  43392. * Define the distance of the eyes to the screen.
  43393. */
  43394. eyeToScreenDistance: number;
  43395. /**
  43396. * Define the distance between both lenses
  43397. */
  43398. lensSeparationDistance: number;
  43399. /**
  43400. * Define the distance between both viewer's eyes.
  43401. */
  43402. interpupillaryDistance: number;
  43403. /**
  43404. * Define the distortion factor of the VR postprocess.
  43405. * Please, touch with care.
  43406. */
  43407. distortionK: number[];
  43408. /**
  43409. * Define the chromatic aberration correction factors for the VR post process.
  43410. */
  43411. chromaAbCorrection: number[];
  43412. /**
  43413. * Define the scale factor of the post process.
  43414. * The smaller the better but the slower.
  43415. */
  43416. postProcessScaleFactor: number;
  43417. /**
  43418. * Define an offset for the lens center.
  43419. */
  43420. lensCenterOffset: number;
  43421. /**
  43422. * Define if the current vr camera should compensate the distortion of the lense or not.
  43423. */
  43424. compensateDistortion: boolean;
  43425. /**
  43426. * Defines if multiview should be enabled when rendering (Default: false)
  43427. */
  43428. multiviewEnabled: boolean;
  43429. /**
  43430. * Gets the rendering aspect ratio based on the provided resolutions.
  43431. */
  43432. get aspectRatio(): number;
  43433. /**
  43434. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43435. */
  43436. get aspectRatioFov(): number;
  43437. /**
  43438. * @hidden
  43439. */
  43440. get leftHMatrix(): Matrix;
  43441. /**
  43442. * @hidden
  43443. */
  43444. get rightHMatrix(): Matrix;
  43445. /**
  43446. * @hidden
  43447. */
  43448. get leftPreViewMatrix(): Matrix;
  43449. /**
  43450. * @hidden
  43451. */
  43452. get rightPreViewMatrix(): Matrix;
  43453. /**
  43454. * Get the default VRMetrics based on the most generic setup.
  43455. * @returns the default vr metrics
  43456. */
  43457. static GetDefault(): VRCameraMetrics;
  43458. }
  43459. }
  43460. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43461. /** @hidden */
  43462. export var vrDistortionCorrectionPixelShader: {
  43463. name: string;
  43464. shader: string;
  43465. };
  43466. }
  43467. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43468. import { Camera } from "babylonjs/Cameras/camera";
  43469. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43470. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43471. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43472. /**
  43473. * VRDistortionCorrectionPostProcess used for mobile VR
  43474. */
  43475. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43476. private _isRightEye;
  43477. private _distortionFactors;
  43478. private _postProcessScaleFactor;
  43479. private _lensCenterOffset;
  43480. private _scaleIn;
  43481. private _scaleFactor;
  43482. private _lensCenter;
  43483. /**
  43484. * Initializes the VRDistortionCorrectionPostProcess
  43485. * @param name The name of the effect.
  43486. * @param camera The camera to apply the render pass to.
  43487. * @param isRightEye If this is for the right eye distortion
  43488. * @param vrMetrics All the required metrics for the VR camera
  43489. */
  43490. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43491. }
  43492. }
  43493. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43494. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43496. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43497. import { Scene } from "babylonjs/scene";
  43498. import { Vector3 } from "babylonjs/Maths/math.vector";
  43499. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43500. import "babylonjs/Cameras/RigModes/vrRigMode";
  43501. /**
  43502. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43503. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43504. */
  43505. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43506. /**
  43507. * Creates a new VRDeviceOrientationArcRotateCamera
  43508. * @param name defines camera name
  43509. * @param alpha defines the camera rotation along the logitudinal axis
  43510. * @param beta defines the camera rotation along the latitudinal axis
  43511. * @param radius defines the camera distance from its target
  43512. * @param target defines the camera target
  43513. * @param scene defines the scene the camera belongs to
  43514. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43515. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43516. */
  43517. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43518. /**
  43519. * Gets camera class name
  43520. * @returns VRDeviceOrientationArcRotateCamera
  43521. */
  43522. getClassName(): string;
  43523. }
  43524. }
  43525. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43526. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43527. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43528. import { Scene } from "babylonjs/scene";
  43529. import { Vector3 } from "babylonjs/Maths/math.vector";
  43530. import "babylonjs/Cameras/RigModes/vrRigMode";
  43531. /**
  43532. * Camera used to simulate VR rendering (based on FreeCamera)
  43533. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43534. */
  43535. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43536. /**
  43537. * Creates a new VRDeviceOrientationFreeCamera
  43538. * @param name defines camera name
  43539. * @param position defines the start position of the camera
  43540. * @param scene defines the scene the camera belongs to
  43541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43543. */
  43544. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43545. /**
  43546. * Gets camera class name
  43547. * @returns VRDeviceOrientationFreeCamera
  43548. */
  43549. getClassName(): string;
  43550. }
  43551. }
  43552. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43553. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43554. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43555. import { Scene } from "babylonjs/scene";
  43556. import { Vector3 } from "babylonjs/Maths/math.vector";
  43557. import "babylonjs/Gamepads/gamepadSceneComponent";
  43558. /**
  43559. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43560. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43561. */
  43562. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43563. /**
  43564. * Creates a new VRDeviceOrientationGamepadCamera
  43565. * @param name defines camera name
  43566. * @param position defines the start position of the camera
  43567. * @param scene defines the scene the camera belongs to
  43568. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43569. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43570. */
  43571. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43572. /**
  43573. * Gets camera class name
  43574. * @returns VRDeviceOrientationGamepadCamera
  43575. */
  43576. getClassName(): string;
  43577. }
  43578. }
  43579. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43580. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43582. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43583. /** @hidden */
  43584. export var imageProcessingPixelShader: {
  43585. name: string;
  43586. shader: string;
  43587. };
  43588. }
  43589. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43590. import { Nullable } from "babylonjs/types";
  43591. import { Color4 } from "babylonjs/Maths/math.color";
  43592. import { Camera } from "babylonjs/Cameras/camera";
  43593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43594. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43595. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43597. import { Engine } from "babylonjs/Engines/engine";
  43598. import "babylonjs/Shaders/imageProcessing.fragment";
  43599. import "babylonjs/Shaders/postprocess.vertex";
  43600. /**
  43601. * ImageProcessingPostProcess
  43602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43603. */
  43604. export class ImageProcessingPostProcess extends PostProcess {
  43605. /**
  43606. * Default configuration related to image processing available in the PBR Material.
  43607. */
  43608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43609. /**
  43610. * Gets the image processing configuration used either in this material.
  43611. */
  43612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43613. /**
  43614. * Sets the Default image processing configuration used either in the this material.
  43615. *
  43616. * If sets to null, the scene one is in use.
  43617. */
  43618. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43619. /**
  43620. * Keep track of the image processing observer to allow dispose and replace.
  43621. */
  43622. private _imageProcessingObserver;
  43623. /**
  43624. * Attaches a new image processing configuration to the PBR Material.
  43625. * @param configuration
  43626. */
  43627. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43628. /**
  43629. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43630. */
  43631. get colorCurves(): Nullable<ColorCurves>;
  43632. /**
  43633. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43634. */
  43635. set colorCurves(value: Nullable<ColorCurves>);
  43636. /**
  43637. * Gets wether the color curves effect is enabled.
  43638. */
  43639. get colorCurvesEnabled(): boolean;
  43640. /**
  43641. * Sets wether the color curves effect is enabled.
  43642. */
  43643. set colorCurvesEnabled(value: boolean);
  43644. /**
  43645. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43646. */
  43647. get colorGradingTexture(): Nullable<BaseTexture>;
  43648. /**
  43649. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43650. */
  43651. set colorGradingTexture(value: Nullable<BaseTexture>);
  43652. /**
  43653. * Gets wether the color grading effect is enabled.
  43654. */
  43655. get colorGradingEnabled(): boolean;
  43656. /**
  43657. * Gets wether the color grading effect is enabled.
  43658. */
  43659. set colorGradingEnabled(value: boolean);
  43660. /**
  43661. * Gets exposure used in the effect.
  43662. */
  43663. get exposure(): number;
  43664. /**
  43665. * Sets exposure used in the effect.
  43666. */
  43667. set exposure(value: number);
  43668. /**
  43669. * Gets wether tonemapping is enabled or not.
  43670. */
  43671. get toneMappingEnabled(): boolean;
  43672. /**
  43673. * Sets wether tonemapping is enabled or not
  43674. */
  43675. set toneMappingEnabled(value: boolean);
  43676. /**
  43677. * Gets the type of tone mapping effect.
  43678. */
  43679. get toneMappingType(): number;
  43680. /**
  43681. * Sets the type of tone mapping effect.
  43682. */
  43683. set toneMappingType(value: number);
  43684. /**
  43685. * Gets contrast used in the effect.
  43686. */
  43687. get contrast(): number;
  43688. /**
  43689. * Sets contrast used in the effect.
  43690. */
  43691. set contrast(value: number);
  43692. /**
  43693. * Gets Vignette stretch size.
  43694. */
  43695. get vignetteStretch(): number;
  43696. /**
  43697. * Sets Vignette stretch size.
  43698. */
  43699. set vignetteStretch(value: number);
  43700. /**
  43701. * Gets Vignette centre X Offset.
  43702. */
  43703. get vignetteCentreX(): number;
  43704. /**
  43705. * Sets Vignette centre X Offset.
  43706. */
  43707. set vignetteCentreX(value: number);
  43708. /**
  43709. * Gets Vignette centre Y Offset.
  43710. */
  43711. get vignetteCentreY(): number;
  43712. /**
  43713. * Sets Vignette centre Y Offset.
  43714. */
  43715. set vignetteCentreY(value: number);
  43716. /**
  43717. * Gets Vignette weight or intensity of the vignette effect.
  43718. */
  43719. get vignetteWeight(): number;
  43720. /**
  43721. * Sets Vignette weight or intensity of the vignette effect.
  43722. */
  43723. set vignetteWeight(value: number);
  43724. /**
  43725. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43726. * if vignetteEnabled is set to true.
  43727. */
  43728. get vignetteColor(): Color4;
  43729. /**
  43730. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43731. * if vignetteEnabled is set to true.
  43732. */
  43733. set vignetteColor(value: Color4);
  43734. /**
  43735. * Gets Camera field of view used by the Vignette effect.
  43736. */
  43737. get vignetteCameraFov(): number;
  43738. /**
  43739. * Sets Camera field of view used by the Vignette effect.
  43740. */
  43741. set vignetteCameraFov(value: number);
  43742. /**
  43743. * Gets the vignette blend mode allowing different kind of effect.
  43744. */
  43745. get vignetteBlendMode(): number;
  43746. /**
  43747. * Sets the vignette blend mode allowing different kind of effect.
  43748. */
  43749. set vignetteBlendMode(value: number);
  43750. /**
  43751. * Gets wether the vignette effect is enabled.
  43752. */
  43753. get vignetteEnabled(): boolean;
  43754. /**
  43755. * Sets wether the vignette effect is enabled.
  43756. */
  43757. set vignetteEnabled(value: boolean);
  43758. private _fromLinearSpace;
  43759. /**
  43760. * Gets wether the input of the processing is in Gamma or Linear Space.
  43761. */
  43762. get fromLinearSpace(): boolean;
  43763. /**
  43764. * Sets wether the input of the processing is in Gamma or Linear Space.
  43765. */
  43766. set fromLinearSpace(value: boolean);
  43767. /**
  43768. * Defines cache preventing GC.
  43769. */
  43770. private _defines;
  43771. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43772. /**
  43773. * "ImageProcessingPostProcess"
  43774. * @returns "ImageProcessingPostProcess"
  43775. */
  43776. getClassName(): string;
  43777. protected _updateParameters(): void;
  43778. dispose(camera?: Camera): void;
  43779. }
  43780. }
  43781. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43782. import { Scene } from "babylonjs/scene";
  43783. import { Color3 } from "babylonjs/Maths/math.color";
  43784. import { Mesh } from "babylonjs/Meshes/mesh";
  43785. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43786. import { Nullable } from "babylonjs/types";
  43787. /**
  43788. * Class containing static functions to help procedurally build meshes
  43789. */
  43790. export class GroundBuilder {
  43791. /**
  43792. * Creates a ground mesh
  43793. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43794. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43796. * @param name defines the name of the mesh
  43797. * @param options defines the options used to create the mesh
  43798. * @param scene defines the hosting scene
  43799. * @returns the ground mesh
  43800. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43801. */
  43802. static CreateGround(name: string, options: {
  43803. width?: number;
  43804. height?: number;
  43805. subdivisions?: number;
  43806. subdivisionsX?: number;
  43807. subdivisionsY?: number;
  43808. updatable?: boolean;
  43809. }, scene: any): Mesh;
  43810. /**
  43811. * Creates a tiled ground mesh
  43812. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43813. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43814. * * 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
  43815. * * 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
  43816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43817. * @param name defines the name of the mesh
  43818. * @param options defines the options used to create the mesh
  43819. * @param scene defines the hosting scene
  43820. * @returns the tiled ground mesh
  43821. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43822. */
  43823. static CreateTiledGround(name: string, options: {
  43824. xmin: number;
  43825. zmin: number;
  43826. xmax: number;
  43827. zmax: number;
  43828. subdivisions?: {
  43829. w: number;
  43830. h: number;
  43831. };
  43832. precision?: {
  43833. w: number;
  43834. h: number;
  43835. };
  43836. updatable?: boolean;
  43837. }, scene?: Nullable<Scene>): Mesh;
  43838. /**
  43839. * Creates a ground mesh from a height map
  43840. * * The parameter `url` sets the URL of the height map image resource.
  43841. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43842. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43843. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43844. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43845. * * 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.
  43846. * * 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).
  43847. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43849. * @param name defines the name of the mesh
  43850. * @param url defines the url to the height map
  43851. * @param options defines the options used to create the mesh
  43852. * @param scene defines the hosting scene
  43853. * @returns the ground mesh
  43854. * @see https://doc.babylonjs.com/babylon101/height_map
  43855. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43856. */
  43857. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43858. width?: number;
  43859. height?: number;
  43860. subdivisions?: number;
  43861. minHeight?: number;
  43862. maxHeight?: number;
  43863. colorFilter?: Color3;
  43864. alphaFilter?: number;
  43865. updatable?: boolean;
  43866. onReady?: (mesh: GroundMesh) => void;
  43867. }, scene?: Nullable<Scene>): GroundMesh;
  43868. }
  43869. }
  43870. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43871. import { Vector4 } from "babylonjs/Maths/math.vector";
  43872. import { Mesh } from "babylonjs/Meshes/mesh";
  43873. /**
  43874. * Class containing static functions to help procedurally build meshes
  43875. */
  43876. export class TorusBuilder {
  43877. /**
  43878. * Creates a torus mesh
  43879. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43880. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43881. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43885. * @param name defines the name of the mesh
  43886. * @param options defines the options used to create the mesh
  43887. * @param scene defines the hosting scene
  43888. * @returns the torus mesh
  43889. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43890. */
  43891. static CreateTorus(name: string, options: {
  43892. diameter?: number;
  43893. thickness?: number;
  43894. tessellation?: number;
  43895. updatable?: boolean;
  43896. sideOrientation?: number;
  43897. frontUVs?: Vector4;
  43898. backUVs?: Vector4;
  43899. }, scene: any): Mesh;
  43900. }
  43901. }
  43902. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43903. import { Vector4 } from "babylonjs/Maths/math.vector";
  43904. import { Color4 } from "babylonjs/Maths/math.color";
  43905. import { Mesh } from "babylonjs/Meshes/mesh";
  43906. /**
  43907. * Class containing static functions to help procedurally build meshes
  43908. */
  43909. export class CylinderBuilder {
  43910. /**
  43911. * Creates a cylinder or a cone mesh
  43912. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43913. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43914. * * 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.
  43915. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43916. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43917. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43918. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43919. * * 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).
  43920. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43921. * * 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).
  43922. * * 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
  43923. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43924. * * 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
  43925. * * 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.
  43926. * * If `enclose` is false, a ring surface is one element.
  43927. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43928. * * 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
  43929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43932. * @param name defines the name of the mesh
  43933. * @param options defines the options used to create the mesh
  43934. * @param scene defines the hosting scene
  43935. * @returns the cylinder mesh
  43936. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43937. */
  43938. static CreateCylinder(name: string, options: {
  43939. height?: number;
  43940. diameterTop?: number;
  43941. diameterBottom?: number;
  43942. diameter?: number;
  43943. tessellation?: number;
  43944. subdivisions?: number;
  43945. arc?: number;
  43946. faceColors?: Color4[];
  43947. faceUV?: Vector4[];
  43948. updatable?: boolean;
  43949. hasRings?: boolean;
  43950. enclose?: boolean;
  43951. cap?: number;
  43952. sideOrientation?: number;
  43953. frontUVs?: Vector4;
  43954. backUVs?: Vector4;
  43955. }, scene: any): Mesh;
  43956. }
  43957. }
  43958. declare module "babylonjs/XR/webXRTypes" {
  43959. import { Nullable } from "babylonjs/types";
  43960. import { IDisposable } from "babylonjs/scene";
  43961. /**
  43962. * States of the webXR experience
  43963. */
  43964. export enum WebXRState {
  43965. /**
  43966. * Transitioning to being in XR mode
  43967. */
  43968. ENTERING_XR = 0,
  43969. /**
  43970. * Transitioning to non XR mode
  43971. */
  43972. EXITING_XR = 1,
  43973. /**
  43974. * In XR mode and presenting
  43975. */
  43976. IN_XR = 2,
  43977. /**
  43978. * Not entered XR mode
  43979. */
  43980. NOT_IN_XR = 3
  43981. }
  43982. /**
  43983. * Abstraction of the XR render target
  43984. */
  43985. export interface WebXRRenderTarget extends IDisposable {
  43986. /**
  43987. * xrpresent context of the canvas which can be used to display/mirror xr content
  43988. */
  43989. canvasContext: WebGLRenderingContext;
  43990. /**
  43991. * xr layer for the canvas
  43992. */
  43993. xrLayer: Nullable<XRWebGLLayer>;
  43994. /**
  43995. * Initializes the xr layer for the session
  43996. * @param xrSession xr session
  43997. * @returns a promise that will resolve once the XR Layer has been created
  43998. */
  43999. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44000. }
  44001. }
  44002. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44003. import { Nullable } from "babylonjs/types";
  44004. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44005. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44006. /**
  44007. * COnfiguration object for WebXR output canvas
  44008. */
  44009. export class WebXRManagedOutputCanvasOptions {
  44010. /**
  44011. * An optional canvas in case you wish to create it yourself and provide it here.
  44012. * If not provided, a new canvas will be created
  44013. */
  44014. canvasElement?: HTMLCanvasElement;
  44015. /**
  44016. * Options for this XR Layer output
  44017. */
  44018. canvasOptions?: XRWebGLLayerOptions;
  44019. /**
  44020. * CSS styling for a newly created canvas (if not provided)
  44021. */
  44022. newCanvasCssStyle?: string;
  44023. /**
  44024. * Get the default values of the configuration object
  44025. * @returns default values of this configuration object
  44026. */
  44027. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44028. }
  44029. /**
  44030. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44031. */
  44032. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44033. private _options;
  44034. private _canvas;
  44035. private _engine;
  44036. /**
  44037. * Rendering context of the canvas which can be used to display/mirror xr content
  44038. */
  44039. canvasContext: WebGLRenderingContext;
  44040. /**
  44041. * xr layer for the canvas
  44042. */
  44043. xrLayer: Nullable<XRWebGLLayer>;
  44044. /**
  44045. * Initializes the canvas to be added/removed upon entering/exiting xr
  44046. * @param _xrSessionManager The XR Session manager
  44047. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44048. */
  44049. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44050. /**
  44051. * Disposes of the object
  44052. */
  44053. dispose(): void;
  44054. /**
  44055. * Initializes the xr layer for the session
  44056. * @param xrSession xr session
  44057. * @returns a promise that will resolve once the XR Layer has been created
  44058. */
  44059. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44060. private _addCanvas;
  44061. private _removeCanvas;
  44062. private _setManagedOutputCanvas;
  44063. }
  44064. }
  44065. declare module "babylonjs/XR/webXRSessionManager" {
  44066. import { Observable } from "babylonjs/Misc/observable";
  44067. import { Nullable } from "babylonjs/types";
  44068. import { IDisposable, Scene } from "babylonjs/scene";
  44069. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44070. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44071. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44072. /**
  44073. * Manages an XRSession to work with Babylon's engine
  44074. * @see https://doc.babylonjs.com/how_to/webxr
  44075. */
  44076. export class WebXRSessionManager implements IDisposable {
  44077. /** The scene which the session should be created for */
  44078. scene: Scene;
  44079. private _referenceSpace;
  44080. private _rttProvider;
  44081. private _sessionEnded;
  44082. private _xrNavigator;
  44083. private baseLayer;
  44084. /**
  44085. * The base reference space from which the session started. good if you want to reset your
  44086. * reference space
  44087. */
  44088. baseReferenceSpace: XRReferenceSpace;
  44089. /**
  44090. * Current XR frame
  44091. */
  44092. currentFrame: Nullable<XRFrame>;
  44093. /** WebXR timestamp updated every frame */
  44094. currentTimestamp: number;
  44095. /**
  44096. * Used just in case of a failure to initialize an immersive session.
  44097. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44098. */
  44099. defaultHeightCompensation: number;
  44100. /**
  44101. * Fires every time a new xrFrame arrives which can be used to update the camera
  44102. */
  44103. onXRFrameObservable: Observable<XRFrame>;
  44104. /**
  44105. * Fires when the reference space changed
  44106. */
  44107. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44108. /**
  44109. * Fires when the xr session is ended either by the device or manually done
  44110. */
  44111. onXRSessionEnded: Observable<any>;
  44112. /**
  44113. * Fires when the xr session is ended either by the device or manually done
  44114. */
  44115. onXRSessionInit: Observable<XRSession>;
  44116. /**
  44117. * Underlying xr session
  44118. */
  44119. session: XRSession;
  44120. /**
  44121. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44122. * or get the offset the player is currently at.
  44123. */
  44124. viewerReferenceSpace: XRReferenceSpace;
  44125. /**
  44126. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44127. * @param scene The scene which the session should be created for
  44128. */
  44129. constructor(
  44130. /** The scene which the session should be created for */
  44131. scene: Scene);
  44132. /**
  44133. * The current reference space used in this session. This reference space can constantly change!
  44134. * It is mainly used to offset the camera's position.
  44135. */
  44136. get referenceSpace(): XRReferenceSpace;
  44137. /**
  44138. * Set a new reference space and triggers the observable
  44139. */
  44140. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44141. /**
  44142. * Disposes of the session manager
  44143. */
  44144. dispose(): void;
  44145. /**
  44146. * Stops the xrSession and restores the render loop
  44147. * @returns Promise which resolves after it exits XR
  44148. */
  44149. exitXRAsync(): Promise<void>;
  44150. /**
  44151. * Gets the correct render target texture to be rendered this frame for this eye
  44152. * @param eye the eye for which to get the render target
  44153. * @returns the render target for the specified eye
  44154. */
  44155. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44156. /**
  44157. * Creates a WebXRRenderTarget object for the XR session
  44158. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44159. * @param options optional options to provide when creating a new render target
  44160. * @returns a WebXR render target to which the session can render
  44161. */
  44162. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44163. /**
  44164. * Initializes the manager
  44165. * After initialization enterXR can be called to start an XR session
  44166. * @returns Promise which resolves after it is initialized
  44167. */
  44168. initializeAsync(): Promise<void>;
  44169. /**
  44170. * Initializes an xr session
  44171. * @param xrSessionMode mode to initialize
  44172. * @param xrSessionInit defines optional and required values to pass to the session builder
  44173. * @returns a promise which will resolve once the session has been initialized
  44174. */
  44175. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44176. /**
  44177. * Checks if a session would be supported for the creation options specified
  44178. * @param sessionMode session mode to check if supported eg. immersive-vr
  44179. * @returns A Promise that resolves to true if supported and false if not
  44180. */
  44181. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44182. /**
  44183. * Resets the reference space to the one started the session
  44184. */
  44185. resetReferenceSpace(): void;
  44186. /**
  44187. * Starts rendering to the xr layer
  44188. */
  44189. runXRRenderLoop(): void;
  44190. /**
  44191. * Sets the reference space on the xr session
  44192. * @param referenceSpaceType space to set
  44193. * @returns a promise that will resolve once the reference space has been set
  44194. */
  44195. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44196. /**
  44197. * Updates the render state of the session
  44198. * @param state state to set
  44199. * @returns a promise that resolves once the render state has been updated
  44200. */
  44201. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44202. /**
  44203. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44204. * @param sessionMode defines the session to test
  44205. * @returns a promise with boolean as final value
  44206. */
  44207. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44208. private _createRenderTargetTexture;
  44209. }
  44210. }
  44211. declare module "babylonjs/XR/webXRCamera" {
  44212. import { Scene } from "babylonjs/scene";
  44213. import { Camera } from "babylonjs/Cameras/camera";
  44214. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44215. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44216. /**
  44217. * WebXR Camera which holds the views for the xrSession
  44218. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44219. */
  44220. export class WebXRCamera extends FreeCamera {
  44221. private _xrSessionManager;
  44222. private _firstFrame;
  44223. private _referenceQuaternion;
  44224. private _referencedPosition;
  44225. private _xrInvPositionCache;
  44226. private _xrInvQuaternionCache;
  44227. /**
  44228. * Should position compensation execute on first frame.
  44229. * This is used when copying the position from a native (non XR) camera
  44230. */
  44231. compensateOnFirstFrame: boolean;
  44232. /**
  44233. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44234. * @param name the name of the camera
  44235. * @param scene the scene to add the camera to
  44236. * @param _xrSessionManager a constructed xr session manager
  44237. */
  44238. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44239. /**
  44240. * Return the user's height, unrelated to the current ground.
  44241. * This will be the y position of this camera, when ground level is 0.
  44242. */
  44243. get realWorldHeight(): number;
  44244. /** @hidden */
  44245. _updateForDualEyeDebugging(): void;
  44246. /**
  44247. * Sets this camera's transformation based on a non-vr camera
  44248. * @param otherCamera the non-vr camera to copy the transformation from
  44249. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44250. */
  44251. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44252. /**
  44253. * Gets the current instance class name ("WebXRCamera").
  44254. * @returns the class name
  44255. */
  44256. getClassName(): string;
  44257. private _updateFromXRSession;
  44258. private _updateNumberOfRigCameras;
  44259. private _updateReferenceSpace;
  44260. private _updateReferenceSpaceOffset;
  44261. }
  44262. }
  44263. declare module "babylonjs/XR/webXRFeaturesManager" {
  44264. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44265. import { IDisposable } from "babylonjs/scene";
  44266. /**
  44267. * Defining the interface required for a (webxr) feature
  44268. */
  44269. export interface IWebXRFeature extends IDisposable {
  44270. /**
  44271. * Is this feature attached
  44272. */
  44273. attached: boolean;
  44274. /**
  44275. * Should auto-attach be disabled?
  44276. */
  44277. disableAutoAttach: boolean;
  44278. /**
  44279. * Attach the feature to the session
  44280. * Will usually be called by the features manager
  44281. *
  44282. * @param force should attachment be forced (even when already attached)
  44283. * @returns true if successful.
  44284. */
  44285. attach(force?: boolean): boolean;
  44286. /**
  44287. * Detach the feature from the session
  44288. * Will usually be called by the features manager
  44289. *
  44290. * @returns true if successful.
  44291. */
  44292. detach(): boolean;
  44293. }
  44294. /**
  44295. * A list of the currently available features without referencing them
  44296. */
  44297. export class WebXRFeatureName {
  44298. /**
  44299. * The name of the anchor system feature
  44300. */
  44301. static ANCHOR_SYSTEM: string;
  44302. /**
  44303. * The name of the background remover feature
  44304. */
  44305. static BACKGROUND_REMOVER: string;
  44306. /**
  44307. * The name of the hit test feature
  44308. */
  44309. static HIT_TEST: string;
  44310. /**
  44311. * physics impostors for xr controllers feature
  44312. */
  44313. static PHYSICS_CONTROLLERS: string;
  44314. /**
  44315. * The name of the plane detection feature
  44316. */
  44317. static PLANE_DETECTION: string;
  44318. /**
  44319. * The name of the pointer selection feature
  44320. */
  44321. static POINTER_SELECTION: string;
  44322. /**
  44323. * The name of the teleportation feature
  44324. */
  44325. static TELEPORTATION: string;
  44326. }
  44327. /**
  44328. * Defining the constructor of a feature. Used to register the modules.
  44329. */
  44330. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44331. /**
  44332. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44333. * It is mainly used in AR sessions.
  44334. *
  44335. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44336. */
  44337. export class WebXRFeaturesManager implements IDisposable {
  44338. private _xrSessionManager;
  44339. private static readonly _AvailableFeatures;
  44340. private _features;
  44341. /**
  44342. * constructs a new features manages.
  44343. *
  44344. * @param _xrSessionManager an instance of WebXRSessionManager
  44345. */
  44346. constructor(_xrSessionManager: WebXRSessionManager);
  44347. /**
  44348. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44349. * Mainly used internally.
  44350. *
  44351. * @param featureName the name of the feature to register
  44352. * @param constructorFunction the function used to construct the module
  44353. * @param version the (babylon) version of the module
  44354. * @param stable is that a stable version of this module
  44355. */
  44356. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44357. /**
  44358. * Returns a constructor of a specific feature.
  44359. *
  44360. * @param featureName the name of the feature to construct
  44361. * @param version the version of the feature to load
  44362. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44363. * @param options optional options provided to the module.
  44364. * @returns a function that, when called, will return a new instance of this feature
  44365. */
  44366. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44367. /**
  44368. * Can be used to return the list of features currently registered
  44369. *
  44370. * @returns an Array of available features
  44371. */
  44372. static GetAvailableFeatures(): string[];
  44373. /**
  44374. * Gets the versions available for a specific feature
  44375. * @param featureName the name of the feature
  44376. * @returns an array with the available versions
  44377. */
  44378. static GetAvailableVersions(featureName: string): string[];
  44379. /**
  44380. * Return the latest unstable version of this feature
  44381. * @param featureName the name of the feature to search
  44382. * @returns the version number. if not found will return -1
  44383. */
  44384. static GetLatestVersionOfFeature(featureName: string): number;
  44385. /**
  44386. * Return the latest stable version of this feature
  44387. * @param featureName the name of the feature to search
  44388. * @returns the version number. if not found will return -1
  44389. */
  44390. static GetStableVersionOfFeature(featureName: string): number;
  44391. /**
  44392. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44393. * Can be used during a session to start a feature
  44394. * @param featureName the name of feature to attach
  44395. */
  44396. attachFeature(featureName: string): void;
  44397. /**
  44398. * Can be used inside a session or when the session ends to detach a specific feature
  44399. * @param featureName the name of the feature to detach
  44400. */
  44401. detachFeature(featureName: string): void;
  44402. /**
  44403. * Used to disable an already-enabled feature
  44404. * The feature will be disposed and will be recreated once enabled.
  44405. * @param featureName the feature to disable
  44406. * @returns true if disable was successful
  44407. */
  44408. disableFeature(featureName: string | {
  44409. Name: string;
  44410. }): boolean;
  44411. /**
  44412. * dispose this features manager
  44413. */
  44414. dispose(): void;
  44415. /**
  44416. * 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.
  44417. * 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.
  44418. *
  44419. * @param featureName the name of the feature to load or the class of the feature
  44420. * @param version optional version to load. if not provided the latest version will be enabled
  44421. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44422. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44423. * @returns a new constructed feature or throws an error if feature not found.
  44424. */
  44425. enableFeature(featureName: string | {
  44426. Name: string;
  44427. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44428. /**
  44429. * get the implementation of an enabled feature.
  44430. * @param featureName the name of the feature to load
  44431. * @returns the feature class, if found
  44432. */
  44433. getEnabledFeature(featureName: string): IWebXRFeature;
  44434. /**
  44435. * Get the list of enabled features
  44436. * @returns an array of enabled features
  44437. */
  44438. getEnabledFeatures(): string[];
  44439. }
  44440. }
  44441. declare module "babylonjs/XR/webXRExperienceHelper" {
  44442. import { Observable } from "babylonjs/Misc/observable";
  44443. import { IDisposable, Scene } from "babylonjs/scene";
  44444. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44445. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44446. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44447. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44448. /**
  44449. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44450. * @see https://doc.babylonjs.com/how_to/webxr
  44451. */
  44452. export class WebXRExperienceHelper implements IDisposable {
  44453. private scene;
  44454. private _nonVRCamera;
  44455. private _originalSceneAutoClear;
  44456. private _supported;
  44457. /**
  44458. * Camera used to render xr content
  44459. */
  44460. camera: WebXRCamera;
  44461. /** A features manager for this xr session */
  44462. featuresManager: WebXRFeaturesManager;
  44463. /**
  44464. * Observers registered here will be triggered after the camera's initial transformation is set
  44465. * This can be used to set a different ground level or an extra rotation.
  44466. *
  44467. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44468. * to the position set after this observable is done executing.
  44469. */
  44470. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44471. /**
  44472. * Fires when the state of the experience helper has changed
  44473. */
  44474. onStateChangedObservable: Observable<WebXRState>;
  44475. /** Session manager used to keep track of xr session */
  44476. sessionManager: WebXRSessionManager;
  44477. /**
  44478. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44479. */
  44480. state: WebXRState;
  44481. /**
  44482. * Creates a WebXRExperienceHelper
  44483. * @param scene The scene the helper should be created in
  44484. */
  44485. private constructor();
  44486. /**
  44487. * Creates the experience helper
  44488. * @param scene the scene to attach the experience helper to
  44489. * @returns a promise for the experience helper
  44490. */
  44491. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44492. /**
  44493. * Disposes of the experience helper
  44494. */
  44495. dispose(): void;
  44496. /**
  44497. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44498. * @param sessionMode options for the XR session
  44499. * @param referenceSpaceType frame of reference of the XR session
  44500. * @param renderTarget the output canvas that will be used to enter XR mode
  44501. * @returns promise that resolves after xr mode has entered
  44502. */
  44503. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44504. /**
  44505. * Exits XR mode and returns the scene to its original state
  44506. * @returns promise that resolves after xr mode has exited
  44507. */
  44508. exitXRAsync(): Promise<void>;
  44509. private _nonXRToXRCamera;
  44510. private _setState;
  44511. }
  44512. }
  44513. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44514. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44515. import { Observable } from "babylonjs/Misc/observable";
  44516. import { IDisposable } from "babylonjs/scene";
  44517. /**
  44518. * X-Y values for axes in WebXR
  44519. */
  44520. export interface IWebXRMotionControllerAxesValue {
  44521. /**
  44522. * The value of the x axis
  44523. */
  44524. x: number;
  44525. /**
  44526. * The value of the y-axis
  44527. */
  44528. y: number;
  44529. }
  44530. /**
  44531. * changed / previous values for the values of this component
  44532. */
  44533. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44534. /**
  44535. * current (this frame) value
  44536. */
  44537. current: T;
  44538. /**
  44539. * previous (last change) value
  44540. */
  44541. previous: T;
  44542. }
  44543. /**
  44544. * Represents changes in the component between current frame and last values recorded
  44545. */
  44546. export interface IWebXRMotionControllerComponentChanges {
  44547. /**
  44548. * will be populated with previous and current values if axes changed
  44549. */
  44550. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44551. /**
  44552. * will be populated with previous and current values if pressed changed
  44553. */
  44554. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44555. /**
  44556. * will be populated with previous and current values if touched changed
  44557. */
  44558. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44559. /**
  44560. * will be populated with previous and current values if value changed
  44561. */
  44562. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44563. }
  44564. /**
  44565. * This class represents a single component (for example button or thumbstick) of a motion controller
  44566. */
  44567. export class WebXRControllerComponent implements IDisposable {
  44568. /**
  44569. * the id of this component
  44570. */
  44571. id: string;
  44572. /**
  44573. * the type of the component
  44574. */
  44575. type: MotionControllerComponentType;
  44576. private _buttonIndex;
  44577. private _axesIndices;
  44578. private _axes;
  44579. private _changes;
  44580. private _currentValue;
  44581. private _hasChanges;
  44582. private _pressed;
  44583. private _touched;
  44584. /**
  44585. * button component type
  44586. */
  44587. static BUTTON_TYPE: MotionControllerComponentType;
  44588. /**
  44589. * squeeze component type
  44590. */
  44591. static SQUEEZE_TYPE: MotionControllerComponentType;
  44592. /**
  44593. * Thumbstick component type
  44594. */
  44595. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44596. /**
  44597. * Touchpad component type
  44598. */
  44599. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44600. /**
  44601. * trigger component type
  44602. */
  44603. static TRIGGER_TYPE: MotionControllerComponentType;
  44604. /**
  44605. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44606. * the axes data changes
  44607. */
  44608. onAxisValueChangedObservable: Observable<{
  44609. x: number;
  44610. y: number;
  44611. }>;
  44612. /**
  44613. * Observers registered here will be triggered when the state of a button changes
  44614. * State change is either pressed / touched / value
  44615. */
  44616. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44617. /**
  44618. * Creates a new component for a motion controller.
  44619. * It is created by the motion controller itself
  44620. *
  44621. * @param id the id of this component
  44622. * @param type the type of the component
  44623. * @param _buttonIndex index in the buttons array of the gamepad
  44624. * @param _axesIndices indices of the values in the axes array of the gamepad
  44625. */
  44626. constructor(
  44627. /**
  44628. * the id of this component
  44629. */
  44630. id: string,
  44631. /**
  44632. * the type of the component
  44633. */
  44634. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44635. /**
  44636. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44637. */
  44638. get axes(): IWebXRMotionControllerAxesValue;
  44639. /**
  44640. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44641. */
  44642. get changes(): IWebXRMotionControllerComponentChanges;
  44643. /**
  44644. * Return whether or not the component changed the last frame
  44645. */
  44646. get hasChanges(): boolean;
  44647. /**
  44648. * is the button currently pressed
  44649. */
  44650. get pressed(): boolean;
  44651. /**
  44652. * is the button currently touched
  44653. */
  44654. get touched(): boolean;
  44655. /**
  44656. * Get the current value of this component
  44657. */
  44658. get value(): number;
  44659. /**
  44660. * Dispose this component
  44661. */
  44662. dispose(): void;
  44663. /**
  44664. * Are there axes correlating to this component
  44665. * @return true is axes data is available
  44666. */
  44667. isAxes(): boolean;
  44668. /**
  44669. * Is this component a button (hence - pressable)
  44670. * @returns true if can be pressed
  44671. */
  44672. isButton(): boolean;
  44673. /**
  44674. * update this component using the gamepad object it is in. Called on every frame
  44675. * @param nativeController the native gamepad controller object
  44676. */
  44677. update(nativeController: IMinimalMotionControllerObject): void;
  44678. }
  44679. }
  44680. declare module "babylonjs/Loading/sceneLoader" {
  44681. import { Observable } from "babylonjs/Misc/observable";
  44682. import { Nullable } from "babylonjs/types";
  44683. import { Scene } from "babylonjs/scene";
  44684. import { Engine } from "babylonjs/Engines/engine";
  44685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44686. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44687. import { AssetContainer } from "babylonjs/assetContainer";
  44688. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44689. import { Skeleton } from "babylonjs/Bones/skeleton";
  44690. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44691. import { WebRequest } from "babylonjs/Misc/webRequest";
  44692. /**
  44693. * Class used to represent data loading progression
  44694. */
  44695. export class SceneLoaderProgressEvent {
  44696. /** defines if data length to load can be evaluated */
  44697. readonly lengthComputable: boolean;
  44698. /** defines the loaded data length */
  44699. readonly loaded: number;
  44700. /** defines the data length to load */
  44701. readonly total: number;
  44702. /**
  44703. * Create a new progress event
  44704. * @param lengthComputable defines if data length to load can be evaluated
  44705. * @param loaded defines the loaded data length
  44706. * @param total defines the data length to load
  44707. */
  44708. constructor(
  44709. /** defines if data length to load can be evaluated */
  44710. lengthComputable: boolean,
  44711. /** defines the loaded data length */
  44712. loaded: number,
  44713. /** defines the data length to load */
  44714. total: number);
  44715. /**
  44716. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44717. * @param event defines the source event
  44718. * @returns a new SceneLoaderProgressEvent
  44719. */
  44720. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44721. }
  44722. /**
  44723. * Interface used by SceneLoader plugins to define supported file extensions
  44724. */
  44725. export interface ISceneLoaderPluginExtensions {
  44726. /**
  44727. * Defines the list of supported extensions
  44728. */
  44729. [extension: string]: {
  44730. isBinary: boolean;
  44731. };
  44732. }
  44733. /**
  44734. * Interface used by SceneLoader plugin factory
  44735. */
  44736. export interface ISceneLoaderPluginFactory {
  44737. /**
  44738. * Defines the name of the factory
  44739. */
  44740. name: string;
  44741. /**
  44742. * Function called to create a new plugin
  44743. * @return the new plugin
  44744. */
  44745. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44746. /**
  44747. * The callback that returns true if the data can be directly loaded.
  44748. * @param data string containing the file data
  44749. * @returns if the data can be loaded directly
  44750. */
  44751. canDirectLoad?(data: string): boolean;
  44752. }
  44753. /**
  44754. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44755. */
  44756. export interface ISceneLoaderPluginBase {
  44757. /**
  44758. * The friendly name of this plugin.
  44759. */
  44760. name: string;
  44761. /**
  44762. * The file extensions supported by this plugin.
  44763. */
  44764. extensions: string | ISceneLoaderPluginExtensions;
  44765. /**
  44766. * The callback called when loading from a url.
  44767. * @param scene scene loading this url
  44768. * @param url url to load
  44769. * @param onSuccess callback called when the file successfully loads
  44770. * @param onProgress callback called while file is loading (if the server supports this mode)
  44771. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44772. * @param onError callback called when the file fails to load
  44773. * @returns a file request object
  44774. */
  44775. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44776. /**
  44777. * The callback called when loading from a file object.
  44778. * @param scene scene loading this file
  44779. * @param file defines the file to load
  44780. * @param onSuccess defines the callback to call when data is loaded
  44781. * @param onProgress defines the callback to call during loading process
  44782. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44783. * @param onError defines the callback to call when an error occurs
  44784. * @returns a file request object
  44785. */
  44786. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44787. /**
  44788. * The callback that returns true if the data can be directly loaded.
  44789. * @param data string containing the file data
  44790. * @returns if the data can be loaded directly
  44791. */
  44792. canDirectLoad?(data: string): boolean;
  44793. /**
  44794. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44795. * @param scene scene loading this data
  44796. * @param data string containing the data
  44797. * @returns data to pass to the plugin
  44798. */
  44799. directLoad?(scene: Scene, data: string): any;
  44800. /**
  44801. * The callback that allows custom handling of the root url based on the response url.
  44802. * @param rootUrl the original root url
  44803. * @param responseURL the response url if available
  44804. * @returns the new root url
  44805. */
  44806. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44807. }
  44808. /**
  44809. * Interface used to define a SceneLoader plugin
  44810. */
  44811. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44812. /**
  44813. * Import meshes into a scene.
  44814. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44815. * @param scene The scene to import into
  44816. * @param data The data to import
  44817. * @param rootUrl The root url for scene and resources
  44818. * @param meshes The meshes array to import into
  44819. * @param particleSystems The particle systems array to import into
  44820. * @param skeletons The skeletons array to import into
  44821. * @param onError The callback when import fails
  44822. * @returns True if successful or false otherwise
  44823. */
  44824. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44825. /**
  44826. * Load into a scene.
  44827. * @param scene The scene to load into
  44828. * @param data The data to import
  44829. * @param rootUrl The root url for scene and resources
  44830. * @param onError The callback when import fails
  44831. * @returns True if successful or false otherwise
  44832. */
  44833. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44834. /**
  44835. * Load into an asset container.
  44836. * @param scene The scene to load into
  44837. * @param data The data to import
  44838. * @param rootUrl The root url for scene and resources
  44839. * @param onError The callback when import fails
  44840. * @returns The loaded asset container
  44841. */
  44842. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44843. }
  44844. /**
  44845. * Interface used to define an async SceneLoader plugin
  44846. */
  44847. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44848. /**
  44849. * Import meshes into a scene.
  44850. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44851. * @param scene The scene to import into
  44852. * @param data The data to import
  44853. * @param rootUrl The root url for scene and resources
  44854. * @param onProgress The callback when the load progresses
  44855. * @param fileName Defines the name of the file to load
  44856. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44857. */
  44858. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44859. meshes: AbstractMesh[];
  44860. particleSystems: IParticleSystem[];
  44861. skeletons: Skeleton[];
  44862. animationGroups: AnimationGroup[];
  44863. }>;
  44864. /**
  44865. * Load into a scene.
  44866. * @param scene The scene to load into
  44867. * @param data The data to import
  44868. * @param rootUrl The root url for scene and resources
  44869. * @param onProgress The callback when the load progresses
  44870. * @param fileName Defines the name of the file to load
  44871. * @returns Nothing
  44872. */
  44873. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44874. /**
  44875. * Load into an asset container.
  44876. * @param scene The scene to load into
  44877. * @param data The data to import
  44878. * @param rootUrl The root url for scene and resources
  44879. * @param onProgress The callback when the load progresses
  44880. * @param fileName Defines the name of the file to load
  44881. * @returns The loaded asset container
  44882. */
  44883. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44884. }
  44885. /**
  44886. * Mode that determines how to handle old animation groups before loading new ones.
  44887. */
  44888. export enum SceneLoaderAnimationGroupLoadingMode {
  44889. /**
  44890. * Reset all old animations to initial state then dispose them.
  44891. */
  44892. Clean = 0,
  44893. /**
  44894. * Stop all old animations.
  44895. */
  44896. Stop = 1,
  44897. /**
  44898. * Restart old animations from first frame.
  44899. */
  44900. Sync = 2,
  44901. /**
  44902. * Old animations remains untouched.
  44903. */
  44904. NoSync = 3
  44905. }
  44906. /**
  44907. * Class used to load scene from various file formats using registered plugins
  44908. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44909. */
  44910. export class SceneLoader {
  44911. /**
  44912. * No logging while loading
  44913. */
  44914. static readonly NO_LOGGING: number;
  44915. /**
  44916. * Minimal logging while loading
  44917. */
  44918. static readonly MINIMAL_LOGGING: number;
  44919. /**
  44920. * Summary logging while loading
  44921. */
  44922. static readonly SUMMARY_LOGGING: number;
  44923. /**
  44924. * Detailled logging while loading
  44925. */
  44926. static readonly DETAILED_LOGGING: number;
  44927. /**
  44928. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44929. */
  44930. static get ForceFullSceneLoadingForIncremental(): boolean;
  44931. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44932. /**
  44933. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44934. */
  44935. static get ShowLoadingScreen(): boolean;
  44936. static set ShowLoadingScreen(value: boolean);
  44937. /**
  44938. * Defines the current logging level (while loading the scene)
  44939. * @ignorenaming
  44940. */
  44941. static get loggingLevel(): number;
  44942. static set loggingLevel(value: number);
  44943. /**
  44944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44945. */
  44946. static get CleanBoneMatrixWeights(): boolean;
  44947. static set CleanBoneMatrixWeights(value: boolean);
  44948. /**
  44949. * Event raised when a plugin is used to load a scene
  44950. */
  44951. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44952. private static _registeredPlugins;
  44953. private static _getDefaultPlugin;
  44954. private static _getPluginForExtension;
  44955. private static _getPluginForDirectLoad;
  44956. private static _getPluginForFilename;
  44957. private static _getDirectLoad;
  44958. private static _loadData;
  44959. private static _getFileInfo;
  44960. /**
  44961. * Gets a plugin that can load the given extension
  44962. * @param extension defines the extension to load
  44963. * @returns a plugin or null if none works
  44964. */
  44965. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44966. /**
  44967. * Gets a boolean indicating that the given extension can be loaded
  44968. * @param extension defines the extension to load
  44969. * @returns true if the extension is supported
  44970. */
  44971. static IsPluginForExtensionAvailable(extension: string): boolean;
  44972. /**
  44973. * Adds a new plugin to the list of registered plugins
  44974. * @param plugin defines the plugin to add
  44975. */
  44976. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44977. /**
  44978. * Import meshes into a scene
  44979. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44980. * @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)
  44981. * @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)
  44982. * @param scene the instance of BABYLON.Scene to append to
  44983. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44984. * @param onProgress a callback with a progress event for each file being loaded
  44985. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44986. * @param pluginExtension the extension used to determine the plugin
  44987. * @returns The loaded plugin
  44988. */
  44989. 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>;
  44990. /**
  44991. * Import meshes into a scene
  44992. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44993. * @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)
  44994. * @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)
  44995. * @param scene the instance of BABYLON.Scene to append to
  44996. * @param onProgress a callback with a progress event for each file being loaded
  44997. * @param pluginExtension the extension used to determine the plugin
  44998. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44999. */
  45000. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45001. meshes: AbstractMesh[];
  45002. particleSystems: IParticleSystem[];
  45003. skeletons: Skeleton[];
  45004. animationGroups: AnimationGroup[];
  45005. }>;
  45006. /**
  45007. * Load a scene
  45008. * @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)
  45009. * @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)
  45010. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45011. * @param onSuccess a callback with the scene when import succeeds
  45012. * @param onProgress a callback with a progress event for each file being loaded
  45013. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45014. * @param pluginExtension the extension used to determine the plugin
  45015. * @returns The loaded plugin
  45016. */
  45017. 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>;
  45018. /**
  45019. * Load a scene
  45020. * @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)
  45021. * @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)
  45022. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45023. * @param onProgress a callback with a progress event for each file being loaded
  45024. * @param pluginExtension the extension used to determine the plugin
  45025. * @returns The loaded scene
  45026. */
  45027. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45028. /**
  45029. * Append a scene
  45030. * @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)
  45031. * @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)
  45032. * @param scene is the instance of BABYLON.Scene to append to
  45033. * @param onSuccess a callback with the scene when import succeeds
  45034. * @param onProgress a callback with a progress event for each file being loaded
  45035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45036. * @param pluginExtension the extension used to determine the plugin
  45037. * @returns The loaded plugin
  45038. */
  45039. 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>;
  45040. /**
  45041. * Append a scene
  45042. * @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)
  45043. * @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)
  45044. * @param scene is the instance of BABYLON.Scene to append to
  45045. * @param onProgress a callback with a progress event for each file being loaded
  45046. * @param pluginExtension the extension used to determine the plugin
  45047. * @returns The given scene
  45048. */
  45049. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45050. /**
  45051. * Load a scene into an asset container
  45052. * @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)
  45053. * @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)
  45054. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45055. * @param onSuccess a callback with the scene when import succeeds
  45056. * @param onProgress a callback with a progress event for each file being loaded
  45057. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45058. * @param pluginExtension the extension used to determine the plugin
  45059. * @returns The loaded plugin
  45060. */
  45061. 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>;
  45062. /**
  45063. * Load a scene into an asset container
  45064. * @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)
  45065. * @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)
  45066. * @param scene is the instance of Scene to append to
  45067. * @param onProgress a callback with a progress event for each file being loaded
  45068. * @param pluginExtension the extension used to determine the plugin
  45069. * @returns The loaded asset container
  45070. */
  45071. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45072. /**
  45073. * Import animations from a file into a scene
  45074. * @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)
  45075. * @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)
  45076. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45077. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45078. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45079. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45080. * @param onSuccess a callback with the scene when import succeeds
  45081. * @param onProgress a callback with a progress event for each file being loaded
  45082. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45083. */
  45084. 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;
  45085. /**
  45086. * Import animations from a file into a scene
  45087. * @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)
  45088. * @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)
  45089. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45090. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45091. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45092. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45093. * @param onSuccess a callback with the scene when import succeeds
  45094. * @param onProgress a callback with a progress event for each file being loaded
  45095. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45096. * @returns the updated scene with imported animations
  45097. */
  45098. 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>;
  45099. }
  45100. }
  45101. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45102. import { IDisposable, Scene } from "babylonjs/scene";
  45103. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45104. import { Observable } from "babylonjs/Misc/observable";
  45105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45106. import { Nullable } from "babylonjs/types";
  45107. /**
  45108. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45109. */
  45110. export type MotionControllerHandness = "none" | "left" | "right";
  45111. /**
  45112. * The type of components available in motion controllers.
  45113. * This is not the name of the component.
  45114. */
  45115. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45116. /**
  45117. * The state of a controller component
  45118. */
  45119. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45120. /**
  45121. * The schema of motion controller layout.
  45122. * No object will be initialized using this interface
  45123. * This is used just to define the profile.
  45124. */
  45125. export interface IMotionControllerLayout {
  45126. /**
  45127. * Path to load the assets. Usually relative to the base path
  45128. */
  45129. assetPath: string;
  45130. /**
  45131. * Available components (unsorted)
  45132. */
  45133. components: {
  45134. /**
  45135. * A map of component Ids
  45136. */
  45137. [componentId: string]: {
  45138. /**
  45139. * The type of input the component outputs
  45140. */
  45141. type: MotionControllerComponentType;
  45142. /**
  45143. * The indices of this component in the gamepad object
  45144. */
  45145. gamepadIndices: {
  45146. /**
  45147. * Index of button
  45148. */
  45149. button?: number;
  45150. /**
  45151. * If available, index of x-axis
  45152. */
  45153. xAxis?: number;
  45154. /**
  45155. * If available, index of y-axis
  45156. */
  45157. yAxis?: number;
  45158. };
  45159. /**
  45160. * The mesh's root node name
  45161. */
  45162. rootNodeName: string;
  45163. /**
  45164. * Animation definitions for this model
  45165. */
  45166. visualResponses: {
  45167. [stateKey: string]: {
  45168. /**
  45169. * What property will be animated
  45170. */
  45171. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45172. /**
  45173. * What states influence this visual response
  45174. */
  45175. states: MotionControllerComponentStateType[];
  45176. /**
  45177. * Type of animation - movement or visibility
  45178. */
  45179. valueNodeProperty: "transform" | "visibility";
  45180. /**
  45181. * Base node name to move. Its position will be calculated according to the min and max nodes
  45182. */
  45183. valueNodeName?: string;
  45184. /**
  45185. * Minimum movement node
  45186. */
  45187. minNodeName?: string;
  45188. /**
  45189. * Max movement node
  45190. */
  45191. maxNodeName?: string;
  45192. };
  45193. };
  45194. /**
  45195. * If touch enabled, what is the name of node to display user feedback
  45196. */
  45197. touchPointNodeName?: string;
  45198. };
  45199. };
  45200. /**
  45201. * Is it xr standard mapping or not
  45202. */
  45203. gamepadMapping: "" | "xr-standard";
  45204. /**
  45205. * Base root node of this entire model
  45206. */
  45207. rootNodeName: string;
  45208. /**
  45209. * Defines the main button component id
  45210. */
  45211. selectComponentId: string;
  45212. }
  45213. /**
  45214. * A definition for the layout map in the input profile
  45215. */
  45216. export interface IMotionControllerLayoutMap {
  45217. /**
  45218. * Layouts with handness type as a key
  45219. */
  45220. [handness: string]: IMotionControllerLayout;
  45221. }
  45222. /**
  45223. * The XR Input profile schema
  45224. * Profiles can be found here:
  45225. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45226. */
  45227. export interface IMotionControllerProfile {
  45228. /**
  45229. * fallback profiles for this profileId
  45230. */
  45231. fallbackProfileIds: string[];
  45232. /**
  45233. * The layout map, with handness as key
  45234. */
  45235. layouts: IMotionControllerLayoutMap;
  45236. /**
  45237. * The id of this profile
  45238. * correlates to the profile(s) in the xrInput.profiles array
  45239. */
  45240. profileId: string;
  45241. }
  45242. /**
  45243. * A helper-interface for the 3 meshes needed for controller button animation
  45244. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45245. */
  45246. export interface IMotionControllerButtonMeshMap {
  45247. /**
  45248. * the mesh that defines the pressed value mesh position.
  45249. * This is used to find the max-position of this button
  45250. */
  45251. pressedMesh: AbstractMesh;
  45252. /**
  45253. * the mesh that defines the unpressed value mesh position.
  45254. * This is used to find the min (or initial) position of this button
  45255. */
  45256. unpressedMesh: AbstractMesh;
  45257. /**
  45258. * The mesh that will be changed when value changes
  45259. */
  45260. valueMesh: AbstractMesh;
  45261. }
  45262. /**
  45263. * A helper-interface for the 3 meshes needed for controller axis animation.
  45264. * This will be expanded when touchpad animations are fully supported
  45265. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45266. */
  45267. export interface IMotionControllerMeshMap {
  45268. /**
  45269. * the mesh that defines the maximum value mesh position.
  45270. */
  45271. maxMesh?: AbstractMesh;
  45272. /**
  45273. * the mesh that defines the minimum value mesh position.
  45274. */
  45275. minMesh?: AbstractMesh;
  45276. /**
  45277. * The mesh that will be changed when axis value changes
  45278. */
  45279. valueMesh: AbstractMesh;
  45280. }
  45281. /**
  45282. * The elements needed for change-detection of the gamepad objects in motion controllers
  45283. */
  45284. export interface IMinimalMotionControllerObject {
  45285. /**
  45286. * Available axes of this controller
  45287. */
  45288. axes: number[];
  45289. /**
  45290. * An array of available buttons
  45291. */
  45292. buttons: Array<{
  45293. /**
  45294. * Value of the button/trigger
  45295. */
  45296. value: number;
  45297. /**
  45298. * If the button/trigger is currently touched
  45299. */
  45300. touched: boolean;
  45301. /**
  45302. * If the button/trigger is currently pressed
  45303. */
  45304. pressed: boolean;
  45305. }>;
  45306. }
  45307. /**
  45308. * An Abstract Motion controller
  45309. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45310. * Each component has an observable to check for changes in value and state
  45311. */
  45312. export abstract class WebXRAbstractMotionController implements IDisposable {
  45313. protected scene: Scene;
  45314. protected layout: IMotionControllerLayout;
  45315. /**
  45316. * The gamepad object correlating to this controller
  45317. */
  45318. gamepadObject: IMinimalMotionControllerObject;
  45319. /**
  45320. * handness (left/right/none) of this controller
  45321. */
  45322. handness: MotionControllerHandness;
  45323. private _initComponent;
  45324. private _modelReady;
  45325. /**
  45326. * A map of components (WebXRControllerComponent) in this motion controller
  45327. * Components have a ComponentType and can also have both button and axis definitions
  45328. */
  45329. readonly components: {
  45330. [id: string]: WebXRControllerComponent;
  45331. };
  45332. /**
  45333. * Disable the model's animation. Can be set at any time.
  45334. */
  45335. disableAnimation: boolean;
  45336. /**
  45337. * Observers registered here will be triggered when the model of this controller is done loading
  45338. */
  45339. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45340. /**
  45341. * The profile id of this motion controller
  45342. */
  45343. abstract profileId: string;
  45344. /**
  45345. * The root mesh of the model. It is null if the model was not yet initialized
  45346. */
  45347. rootMesh: Nullable<AbstractMesh>;
  45348. /**
  45349. * constructs a new abstract motion controller
  45350. * @param scene the scene to which the model of the controller will be added
  45351. * @param layout The profile layout to load
  45352. * @param gamepadObject The gamepad object correlating to this controller
  45353. * @param handness handness (left/right/none) of this controller
  45354. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45355. */
  45356. constructor(scene: Scene, layout: IMotionControllerLayout,
  45357. /**
  45358. * The gamepad object correlating to this controller
  45359. */
  45360. gamepadObject: IMinimalMotionControllerObject,
  45361. /**
  45362. * handness (left/right/none) of this controller
  45363. */
  45364. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45365. /**
  45366. * Dispose this controller, the model mesh and all its components
  45367. */
  45368. dispose(): void;
  45369. /**
  45370. * Returns all components of specific type
  45371. * @param type the type to search for
  45372. * @return an array of components with this type
  45373. */
  45374. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45375. /**
  45376. * get a component based an its component id as defined in layout.components
  45377. * @param id the id of the component
  45378. * @returns the component correlates to the id or undefined if not found
  45379. */
  45380. getComponent(id: string): WebXRControllerComponent;
  45381. /**
  45382. * Get the list of components available in this motion controller
  45383. * @returns an array of strings correlating to available components
  45384. */
  45385. getComponentIds(): string[];
  45386. /**
  45387. * Get the first component of specific type
  45388. * @param type type of component to find
  45389. * @return a controller component or null if not found
  45390. */
  45391. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45392. /**
  45393. * Get the main (Select) component of this controller as defined in the layout
  45394. * @returns the main component of this controller
  45395. */
  45396. getMainComponent(): WebXRControllerComponent;
  45397. /**
  45398. * Loads the model correlating to this controller
  45399. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45400. * @returns A promise fulfilled with the result of the model loading
  45401. */
  45402. loadModel(): Promise<boolean>;
  45403. /**
  45404. * Update this model using the current XRFrame
  45405. * @param xrFrame the current xr frame to use and update the model
  45406. */
  45407. updateFromXRFrame(xrFrame: XRFrame): void;
  45408. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45409. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45410. /**
  45411. * Moves the axis on the controller mesh based on its current state
  45412. * @param axis the index of the axis
  45413. * @param axisValue the value of the axis which determines the meshes new position
  45414. * @hidden
  45415. */
  45416. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45417. /**
  45418. * Update the model itself with the current frame data
  45419. * @param xrFrame the frame to use for updating the model mesh
  45420. */
  45421. protected updateModel(xrFrame: XRFrame): void;
  45422. /**
  45423. * Get the filename and path for this controller's model
  45424. * @returns a map of filename and path
  45425. */
  45426. protected abstract _getFilenameAndPath(): {
  45427. filename: string;
  45428. path: string;
  45429. };
  45430. /**
  45431. * This function is called before the mesh is loaded. It checks for loading constraints.
  45432. * For example, this function can check if the GLB loader is available
  45433. * If this function returns false, the generic controller will be loaded instead
  45434. * @returns Is the client ready to load the mesh
  45435. */
  45436. protected abstract _getModelLoadingConstraints(): boolean;
  45437. /**
  45438. * This function will be called after the model was successfully loaded and can be used
  45439. * for mesh transformations before it is available for the user
  45440. * @param meshes the loaded meshes
  45441. */
  45442. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45443. /**
  45444. * Set the root mesh for this controller. Important for the WebXR controller class
  45445. * @param meshes the loaded meshes
  45446. */
  45447. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45448. /**
  45449. * A function executed each frame that updates the mesh (if needed)
  45450. * @param xrFrame the current xrFrame
  45451. */
  45452. protected abstract _updateModel(xrFrame: XRFrame): void;
  45453. private _getGenericFilenameAndPath;
  45454. private _getGenericParentMesh;
  45455. }
  45456. }
  45457. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45458. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45460. import { Scene } from "babylonjs/scene";
  45461. /**
  45462. * A generic trigger-only motion controller for WebXR
  45463. */
  45464. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45465. /**
  45466. * Static version of the profile id of this controller
  45467. */
  45468. static ProfileId: string;
  45469. profileId: string;
  45470. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45471. protected _getFilenameAndPath(): {
  45472. filename: string;
  45473. path: string;
  45474. };
  45475. protected _getModelLoadingConstraints(): boolean;
  45476. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45477. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45478. protected _updateModel(): void;
  45479. }
  45480. }
  45481. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45482. import { Vector4 } from "babylonjs/Maths/math.vector";
  45483. import { Mesh } from "babylonjs/Meshes/mesh";
  45484. import { Scene } from "babylonjs/scene";
  45485. import { Nullable } from "babylonjs/types";
  45486. /**
  45487. * Class containing static functions to help procedurally build meshes
  45488. */
  45489. export class SphereBuilder {
  45490. /**
  45491. * Creates a sphere mesh
  45492. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45493. * * 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`)
  45494. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45495. * * 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
  45496. * * 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)
  45497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45500. * @param name defines the name of the mesh
  45501. * @param options defines the options used to create the mesh
  45502. * @param scene defines the hosting scene
  45503. * @returns the sphere mesh
  45504. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45505. */
  45506. static CreateSphere(name: string, options: {
  45507. segments?: number;
  45508. diameter?: number;
  45509. diameterX?: number;
  45510. diameterY?: number;
  45511. diameterZ?: number;
  45512. arc?: number;
  45513. slice?: number;
  45514. sideOrientation?: number;
  45515. frontUVs?: Vector4;
  45516. backUVs?: Vector4;
  45517. updatable?: boolean;
  45518. }, scene?: Nullable<Scene>): Mesh;
  45519. }
  45520. }
  45521. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45523. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45524. import { Scene } from "babylonjs/scene";
  45525. /**
  45526. * A profiled motion controller has its profile loaded from an online repository.
  45527. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45528. */
  45529. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45530. private _repositoryUrl;
  45531. private _buttonMeshMapping;
  45532. private _touchDots;
  45533. /**
  45534. * The profile ID of this controller. Will be populated when the controller initializes.
  45535. */
  45536. profileId: string;
  45537. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45538. dispose(): void;
  45539. protected _getFilenameAndPath(): {
  45540. filename: string;
  45541. path: string;
  45542. };
  45543. protected _getModelLoadingConstraints(): boolean;
  45544. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45545. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45546. protected _updateModel(_xrFrame: XRFrame): void;
  45547. }
  45548. }
  45549. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45550. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45551. import { Scene } from "babylonjs/scene";
  45552. /**
  45553. * A construction function type to create a new controller based on an xrInput object
  45554. */
  45555. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45556. /**
  45557. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45558. *
  45559. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45560. * it should be replaced with auto-loaded controllers.
  45561. *
  45562. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45563. */
  45564. export class WebXRMotionControllerManager {
  45565. private static _AvailableControllers;
  45566. private static _Fallbacks;
  45567. private static _ProfileLoadingPromises;
  45568. private static _ProfilesList;
  45569. /**
  45570. * The base URL of the online controller repository. Can be changed at any time.
  45571. */
  45572. static BaseRepositoryUrl: string;
  45573. /**
  45574. * Which repository gets priority - local or online
  45575. */
  45576. static PrioritizeOnlineRepository: boolean;
  45577. /**
  45578. * Use the online repository, or use only locally-defined controllers
  45579. */
  45580. static UseOnlineRepository: boolean;
  45581. /**
  45582. * Clear the cache used for profile loading and reload when requested again
  45583. */
  45584. static ClearProfilesCache(): void;
  45585. /**
  45586. * Register the default fallbacks.
  45587. * This function is called automatically when this file is imported.
  45588. */
  45589. static DefaultFallbacks(): void;
  45590. /**
  45591. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45592. * @param profileId the profile to which a fallback needs to be found
  45593. * @return an array with corresponding fallback profiles
  45594. */
  45595. static FindFallbackWithProfileId(profileId: string): string[];
  45596. /**
  45597. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45598. * The order of search:
  45599. *
  45600. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45601. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45602. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45603. * 4) return the generic trigger controller if none were found
  45604. *
  45605. * @param xrInput the xrInput to which a new controller is initialized
  45606. * @param scene the scene to which the model will be added
  45607. * @param forceProfile force a certain profile for this controller
  45608. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45609. */
  45610. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45611. /**
  45612. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45613. *
  45614. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45615. *
  45616. * @param type the profile type to register
  45617. * @param constructFunction the function to be called when loading this profile
  45618. */
  45619. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45620. /**
  45621. * Register a fallback to a specific profile.
  45622. * @param profileId the profileId that will receive the fallbacks
  45623. * @param fallbacks A list of fallback profiles
  45624. */
  45625. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45626. /**
  45627. * Will update the list of profiles available in the repository
  45628. * @return a promise that resolves to a map of profiles available online
  45629. */
  45630. static UpdateProfilesList(): Promise<{
  45631. [profile: string]: string;
  45632. }>;
  45633. private static _LoadProfileFromRepository;
  45634. private static _LoadProfilesFromAvailableControllers;
  45635. }
  45636. }
  45637. declare module "babylonjs/XR/webXRInputSource" {
  45638. import { Observable } from "babylonjs/Misc/observable";
  45639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45640. import { Ray } from "babylonjs/Culling/ray";
  45641. import { Scene } from "babylonjs/scene";
  45642. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45643. /**
  45644. * Configuration options for the WebXR controller creation
  45645. */
  45646. export interface IWebXRControllerOptions {
  45647. /**
  45648. * Should the controller mesh be animated when a user interacts with it
  45649. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45650. */
  45651. disableMotionControllerAnimation?: boolean;
  45652. /**
  45653. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45654. */
  45655. doNotLoadControllerMesh?: boolean;
  45656. /**
  45657. * Force a specific controller type for this controller.
  45658. * This can be used when creating your own profile or when testing different controllers
  45659. */
  45660. forceControllerProfile?: string;
  45661. }
  45662. /**
  45663. * Represents an XR controller
  45664. */
  45665. export class WebXRInputSource {
  45666. private _scene;
  45667. /** The underlying input source for the controller */
  45668. inputSource: XRInputSource;
  45669. private _options;
  45670. private _tmpQuaternion;
  45671. private _tmpVector;
  45672. private _uniqueId;
  45673. /**
  45674. * 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
  45675. */
  45676. grip?: AbstractMesh;
  45677. /**
  45678. * If available, this is the gamepad object related to this controller.
  45679. * Using this object it is possible to get click events and trackpad changes of the
  45680. * webxr controller that is currently being used.
  45681. */
  45682. motionController?: WebXRAbstractMotionController;
  45683. /**
  45684. * Event that fires when the controller is removed/disposed.
  45685. * The object provided as event data is this controller, after associated assets were disposed.
  45686. * uniqueId is still available.
  45687. */
  45688. onDisposeObservable: Observable<WebXRInputSource>;
  45689. /**
  45690. * Will be triggered when the mesh associated with the motion controller is done loading.
  45691. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45692. * A shortened version of controller -> motion controller -> on mesh loaded.
  45693. */
  45694. onMeshLoadedObservable: Observable<AbstractMesh>;
  45695. /**
  45696. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45697. */
  45698. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45699. /**
  45700. * Pointer which can be used to select objects or attach a visible laser to
  45701. */
  45702. pointer: AbstractMesh;
  45703. /**
  45704. * Creates the controller
  45705. * @see https://doc.babylonjs.com/how_to/webxr
  45706. * @param _scene the scene which the controller should be associated to
  45707. * @param inputSource the underlying input source for the controller
  45708. * @param _options options for this controller creation
  45709. */
  45710. constructor(_scene: Scene,
  45711. /** The underlying input source for the controller */
  45712. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45713. /**
  45714. * Get this controllers unique id
  45715. */
  45716. get uniqueId(): string;
  45717. /**
  45718. * Disposes of the object
  45719. */
  45720. dispose(): void;
  45721. /**
  45722. * Gets a world space ray coming from the pointer or grip
  45723. * @param result the resulting ray
  45724. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45725. */
  45726. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45727. /**
  45728. * Updates the controller pose based on the given XRFrame
  45729. * @param xrFrame xr frame to update the pose with
  45730. * @param referenceSpace reference space to use
  45731. */
  45732. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45733. }
  45734. }
  45735. declare module "babylonjs/XR/webXRInput" {
  45736. import { Observable } from "babylonjs/Misc/observable";
  45737. import { IDisposable } from "babylonjs/scene";
  45738. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45739. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45740. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45741. /**
  45742. * The schema for initialization options of the XR Input class
  45743. */
  45744. export interface IWebXRInputOptions {
  45745. /**
  45746. * If set to true no model will be automatically loaded
  45747. */
  45748. doNotLoadControllerMeshes?: boolean;
  45749. /**
  45750. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45751. * If not found, the xr input profile data will be used.
  45752. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45753. */
  45754. forceInputProfile?: string;
  45755. /**
  45756. * Do not send a request to the controller repository to load the profile.
  45757. *
  45758. * Instead, use the controllers available in babylon itself.
  45759. */
  45760. disableOnlineControllerRepository?: boolean;
  45761. /**
  45762. * A custom URL for the controllers repository
  45763. */
  45764. customControllersRepositoryURL?: string;
  45765. /**
  45766. * Should the controller model's components not move according to the user input
  45767. */
  45768. disableControllerAnimation?: boolean;
  45769. }
  45770. /**
  45771. * XR input used to track XR inputs such as controllers/rays
  45772. */
  45773. export class WebXRInput implements IDisposable {
  45774. /**
  45775. * the xr session manager for this session
  45776. */
  45777. xrSessionManager: WebXRSessionManager;
  45778. /**
  45779. * the WebXR camera for this session. Mainly used for teleportation
  45780. */
  45781. xrCamera: WebXRCamera;
  45782. private readonly options;
  45783. /**
  45784. * XR controllers being tracked
  45785. */
  45786. controllers: Array<WebXRInputSource>;
  45787. private _frameObserver;
  45788. private _sessionEndedObserver;
  45789. private _sessionInitObserver;
  45790. /**
  45791. * Event when a controller has been connected/added
  45792. */
  45793. onControllerAddedObservable: Observable<WebXRInputSource>;
  45794. /**
  45795. * Event when a controller has been removed/disconnected
  45796. */
  45797. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45798. /**
  45799. * Initializes the WebXRInput
  45800. * @param xrSessionManager the xr session manager for this session
  45801. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45802. * @param options = initialization options for this xr input
  45803. */
  45804. constructor(
  45805. /**
  45806. * the xr session manager for this session
  45807. */
  45808. xrSessionManager: WebXRSessionManager,
  45809. /**
  45810. * the WebXR camera for this session. Mainly used for teleportation
  45811. */
  45812. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45813. private _onInputSourcesChange;
  45814. private _addAndRemoveControllers;
  45815. /**
  45816. * Disposes of the object
  45817. */
  45818. dispose(): void;
  45819. }
  45820. }
  45821. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45822. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45823. import { Observable, EventState } from "babylonjs/Misc/observable";
  45824. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45825. /**
  45826. * This is the base class for all WebXR features.
  45827. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45828. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45829. */
  45830. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45831. protected _xrSessionManager: WebXRSessionManager;
  45832. private _attached;
  45833. private _removeOnDetach;
  45834. /**
  45835. * Should auto-attach be disabled?
  45836. */
  45837. disableAutoAttach: boolean;
  45838. /**
  45839. * Construct a new (abstract) WebXR feature
  45840. * @param _xrSessionManager the xr session manager for this feature
  45841. */
  45842. constructor(_xrSessionManager: WebXRSessionManager);
  45843. /**
  45844. * Is this feature attached
  45845. */
  45846. get attached(): boolean;
  45847. /**
  45848. * attach this feature
  45849. *
  45850. * @param force should attachment be forced (even when already attached)
  45851. * @returns true if successful, false is failed or already attached
  45852. */
  45853. attach(force?: boolean): boolean;
  45854. /**
  45855. * detach this feature.
  45856. *
  45857. * @returns true if successful, false if failed or already detached
  45858. */
  45859. detach(): boolean;
  45860. /**
  45861. * Dispose this feature and all of the resources attached
  45862. */
  45863. dispose(): void;
  45864. /**
  45865. * This is used to register callbacks that will automatically be removed when detach is called.
  45866. * @param observable the observable to which the observer will be attached
  45867. * @param callback the callback to register
  45868. */
  45869. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45870. /**
  45871. * Code in this function will be executed on each xrFrame received from the browser.
  45872. * This function will not execute after the feature is detached.
  45873. * @param _xrFrame the current frame
  45874. */
  45875. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45876. }
  45877. }
  45878. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45879. import { IDisposable, Scene } from "babylonjs/scene";
  45880. import { Nullable } from "babylonjs/types";
  45881. import { Observable } from "babylonjs/Misc/observable";
  45882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45883. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45884. import { Camera } from "babylonjs/Cameras/camera";
  45885. /**
  45886. * Renders a layer on top of an existing scene
  45887. */
  45888. export class UtilityLayerRenderer implements IDisposable {
  45889. /** the original scene that will be rendered on top of */
  45890. originalScene: Scene;
  45891. private _pointerCaptures;
  45892. private _lastPointerEvents;
  45893. private static _DefaultUtilityLayer;
  45894. private static _DefaultKeepDepthUtilityLayer;
  45895. private _sharedGizmoLight;
  45896. private _renderCamera;
  45897. /**
  45898. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45899. * @returns the camera that is used when rendering the utility layer
  45900. */
  45901. getRenderCamera(): Camera;
  45902. /**
  45903. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45904. * @param cam the camera that should be used when rendering the utility layer
  45905. */
  45906. setRenderCamera(cam: Nullable<Camera>): void;
  45907. /**
  45908. * @hidden
  45909. * Light which used by gizmos to get light shading
  45910. */
  45911. _getSharedGizmoLight(): HemisphericLight;
  45912. /**
  45913. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45914. */
  45915. pickUtilitySceneFirst: boolean;
  45916. /**
  45917. * 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)
  45918. */
  45919. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45920. /**
  45921. * 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)
  45922. */
  45923. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45924. /**
  45925. * The scene that is rendered on top of the original scene
  45926. */
  45927. utilityLayerScene: Scene;
  45928. /**
  45929. * If the utility layer should automatically be rendered on top of existing scene
  45930. */
  45931. shouldRender: boolean;
  45932. /**
  45933. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45934. */
  45935. onlyCheckPointerDownEvents: boolean;
  45936. /**
  45937. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45938. */
  45939. processAllEvents: boolean;
  45940. /**
  45941. * Observable raised when the pointer move from the utility layer scene to the main scene
  45942. */
  45943. onPointerOutObservable: Observable<number>;
  45944. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45945. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45946. private _afterRenderObserver;
  45947. private _sceneDisposeObserver;
  45948. private _originalPointerObserver;
  45949. /**
  45950. * Instantiates a UtilityLayerRenderer
  45951. * @param originalScene the original scene that will be rendered on top of
  45952. * @param handleEvents boolean indicating if the utility layer should handle events
  45953. */
  45954. constructor(
  45955. /** the original scene that will be rendered on top of */
  45956. originalScene: Scene, handleEvents?: boolean);
  45957. private _notifyObservers;
  45958. /**
  45959. * Renders the utility layers scene on top of the original scene
  45960. */
  45961. render(): void;
  45962. /**
  45963. * Disposes of the renderer
  45964. */
  45965. dispose(): void;
  45966. private _updateCamera;
  45967. }
  45968. }
  45969. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45970. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45972. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45973. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45974. import { Scene } from "babylonjs/scene";
  45975. import { Nullable } from "babylonjs/types";
  45976. import { Color3 } from "babylonjs/Maths/math.color";
  45977. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45978. /**
  45979. * Options interface for the pointer selection module
  45980. */
  45981. export interface IWebXRControllerPointerSelectionOptions {
  45982. /**
  45983. * if provided, this scene will be used to render meshes.
  45984. */
  45985. customUtilityLayerScene?: Scene;
  45986. /**
  45987. * 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)
  45988. * If not disabled, the last picked point will be used to execute a pointer up event
  45989. * If disabled, pointer up event will be triggered right after the pointer down event.
  45990. * Used in screen and gaze target ray mode only
  45991. */
  45992. disablePointerUpOnTouchOut: boolean;
  45993. /**
  45994. * For gaze mode (time to select instead of press)
  45995. */
  45996. forceGazeMode: boolean;
  45997. /**
  45998. * 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
  45999. * to start a new countdown to the pointer down event.
  46000. * Defaults to 1.
  46001. */
  46002. gazeModePointerMovedFactor?: number;
  46003. /**
  46004. * Different button type to use instead of the main component
  46005. */
  46006. overrideButtonId?: string;
  46007. /**
  46008. * use this rendering group id for the meshes (optional)
  46009. */
  46010. renderingGroupId?: number;
  46011. /**
  46012. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46013. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46014. * 3000 means 3 seconds between pointing at something and selecting it
  46015. */
  46016. timeToSelect?: number;
  46017. /**
  46018. * Should meshes created here be added to a utility layer or the main scene
  46019. */
  46020. useUtilityLayer?: boolean;
  46021. /**
  46022. * the xr input to use with this pointer selection
  46023. */
  46024. xrInput: WebXRInput;
  46025. }
  46026. /**
  46027. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46028. */
  46029. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46030. private readonly _options;
  46031. private static _idCounter;
  46032. private _attachController;
  46033. private _controllers;
  46034. private _scene;
  46035. private _tmpVectorForPickCompare;
  46036. /**
  46037. * The module's name
  46038. */
  46039. static readonly Name: string;
  46040. /**
  46041. * The (Babylon) version of this module.
  46042. * This is an integer representing the implementation version.
  46043. * This number does not correspond to the WebXR specs version
  46044. */
  46045. static readonly Version: number;
  46046. /**
  46047. * Disable lighting on the laser pointer (so it will always be visible)
  46048. */
  46049. disablePointerLighting: boolean;
  46050. /**
  46051. * Disable lighting on the selection mesh (so it will always be visible)
  46052. */
  46053. disableSelectionMeshLighting: boolean;
  46054. /**
  46055. * Should the laser pointer be displayed
  46056. */
  46057. displayLaserPointer: boolean;
  46058. /**
  46059. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46060. */
  46061. displaySelectionMesh: boolean;
  46062. /**
  46063. * This color will be set to the laser pointer when selection is triggered
  46064. */
  46065. laserPointerPickedColor: Color3;
  46066. /**
  46067. * Default color of the laser pointer
  46068. */
  46069. lasterPointerDefaultColor: Color3;
  46070. /**
  46071. * default color of the selection ring
  46072. */
  46073. selectionMeshDefaultColor: Color3;
  46074. /**
  46075. * This color will be applied to the selection ring when selection is triggered
  46076. */
  46077. selectionMeshPickedColor: Color3;
  46078. /**
  46079. * constructs a new background remover module
  46080. * @param _xrSessionManager the session manager for this module
  46081. * @param _options read-only options to be used in this module
  46082. */
  46083. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46084. /**
  46085. * attach this feature
  46086. * Will usually be called by the features manager
  46087. *
  46088. * @returns true if successful.
  46089. */
  46090. attach(): boolean;
  46091. /**
  46092. * detach this feature.
  46093. * Will usually be called by the features manager
  46094. *
  46095. * @returns true if successful.
  46096. */
  46097. detach(): boolean;
  46098. /**
  46099. * Will get the mesh under a specific pointer.
  46100. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46101. * @param controllerId the controllerId to check
  46102. * @returns The mesh under pointer or null if no mesh is under the pointer
  46103. */
  46104. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46105. /**
  46106. * Get the xr controller that correlates to the pointer id in the pointer event
  46107. *
  46108. * @param id the pointer id to search for
  46109. * @returns the controller that correlates to this id or null if not found
  46110. */
  46111. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46112. protected _onXRFrame(_xrFrame: XRFrame): void;
  46113. private _attachGazeMode;
  46114. private _attachScreenRayMode;
  46115. private _attachTrackedPointerRayMode;
  46116. private _convertNormalToDirectionOfRay;
  46117. private _detachController;
  46118. private _generateNewMeshPair;
  46119. private _pickingMoved;
  46120. private _updatePointerDistance;
  46121. }
  46122. }
  46123. declare module "babylonjs/XR/webXREnterExitUI" {
  46124. import { Nullable } from "babylonjs/types";
  46125. import { Observable } from "babylonjs/Misc/observable";
  46126. import { IDisposable, Scene } from "babylonjs/scene";
  46127. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46128. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46129. /**
  46130. * Button which can be used to enter a different mode of XR
  46131. */
  46132. export class WebXREnterExitUIButton {
  46133. /** button element */
  46134. element: HTMLElement;
  46135. /** XR initialization options for the button */
  46136. sessionMode: XRSessionMode;
  46137. /** Reference space type */
  46138. referenceSpaceType: XRReferenceSpaceType;
  46139. /**
  46140. * Creates a WebXREnterExitUIButton
  46141. * @param element button element
  46142. * @param sessionMode XR initialization session mode
  46143. * @param referenceSpaceType the type of reference space to be used
  46144. */
  46145. constructor(
  46146. /** button element */
  46147. element: HTMLElement,
  46148. /** XR initialization options for the button */
  46149. sessionMode: XRSessionMode,
  46150. /** Reference space type */
  46151. referenceSpaceType: XRReferenceSpaceType);
  46152. /**
  46153. * Extendable function which can be used to update the button's visuals when the state changes
  46154. * @param activeButton the current active button in the UI
  46155. */
  46156. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46157. }
  46158. /**
  46159. * Options to create the webXR UI
  46160. */
  46161. export class WebXREnterExitUIOptions {
  46162. /**
  46163. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46164. */
  46165. customButtons?: Array<WebXREnterExitUIButton>;
  46166. /**
  46167. * A reference space type to use when creating the default button.
  46168. * Default is local-floor
  46169. */
  46170. referenceSpaceType?: XRReferenceSpaceType;
  46171. /**
  46172. * Context to enter xr with
  46173. */
  46174. renderTarget?: Nullable<WebXRRenderTarget>;
  46175. /**
  46176. * A session mode to use when creating the default button.
  46177. * Default is immersive-vr
  46178. */
  46179. sessionMode?: XRSessionMode;
  46180. }
  46181. /**
  46182. * UI to allow the user to enter/exit XR mode
  46183. */
  46184. export class WebXREnterExitUI implements IDisposable {
  46185. private scene;
  46186. /** version of the options passed to this UI */
  46187. options: WebXREnterExitUIOptions;
  46188. private _activeButton;
  46189. private _buttons;
  46190. private _overlay;
  46191. /**
  46192. * Fired every time the active button is changed.
  46193. *
  46194. * When xr is entered via a button that launches xr that button will be the callback parameter
  46195. *
  46196. * When exiting xr the callback parameter will be null)
  46197. */
  46198. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46199. /**
  46200. *
  46201. * @param scene babylon scene object to use
  46202. * @param options (read-only) version of the options passed to this UI
  46203. */
  46204. private constructor();
  46205. /**
  46206. * Creates UI to allow the user to enter/exit XR mode
  46207. * @param scene the scene to add the ui to
  46208. * @param helper the xr experience helper to enter/exit xr with
  46209. * @param options options to configure the UI
  46210. * @returns the created ui
  46211. */
  46212. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46213. /**
  46214. * Disposes of the XR UI component
  46215. */
  46216. dispose(): void;
  46217. private _updateButtons;
  46218. }
  46219. }
  46220. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46221. import { Vector3 } from "babylonjs/Maths/math.vector";
  46222. import { Color4 } from "babylonjs/Maths/math.color";
  46223. import { Nullable } from "babylonjs/types";
  46224. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46225. import { Scene } from "babylonjs/scene";
  46226. /**
  46227. * Class containing static functions to help procedurally build meshes
  46228. */
  46229. export class LinesBuilder {
  46230. /**
  46231. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46232. * * 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
  46233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46234. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46235. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46236. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46237. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46238. * * 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
  46239. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46242. * @param name defines the name of the new line system
  46243. * @param options defines the options used to create the line system
  46244. * @param scene defines the hosting scene
  46245. * @returns a new line system mesh
  46246. */
  46247. static CreateLineSystem(name: string, options: {
  46248. lines: Vector3[][];
  46249. updatable?: boolean;
  46250. instance?: Nullable<LinesMesh>;
  46251. colors?: Nullable<Color4[][]>;
  46252. useVertexAlpha?: boolean;
  46253. }, scene: Nullable<Scene>): LinesMesh;
  46254. /**
  46255. * Creates a line mesh
  46256. * 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
  46257. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46258. * * The parameter `points` is an array successive Vector3
  46259. * * 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
  46260. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46261. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46262. * * When updating an instance, remember that only point positions can change, not the number of points
  46263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46265. * @param name defines the name of the new line system
  46266. * @param options defines the options used to create the line system
  46267. * @param scene defines the hosting scene
  46268. * @returns a new line mesh
  46269. */
  46270. static CreateLines(name: string, options: {
  46271. points: Vector3[];
  46272. updatable?: boolean;
  46273. instance?: Nullable<LinesMesh>;
  46274. colors?: Color4[];
  46275. useVertexAlpha?: boolean;
  46276. }, scene?: Nullable<Scene>): LinesMesh;
  46277. /**
  46278. * Creates a dashed line mesh
  46279. * * 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
  46280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46281. * * The parameter `points` is an array successive Vector3
  46282. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46283. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46284. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46285. * * 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
  46286. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46287. * * When updating an instance, remember that only point positions can change, not the number of points
  46288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46289. * @param name defines the name of the mesh
  46290. * @param options defines the options used to create the mesh
  46291. * @param scene defines the hosting scene
  46292. * @returns the dashed line mesh
  46293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46294. */
  46295. static CreateDashedLines(name: string, options: {
  46296. points: Vector3[];
  46297. dashSize?: number;
  46298. gapSize?: number;
  46299. dashNb?: number;
  46300. updatable?: boolean;
  46301. instance?: LinesMesh;
  46302. useVertexAlpha?: boolean;
  46303. }, scene?: Nullable<Scene>): LinesMesh;
  46304. }
  46305. }
  46306. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46307. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46308. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46309. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46311. import { Vector3 } from "babylonjs/Maths/math.vector";
  46312. import { Material } from "babylonjs/Materials/material";
  46313. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46314. import { Scene } from "babylonjs/scene";
  46315. /**
  46316. * The options container for the teleportation module
  46317. */
  46318. export interface IWebXRTeleportationOptions {
  46319. /**
  46320. * if provided, this scene will be used to render meshes.
  46321. */
  46322. customUtilityLayerScene?: Scene;
  46323. /**
  46324. * Values to configure the default target mesh
  46325. */
  46326. defaultTargetMeshOptions?: {
  46327. /**
  46328. * Fill color of the teleportation area
  46329. */
  46330. teleportationFillColor?: string;
  46331. /**
  46332. * Border color for the teleportation area
  46333. */
  46334. teleportationBorderColor?: string;
  46335. /**
  46336. * Disable the mesh's animation sequence
  46337. */
  46338. disableAnimation?: boolean;
  46339. /**
  46340. * Disable lighting on the material or the ring and arrow
  46341. */
  46342. disableLighting?: boolean;
  46343. /**
  46344. * Override the default material of the torus and arrow
  46345. */
  46346. torusArrowMaterial?: Material;
  46347. };
  46348. /**
  46349. * A list of meshes to use as floor meshes.
  46350. * Meshes can be added and removed after initializing the feature using the
  46351. * addFloorMesh and removeFloorMesh functions
  46352. * If empty, rotation will still work
  46353. */
  46354. floorMeshes?: AbstractMesh[];
  46355. /**
  46356. * use this rendering group id for the meshes (optional)
  46357. */
  46358. renderingGroupId?: number;
  46359. /**
  46360. * Should teleportation move only to snap points
  46361. */
  46362. snapPointsOnly?: boolean;
  46363. /**
  46364. * An array of points to which the teleportation will snap to.
  46365. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46366. */
  46367. snapPositions?: Vector3[];
  46368. /**
  46369. * How close should the teleportation ray be in order to snap to position.
  46370. * Default to 0.8 units (meters)
  46371. */
  46372. snapToPositionRadius?: number;
  46373. /**
  46374. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46375. * If you want to support rotation, make sure your mesh has a direction indicator.
  46376. *
  46377. * When left untouched, the default mesh will be initialized.
  46378. */
  46379. teleportationTargetMesh?: AbstractMesh;
  46380. /**
  46381. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46382. */
  46383. timeToTeleport?: number;
  46384. /**
  46385. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46386. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46387. */
  46388. useMainComponentOnly?: boolean;
  46389. /**
  46390. * Should meshes created here be added to a utility layer or the main scene
  46391. */
  46392. useUtilityLayer?: boolean;
  46393. /**
  46394. * Babylon XR Input class for controller
  46395. */
  46396. xrInput: WebXRInput;
  46397. }
  46398. /**
  46399. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46400. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46401. * the input of the attached controllers.
  46402. */
  46403. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46404. private _options;
  46405. private _controllers;
  46406. private _currentTeleportationControllerId;
  46407. private _floorMeshes;
  46408. private _quadraticBezierCurve;
  46409. private _selectionFeature;
  46410. private _snapToPositions;
  46411. private _snappedToPoint;
  46412. private _teleportationRingMaterial?;
  46413. private _tmpRay;
  46414. private _tmpVector;
  46415. /**
  46416. * The module's name
  46417. */
  46418. static readonly Name: string;
  46419. /**
  46420. * The (Babylon) version of this module.
  46421. * This is an integer representing the implementation version.
  46422. * This number does not correspond to the webxr specs version
  46423. */
  46424. static readonly Version: number;
  46425. /**
  46426. * Is movement backwards enabled
  46427. */
  46428. backwardsMovementEnabled: boolean;
  46429. /**
  46430. * Distance to travel when moving backwards
  46431. */
  46432. backwardsTeleportationDistance: number;
  46433. /**
  46434. * The distance from the user to the inspection point in the direction of the controller
  46435. * A higher number will allow the user to move further
  46436. * defaults to 5 (meters, in xr units)
  46437. */
  46438. parabolicCheckRadius: number;
  46439. /**
  46440. * Should the module support parabolic ray on top of direct ray
  46441. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46442. * Very helpful when moving between floors / different heights
  46443. */
  46444. parabolicRayEnabled: boolean;
  46445. /**
  46446. * How much rotation should be applied when rotating right and left
  46447. */
  46448. rotationAngle: number;
  46449. /**
  46450. * Is rotation enabled when moving forward?
  46451. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46452. */
  46453. rotationEnabled: boolean;
  46454. /**
  46455. * constructs a new anchor system
  46456. * @param _xrSessionManager an instance of WebXRSessionManager
  46457. * @param _options configuration object for this feature
  46458. */
  46459. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46460. /**
  46461. * Get the snapPointsOnly flag
  46462. */
  46463. get snapPointsOnly(): boolean;
  46464. /**
  46465. * Sets the snapPointsOnly flag
  46466. * @param snapToPoints should teleportation be exclusively to snap points
  46467. */
  46468. set snapPointsOnly(snapToPoints: boolean);
  46469. /**
  46470. * Add a new mesh to the floor meshes array
  46471. * @param mesh the mesh to use as floor mesh
  46472. */
  46473. addFloorMesh(mesh: AbstractMesh): void;
  46474. /**
  46475. * Add a new snap-to point to fix teleportation to this position
  46476. * @param newSnapPoint The new Snap-To point
  46477. */
  46478. addSnapPoint(newSnapPoint: Vector3): void;
  46479. attach(): boolean;
  46480. detach(): boolean;
  46481. dispose(): void;
  46482. /**
  46483. * Remove a mesh from the floor meshes array
  46484. * @param mesh the mesh to remove
  46485. */
  46486. removeFloorMesh(mesh: AbstractMesh): void;
  46487. /**
  46488. * Remove a mesh from the floor meshes array using its name
  46489. * @param name the mesh name to remove
  46490. */
  46491. removeFloorMeshByName(name: string): void;
  46492. /**
  46493. * 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
  46494. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46495. * @returns was the point found and removed or not
  46496. */
  46497. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46498. /**
  46499. * This function sets a selection feature that will be disabled when
  46500. * the forward ray is shown and will be reattached when hidden.
  46501. * This is used to remove the selection rays when moving.
  46502. * @param selectionFeature the feature to disable when forward movement is enabled
  46503. */
  46504. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46505. protected _onXRFrame(_xrFrame: XRFrame): void;
  46506. private _attachController;
  46507. private _createDefaultTargetMesh;
  46508. private _detachController;
  46509. private _findClosestSnapPointWithRadius;
  46510. private _setTargetMeshPosition;
  46511. private _setTargetMeshVisibility;
  46512. private _showParabolicPath;
  46513. private _teleportForward;
  46514. }
  46515. }
  46516. declare module "babylonjs/XR/webXRDefaultExperience" {
  46517. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46518. import { Scene } from "babylonjs/scene";
  46519. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46520. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46521. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46522. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46524. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46525. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46526. /**
  46527. * Options for the default xr helper
  46528. */
  46529. export class WebXRDefaultExperienceOptions {
  46530. /**
  46531. * Enable or disable default UI to enter XR
  46532. */
  46533. disableDefaultUI?: boolean;
  46534. /**
  46535. * Should teleportation not initialize. defaults to false.
  46536. */
  46537. disableTeleportation?: boolean;
  46538. /**
  46539. * Floor meshes that will be used for teleport
  46540. */
  46541. floorMeshes?: Array<AbstractMesh>;
  46542. /**
  46543. * If set to true, the first frame will not be used to reset position
  46544. * The first frame is mainly used when copying transformation from the old camera
  46545. * Mainly used in AR
  46546. */
  46547. ignoreNativeCameraTransformation?: boolean;
  46548. /**
  46549. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46550. */
  46551. inputOptions?: IWebXRInputOptions;
  46552. /**
  46553. * optional configuration for the output canvas
  46554. */
  46555. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46556. /**
  46557. * optional UI options. This can be used among other to change session mode and reference space type
  46558. */
  46559. uiOptions?: WebXREnterExitUIOptions;
  46560. /**
  46561. * When loading teleportation and pointer select, use stable versions instead of latest.
  46562. */
  46563. useStablePlugins?: boolean;
  46564. }
  46565. /**
  46566. * Default experience which provides a similar setup to the previous webVRExperience
  46567. */
  46568. export class WebXRDefaultExperience {
  46569. /**
  46570. * Base experience
  46571. */
  46572. baseExperience: WebXRExperienceHelper;
  46573. /**
  46574. * Enables ui for entering/exiting xr
  46575. */
  46576. enterExitUI: WebXREnterExitUI;
  46577. /**
  46578. * Input experience extension
  46579. */
  46580. input: WebXRInput;
  46581. /**
  46582. * Enables laser pointer and selection
  46583. */
  46584. pointerSelection: WebXRControllerPointerSelection;
  46585. /**
  46586. * Default target xr should render to
  46587. */
  46588. renderTarget: WebXRRenderTarget;
  46589. /**
  46590. * Enables teleportation
  46591. */
  46592. teleportation: WebXRMotionControllerTeleportation;
  46593. private constructor();
  46594. /**
  46595. * Creates the default xr experience
  46596. * @param scene scene
  46597. * @param options options for basic configuration
  46598. * @returns resulting WebXRDefaultExperience
  46599. */
  46600. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46601. /**
  46602. * DIsposes of the experience helper
  46603. */
  46604. dispose(): void;
  46605. }
  46606. }
  46607. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46608. import { Observable } from "babylonjs/Misc/observable";
  46609. import { Nullable } from "babylonjs/types";
  46610. import { Camera } from "babylonjs/Cameras/camera";
  46611. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46612. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46613. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46614. import { Scene } from "babylonjs/scene";
  46615. import { Vector3 } from "babylonjs/Maths/math.vector";
  46616. import { Color3 } from "babylonjs/Maths/math.color";
  46617. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46619. import { Mesh } from "babylonjs/Meshes/mesh";
  46620. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46621. import { EasingFunction } from "babylonjs/Animations/easing";
  46622. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46623. import "babylonjs/Meshes/Builders/groundBuilder";
  46624. import "babylonjs/Meshes/Builders/torusBuilder";
  46625. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46626. import "babylonjs/Gamepads/gamepadSceneComponent";
  46627. import "babylonjs/Animations/animatable";
  46628. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46629. /**
  46630. * Options to modify the vr teleportation behavior.
  46631. */
  46632. export interface VRTeleportationOptions {
  46633. /**
  46634. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46635. */
  46636. floorMeshName?: string;
  46637. /**
  46638. * A list of meshes to be used as the teleportation floor. (default: empty)
  46639. */
  46640. floorMeshes?: Mesh[];
  46641. /**
  46642. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46643. */
  46644. teleportationMode?: number;
  46645. /**
  46646. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46647. */
  46648. teleportationTime?: number;
  46649. /**
  46650. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46651. */
  46652. teleportationSpeed?: number;
  46653. /**
  46654. * The easing function used in the animation or null for Linear. (default CircleEase)
  46655. */
  46656. easingFunction?: EasingFunction;
  46657. }
  46658. /**
  46659. * Options to modify the vr experience helper's behavior.
  46660. */
  46661. export interface VRExperienceHelperOptions extends WebVROptions {
  46662. /**
  46663. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46664. */
  46665. createDeviceOrientationCamera?: boolean;
  46666. /**
  46667. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46668. */
  46669. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46670. /**
  46671. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46672. */
  46673. laserToggle?: boolean;
  46674. /**
  46675. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46676. */
  46677. floorMeshes?: Mesh[];
  46678. /**
  46679. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46680. */
  46681. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46682. /**
  46683. * Defines if WebXR should be used instead of WebVR (if available)
  46684. */
  46685. useXR?: boolean;
  46686. }
  46687. /**
  46688. * Event containing information after VR has been entered
  46689. */
  46690. export class OnAfterEnteringVRObservableEvent {
  46691. /**
  46692. * If entering vr was successful
  46693. */
  46694. success: boolean;
  46695. }
  46696. /**
  46697. * Helps to quickly add VR support to an existing scene.
  46698. * See http://doc.babylonjs.com/how_to/webvr_helper
  46699. */
  46700. export class VRExperienceHelper {
  46701. /** Options to modify the vr experience helper's behavior. */
  46702. webVROptions: VRExperienceHelperOptions;
  46703. private _scene;
  46704. private _position;
  46705. private _btnVR;
  46706. private _btnVRDisplayed;
  46707. private _webVRsupported;
  46708. private _webVRready;
  46709. private _webVRrequesting;
  46710. private _webVRpresenting;
  46711. private _hasEnteredVR;
  46712. private _fullscreenVRpresenting;
  46713. private _inputElement;
  46714. private _webVRCamera;
  46715. private _vrDeviceOrientationCamera;
  46716. private _deviceOrientationCamera;
  46717. private _existingCamera;
  46718. private _onKeyDown;
  46719. private _onVrDisplayPresentChange;
  46720. private _onVRDisplayChanged;
  46721. private _onVRRequestPresentStart;
  46722. private _onVRRequestPresentComplete;
  46723. /**
  46724. * 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)
  46725. */
  46726. enableGazeEvenWhenNoPointerLock: boolean;
  46727. /**
  46728. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46729. */
  46730. exitVROnDoubleTap: boolean;
  46731. /**
  46732. * Observable raised right before entering VR.
  46733. */
  46734. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46735. /**
  46736. * Observable raised when entering VR has completed.
  46737. */
  46738. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46739. /**
  46740. * Observable raised when exiting VR.
  46741. */
  46742. onExitingVRObservable: Observable<VRExperienceHelper>;
  46743. /**
  46744. * Observable raised when controller mesh is loaded.
  46745. */
  46746. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46747. /** Return this.onEnteringVRObservable
  46748. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46749. */
  46750. get onEnteringVR(): Observable<VRExperienceHelper>;
  46751. /** Return this.onExitingVRObservable
  46752. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46753. */
  46754. get onExitingVR(): Observable<VRExperienceHelper>;
  46755. /** Return this.onControllerMeshLoadedObservable
  46756. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46757. */
  46758. get onControllerMeshLoaded(): Observable<WebVRController>;
  46759. private _rayLength;
  46760. private _useCustomVRButton;
  46761. private _teleportationRequested;
  46762. private _teleportActive;
  46763. private _floorMeshName;
  46764. private _floorMeshesCollection;
  46765. private _teleportationMode;
  46766. private _teleportationTime;
  46767. private _teleportationSpeed;
  46768. private _teleportationEasing;
  46769. private _rotationAllowed;
  46770. private _teleportBackwardsVector;
  46771. private _teleportationTarget;
  46772. private _isDefaultTeleportationTarget;
  46773. private _postProcessMove;
  46774. private _teleportationFillColor;
  46775. private _teleportationBorderColor;
  46776. private _rotationAngle;
  46777. private _haloCenter;
  46778. private _cameraGazer;
  46779. private _padSensibilityUp;
  46780. private _padSensibilityDown;
  46781. private _leftController;
  46782. private _rightController;
  46783. private _gazeColor;
  46784. private _laserColor;
  46785. private _pickedLaserColor;
  46786. private _pickedGazeColor;
  46787. /**
  46788. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46789. */
  46790. onNewMeshSelected: Observable<AbstractMesh>;
  46791. /**
  46792. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46793. * This observable will provide the mesh and the controller used to select the mesh
  46794. */
  46795. onMeshSelectedWithController: Observable<{
  46796. mesh: AbstractMesh;
  46797. controller: WebVRController;
  46798. }>;
  46799. /**
  46800. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46801. */
  46802. onNewMeshPicked: Observable<PickingInfo>;
  46803. private _circleEase;
  46804. /**
  46805. * Observable raised before camera teleportation
  46806. */
  46807. onBeforeCameraTeleport: Observable<Vector3>;
  46808. /**
  46809. * Observable raised after camera teleportation
  46810. */
  46811. onAfterCameraTeleport: Observable<Vector3>;
  46812. /**
  46813. * Observable raised when current selected mesh gets unselected
  46814. */
  46815. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46816. private _raySelectionPredicate;
  46817. /**
  46818. * To be optionaly changed by user to define custom ray selection
  46819. */
  46820. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46821. /**
  46822. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46823. */
  46824. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46825. /**
  46826. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46827. */
  46828. teleportationEnabled: boolean;
  46829. private _defaultHeight;
  46830. private _teleportationInitialized;
  46831. private _interactionsEnabled;
  46832. private _interactionsRequested;
  46833. private _displayGaze;
  46834. private _displayLaserPointer;
  46835. /**
  46836. * The mesh used to display where the user is going to teleport.
  46837. */
  46838. get teleportationTarget(): Mesh;
  46839. /**
  46840. * Sets the mesh to be used to display where the user is going to teleport.
  46841. */
  46842. set teleportationTarget(value: Mesh);
  46843. /**
  46844. * 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
  46845. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46846. * See http://doc.babylonjs.com/resources/baking_transformations
  46847. */
  46848. get gazeTrackerMesh(): Mesh;
  46849. set gazeTrackerMesh(value: Mesh);
  46850. /**
  46851. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46852. */
  46853. updateGazeTrackerScale: boolean;
  46854. /**
  46855. * If the gaze trackers color should be updated when selecting meshes
  46856. */
  46857. updateGazeTrackerColor: boolean;
  46858. /**
  46859. * If the controller laser color should be updated when selecting meshes
  46860. */
  46861. updateControllerLaserColor: boolean;
  46862. /**
  46863. * The gaze tracking mesh corresponding to the left controller
  46864. */
  46865. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46866. /**
  46867. * The gaze tracking mesh corresponding to the right controller
  46868. */
  46869. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46870. /**
  46871. * If the ray of the gaze should be displayed.
  46872. */
  46873. get displayGaze(): boolean;
  46874. /**
  46875. * Sets if the ray of the gaze should be displayed.
  46876. */
  46877. set displayGaze(value: boolean);
  46878. /**
  46879. * If the ray of the LaserPointer should be displayed.
  46880. */
  46881. get displayLaserPointer(): boolean;
  46882. /**
  46883. * Sets if the ray of the LaserPointer should be displayed.
  46884. */
  46885. set displayLaserPointer(value: boolean);
  46886. /**
  46887. * The deviceOrientationCamera used as the camera when not in VR.
  46888. */
  46889. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46890. /**
  46891. * Based on the current WebVR support, returns the current VR camera used.
  46892. */
  46893. get currentVRCamera(): Nullable<Camera>;
  46894. /**
  46895. * The webVRCamera which is used when in VR.
  46896. */
  46897. get webVRCamera(): WebVRFreeCamera;
  46898. /**
  46899. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46900. */
  46901. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46902. /**
  46903. * The html button that is used to trigger entering into VR.
  46904. */
  46905. get vrButton(): Nullable<HTMLButtonElement>;
  46906. private get _teleportationRequestInitiated();
  46907. /**
  46908. * Defines whether or not Pointer lock should be requested when switching to
  46909. * full screen.
  46910. */
  46911. requestPointerLockOnFullScreen: boolean;
  46912. /**
  46913. * If asking to force XR, this will be populated with the default xr experience
  46914. */
  46915. xr: WebXRDefaultExperience;
  46916. /**
  46917. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46918. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46919. */
  46920. xrTestDone: boolean;
  46921. /**
  46922. * Instantiates a VRExperienceHelper.
  46923. * Helps to quickly add VR support to an existing scene.
  46924. * @param scene The scene the VRExperienceHelper belongs to.
  46925. * @param webVROptions Options to modify the vr experience helper's behavior.
  46926. */
  46927. constructor(scene: Scene,
  46928. /** Options to modify the vr experience helper's behavior. */
  46929. webVROptions?: VRExperienceHelperOptions);
  46930. private completeVRInit;
  46931. private _onDefaultMeshLoaded;
  46932. private _onResize;
  46933. private _onFullscreenChange;
  46934. /**
  46935. * Gets a value indicating if we are currently in VR mode.
  46936. */
  46937. get isInVRMode(): boolean;
  46938. private onVrDisplayPresentChange;
  46939. private onVRDisplayChanged;
  46940. private moveButtonToBottomRight;
  46941. private displayVRButton;
  46942. private updateButtonVisibility;
  46943. private _cachedAngularSensibility;
  46944. /**
  46945. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46946. * Otherwise, will use the fullscreen API.
  46947. */
  46948. enterVR(): void;
  46949. /**
  46950. * Attempt to exit VR, or fullscreen.
  46951. */
  46952. exitVR(): void;
  46953. /**
  46954. * The position of the vr experience helper.
  46955. */
  46956. get position(): Vector3;
  46957. /**
  46958. * Sets the position of the vr experience helper.
  46959. */
  46960. set position(value: Vector3);
  46961. /**
  46962. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46963. */
  46964. enableInteractions(): void;
  46965. private get _noControllerIsActive();
  46966. private beforeRender;
  46967. private _isTeleportationFloor;
  46968. /**
  46969. * Adds a floor mesh to be used for teleportation.
  46970. * @param floorMesh the mesh to be used for teleportation.
  46971. */
  46972. addFloorMesh(floorMesh: Mesh): void;
  46973. /**
  46974. * Removes a floor mesh from being used for teleportation.
  46975. * @param floorMesh the mesh to be removed.
  46976. */
  46977. removeFloorMesh(floorMesh: Mesh): void;
  46978. /**
  46979. * Enables interactions and teleportation using the VR controllers and gaze.
  46980. * @param vrTeleportationOptions options to modify teleportation behavior.
  46981. */
  46982. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46983. private _onNewGamepadConnected;
  46984. private _tryEnableInteractionOnController;
  46985. private _onNewGamepadDisconnected;
  46986. private _enableInteractionOnController;
  46987. private _checkTeleportWithRay;
  46988. private _checkRotate;
  46989. private _checkTeleportBackwards;
  46990. private _enableTeleportationOnController;
  46991. private _createTeleportationCircles;
  46992. private _displayTeleportationTarget;
  46993. private _hideTeleportationTarget;
  46994. private _rotateCamera;
  46995. private _moveTeleportationSelectorTo;
  46996. private _workingVector;
  46997. private _workingQuaternion;
  46998. private _workingMatrix;
  46999. /**
  47000. * Time Constant Teleportation Mode
  47001. */
  47002. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47003. /**
  47004. * Speed Constant Teleportation Mode
  47005. */
  47006. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47007. /**
  47008. * Teleports the users feet to the desired location
  47009. * @param location The location where the user's feet should be placed
  47010. */
  47011. teleportCamera(location: Vector3): void;
  47012. private _convertNormalToDirectionOfRay;
  47013. private _castRayAndSelectObject;
  47014. private _notifySelectedMeshUnselected;
  47015. /**
  47016. * Permanently set new colors for the laser pointer
  47017. * @param color the new laser color
  47018. * @param pickedColor the new laser color when picked mesh detected
  47019. */
  47020. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47021. /**
  47022. * Set lighting enabled / disabled on the laser pointer of both controllers
  47023. * @param enabled should the lighting be enabled on the laser pointer
  47024. */
  47025. setLaserLightingState(enabled?: boolean): void;
  47026. /**
  47027. * Permanently set new colors for the gaze pointer
  47028. * @param color the new gaze color
  47029. * @param pickedColor the new gaze color when picked mesh detected
  47030. */
  47031. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47032. /**
  47033. * Sets the color of the laser ray from the vr controllers.
  47034. * @param color new color for the ray.
  47035. */
  47036. changeLaserColor(color: Color3): void;
  47037. /**
  47038. * Sets the color of the ray from the vr headsets gaze.
  47039. * @param color new color for the ray.
  47040. */
  47041. changeGazeColor(color: Color3): void;
  47042. /**
  47043. * Exits VR and disposes of the vr experience helper
  47044. */
  47045. dispose(): void;
  47046. /**
  47047. * Gets the name of the VRExperienceHelper class
  47048. * @returns "VRExperienceHelper"
  47049. */
  47050. getClassName(): string;
  47051. }
  47052. }
  47053. declare module "babylonjs/Cameras/VR/index" {
  47054. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47055. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47056. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47057. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47058. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47059. export * from "babylonjs/Cameras/VR/webVRCamera";
  47060. }
  47061. declare module "babylonjs/Cameras/RigModes/index" {
  47062. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47063. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47064. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47065. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47066. }
  47067. declare module "babylonjs/Cameras/index" {
  47068. export * from "babylonjs/Cameras/Inputs/index";
  47069. export * from "babylonjs/Cameras/cameraInputsManager";
  47070. export * from "babylonjs/Cameras/camera";
  47071. export * from "babylonjs/Cameras/targetCamera";
  47072. export * from "babylonjs/Cameras/freeCamera";
  47073. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47074. export * from "babylonjs/Cameras/touchCamera";
  47075. export * from "babylonjs/Cameras/arcRotateCamera";
  47076. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47077. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47078. export * from "babylonjs/Cameras/flyCamera";
  47079. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47080. export * from "babylonjs/Cameras/followCamera";
  47081. export * from "babylonjs/Cameras/followCameraInputsManager";
  47082. export * from "babylonjs/Cameras/gamepadCamera";
  47083. export * from "babylonjs/Cameras/Stereoscopic/index";
  47084. export * from "babylonjs/Cameras/universalCamera";
  47085. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47086. export * from "babylonjs/Cameras/VR/index";
  47087. export * from "babylonjs/Cameras/RigModes/index";
  47088. }
  47089. declare module "babylonjs/Collisions/index" {
  47090. export * from "babylonjs/Collisions/collider";
  47091. export * from "babylonjs/Collisions/collisionCoordinator";
  47092. export * from "babylonjs/Collisions/pickingInfo";
  47093. export * from "babylonjs/Collisions/intersectionInfo";
  47094. export * from "babylonjs/Collisions/meshCollisionData";
  47095. }
  47096. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47097. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47098. import { Vector3 } from "babylonjs/Maths/math.vector";
  47099. import { Ray } from "babylonjs/Culling/ray";
  47100. import { Plane } from "babylonjs/Maths/math.plane";
  47101. /**
  47102. * Contains an array of blocks representing the octree
  47103. */
  47104. export interface IOctreeContainer<T> {
  47105. /**
  47106. * Blocks within the octree
  47107. */
  47108. blocks: Array<OctreeBlock<T>>;
  47109. }
  47110. /**
  47111. * Class used to store a cell in an octree
  47112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47113. */
  47114. export class OctreeBlock<T> {
  47115. /**
  47116. * Gets the content of the current block
  47117. */
  47118. entries: T[];
  47119. /**
  47120. * Gets the list of block children
  47121. */
  47122. blocks: Array<OctreeBlock<T>>;
  47123. private _depth;
  47124. private _maxDepth;
  47125. private _capacity;
  47126. private _minPoint;
  47127. private _maxPoint;
  47128. private _boundingVectors;
  47129. private _creationFunc;
  47130. /**
  47131. * Creates a new block
  47132. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47133. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47134. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47135. * @param depth defines the current depth of this block in the octree
  47136. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47137. * @param creationFunc defines a callback to call when an element is added to the block
  47138. */
  47139. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47140. /**
  47141. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47142. */
  47143. get capacity(): number;
  47144. /**
  47145. * Gets the minimum vector (in world space) of the block's bounding box
  47146. */
  47147. get minPoint(): Vector3;
  47148. /**
  47149. * Gets the maximum vector (in world space) of the block's bounding box
  47150. */
  47151. get maxPoint(): Vector3;
  47152. /**
  47153. * Add a new element to this block
  47154. * @param entry defines the element to add
  47155. */
  47156. addEntry(entry: T): void;
  47157. /**
  47158. * Remove an element from this block
  47159. * @param entry defines the element to remove
  47160. */
  47161. removeEntry(entry: T): void;
  47162. /**
  47163. * Add an array of elements to this block
  47164. * @param entries defines the array of elements to add
  47165. */
  47166. addEntries(entries: T[]): void;
  47167. /**
  47168. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47169. * @param frustumPlanes defines the frustum planes to test
  47170. * @param selection defines the array to store current content if selection is positive
  47171. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47172. */
  47173. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47174. /**
  47175. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47176. * @param sphereCenter defines the bounding sphere center
  47177. * @param sphereRadius defines the bounding sphere radius
  47178. * @param selection defines the array to store current content if selection is positive
  47179. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47180. */
  47181. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47182. /**
  47183. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47184. * @param ray defines the ray to test with
  47185. * @param selection defines the array to store current content if selection is positive
  47186. */
  47187. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47188. /**
  47189. * Subdivide the content into child blocks (this block will then be empty)
  47190. */
  47191. createInnerBlocks(): void;
  47192. /**
  47193. * @hidden
  47194. */
  47195. 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;
  47196. }
  47197. }
  47198. declare module "babylonjs/Culling/Octrees/octree" {
  47199. import { SmartArray } from "babylonjs/Misc/smartArray";
  47200. import { Vector3 } from "babylonjs/Maths/math.vector";
  47201. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47203. import { Ray } from "babylonjs/Culling/ray";
  47204. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47205. import { Plane } from "babylonjs/Maths/math.plane";
  47206. /**
  47207. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47208. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47209. */
  47210. export class Octree<T> {
  47211. /** 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.) */
  47212. maxDepth: number;
  47213. /**
  47214. * Blocks within the octree containing objects
  47215. */
  47216. blocks: Array<OctreeBlock<T>>;
  47217. /**
  47218. * Content stored in the octree
  47219. */
  47220. dynamicContent: T[];
  47221. private _maxBlockCapacity;
  47222. private _selectionContent;
  47223. private _creationFunc;
  47224. /**
  47225. * Creates a octree
  47226. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47227. * @param creationFunc function to be used to instatiate the octree
  47228. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47229. * @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.)
  47230. */
  47231. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47232. /** 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.) */
  47233. maxDepth?: number);
  47234. /**
  47235. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47236. * @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);
  47237. * @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);
  47238. * @param entries meshes to be added to the octree blocks
  47239. */
  47240. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47241. /**
  47242. * Adds a mesh to the octree
  47243. * @param entry Mesh to add to the octree
  47244. */
  47245. addMesh(entry: T): void;
  47246. /**
  47247. * Remove an element from the octree
  47248. * @param entry defines the element to remove
  47249. */
  47250. removeMesh(entry: T): void;
  47251. /**
  47252. * Selects an array of meshes within the frustum
  47253. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47254. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47255. * @returns array of meshes within the frustum
  47256. */
  47257. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47258. /**
  47259. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47260. * @param sphereCenter defines the bounding sphere center
  47261. * @param sphereRadius defines the bounding sphere radius
  47262. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47263. * @returns an array of objects that intersect the sphere
  47264. */
  47265. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47266. /**
  47267. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47268. * @param ray defines the ray to test with
  47269. * @returns array of intersected objects
  47270. */
  47271. intersectsRay(ray: Ray): SmartArray<T>;
  47272. /**
  47273. * Adds a mesh into the octree block if it intersects the block
  47274. */
  47275. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47276. /**
  47277. * Adds a submesh into the octree block if it intersects the block
  47278. */
  47279. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47283. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47284. import { Scene } from "babylonjs/scene";
  47285. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47287. import { Ray } from "babylonjs/Culling/ray";
  47288. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47289. import { Collider } from "babylonjs/Collisions/collider";
  47290. module "babylonjs/scene" {
  47291. interface Scene {
  47292. /**
  47293. * @hidden
  47294. * Backing Filed
  47295. */
  47296. _selectionOctree: Octree<AbstractMesh>;
  47297. /**
  47298. * Gets the octree used to boost mesh selection (picking)
  47299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47300. */
  47301. selectionOctree: Octree<AbstractMesh>;
  47302. /**
  47303. * Creates or updates the octree used to boost selection (picking)
  47304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47305. * @param maxCapacity defines the maximum capacity per leaf
  47306. * @param maxDepth defines the maximum depth of the octree
  47307. * @returns an octree of AbstractMesh
  47308. */
  47309. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47310. }
  47311. }
  47312. module "babylonjs/Meshes/abstractMesh" {
  47313. interface AbstractMesh {
  47314. /**
  47315. * @hidden
  47316. * Backing Field
  47317. */
  47318. _submeshesOctree: Octree<SubMesh>;
  47319. /**
  47320. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47321. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47322. * @param maxCapacity defines the maximum size of each block (64 by default)
  47323. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47324. * @returns the new octree
  47325. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47327. */
  47328. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47329. }
  47330. }
  47331. /**
  47332. * Defines the octree scene component responsible to manage any octrees
  47333. * in a given scene.
  47334. */
  47335. export class OctreeSceneComponent {
  47336. /**
  47337. * The component name help to identify the component in the list of scene components.
  47338. */
  47339. readonly name: string;
  47340. /**
  47341. * The scene the component belongs to.
  47342. */
  47343. scene: Scene;
  47344. /**
  47345. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47346. */
  47347. readonly checksIsEnabled: boolean;
  47348. /**
  47349. * Creates a new instance of the component for the given scene
  47350. * @param scene Defines the scene to register the component in
  47351. */
  47352. constructor(scene: Scene);
  47353. /**
  47354. * Registers the component in a given scene
  47355. */
  47356. register(): void;
  47357. /**
  47358. * Return the list of active meshes
  47359. * @returns the list of active meshes
  47360. */
  47361. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47362. /**
  47363. * Return the list of active sub meshes
  47364. * @param mesh The mesh to get the candidates sub meshes from
  47365. * @returns the list of active sub meshes
  47366. */
  47367. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47368. private _tempRay;
  47369. /**
  47370. * Return the list of sub meshes intersecting with a given local ray
  47371. * @param mesh defines the mesh to find the submesh for
  47372. * @param localRay defines the ray in local space
  47373. * @returns the list of intersecting sub meshes
  47374. */
  47375. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47376. /**
  47377. * Return the list of sub meshes colliding with a collider
  47378. * @param mesh defines the mesh to find the submesh for
  47379. * @param collider defines the collider to evaluate the collision against
  47380. * @returns the list of colliding sub meshes
  47381. */
  47382. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47383. /**
  47384. * Rebuilds the elements related to this component in case of
  47385. * context lost for instance.
  47386. */
  47387. rebuild(): void;
  47388. /**
  47389. * Disposes the component and the associated ressources.
  47390. */
  47391. dispose(): void;
  47392. }
  47393. }
  47394. declare module "babylonjs/Culling/Octrees/index" {
  47395. export * from "babylonjs/Culling/Octrees/octree";
  47396. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47397. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47398. }
  47399. declare module "babylonjs/Culling/index" {
  47400. export * from "babylonjs/Culling/boundingBox";
  47401. export * from "babylonjs/Culling/boundingInfo";
  47402. export * from "babylonjs/Culling/boundingSphere";
  47403. export * from "babylonjs/Culling/Octrees/index";
  47404. export * from "babylonjs/Culling/ray";
  47405. }
  47406. declare module "babylonjs/Gizmos/gizmo" {
  47407. import { Nullable } from "babylonjs/types";
  47408. import { IDisposable } from "babylonjs/scene";
  47409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47410. import { Mesh } from "babylonjs/Meshes/mesh";
  47411. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47412. /**
  47413. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47414. */
  47415. export class Gizmo implements IDisposable {
  47416. /** The utility layer the gizmo will be added to */
  47417. gizmoLayer: UtilityLayerRenderer;
  47418. /**
  47419. * The root mesh of the gizmo
  47420. */
  47421. _rootMesh: Mesh;
  47422. private _attachedMesh;
  47423. /**
  47424. * Ratio for the scale of the gizmo (Default: 1)
  47425. */
  47426. scaleRatio: number;
  47427. /**
  47428. * If a custom mesh has been set (Default: false)
  47429. */
  47430. protected _customMeshSet: boolean;
  47431. /**
  47432. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47433. * * When set, interactions will be enabled
  47434. */
  47435. get attachedMesh(): Nullable<AbstractMesh>;
  47436. set attachedMesh(value: Nullable<AbstractMesh>);
  47437. /**
  47438. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47439. * @param mesh The mesh to replace the default mesh of the gizmo
  47440. */
  47441. setCustomMesh(mesh: Mesh): void;
  47442. /**
  47443. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47444. */
  47445. updateGizmoRotationToMatchAttachedMesh: boolean;
  47446. /**
  47447. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47448. */
  47449. updateGizmoPositionToMatchAttachedMesh: boolean;
  47450. /**
  47451. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47452. */
  47453. updateScale: boolean;
  47454. protected _interactionsEnabled: boolean;
  47455. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47456. private _beforeRenderObserver;
  47457. private _tempVector;
  47458. /**
  47459. * Creates a gizmo
  47460. * @param gizmoLayer The utility layer the gizmo will be added to
  47461. */
  47462. constructor(
  47463. /** The utility layer the gizmo will be added to */
  47464. gizmoLayer?: UtilityLayerRenderer);
  47465. /**
  47466. * Updates the gizmo to match the attached mesh's position/rotation
  47467. */
  47468. protected _update(): void;
  47469. /**
  47470. * Disposes of the gizmo
  47471. */
  47472. dispose(): void;
  47473. }
  47474. }
  47475. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47476. import { Observable } from "babylonjs/Misc/observable";
  47477. import { Nullable } from "babylonjs/types";
  47478. import { Vector3 } from "babylonjs/Maths/math.vector";
  47479. import { Color3 } from "babylonjs/Maths/math.color";
  47480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47482. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47483. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47484. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47485. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47486. import { Scene } from "babylonjs/scene";
  47487. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47488. /**
  47489. * Single plane drag gizmo
  47490. */
  47491. export class PlaneDragGizmo extends Gizmo {
  47492. /**
  47493. * Drag behavior responsible for the gizmos dragging interactions
  47494. */
  47495. dragBehavior: PointerDragBehavior;
  47496. private _pointerObserver;
  47497. /**
  47498. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47499. */
  47500. snapDistance: number;
  47501. /**
  47502. * Event that fires each time the gizmo snaps to a new location.
  47503. * * snapDistance is the the change in distance
  47504. */
  47505. onSnapObservable: Observable<{
  47506. snapDistance: number;
  47507. }>;
  47508. private _plane;
  47509. private _coloredMaterial;
  47510. private _hoverMaterial;
  47511. private _isEnabled;
  47512. private _parent;
  47513. /** @hidden */
  47514. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47515. /** @hidden */
  47516. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47517. /**
  47518. * Creates a PlaneDragGizmo
  47519. * @param gizmoLayer The utility layer the gizmo will be added to
  47520. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47521. * @param color The color of the gizmo
  47522. */
  47523. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47524. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47525. /**
  47526. * If the gizmo is enabled
  47527. */
  47528. set isEnabled(value: boolean);
  47529. get isEnabled(): boolean;
  47530. /**
  47531. * Disposes of the gizmo
  47532. */
  47533. dispose(): void;
  47534. }
  47535. }
  47536. declare module "babylonjs/Gizmos/positionGizmo" {
  47537. import { Observable } from "babylonjs/Misc/observable";
  47538. import { Nullable } from "babylonjs/types";
  47539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47540. import { Mesh } from "babylonjs/Meshes/mesh";
  47541. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47542. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47543. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47544. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47545. /**
  47546. * Gizmo that enables dragging a mesh along 3 axis
  47547. */
  47548. export class PositionGizmo extends Gizmo {
  47549. /**
  47550. * Internal gizmo used for interactions on the x axis
  47551. */
  47552. xGizmo: AxisDragGizmo;
  47553. /**
  47554. * Internal gizmo used for interactions on the y axis
  47555. */
  47556. yGizmo: AxisDragGizmo;
  47557. /**
  47558. * Internal gizmo used for interactions on the z axis
  47559. */
  47560. zGizmo: AxisDragGizmo;
  47561. /**
  47562. * Internal gizmo used for interactions on the yz plane
  47563. */
  47564. xPlaneGizmo: PlaneDragGizmo;
  47565. /**
  47566. * Internal gizmo used for interactions on the xz plane
  47567. */
  47568. yPlaneGizmo: PlaneDragGizmo;
  47569. /**
  47570. * Internal gizmo used for interactions on the xy plane
  47571. */
  47572. zPlaneGizmo: PlaneDragGizmo;
  47573. /**
  47574. * private variables
  47575. */
  47576. private _meshAttached;
  47577. private _updateGizmoRotationToMatchAttachedMesh;
  47578. private _snapDistance;
  47579. private _scaleRatio;
  47580. /** Fires an event when any of it's sub gizmos are dragged */
  47581. onDragStartObservable: Observable<unknown>;
  47582. /** Fires an event when any of it's sub gizmos are released from dragging */
  47583. onDragEndObservable: Observable<unknown>;
  47584. /**
  47585. * If set to true, planar drag is enabled
  47586. */
  47587. private _planarGizmoEnabled;
  47588. get attachedMesh(): Nullable<AbstractMesh>;
  47589. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47590. /**
  47591. * Creates a PositionGizmo
  47592. * @param gizmoLayer The utility layer the gizmo will be added to
  47593. */
  47594. constructor(gizmoLayer?: UtilityLayerRenderer);
  47595. /**
  47596. * If the planar drag gizmo is enabled
  47597. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47598. */
  47599. set planarGizmoEnabled(value: boolean);
  47600. get planarGizmoEnabled(): boolean;
  47601. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47602. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47603. /**
  47604. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47605. */
  47606. set snapDistance(value: number);
  47607. get snapDistance(): number;
  47608. /**
  47609. * Ratio for the scale of the gizmo (Default: 1)
  47610. */
  47611. set scaleRatio(value: number);
  47612. get scaleRatio(): number;
  47613. /**
  47614. * Disposes of the gizmo
  47615. */
  47616. dispose(): void;
  47617. /**
  47618. * CustomMeshes are not supported by this gizmo
  47619. * @param mesh The mesh to replace the default mesh of the gizmo
  47620. */
  47621. setCustomMesh(mesh: Mesh): void;
  47622. }
  47623. }
  47624. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47625. import { Observable } from "babylonjs/Misc/observable";
  47626. import { Nullable } from "babylonjs/types";
  47627. import { Vector3 } from "babylonjs/Maths/math.vector";
  47628. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47630. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47631. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47632. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47633. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47634. import { Scene } from "babylonjs/scene";
  47635. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47636. import { Color3 } from "babylonjs/Maths/math.color";
  47637. /**
  47638. * Single axis drag gizmo
  47639. */
  47640. export class AxisDragGizmo extends Gizmo {
  47641. /**
  47642. * Drag behavior responsible for the gizmos dragging interactions
  47643. */
  47644. dragBehavior: PointerDragBehavior;
  47645. private _pointerObserver;
  47646. /**
  47647. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47648. */
  47649. snapDistance: number;
  47650. /**
  47651. * Event that fires each time the gizmo snaps to a new location.
  47652. * * snapDistance is the the change in distance
  47653. */
  47654. onSnapObservable: Observable<{
  47655. snapDistance: number;
  47656. }>;
  47657. private _isEnabled;
  47658. private _parent;
  47659. private _arrow;
  47660. private _coloredMaterial;
  47661. private _hoverMaterial;
  47662. /** @hidden */
  47663. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47664. /** @hidden */
  47665. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47666. /**
  47667. * Creates an AxisDragGizmo
  47668. * @param gizmoLayer The utility layer the gizmo will be added to
  47669. * @param dragAxis The axis which the gizmo will be able to drag on
  47670. * @param color The color of the gizmo
  47671. */
  47672. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47673. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47674. /**
  47675. * If the gizmo is enabled
  47676. */
  47677. set isEnabled(value: boolean);
  47678. get isEnabled(): boolean;
  47679. /**
  47680. * Disposes of the gizmo
  47681. */
  47682. dispose(): void;
  47683. }
  47684. }
  47685. declare module "babylonjs/Debug/axesViewer" {
  47686. import { Vector3 } from "babylonjs/Maths/math.vector";
  47687. import { Nullable } from "babylonjs/types";
  47688. import { Scene } from "babylonjs/scene";
  47689. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47690. /**
  47691. * The Axes viewer will show 3 axes in a specific point in space
  47692. */
  47693. export class AxesViewer {
  47694. private _xAxis;
  47695. private _yAxis;
  47696. private _zAxis;
  47697. private _scaleLinesFactor;
  47698. private _instanced;
  47699. /**
  47700. * Gets the hosting scene
  47701. */
  47702. scene: Scene;
  47703. /**
  47704. * Gets or sets a number used to scale line length
  47705. */
  47706. scaleLines: number;
  47707. /** Gets the node hierarchy used to render x-axis */
  47708. get xAxis(): TransformNode;
  47709. /** Gets the node hierarchy used to render y-axis */
  47710. get yAxis(): TransformNode;
  47711. /** Gets the node hierarchy used to render z-axis */
  47712. get zAxis(): TransformNode;
  47713. /**
  47714. * Creates a new AxesViewer
  47715. * @param scene defines the hosting scene
  47716. * @param scaleLines defines a number used to scale line length (1 by default)
  47717. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47718. * @param xAxis defines the node hierarchy used to render the x-axis
  47719. * @param yAxis defines the node hierarchy used to render the y-axis
  47720. * @param zAxis defines the node hierarchy used to render the z-axis
  47721. */
  47722. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47723. /**
  47724. * Force the viewer to update
  47725. * @param position defines the position of the viewer
  47726. * @param xaxis defines the x axis of the viewer
  47727. * @param yaxis defines the y axis of the viewer
  47728. * @param zaxis defines the z axis of the viewer
  47729. */
  47730. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47731. /**
  47732. * Creates an instance of this axes viewer.
  47733. * @returns a new axes viewer with instanced meshes
  47734. */
  47735. createInstance(): AxesViewer;
  47736. /** Releases resources */
  47737. dispose(): void;
  47738. private static _SetRenderingGroupId;
  47739. }
  47740. }
  47741. declare module "babylonjs/Debug/boneAxesViewer" {
  47742. import { Nullable } from "babylonjs/types";
  47743. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47744. import { Vector3 } from "babylonjs/Maths/math.vector";
  47745. import { Mesh } from "babylonjs/Meshes/mesh";
  47746. import { Bone } from "babylonjs/Bones/bone";
  47747. import { Scene } from "babylonjs/scene";
  47748. /**
  47749. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47750. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47751. */
  47752. export class BoneAxesViewer extends AxesViewer {
  47753. /**
  47754. * Gets or sets the target mesh where to display the axes viewer
  47755. */
  47756. mesh: Nullable<Mesh>;
  47757. /**
  47758. * Gets or sets the target bone where to display the axes viewer
  47759. */
  47760. bone: Nullable<Bone>;
  47761. /** Gets current position */
  47762. pos: Vector3;
  47763. /** Gets direction of X axis */
  47764. xaxis: Vector3;
  47765. /** Gets direction of Y axis */
  47766. yaxis: Vector3;
  47767. /** Gets direction of Z axis */
  47768. zaxis: Vector3;
  47769. /**
  47770. * Creates a new BoneAxesViewer
  47771. * @param scene defines the hosting scene
  47772. * @param bone defines the target bone
  47773. * @param mesh defines the target mesh
  47774. * @param scaleLines defines a scaling factor for line length (1 by default)
  47775. */
  47776. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47777. /**
  47778. * Force the viewer to update
  47779. */
  47780. update(): void;
  47781. /** Releases resources */
  47782. dispose(): void;
  47783. }
  47784. }
  47785. declare module "babylonjs/Debug/debugLayer" {
  47786. import { Scene } from "babylonjs/scene";
  47787. /**
  47788. * Interface used to define scene explorer extensibility option
  47789. */
  47790. export interface IExplorerExtensibilityOption {
  47791. /**
  47792. * Define the option label
  47793. */
  47794. label: string;
  47795. /**
  47796. * Defines the action to execute on click
  47797. */
  47798. action: (entity: any) => void;
  47799. }
  47800. /**
  47801. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47802. */
  47803. export interface IExplorerExtensibilityGroup {
  47804. /**
  47805. * Defines a predicate to test if a given type mut be extended
  47806. */
  47807. predicate: (entity: any) => boolean;
  47808. /**
  47809. * Gets the list of options added to a type
  47810. */
  47811. entries: IExplorerExtensibilityOption[];
  47812. }
  47813. /**
  47814. * Interface used to define the options to use to create the Inspector
  47815. */
  47816. export interface IInspectorOptions {
  47817. /**
  47818. * Display in overlay mode (default: false)
  47819. */
  47820. overlay?: boolean;
  47821. /**
  47822. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47823. */
  47824. globalRoot?: HTMLElement;
  47825. /**
  47826. * Display the Scene explorer
  47827. */
  47828. showExplorer?: boolean;
  47829. /**
  47830. * Display the property inspector
  47831. */
  47832. showInspector?: boolean;
  47833. /**
  47834. * Display in embed mode (both panes on the right)
  47835. */
  47836. embedMode?: boolean;
  47837. /**
  47838. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47839. */
  47840. handleResize?: boolean;
  47841. /**
  47842. * Allow the panes to popup (default: true)
  47843. */
  47844. enablePopup?: boolean;
  47845. /**
  47846. * Allow the panes to be closed by users (default: true)
  47847. */
  47848. enableClose?: boolean;
  47849. /**
  47850. * Optional list of extensibility entries
  47851. */
  47852. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47853. /**
  47854. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47855. */
  47856. inspectorURL?: string;
  47857. /**
  47858. * Optional initial tab (default to DebugLayerTab.Properties)
  47859. */
  47860. initialTab?: DebugLayerTab;
  47861. }
  47862. module "babylonjs/scene" {
  47863. interface Scene {
  47864. /**
  47865. * @hidden
  47866. * Backing field
  47867. */
  47868. _debugLayer: DebugLayer;
  47869. /**
  47870. * Gets the debug layer (aka Inspector) associated with the scene
  47871. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47872. */
  47873. debugLayer: DebugLayer;
  47874. }
  47875. }
  47876. /**
  47877. * Enum of inspector action tab
  47878. */
  47879. export enum DebugLayerTab {
  47880. /**
  47881. * Properties tag (default)
  47882. */
  47883. Properties = 0,
  47884. /**
  47885. * Debug tab
  47886. */
  47887. Debug = 1,
  47888. /**
  47889. * Statistics tab
  47890. */
  47891. Statistics = 2,
  47892. /**
  47893. * Tools tab
  47894. */
  47895. Tools = 3,
  47896. /**
  47897. * Settings tab
  47898. */
  47899. Settings = 4
  47900. }
  47901. /**
  47902. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47903. * what is happening in your scene
  47904. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47905. */
  47906. export class DebugLayer {
  47907. /**
  47908. * Define the url to get the inspector script from.
  47909. * By default it uses the babylonjs CDN.
  47910. * @ignoreNaming
  47911. */
  47912. static InspectorURL: string;
  47913. private _scene;
  47914. private BJSINSPECTOR;
  47915. private _onPropertyChangedObservable?;
  47916. /**
  47917. * Observable triggered when a property is changed through the inspector.
  47918. */
  47919. get onPropertyChangedObservable(): any;
  47920. /**
  47921. * Instantiates a new debug layer.
  47922. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47923. * what is happening in your scene
  47924. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47925. * @param scene Defines the scene to inspect
  47926. */
  47927. constructor(scene: Scene);
  47928. /** Creates the inspector window. */
  47929. private _createInspector;
  47930. /**
  47931. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47932. * @param entity defines the entity to select
  47933. * @param lineContainerTitle defines the specific block to highlight
  47934. */
  47935. select(entity: any, lineContainerTitle?: string): void;
  47936. /** Get the inspector from bundle or global */
  47937. private _getGlobalInspector;
  47938. /**
  47939. * Get if the inspector is visible or not.
  47940. * @returns true if visible otherwise, false
  47941. */
  47942. isVisible(): boolean;
  47943. /**
  47944. * Hide the inspector and close its window.
  47945. */
  47946. hide(): void;
  47947. /**
  47948. * Launch the debugLayer.
  47949. * @param config Define the configuration of the inspector
  47950. * @return a promise fulfilled when the debug layer is visible
  47951. */
  47952. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47953. }
  47954. }
  47955. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47956. import { Nullable } from "babylonjs/types";
  47957. import { Scene } from "babylonjs/scene";
  47958. import { Vector4 } from "babylonjs/Maths/math.vector";
  47959. import { Color4 } from "babylonjs/Maths/math.color";
  47960. import { Mesh } from "babylonjs/Meshes/mesh";
  47961. /**
  47962. * Class containing static functions to help procedurally build meshes
  47963. */
  47964. export class BoxBuilder {
  47965. /**
  47966. * Creates a box mesh
  47967. * * The parameter `size` sets the size (float) of each box side (default 1)
  47968. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47969. * * 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)
  47970. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47974. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47975. * @param name defines the name of the mesh
  47976. * @param options defines the options used to create the mesh
  47977. * @param scene defines the hosting scene
  47978. * @returns the box mesh
  47979. */
  47980. static CreateBox(name: string, options: {
  47981. size?: number;
  47982. width?: number;
  47983. height?: number;
  47984. depth?: number;
  47985. faceUV?: Vector4[];
  47986. faceColors?: Color4[];
  47987. sideOrientation?: number;
  47988. frontUVs?: Vector4;
  47989. backUVs?: Vector4;
  47990. wrap?: boolean;
  47991. topBaseAt?: number;
  47992. bottomBaseAt?: number;
  47993. updatable?: boolean;
  47994. }, scene?: Nullable<Scene>): Mesh;
  47995. }
  47996. }
  47997. declare module "babylonjs/Debug/physicsViewer" {
  47998. import { Nullable } from "babylonjs/types";
  47999. import { Scene } from "babylonjs/scene";
  48000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48001. import { Mesh } from "babylonjs/Meshes/mesh";
  48002. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48003. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48004. /**
  48005. * Used to show the physics impostor around the specific mesh
  48006. */
  48007. export class PhysicsViewer {
  48008. /** @hidden */
  48009. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48010. /** @hidden */
  48011. protected _meshes: Array<Nullable<AbstractMesh>>;
  48012. /** @hidden */
  48013. protected _scene: Nullable<Scene>;
  48014. /** @hidden */
  48015. protected _numMeshes: number;
  48016. /** @hidden */
  48017. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48018. private _renderFunction;
  48019. private _utilityLayer;
  48020. private _debugBoxMesh;
  48021. private _debugSphereMesh;
  48022. private _debugCylinderMesh;
  48023. private _debugMaterial;
  48024. private _debugMeshMeshes;
  48025. /**
  48026. * Creates a new PhysicsViewer
  48027. * @param scene defines the hosting scene
  48028. */
  48029. constructor(scene: Scene);
  48030. /** @hidden */
  48031. protected _updateDebugMeshes(): void;
  48032. /**
  48033. * Renders a specified physic impostor
  48034. * @param impostor defines the impostor to render
  48035. * @param targetMesh defines the mesh represented by the impostor
  48036. * @returns the new debug mesh used to render the impostor
  48037. */
  48038. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48039. /**
  48040. * Hides a specified physic impostor
  48041. * @param impostor defines the impostor to hide
  48042. */
  48043. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48044. private _getDebugMaterial;
  48045. private _getDebugBoxMesh;
  48046. private _getDebugSphereMesh;
  48047. private _getDebugCylinderMesh;
  48048. private _getDebugMeshMesh;
  48049. private _getDebugMesh;
  48050. /** Releases all resources */
  48051. dispose(): void;
  48052. }
  48053. }
  48054. declare module "babylonjs/Debug/rayHelper" {
  48055. import { Nullable } from "babylonjs/types";
  48056. import { Ray } from "babylonjs/Culling/ray";
  48057. import { Vector3 } from "babylonjs/Maths/math.vector";
  48058. import { Color3 } from "babylonjs/Maths/math.color";
  48059. import { Scene } from "babylonjs/scene";
  48060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48061. import "babylonjs/Meshes/Builders/linesBuilder";
  48062. /**
  48063. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48064. * in order to better appreciate the issue one might have.
  48065. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48066. */
  48067. export class RayHelper {
  48068. /**
  48069. * Defines the ray we are currently tryin to visualize.
  48070. */
  48071. ray: Nullable<Ray>;
  48072. private _renderPoints;
  48073. private _renderLine;
  48074. private _renderFunction;
  48075. private _scene;
  48076. private _updateToMeshFunction;
  48077. private _attachedToMesh;
  48078. private _meshSpaceDirection;
  48079. private _meshSpaceOrigin;
  48080. /**
  48081. * Helper function to create a colored helper in a scene in one line.
  48082. * @param ray Defines the ray we are currently tryin to visualize
  48083. * @param scene Defines the scene the ray is used in
  48084. * @param color Defines the color we want to see the ray in
  48085. * @returns The newly created ray helper.
  48086. */
  48087. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48088. /**
  48089. * Instantiate a new ray helper.
  48090. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48091. * in order to better appreciate the issue one might have.
  48092. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48093. * @param ray Defines the ray we are currently tryin to visualize
  48094. */
  48095. constructor(ray: Ray);
  48096. /**
  48097. * Shows the ray we are willing to debug.
  48098. * @param scene Defines the scene the ray needs to be rendered in
  48099. * @param color Defines the color the ray needs to be rendered in
  48100. */
  48101. show(scene: Scene, color?: Color3): void;
  48102. /**
  48103. * Hides the ray we are debugging.
  48104. */
  48105. hide(): void;
  48106. private _render;
  48107. /**
  48108. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48109. * @param mesh Defines the mesh we want the helper attached to
  48110. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48111. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48112. * @param length Defines the length of the ray
  48113. */
  48114. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48115. /**
  48116. * Detach the ray helper from the mesh it has previously been attached to.
  48117. */
  48118. detachFromMesh(): void;
  48119. private _updateToMesh;
  48120. /**
  48121. * Dispose the helper and release its associated resources.
  48122. */
  48123. dispose(): void;
  48124. }
  48125. }
  48126. declare module "babylonjs/Debug/skeletonViewer" {
  48127. import { Color3 } from "babylonjs/Maths/math.color";
  48128. import { Scene } from "babylonjs/scene";
  48129. import { Nullable } from "babylonjs/types";
  48130. import { Skeleton } from "babylonjs/Bones/skeleton";
  48131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48132. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48133. /**
  48134. * Class used to render a debug view of a given skeleton
  48135. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48136. */
  48137. export class SkeletonViewer {
  48138. /** defines the skeleton to render */
  48139. skeleton: Skeleton;
  48140. /** defines the mesh attached to the skeleton */
  48141. mesh: AbstractMesh;
  48142. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48143. autoUpdateBonesMatrices: boolean;
  48144. /** defines the rendering group id to use with the viewer */
  48145. renderingGroupId: number;
  48146. /** Gets or sets the color used to render the skeleton */
  48147. color: Color3;
  48148. private _scene;
  48149. private _debugLines;
  48150. private _debugMesh;
  48151. private _isEnabled;
  48152. private _renderFunction;
  48153. private _utilityLayer;
  48154. /**
  48155. * Returns the mesh used to render the bones
  48156. */
  48157. get debugMesh(): Nullable<LinesMesh>;
  48158. /**
  48159. * Creates a new SkeletonViewer
  48160. * @param skeleton defines the skeleton to render
  48161. * @param mesh defines the mesh attached to the skeleton
  48162. * @param scene defines the hosting scene
  48163. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48164. * @param renderingGroupId defines the rendering group id to use with the viewer
  48165. */
  48166. constructor(
  48167. /** defines the skeleton to render */
  48168. skeleton: Skeleton,
  48169. /** defines the mesh attached to the skeleton */
  48170. mesh: AbstractMesh, scene: Scene,
  48171. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48172. autoUpdateBonesMatrices?: boolean,
  48173. /** defines the rendering group id to use with the viewer */
  48174. renderingGroupId?: number);
  48175. /** Gets or sets a boolean indicating if the viewer is enabled */
  48176. set isEnabled(value: boolean);
  48177. get isEnabled(): boolean;
  48178. private _getBonePosition;
  48179. private _getLinesForBonesWithLength;
  48180. private _getLinesForBonesNoLength;
  48181. /** Update the viewer to sync with current skeleton state */
  48182. update(): void;
  48183. /** Release associated resources */
  48184. dispose(): void;
  48185. }
  48186. }
  48187. declare module "babylonjs/Debug/index" {
  48188. export * from "babylonjs/Debug/axesViewer";
  48189. export * from "babylonjs/Debug/boneAxesViewer";
  48190. export * from "babylonjs/Debug/debugLayer";
  48191. export * from "babylonjs/Debug/physicsViewer";
  48192. export * from "babylonjs/Debug/rayHelper";
  48193. export * from "babylonjs/Debug/skeletonViewer";
  48194. }
  48195. declare module "babylonjs/Engines/nullEngine" {
  48196. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48197. import { Engine } from "babylonjs/Engines/engine";
  48198. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48199. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48201. import { Effect } from "babylonjs/Materials/effect";
  48202. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48204. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48205. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48206. /**
  48207. * Options to create the null engine
  48208. */
  48209. export class NullEngineOptions {
  48210. /**
  48211. * Render width (Default: 512)
  48212. */
  48213. renderWidth: number;
  48214. /**
  48215. * Render height (Default: 256)
  48216. */
  48217. renderHeight: number;
  48218. /**
  48219. * Texture size (Default: 512)
  48220. */
  48221. textureSize: number;
  48222. /**
  48223. * If delta time between frames should be constant
  48224. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48225. */
  48226. deterministicLockstep: boolean;
  48227. /**
  48228. * Maximum about of steps between frames (Default: 4)
  48229. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48230. */
  48231. lockstepMaxSteps: number;
  48232. }
  48233. /**
  48234. * The null engine class provides support for headless version of babylon.js.
  48235. * This can be used in server side scenario or for testing purposes
  48236. */
  48237. export class NullEngine extends Engine {
  48238. private _options;
  48239. /**
  48240. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48241. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48242. * @returns true if engine is in deterministic lock step mode
  48243. */
  48244. isDeterministicLockStep(): boolean;
  48245. /**
  48246. * Gets the max steps when engine is running in deterministic lock step
  48247. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48248. * @returns the max steps
  48249. */
  48250. getLockstepMaxSteps(): number;
  48251. /**
  48252. * Gets the current hardware scaling level.
  48253. * By default the hardware scaling level is computed from the window device ratio.
  48254. * 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.
  48255. * @returns a number indicating the current hardware scaling level
  48256. */
  48257. getHardwareScalingLevel(): number;
  48258. constructor(options?: NullEngineOptions);
  48259. /**
  48260. * Creates a vertex buffer
  48261. * @param vertices the data for the vertex buffer
  48262. * @returns the new WebGL static buffer
  48263. */
  48264. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48265. /**
  48266. * Creates a new index buffer
  48267. * @param indices defines the content of the index buffer
  48268. * @param updatable defines if the index buffer must be updatable
  48269. * @returns a new webGL buffer
  48270. */
  48271. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48272. /**
  48273. * Clear the current render buffer or the current render target (if any is set up)
  48274. * @param color defines the color to use
  48275. * @param backBuffer defines if the back buffer must be cleared
  48276. * @param depth defines if the depth buffer must be cleared
  48277. * @param stencil defines if the stencil buffer must be cleared
  48278. */
  48279. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48280. /**
  48281. * Gets the current render width
  48282. * @param useScreen defines if screen size must be used (or the current render target if any)
  48283. * @returns a number defining the current render width
  48284. */
  48285. getRenderWidth(useScreen?: boolean): number;
  48286. /**
  48287. * Gets the current render height
  48288. * @param useScreen defines if screen size must be used (or the current render target if any)
  48289. * @returns a number defining the current render height
  48290. */
  48291. getRenderHeight(useScreen?: boolean): number;
  48292. /**
  48293. * Set the WebGL's viewport
  48294. * @param viewport defines the viewport element to be used
  48295. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48296. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48297. */
  48298. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48299. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48300. /**
  48301. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48302. * @param pipelineContext defines the pipeline context to use
  48303. * @param uniformsNames defines the list of uniform names
  48304. * @returns an array of webGL uniform locations
  48305. */
  48306. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48307. /**
  48308. * Gets the lsit of active attributes for a given webGL program
  48309. * @param pipelineContext defines the pipeline context to use
  48310. * @param attributesNames defines the list of attribute names to get
  48311. * @returns an array of indices indicating the offset of each attribute
  48312. */
  48313. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48314. /**
  48315. * Binds an effect to the webGL context
  48316. * @param effect defines the effect to bind
  48317. */
  48318. bindSamplers(effect: Effect): void;
  48319. /**
  48320. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48321. * @param effect defines the effect to activate
  48322. */
  48323. enableEffect(effect: Effect): void;
  48324. /**
  48325. * Set various states to the webGL context
  48326. * @param culling defines backface culling state
  48327. * @param zOffset defines the value to apply to zOffset (0 by default)
  48328. * @param force defines if states must be applied even if cache is up to date
  48329. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48330. */
  48331. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48332. /**
  48333. * Set the value of an uniform to an array of int32
  48334. * @param uniform defines the webGL uniform location where to store the value
  48335. * @param array defines the array of int32 to store
  48336. */
  48337. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48338. /**
  48339. * Set the value of an uniform to an array of int32 (stored as vec2)
  48340. * @param uniform defines the webGL uniform location where to store the value
  48341. * @param array defines the array of int32 to store
  48342. */
  48343. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48344. /**
  48345. * Set the value of an uniform to an array of int32 (stored as vec3)
  48346. * @param uniform defines the webGL uniform location where to store the value
  48347. * @param array defines the array of int32 to store
  48348. */
  48349. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48350. /**
  48351. * Set the value of an uniform to an array of int32 (stored as vec4)
  48352. * @param uniform defines the webGL uniform location where to store the value
  48353. * @param array defines the array of int32 to store
  48354. */
  48355. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48356. /**
  48357. * Set the value of an uniform to an array of float32
  48358. * @param uniform defines the webGL uniform location where to store the value
  48359. * @param array defines the array of float32 to store
  48360. */
  48361. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48362. /**
  48363. * Set the value of an uniform to an array of float32 (stored as vec2)
  48364. * @param uniform defines the webGL uniform location where to store the value
  48365. * @param array defines the array of float32 to store
  48366. */
  48367. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48368. /**
  48369. * Set the value of an uniform to an array of float32 (stored as vec3)
  48370. * @param uniform defines the webGL uniform location where to store the value
  48371. * @param array defines the array of float32 to store
  48372. */
  48373. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48374. /**
  48375. * Set the value of an uniform to an array of float32 (stored as vec4)
  48376. * @param uniform defines the webGL uniform location where to store the value
  48377. * @param array defines the array of float32 to store
  48378. */
  48379. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48380. /**
  48381. * Set the value of an uniform to an array of number
  48382. * @param uniform defines the webGL uniform location where to store the value
  48383. * @param array defines the array of number to store
  48384. */
  48385. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48386. /**
  48387. * Set the value of an uniform to an array of number (stored as vec2)
  48388. * @param uniform defines the webGL uniform location where to store the value
  48389. * @param array defines the array of number to store
  48390. */
  48391. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48392. /**
  48393. * Set the value of an uniform to an array of number (stored as vec3)
  48394. * @param uniform defines the webGL uniform location where to store the value
  48395. * @param array defines the array of number to store
  48396. */
  48397. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48398. /**
  48399. * Set the value of an uniform to an array of number (stored as vec4)
  48400. * @param uniform defines the webGL uniform location where to store the value
  48401. * @param array defines the array of number to store
  48402. */
  48403. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48404. /**
  48405. * Set the value of an uniform to an array of float32 (stored as matrices)
  48406. * @param uniform defines the webGL uniform location where to store the value
  48407. * @param matrices defines the array of float32 to store
  48408. */
  48409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48410. /**
  48411. * Set the value of an uniform to a matrix (3x3)
  48412. * @param uniform defines the webGL uniform location where to store the value
  48413. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48414. */
  48415. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48416. /**
  48417. * Set the value of an uniform to a matrix (2x2)
  48418. * @param uniform defines the webGL uniform location where to store the value
  48419. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48420. */
  48421. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48422. /**
  48423. * Set the value of an uniform to a number (float)
  48424. * @param uniform defines the webGL uniform location where to store the value
  48425. * @param value defines the float number to store
  48426. */
  48427. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48428. /**
  48429. * Set the value of an uniform to a vec2
  48430. * @param uniform defines the webGL uniform location where to store the value
  48431. * @param x defines the 1st component of the value
  48432. * @param y defines the 2nd component of the value
  48433. */
  48434. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48435. /**
  48436. * Set the value of an uniform to a vec3
  48437. * @param uniform defines the webGL uniform location where to store the value
  48438. * @param x defines the 1st component of the value
  48439. * @param y defines the 2nd component of the value
  48440. * @param z defines the 3rd component of the value
  48441. */
  48442. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48443. /**
  48444. * Set the value of an uniform to a boolean
  48445. * @param uniform defines the webGL uniform location where to store the value
  48446. * @param bool defines the boolean to store
  48447. */
  48448. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48449. /**
  48450. * Set the value of an uniform to a vec4
  48451. * @param uniform defines the webGL uniform location where to store the value
  48452. * @param x defines the 1st component of the value
  48453. * @param y defines the 2nd component of the value
  48454. * @param z defines the 3rd component of the value
  48455. * @param w defines the 4th component of the value
  48456. */
  48457. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48458. /**
  48459. * Sets the current alpha mode
  48460. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48461. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48462. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48463. */
  48464. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48465. /**
  48466. * Bind webGl buffers directly to the webGL context
  48467. * @param vertexBuffers defines the vertex buffer to bind
  48468. * @param indexBuffer defines the index buffer to bind
  48469. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48470. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48471. * @param effect defines the effect associated with the vertex buffer
  48472. */
  48473. bindBuffers(vertexBuffers: {
  48474. [key: string]: VertexBuffer;
  48475. }, indexBuffer: DataBuffer, effect: Effect): void;
  48476. /**
  48477. * Force the entire cache to be cleared
  48478. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48479. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48480. */
  48481. wipeCaches(bruteForce?: boolean): void;
  48482. /**
  48483. * Send a draw order
  48484. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48485. * @param indexStart defines the starting index
  48486. * @param indexCount defines the number of index to draw
  48487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48488. */
  48489. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48490. /**
  48491. * Draw a list of indexed primitives
  48492. * @param fillMode defines the primitive to use
  48493. * @param indexStart defines the starting index
  48494. * @param indexCount defines the number of index to draw
  48495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48496. */
  48497. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48498. /**
  48499. * Draw a list of unindexed primitives
  48500. * @param fillMode defines the primitive to use
  48501. * @param verticesStart defines the index of first vertex to draw
  48502. * @param verticesCount defines the count of vertices to draw
  48503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48504. */
  48505. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48506. /** @hidden */
  48507. _createTexture(): WebGLTexture;
  48508. /** @hidden */
  48509. _releaseTexture(texture: InternalTexture): void;
  48510. /**
  48511. * Usually called from Texture.ts.
  48512. * Passed information to create a WebGLTexture
  48513. * @param urlArg defines a value which contains one of the following:
  48514. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48515. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48516. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48518. * @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)
  48519. * @param scene needed for loading to the correct scene
  48520. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48521. * @param onLoad optional callback to be called upon successful completion
  48522. * @param onError optional callback to be called upon failure
  48523. * @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
  48524. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48525. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48526. * @param forcedExtension defines the extension to use to pick the right loader
  48527. * @param mimeType defines an optional mime type
  48528. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48529. */
  48530. 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;
  48531. /**
  48532. * Creates a new render target texture
  48533. * @param size defines the size of the texture
  48534. * @param options defines the options used to create the texture
  48535. * @returns a new render target texture stored in an InternalTexture
  48536. */
  48537. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48538. /**
  48539. * Update the sampling mode of a given texture
  48540. * @param samplingMode defines the required sampling mode
  48541. * @param texture defines the texture to update
  48542. */
  48543. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48544. /**
  48545. * Binds the frame buffer to the specified texture.
  48546. * @param texture The texture to render to or null for the default canvas
  48547. * @param faceIndex The face of the texture to render to in case of cube texture
  48548. * @param requiredWidth The width of the target to render to
  48549. * @param requiredHeight The height of the target to render to
  48550. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48551. * @param lodLevel defines le lod level to bind to the frame buffer
  48552. */
  48553. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48554. /**
  48555. * Unbind the current render target texture from the webGL context
  48556. * @param texture defines the render target texture to unbind
  48557. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48558. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48559. */
  48560. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48561. /**
  48562. * Creates a dynamic vertex buffer
  48563. * @param vertices the data for the dynamic vertex buffer
  48564. * @returns the new WebGL dynamic buffer
  48565. */
  48566. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48567. /**
  48568. * Update the content of a dynamic texture
  48569. * @param texture defines the texture to update
  48570. * @param canvas defines the canvas containing the source
  48571. * @param invertY defines if data must be stored with Y axis inverted
  48572. * @param premulAlpha defines if alpha is stored as premultiplied
  48573. * @param format defines the format of the data
  48574. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48575. */
  48576. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48577. /**
  48578. * Gets a boolean indicating if all created effects are ready
  48579. * @returns true if all effects are ready
  48580. */
  48581. areAllEffectsReady(): boolean;
  48582. /**
  48583. * @hidden
  48584. * Get the current error code of the webGL context
  48585. * @returns the error code
  48586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48587. */
  48588. getError(): number;
  48589. /** @hidden */
  48590. _getUnpackAlignement(): number;
  48591. /** @hidden */
  48592. _unpackFlipY(value: boolean): void;
  48593. /**
  48594. * Update a dynamic index buffer
  48595. * @param indexBuffer defines the target index buffer
  48596. * @param indices defines the data to update
  48597. * @param offset defines the offset in the target index buffer where update should start
  48598. */
  48599. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48600. /**
  48601. * Updates a dynamic vertex buffer.
  48602. * @param vertexBuffer the vertex buffer to update
  48603. * @param vertices the data used to update the vertex buffer
  48604. * @param byteOffset the byte offset of the data (optional)
  48605. * @param byteLength the byte length of the data (optional)
  48606. */
  48607. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48608. /** @hidden */
  48609. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48610. /** @hidden */
  48611. _bindTexture(channel: number, texture: InternalTexture): void;
  48612. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48613. /**
  48614. * 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
  48615. */
  48616. releaseEffects(): void;
  48617. displayLoadingUI(): void;
  48618. hideLoadingUI(): void;
  48619. /** @hidden */
  48620. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48621. /** @hidden */
  48622. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48623. /** @hidden */
  48624. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48625. /** @hidden */
  48626. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48627. }
  48628. }
  48629. declare module "babylonjs/Instrumentation/timeToken" {
  48630. import { Nullable } from "babylonjs/types";
  48631. /**
  48632. * @hidden
  48633. **/
  48634. export class _TimeToken {
  48635. _startTimeQuery: Nullable<WebGLQuery>;
  48636. _endTimeQuery: Nullable<WebGLQuery>;
  48637. _timeElapsedQuery: Nullable<WebGLQuery>;
  48638. _timeElapsedQueryEnded: boolean;
  48639. }
  48640. }
  48641. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48642. import { Nullable, int } from "babylonjs/types";
  48643. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48644. /** @hidden */
  48645. export class _OcclusionDataStorage {
  48646. /** @hidden */
  48647. occlusionInternalRetryCounter: number;
  48648. /** @hidden */
  48649. isOcclusionQueryInProgress: boolean;
  48650. /** @hidden */
  48651. isOccluded: boolean;
  48652. /** @hidden */
  48653. occlusionRetryCount: number;
  48654. /** @hidden */
  48655. occlusionType: number;
  48656. /** @hidden */
  48657. occlusionQueryAlgorithmType: number;
  48658. }
  48659. module "babylonjs/Engines/engine" {
  48660. interface Engine {
  48661. /**
  48662. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48663. * @return the new query
  48664. */
  48665. createQuery(): WebGLQuery;
  48666. /**
  48667. * Delete and release a webGL query
  48668. * @param query defines the query to delete
  48669. * @return the current engine
  48670. */
  48671. deleteQuery(query: WebGLQuery): Engine;
  48672. /**
  48673. * Check if a given query has resolved and got its value
  48674. * @param query defines the query to check
  48675. * @returns true if the query got its value
  48676. */
  48677. isQueryResultAvailable(query: WebGLQuery): boolean;
  48678. /**
  48679. * Gets the value of a given query
  48680. * @param query defines the query to check
  48681. * @returns the value of the query
  48682. */
  48683. getQueryResult(query: WebGLQuery): number;
  48684. /**
  48685. * Initiates an occlusion query
  48686. * @param algorithmType defines the algorithm to use
  48687. * @param query defines the query to use
  48688. * @returns the current engine
  48689. * @see http://doc.babylonjs.com/features/occlusionquery
  48690. */
  48691. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48692. /**
  48693. * Ends an occlusion query
  48694. * @see http://doc.babylonjs.com/features/occlusionquery
  48695. * @param algorithmType defines the algorithm to use
  48696. * @returns the current engine
  48697. */
  48698. endOcclusionQuery(algorithmType: number): Engine;
  48699. /**
  48700. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48701. * Please note that only one query can be issued at a time
  48702. * @returns a time token used to track the time span
  48703. */
  48704. startTimeQuery(): Nullable<_TimeToken>;
  48705. /**
  48706. * Ends a time query
  48707. * @param token defines the token used to measure the time span
  48708. * @returns the time spent (in ns)
  48709. */
  48710. endTimeQuery(token: _TimeToken): int;
  48711. /** @hidden */
  48712. _currentNonTimestampToken: Nullable<_TimeToken>;
  48713. /** @hidden */
  48714. _createTimeQuery(): WebGLQuery;
  48715. /** @hidden */
  48716. _deleteTimeQuery(query: WebGLQuery): void;
  48717. /** @hidden */
  48718. _getGlAlgorithmType(algorithmType: number): number;
  48719. /** @hidden */
  48720. _getTimeQueryResult(query: WebGLQuery): any;
  48721. /** @hidden */
  48722. _getTimeQueryAvailability(query: WebGLQuery): any;
  48723. }
  48724. }
  48725. module "babylonjs/Meshes/abstractMesh" {
  48726. interface AbstractMesh {
  48727. /**
  48728. * Backing filed
  48729. * @hidden
  48730. */
  48731. __occlusionDataStorage: _OcclusionDataStorage;
  48732. /**
  48733. * Access property
  48734. * @hidden
  48735. */
  48736. _occlusionDataStorage: _OcclusionDataStorage;
  48737. /**
  48738. * 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.
  48739. * The default value is -1 which means don't break the query and wait till the result
  48740. * @see http://doc.babylonjs.com/features/occlusionquery
  48741. */
  48742. occlusionRetryCount: number;
  48743. /**
  48744. * 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:
  48745. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48746. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48747. * * 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.
  48748. * @see http://doc.babylonjs.com/features/occlusionquery
  48749. */
  48750. occlusionType: number;
  48751. /**
  48752. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48753. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48754. * * 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.
  48755. * @see http://doc.babylonjs.com/features/occlusionquery
  48756. */
  48757. occlusionQueryAlgorithmType: number;
  48758. /**
  48759. * 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
  48760. * @see http://doc.babylonjs.com/features/occlusionquery
  48761. */
  48762. isOccluded: boolean;
  48763. /**
  48764. * Flag to check the progress status of the query
  48765. * @see http://doc.babylonjs.com/features/occlusionquery
  48766. */
  48767. isOcclusionQueryInProgress: boolean;
  48768. }
  48769. }
  48770. }
  48771. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48772. import { Nullable } from "babylonjs/types";
  48773. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48774. /** @hidden */
  48775. export var _forceTransformFeedbackToBundle: boolean;
  48776. module "babylonjs/Engines/engine" {
  48777. interface Engine {
  48778. /**
  48779. * Creates a webGL transform feedback object
  48780. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48781. * @returns the webGL transform feedback object
  48782. */
  48783. createTransformFeedback(): WebGLTransformFeedback;
  48784. /**
  48785. * Delete a webGL transform feedback object
  48786. * @param value defines the webGL transform feedback object to delete
  48787. */
  48788. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48789. /**
  48790. * Bind a webGL transform feedback object to the webgl context
  48791. * @param value defines the webGL transform feedback object to bind
  48792. */
  48793. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48794. /**
  48795. * Begins a transform feedback operation
  48796. * @param usePoints defines if points or triangles must be used
  48797. */
  48798. beginTransformFeedback(usePoints: boolean): void;
  48799. /**
  48800. * Ends a transform feedback operation
  48801. */
  48802. endTransformFeedback(): void;
  48803. /**
  48804. * Specify the varyings to use with transform feedback
  48805. * @param program defines the associated webGL program
  48806. * @param value defines the list of strings representing the varying names
  48807. */
  48808. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48809. /**
  48810. * Bind a webGL buffer for a transform feedback operation
  48811. * @param value defines the webGL buffer to bind
  48812. */
  48813. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48814. }
  48815. }
  48816. }
  48817. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48818. import { Scene } from "babylonjs/scene";
  48819. import { Engine } from "babylonjs/Engines/engine";
  48820. import { Texture } from "babylonjs/Materials/Textures/texture";
  48821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48822. import "babylonjs/Engines/Extensions/engine.multiRender";
  48823. /**
  48824. * Creation options of the multi render target texture.
  48825. */
  48826. export interface IMultiRenderTargetOptions {
  48827. /**
  48828. * Define if the texture needs to create mip maps after render.
  48829. */
  48830. generateMipMaps?: boolean;
  48831. /**
  48832. * Define the types of all the draw buffers we want to create
  48833. */
  48834. types?: number[];
  48835. /**
  48836. * Define the sampling modes of all the draw buffers we want to create
  48837. */
  48838. samplingModes?: number[];
  48839. /**
  48840. * Define if a depth buffer is required
  48841. */
  48842. generateDepthBuffer?: boolean;
  48843. /**
  48844. * Define if a stencil buffer is required
  48845. */
  48846. generateStencilBuffer?: boolean;
  48847. /**
  48848. * Define if a depth texture is required instead of a depth buffer
  48849. */
  48850. generateDepthTexture?: boolean;
  48851. /**
  48852. * Define the number of desired draw buffers
  48853. */
  48854. textureCount?: number;
  48855. /**
  48856. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48857. */
  48858. doNotChangeAspectRatio?: boolean;
  48859. /**
  48860. * Define the default type of the buffers we are creating
  48861. */
  48862. defaultType?: number;
  48863. }
  48864. /**
  48865. * A multi render target, like a render target provides the ability to render to a texture.
  48866. * Unlike the render target, it can render to several draw buffers in one draw.
  48867. * This is specially interesting in deferred rendering or for any effects requiring more than
  48868. * just one color from a single pass.
  48869. */
  48870. export class MultiRenderTarget extends RenderTargetTexture {
  48871. private _internalTextures;
  48872. private _textures;
  48873. private _multiRenderTargetOptions;
  48874. /**
  48875. * Get if draw buffers are currently supported by the used hardware and browser.
  48876. */
  48877. get isSupported(): boolean;
  48878. /**
  48879. * Get the list of textures generated by the multi render target.
  48880. */
  48881. get textures(): Texture[];
  48882. /**
  48883. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48884. */
  48885. get depthTexture(): Texture;
  48886. /**
  48887. * Set the wrapping mode on U of all the textures we are rendering to.
  48888. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48889. */
  48890. set wrapU(wrap: number);
  48891. /**
  48892. * Set the wrapping mode on V of all the textures we are rendering to.
  48893. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48894. */
  48895. set wrapV(wrap: number);
  48896. /**
  48897. * Instantiate a new multi render target texture.
  48898. * A multi render target, like a render target provides the ability to render to a texture.
  48899. * Unlike the render target, it can render to several draw buffers in one draw.
  48900. * This is specially interesting in deferred rendering or for any effects requiring more than
  48901. * just one color from a single pass.
  48902. * @param name Define the name of the texture
  48903. * @param size Define the size of the buffers to render to
  48904. * @param count Define the number of target we are rendering into
  48905. * @param scene Define the scene the texture belongs to
  48906. * @param options Define the options used to create the multi render target
  48907. */
  48908. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48909. /** @hidden */
  48910. _rebuild(): void;
  48911. private _createInternalTextures;
  48912. private _createTextures;
  48913. /**
  48914. * Define the number of samples used if MSAA is enabled.
  48915. */
  48916. get samples(): number;
  48917. set samples(value: number);
  48918. /**
  48919. * Resize all the textures in the multi render target.
  48920. * Be carrefull as it will recreate all the data in the new texture.
  48921. * @param size Define the new size
  48922. */
  48923. resize(size: any): void;
  48924. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48925. /**
  48926. * Dispose the render targets and their associated resources
  48927. */
  48928. dispose(): void;
  48929. /**
  48930. * Release all the underlying texture used as draw buffers.
  48931. */
  48932. releaseInternalTextures(): void;
  48933. }
  48934. }
  48935. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48937. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48938. import { Nullable } from "babylonjs/types";
  48939. module "babylonjs/Engines/thinEngine" {
  48940. interface ThinEngine {
  48941. /**
  48942. * Unbind a list of render target textures from the webGL context
  48943. * This is used only when drawBuffer extension or webGL2 are active
  48944. * @param textures defines the render target textures to unbind
  48945. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48946. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48947. */
  48948. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48949. /**
  48950. * Create a multi render target texture
  48951. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48952. * @param size defines the size of the texture
  48953. * @param options defines the creation options
  48954. * @returns the cube texture as an InternalTexture
  48955. */
  48956. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48957. /**
  48958. * Update the sample count for a given multiple render target texture
  48959. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48960. * @param textures defines the textures to update
  48961. * @param samples defines the sample count to set
  48962. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48963. */
  48964. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48965. }
  48966. }
  48967. }
  48968. declare module "babylonjs/Engines/Extensions/engine.views" {
  48969. import { Camera } from "babylonjs/Cameras/camera";
  48970. import { Nullable } from "babylonjs/types";
  48971. /**
  48972. * Class used to define an additional view for the engine
  48973. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48974. */
  48975. export class EngineView {
  48976. /** Defines the canvas where to render the view */
  48977. target: HTMLCanvasElement;
  48978. /** Defines an optional camera used to render the view (will use active camera else) */
  48979. camera?: Camera;
  48980. }
  48981. module "babylonjs/Engines/engine" {
  48982. interface Engine {
  48983. /**
  48984. * Gets or sets the HTML element to use for attaching events
  48985. */
  48986. inputElement: Nullable<HTMLElement>;
  48987. /**
  48988. * Gets the current engine view
  48989. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48990. */
  48991. activeView: Nullable<EngineView>;
  48992. /** Gets or sets the list of views */
  48993. views: EngineView[];
  48994. /**
  48995. * Register a new child canvas
  48996. * @param canvas defines the canvas to register
  48997. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48998. * @returns the associated view
  48999. */
  49000. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49001. /**
  49002. * Remove a registered child canvas
  49003. * @param canvas defines the canvas to remove
  49004. * @returns the current engine
  49005. */
  49006. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49007. }
  49008. }
  49009. }
  49010. declare module "babylonjs/Engines/Extensions/index" {
  49011. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49012. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49013. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49014. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49015. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49016. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49017. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49018. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49019. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49020. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49021. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49022. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49023. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49024. export * from "babylonjs/Engines/Extensions/engine.views";
  49025. }
  49026. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49027. import { Nullable } from "babylonjs/types";
  49028. /**
  49029. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49030. */
  49031. export interface CubeMapInfo {
  49032. /**
  49033. * The pixel array for the front face.
  49034. * This is stored in format, left to right, up to down format.
  49035. */
  49036. front: Nullable<ArrayBufferView>;
  49037. /**
  49038. * The pixel array for the back face.
  49039. * This is stored in format, left to right, up to down format.
  49040. */
  49041. back: Nullable<ArrayBufferView>;
  49042. /**
  49043. * The pixel array for the left face.
  49044. * This is stored in format, left to right, up to down format.
  49045. */
  49046. left: Nullable<ArrayBufferView>;
  49047. /**
  49048. * The pixel array for the right face.
  49049. * This is stored in format, left to right, up to down format.
  49050. */
  49051. right: Nullable<ArrayBufferView>;
  49052. /**
  49053. * The pixel array for the up face.
  49054. * This is stored in format, left to right, up to down format.
  49055. */
  49056. up: Nullable<ArrayBufferView>;
  49057. /**
  49058. * The pixel array for the down face.
  49059. * This is stored in format, left to right, up to down format.
  49060. */
  49061. down: Nullable<ArrayBufferView>;
  49062. /**
  49063. * The size of the cubemap stored.
  49064. *
  49065. * Each faces will be size * size pixels.
  49066. */
  49067. size: number;
  49068. /**
  49069. * The format of the texture.
  49070. *
  49071. * RGBA, RGB.
  49072. */
  49073. format: number;
  49074. /**
  49075. * The type of the texture data.
  49076. *
  49077. * UNSIGNED_INT, FLOAT.
  49078. */
  49079. type: number;
  49080. /**
  49081. * Specifies whether the texture is in gamma space.
  49082. */
  49083. gammaSpace: boolean;
  49084. }
  49085. /**
  49086. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49087. */
  49088. export class PanoramaToCubeMapTools {
  49089. private static FACE_FRONT;
  49090. private static FACE_BACK;
  49091. private static FACE_RIGHT;
  49092. private static FACE_LEFT;
  49093. private static FACE_DOWN;
  49094. private static FACE_UP;
  49095. /**
  49096. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49097. *
  49098. * @param float32Array The source data.
  49099. * @param inputWidth The width of the input panorama.
  49100. * @param inputHeight The height of the input panorama.
  49101. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49102. * @return The cubemap data
  49103. */
  49104. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49105. private static CreateCubemapTexture;
  49106. private static CalcProjectionSpherical;
  49107. }
  49108. }
  49109. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49110. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49112. import { Nullable } from "babylonjs/types";
  49113. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49114. /**
  49115. * Helper class dealing with the extraction of spherical polynomial dataArray
  49116. * from a cube map.
  49117. */
  49118. export class CubeMapToSphericalPolynomialTools {
  49119. private static FileFaces;
  49120. /**
  49121. * Converts a texture to the according Spherical Polynomial data.
  49122. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49123. *
  49124. * @param texture The texture to extract the information from.
  49125. * @return The Spherical Polynomial data.
  49126. */
  49127. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49128. /**
  49129. * Converts a cubemap to the according Spherical Polynomial data.
  49130. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49131. *
  49132. * @param cubeInfo The Cube map to extract the information from.
  49133. * @return The Spherical Polynomial data.
  49134. */
  49135. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49136. }
  49137. }
  49138. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49139. import { Nullable } from "babylonjs/types";
  49140. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49141. module "babylonjs/Materials/Textures/baseTexture" {
  49142. interface BaseTexture {
  49143. /**
  49144. * Get the polynomial representation of the texture data.
  49145. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49146. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49147. */
  49148. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49149. }
  49150. }
  49151. }
  49152. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49154. /** @hidden */
  49155. export var rgbdEncodePixelShader: {
  49156. name: string;
  49157. shader: string;
  49158. };
  49159. }
  49160. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49161. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49162. /** @hidden */
  49163. export var rgbdDecodePixelShader: {
  49164. name: string;
  49165. shader: string;
  49166. };
  49167. }
  49168. declare module "babylonjs/Misc/environmentTextureTools" {
  49169. import { Nullable } from "babylonjs/types";
  49170. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49172. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49173. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49174. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49175. import "babylonjs/Shaders/rgbdEncode.fragment";
  49176. import "babylonjs/Shaders/rgbdDecode.fragment";
  49177. /**
  49178. * Raw texture data and descriptor sufficient for WebGL texture upload
  49179. */
  49180. export interface EnvironmentTextureInfo {
  49181. /**
  49182. * Version of the environment map
  49183. */
  49184. version: number;
  49185. /**
  49186. * Width of image
  49187. */
  49188. width: number;
  49189. /**
  49190. * Irradiance information stored in the file.
  49191. */
  49192. irradiance: any;
  49193. /**
  49194. * Specular information stored in the file.
  49195. */
  49196. specular: any;
  49197. }
  49198. /**
  49199. * Defines One Image in the file. It requires only the position in the file
  49200. * as well as the length.
  49201. */
  49202. interface BufferImageData {
  49203. /**
  49204. * Length of the image data.
  49205. */
  49206. length: number;
  49207. /**
  49208. * Position of the data from the null terminator delimiting the end of the JSON.
  49209. */
  49210. position: number;
  49211. }
  49212. /**
  49213. * Defines the specular data enclosed in the file.
  49214. * This corresponds to the version 1 of the data.
  49215. */
  49216. export interface EnvironmentTextureSpecularInfoV1 {
  49217. /**
  49218. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49219. */
  49220. specularDataPosition?: number;
  49221. /**
  49222. * This contains all the images data needed to reconstruct the cubemap.
  49223. */
  49224. mipmaps: Array<BufferImageData>;
  49225. /**
  49226. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49227. */
  49228. lodGenerationScale: number;
  49229. }
  49230. /**
  49231. * Sets of helpers addressing the serialization and deserialization of environment texture
  49232. * stored in a BabylonJS env file.
  49233. * Those files are usually stored as .env files.
  49234. */
  49235. export class EnvironmentTextureTools {
  49236. /**
  49237. * Magic number identifying the env file.
  49238. */
  49239. private static _MagicBytes;
  49240. /**
  49241. * Gets the environment info from an env file.
  49242. * @param data The array buffer containing the .env bytes.
  49243. * @returns the environment file info (the json header) if successfully parsed.
  49244. */
  49245. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49246. /**
  49247. * Creates an environment texture from a loaded cube texture.
  49248. * @param texture defines the cube texture to convert in env file
  49249. * @return a promise containing the environment data if succesfull.
  49250. */
  49251. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49252. /**
  49253. * Creates a JSON representation of the spherical data.
  49254. * @param texture defines the texture containing the polynomials
  49255. * @return the JSON representation of the spherical info
  49256. */
  49257. private static _CreateEnvTextureIrradiance;
  49258. /**
  49259. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49260. * @param data the image data
  49261. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49262. * @return the views described by info providing access to the underlying buffer
  49263. */
  49264. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49265. /**
  49266. * Uploads the texture info contained in the env file to the GPU.
  49267. * @param texture defines the internal texture to upload to
  49268. * @param data defines the data to load
  49269. * @param info defines the texture info retrieved through the GetEnvInfo method
  49270. * @returns a promise
  49271. */
  49272. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49273. private static _OnImageReadyAsync;
  49274. /**
  49275. * Uploads the levels of image data to the GPU.
  49276. * @param texture defines the internal texture to upload to
  49277. * @param imageData defines the array buffer views of image data [mipmap][face]
  49278. * @returns a promise
  49279. */
  49280. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49281. /**
  49282. * Uploads spherical polynomials information to the texture.
  49283. * @param texture defines the texture we are trying to upload the information to
  49284. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49285. */
  49286. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49287. /** @hidden */
  49288. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49289. }
  49290. }
  49291. declare module "babylonjs/Maths/math.vertexFormat" {
  49292. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49293. /**
  49294. * Contains position and normal vectors for a vertex
  49295. */
  49296. export class PositionNormalVertex {
  49297. /** the position of the vertex (defaut: 0,0,0) */
  49298. position: Vector3;
  49299. /** the normal of the vertex (defaut: 0,1,0) */
  49300. normal: Vector3;
  49301. /**
  49302. * Creates a PositionNormalVertex
  49303. * @param position the position of the vertex (defaut: 0,0,0)
  49304. * @param normal the normal of the vertex (defaut: 0,1,0)
  49305. */
  49306. constructor(
  49307. /** the position of the vertex (defaut: 0,0,0) */
  49308. position?: Vector3,
  49309. /** the normal of the vertex (defaut: 0,1,0) */
  49310. normal?: Vector3);
  49311. /**
  49312. * Clones the PositionNormalVertex
  49313. * @returns the cloned PositionNormalVertex
  49314. */
  49315. clone(): PositionNormalVertex;
  49316. }
  49317. /**
  49318. * Contains position, normal and uv vectors for a vertex
  49319. */
  49320. export class PositionNormalTextureVertex {
  49321. /** the position of the vertex (defaut: 0,0,0) */
  49322. position: Vector3;
  49323. /** the normal of the vertex (defaut: 0,1,0) */
  49324. normal: Vector3;
  49325. /** the uv of the vertex (default: 0,0) */
  49326. uv: Vector2;
  49327. /**
  49328. * Creates a PositionNormalTextureVertex
  49329. * @param position the position of the vertex (defaut: 0,0,0)
  49330. * @param normal the normal of the vertex (defaut: 0,1,0)
  49331. * @param uv the uv of the vertex (default: 0,0)
  49332. */
  49333. constructor(
  49334. /** the position of the vertex (defaut: 0,0,0) */
  49335. position?: Vector3,
  49336. /** the normal of the vertex (defaut: 0,1,0) */
  49337. normal?: Vector3,
  49338. /** the uv of the vertex (default: 0,0) */
  49339. uv?: Vector2);
  49340. /**
  49341. * Clones the PositionNormalTextureVertex
  49342. * @returns the cloned PositionNormalTextureVertex
  49343. */
  49344. clone(): PositionNormalTextureVertex;
  49345. }
  49346. }
  49347. declare module "babylonjs/Maths/math" {
  49348. export * from "babylonjs/Maths/math.axis";
  49349. export * from "babylonjs/Maths/math.color";
  49350. export * from "babylonjs/Maths/math.constants";
  49351. export * from "babylonjs/Maths/math.frustum";
  49352. export * from "babylonjs/Maths/math.path";
  49353. export * from "babylonjs/Maths/math.plane";
  49354. export * from "babylonjs/Maths/math.size";
  49355. export * from "babylonjs/Maths/math.vector";
  49356. export * from "babylonjs/Maths/math.vertexFormat";
  49357. export * from "babylonjs/Maths/math.viewport";
  49358. }
  49359. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49360. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49361. /** @hidden */
  49362. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49363. private _genericAttributeLocation;
  49364. private _varyingLocationCount;
  49365. private _varyingLocationMap;
  49366. private _replacements;
  49367. private _textureCount;
  49368. private _uniforms;
  49369. lineProcessor(line: string): string;
  49370. attributeProcessor(attribute: string): string;
  49371. varyingProcessor(varying: string, isFragment: boolean): string;
  49372. uniformProcessor(uniform: string): string;
  49373. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49374. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49375. }
  49376. }
  49377. declare module "babylonjs/Engines/nativeEngine" {
  49378. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49379. import { Engine } from "babylonjs/Engines/engine";
  49380. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49381. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49383. import { Effect } from "babylonjs/Materials/effect";
  49384. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49385. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49386. import { IColor4Like } from "babylonjs/Maths/math.like";
  49387. import { Scene } from "babylonjs/scene";
  49388. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49389. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49390. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49391. /**
  49392. * Container for accessors for natively-stored mesh data buffers.
  49393. */
  49394. class NativeDataBuffer extends DataBuffer {
  49395. /**
  49396. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49397. */
  49398. nativeIndexBuffer?: any;
  49399. /**
  49400. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49401. */
  49402. nativeVertexBuffer?: any;
  49403. }
  49404. /** @hidden */
  49405. class NativeTexture extends InternalTexture {
  49406. getInternalTexture(): InternalTexture;
  49407. getViewCount(): number;
  49408. }
  49409. /** @hidden */
  49410. export class NativeEngine extends Engine {
  49411. private readonly _native;
  49412. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49413. private readonly INVALID_HANDLE;
  49414. getHardwareScalingLevel(): number;
  49415. constructor();
  49416. /**
  49417. * Can be used to override the current requestAnimationFrame requester.
  49418. * @hidden
  49419. */
  49420. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49421. /**
  49422. * Override default engine behavior.
  49423. * @param color
  49424. * @param backBuffer
  49425. * @param depth
  49426. * @param stencil
  49427. */
  49428. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49429. /**
  49430. * Gets host document
  49431. * @returns the host document object
  49432. */
  49433. getHostDocument(): Nullable<Document>;
  49434. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49435. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49436. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49437. recordVertexArrayObject(vertexBuffers: {
  49438. [key: string]: VertexBuffer;
  49439. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49440. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49441. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49442. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49443. /**
  49444. * Draw a list of indexed primitives
  49445. * @param fillMode defines the primitive to use
  49446. * @param indexStart defines the starting index
  49447. * @param indexCount defines the number of index to draw
  49448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49449. */
  49450. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49451. /**
  49452. * Draw a list of unindexed primitives
  49453. * @param fillMode defines the primitive to use
  49454. * @param verticesStart defines the index of first vertex to draw
  49455. * @param verticesCount defines the count of vertices to draw
  49456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49457. */
  49458. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49459. createPipelineContext(): IPipelineContext;
  49460. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49461. /** @hidden */
  49462. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49463. /** @hidden */
  49464. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49465. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49466. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49467. protected _setProgram(program: WebGLProgram): void;
  49468. _releaseEffect(effect: Effect): void;
  49469. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49470. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49471. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49472. bindSamplers(effect: Effect): void;
  49473. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49474. getRenderWidth(useScreen?: boolean): number;
  49475. getRenderHeight(useScreen?: boolean): number;
  49476. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49477. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49478. /**
  49479. * Set the z offset to apply to current rendering
  49480. * @param value defines the offset to apply
  49481. */
  49482. setZOffset(value: number): void;
  49483. /**
  49484. * Gets the current value of the zOffset
  49485. * @returns the current zOffset state
  49486. */
  49487. getZOffset(): number;
  49488. /**
  49489. * Enable or disable depth buffering
  49490. * @param enable defines the state to set
  49491. */
  49492. setDepthBuffer(enable: boolean): void;
  49493. /**
  49494. * Gets a boolean indicating if depth writing is enabled
  49495. * @returns the current depth writing state
  49496. */
  49497. getDepthWrite(): boolean;
  49498. /**
  49499. * Enable or disable depth writing
  49500. * @param enable defines the state to set
  49501. */
  49502. setDepthWrite(enable: boolean): void;
  49503. /**
  49504. * Enable or disable color writing
  49505. * @param enable defines the state to set
  49506. */
  49507. setColorWrite(enable: boolean): void;
  49508. /**
  49509. * Gets a boolean indicating if color writing is enabled
  49510. * @returns the current color writing state
  49511. */
  49512. getColorWrite(): boolean;
  49513. /**
  49514. * Sets alpha constants used by some alpha blending modes
  49515. * @param r defines the red component
  49516. * @param g defines the green component
  49517. * @param b defines the blue component
  49518. * @param a defines the alpha component
  49519. */
  49520. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49521. /**
  49522. * Sets the current alpha mode
  49523. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49524. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49526. */
  49527. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49528. /**
  49529. * Gets the current alpha mode
  49530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49531. * @returns the current alpha mode
  49532. */
  49533. getAlphaMode(): number;
  49534. setInt(uniform: WebGLUniformLocation, int: number): void;
  49535. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49536. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49537. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49538. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49539. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49540. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49541. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49542. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49543. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49544. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49545. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49546. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49547. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49548. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49549. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49550. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49551. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49552. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49553. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49554. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49555. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49556. wipeCaches(bruteForce?: boolean): void;
  49557. _createTexture(): WebGLTexture;
  49558. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49559. /**
  49560. * Usually called from Texture.ts.
  49561. * Passed information to create a WebGLTexture
  49562. * @param urlArg defines a value which contains one of the following:
  49563. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49564. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49565. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49566. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49567. * @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)
  49568. * @param scene needed for loading to the correct scene
  49569. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49570. * @param onLoad optional callback to be called upon successful completion
  49571. * @param onError optional callback to be called upon failure
  49572. * @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
  49573. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49574. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49575. * @param forcedExtension defines the extension to use to pick the right loader
  49576. * @param mimeType defines an optional mime type
  49577. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49578. */
  49579. 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;
  49580. /**
  49581. * Creates a cube texture
  49582. * @param rootUrl defines the url where the files to load is located
  49583. * @param scene defines the current scene
  49584. * @param files defines the list of files to load (1 per face)
  49585. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49586. * @param onLoad defines an optional callback raised when the texture is loaded
  49587. * @param onError defines an optional callback raised if there is an issue to load the texture
  49588. * @param format defines the format of the data
  49589. * @param forcedExtension defines the extension to use to pick the right loader
  49590. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49591. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49592. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49593. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49594. * @returns the cube texture as an InternalTexture
  49595. */
  49596. 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;
  49597. private _getSamplingFilter;
  49598. private static _GetNativeTextureFormat;
  49599. createRenderTargetTexture(size: number | {
  49600. width: number;
  49601. height: number;
  49602. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49603. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49604. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49605. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49606. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49607. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49608. /**
  49609. * Updates a dynamic vertex buffer.
  49610. * @param vertexBuffer the vertex buffer to update
  49611. * @param data the data used to update the vertex buffer
  49612. * @param byteOffset the byte offset of the data (optional)
  49613. * @param byteLength the byte length of the data (optional)
  49614. */
  49615. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49616. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49617. private _updateAnisotropicLevel;
  49618. private _getAddressMode;
  49619. /** @hidden */
  49620. _bindTexture(channel: number, texture: InternalTexture): void;
  49621. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49622. releaseEffects(): void;
  49623. /** @hidden */
  49624. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49625. /** @hidden */
  49626. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49627. /** @hidden */
  49628. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49629. /** @hidden */
  49630. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49631. }
  49632. }
  49633. declare module "babylonjs/Engines/index" {
  49634. export * from "babylonjs/Engines/constants";
  49635. export * from "babylonjs/Engines/engineCapabilities";
  49636. export * from "babylonjs/Engines/instancingAttributeInfo";
  49637. export * from "babylonjs/Engines/thinEngine";
  49638. export * from "babylonjs/Engines/engine";
  49639. export * from "babylonjs/Engines/engineStore";
  49640. export * from "babylonjs/Engines/nullEngine";
  49641. export * from "babylonjs/Engines/Extensions/index";
  49642. export * from "babylonjs/Engines/IPipelineContext";
  49643. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49644. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49645. export * from "babylonjs/Engines/nativeEngine";
  49646. }
  49647. declare module "babylonjs/Events/clipboardEvents" {
  49648. /**
  49649. * Gather the list of clipboard event types as constants.
  49650. */
  49651. export class ClipboardEventTypes {
  49652. /**
  49653. * The clipboard event is fired when a copy command is active (pressed).
  49654. */
  49655. static readonly COPY: number;
  49656. /**
  49657. * The clipboard event is fired when a cut command is active (pressed).
  49658. */
  49659. static readonly CUT: number;
  49660. /**
  49661. * The clipboard event is fired when a paste command is active (pressed).
  49662. */
  49663. static readonly PASTE: number;
  49664. }
  49665. /**
  49666. * This class is used to store clipboard related info for the onClipboardObservable event.
  49667. */
  49668. export class ClipboardInfo {
  49669. /**
  49670. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49671. */
  49672. type: number;
  49673. /**
  49674. * Defines the related dom event
  49675. */
  49676. event: ClipboardEvent;
  49677. /**
  49678. *Creates an instance of ClipboardInfo.
  49679. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49680. * @param event Defines the related dom event
  49681. */
  49682. constructor(
  49683. /**
  49684. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49685. */
  49686. type: number,
  49687. /**
  49688. * Defines the related dom event
  49689. */
  49690. event: ClipboardEvent);
  49691. /**
  49692. * Get the clipboard event's type from the keycode.
  49693. * @param keyCode Defines the keyCode for the current keyboard event.
  49694. * @return {number}
  49695. */
  49696. static GetTypeFromCharacter(keyCode: number): number;
  49697. }
  49698. }
  49699. declare module "babylonjs/Events/index" {
  49700. export * from "babylonjs/Events/keyboardEvents";
  49701. export * from "babylonjs/Events/pointerEvents";
  49702. export * from "babylonjs/Events/clipboardEvents";
  49703. }
  49704. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49705. import { Scene } from "babylonjs/scene";
  49706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49707. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49708. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49709. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49710. /**
  49711. * Google Daydream controller
  49712. */
  49713. export class DaydreamController extends WebVRController {
  49714. /**
  49715. * Base Url for the controller model.
  49716. */
  49717. static MODEL_BASE_URL: string;
  49718. /**
  49719. * File name for the controller model.
  49720. */
  49721. static MODEL_FILENAME: string;
  49722. /**
  49723. * Gamepad Id prefix used to identify Daydream Controller.
  49724. */
  49725. static readonly GAMEPAD_ID_PREFIX: string;
  49726. /**
  49727. * Creates a new DaydreamController from a gamepad
  49728. * @param vrGamepad the gamepad that the controller should be created from
  49729. */
  49730. constructor(vrGamepad: any);
  49731. /**
  49732. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49733. * @param scene scene in which to add meshes
  49734. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49735. */
  49736. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49737. /**
  49738. * Called once for each button that changed state since the last frame
  49739. * @param buttonIdx Which button index changed
  49740. * @param state New state of the button
  49741. * @param changes Which properties on the state changed since last frame
  49742. */
  49743. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49744. }
  49745. }
  49746. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49747. import { Scene } from "babylonjs/scene";
  49748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49749. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49750. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49751. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49752. /**
  49753. * Gear VR Controller
  49754. */
  49755. export class GearVRController extends WebVRController {
  49756. /**
  49757. * Base Url for the controller model.
  49758. */
  49759. static MODEL_BASE_URL: string;
  49760. /**
  49761. * File name for the controller model.
  49762. */
  49763. static MODEL_FILENAME: string;
  49764. /**
  49765. * Gamepad Id prefix used to identify this controller.
  49766. */
  49767. static readonly GAMEPAD_ID_PREFIX: string;
  49768. private readonly _buttonIndexToObservableNameMap;
  49769. /**
  49770. * Creates a new GearVRController from a gamepad
  49771. * @param vrGamepad the gamepad that the controller should be created from
  49772. */
  49773. constructor(vrGamepad: any);
  49774. /**
  49775. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49776. * @param scene scene in which to add meshes
  49777. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49778. */
  49779. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49780. /**
  49781. * Called once for each button that changed state since the last frame
  49782. * @param buttonIdx Which button index changed
  49783. * @param state New state of the button
  49784. * @param changes Which properties on the state changed since last frame
  49785. */
  49786. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49787. }
  49788. }
  49789. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49790. import { Scene } from "babylonjs/scene";
  49791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49792. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49793. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49794. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49795. /**
  49796. * Generic Controller
  49797. */
  49798. export class GenericController extends WebVRController {
  49799. /**
  49800. * Base Url for the controller model.
  49801. */
  49802. static readonly MODEL_BASE_URL: string;
  49803. /**
  49804. * File name for the controller model.
  49805. */
  49806. static readonly MODEL_FILENAME: string;
  49807. /**
  49808. * Creates a new GenericController from a gamepad
  49809. * @param vrGamepad the gamepad that the controller should be created from
  49810. */
  49811. constructor(vrGamepad: any);
  49812. /**
  49813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49814. * @param scene scene in which to add meshes
  49815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49816. */
  49817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49818. /**
  49819. * Called once for each button that changed state since the last frame
  49820. * @param buttonIdx Which button index changed
  49821. * @param state New state of the button
  49822. * @param changes Which properties on the state changed since last frame
  49823. */
  49824. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49825. }
  49826. }
  49827. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49828. import { Observable } from "babylonjs/Misc/observable";
  49829. import { Scene } from "babylonjs/scene";
  49830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49831. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49832. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49833. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49834. /**
  49835. * Oculus Touch Controller
  49836. */
  49837. export class OculusTouchController extends WebVRController {
  49838. /**
  49839. * Base Url for the controller model.
  49840. */
  49841. static MODEL_BASE_URL: string;
  49842. /**
  49843. * File name for the left controller model.
  49844. */
  49845. static MODEL_LEFT_FILENAME: string;
  49846. /**
  49847. * File name for the right controller model.
  49848. */
  49849. static MODEL_RIGHT_FILENAME: string;
  49850. /**
  49851. * Base Url for the Quest controller model.
  49852. */
  49853. static QUEST_MODEL_BASE_URL: string;
  49854. /**
  49855. * @hidden
  49856. * If the controllers are running on a device that needs the updated Quest controller models
  49857. */
  49858. static _IsQuest: boolean;
  49859. /**
  49860. * Fired when the secondary trigger on this controller is modified
  49861. */
  49862. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49863. /**
  49864. * Fired when the thumb rest on this controller is modified
  49865. */
  49866. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49867. /**
  49868. * Creates a new OculusTouchController from a gamepad
  49869. * @param vrGamepad the gamepad that the controller should be created from
  49870. */
  49871. constructor(vrGamepad: any);
  49872. /**
  49873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49874. * @param scene scene in which to add meshes
  49875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49876. */
  49877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49878. /**
  49879. * Fired when the A button on this controller is modified
  49880. */
  49881. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49882. /**
  49883. * Fired when the B button on this controller is modified
  49884. */
  49885. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49886. /**
  49887. * Fired when the X button on this controller is modified
  49888. */
  49889. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49890. /**
  49891. * Fired when the Y button on this controller is modified
  49892. */
  49893. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49894. /**
  49895. * Called once for each button that changed state since the last frame
  49896. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49897. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49898. * 2) secondary trigger (same)
  49899. * 3) A (right) X (left), touch, pressed = value
  49900. * 4) B / Y
  49901. * 5) thumb rest
  49902. * @param buttonIdx Which button index changed
  49903. * @param state New state of the button
  49904. * @param changes Which properties on the state changed since last frame
  49905. */
  49906. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49907. }
  49908. }
  49909. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49910. import { Scene } from "babylonjs/scene";
  49911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49912. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49913. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49914. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49915. import { Observable } from "babylonjs/Misc/observable";
  49916. /**
  49917. * Vive Controller
  49918. */
  49919. export class ViveController extends WebVRController {
  49920. /**
  49921. * Base Url for the controller model.
  49922. */
  49923. static MODEL_BASE_URL: string;
  49924. /**
  49925. * File name for the controller model.
  49926. */
  49927. static MODEL_FILENAME: string;
  49928. /**
  49929. * Creates a new ViveController from a gamepad
  49930. * @param vrGamepad the gamepad that the controller should be created from
  49931. */
  49932. constructor(vrGamepad: any);
  49933. /**
  49934. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49935. * @param scene scene in which to add meshes
  49936. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49937. */
  49938. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49939. /**
  49940. * Fired when the left button on this controller is modified
  49941. */
  49942. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49943. /**
  49944. * Fired when the right button on this controller is modified
  49945. */
  49946. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49947. /**
  49948. * Fired when the menu button on this controller is modified
  49949. */
  49950. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49951. /**
  49952. * Called once for each button that changed state since the last frame
  49953. * Vive mapping:
  49954. * 0: touchpad
  49955. * 1: trigger
  49956. * 2: left AND right buttons
  49957. * 3: menu button
  49958. * @param buttonIdx Which button index changed
  49959. * @param state New state of the button
  49960. * @param changes Which properties on the state changed since last frame
  49961. */
  49962. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49963. }
  49964. }
  49965. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49966. import { Observable } from "babylonjs/Misc/observable";
  49967. import { Scene } from "babylonjs/scene";
  49968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49969. import { Ray } from "babylonjs/Culling/ray";
  49970. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49971. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49972. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49973. /**
  49974. * Defines the WindowsMotionController object that the state of the windows motion controller
  49975. */
  49976. export class WindowsMotionController extends WebVRController {
  49977. /**
  49978. * The base url used to load the left and right controller models
  49979. */
  49980. static MODEL_BASE_URL: string;
  49981. /**
  49982. * The name of the left controller model file
  49983. */
  49984. static MODEL_LEFT_FILENAME: string;
  49985. /**
  49986. * The name of the right controller model file
  49987. */
  49988. static MODEL_RIGHT_FILENAME: string;
  49989. /**
  49990. * The controller name prefix for this controller type
  49991. */
  49992. static readonly GAMEPAD_ID_PREFIX: string;
  49993. /**
  49994. * The controller id pattern for this controller type
  49995. */
  49996. private static readonly GAMEPAD_ID_PATTERN;
  49997. private _loadedMeshInfo;
  49998. protected readonly _mapping: {
  49999. buttons: string[];
  50000. buttonMeshNames: {
  50001. 'trigger': string;
  50002. 'menu': string;
  50003. 'grip': string;
  50004. 'thumbstick': string;
  50005. 'trackpad': string;
  50006. };
  50007. buttonObservableNames: {
  50008. 'trigger': string;
  50009. 'menu': string;
  50010. 'grip': string;
  50011. 'thumbstick': string;
  50012. 'trackpad': string;
  50013. };
  50014. axisMeshNames: string[];
  50015. pointingPoseMeshName: string;
  50016. };
  50017. /**
  50018. * Fired when the trackpad on this controller is clicked
  50019. */
  50020. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50021. /**
  50022. * Fired when the trackpad on this controller is modified
  50023. */
  50024. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50025. /**
  50026. * The current x and y values of this controller's trackpad
  50027. */
  50028. trackpad: StickValues;
  50029. /**
  50030. * Creates a new WindowsMotionController from a gamepad
  50031. * @param vrGamepad the gamepad that the controller should be created from
  50032. */
  50033. constructor(vrGamepad: any);
  50034. /**
  50035. * Fired when the trigger on this controller is modified
  50036. */
  50037. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50038. /**
  50039. * Fired when the menu button on this controller is modified
  50040. */
  50041. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50042. /**
  50043. * Fired when the grip button on this controller is modified
  50044. */
  50045. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50046. /**
  50047. * Fired when the thumbstick button on this controller is modified
  50048. */
  50049. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50050. /**
  50051. * Fired when the touchpad button on this controller is modified
  50052. */
  50053. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50054. /**
  50055. * Fired when the touchpad values on this controller are modified
  50056. */
  50057. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50058. protected _updateTrackpad(): void;
  50059. /**
  50060. * Called once per frame by the engine.
  50061. */
  50062. update(): void;
  50063. /**
  50064. * Called once for each button that changed state since the last frame
  50065. * @param buttonIdx Which button index changed
  50066. * @param state New state of the button
  50067. * @param changes Which properties on the state changed since last frame
  50068. */
  50069. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50070. /**
  50071. * Moves the buttons on the controller mesh based on their current state
  50072. * @param buttonName the name of the button to move
  50073. * @param buttonValue the value of the button which determines the buttons new position
  50074. */
  50075. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50076. /**
  50077. * Moves the axis on the controller mesh based on its current state
  50078. * @param axis the index of the axis
  50079. * @param axisValue the value of the axis which determines the meshes new position
  50080. * @hidden
  50081. */
  50082. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50083. /**
  50084. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50085. * @param scene scene in which to add meshes
  50086. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50087. */
  50088. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50089. /**
  50090. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50091. * can be transformed by button presses and axes values, based on this._mapping.
  50092. *
  50093. * @param scene scene in which the meshes exist
  50094. * @param meshes list of meshes that make up the controller model to process
  50095. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50096. */
  50097. private processModel;
  50098. private createMeshInfo;
  50099. /**
  50100. * Gets the ray of the controller in the direction the controller is pointing
  50101. * @param length the length the resulting ray should be
  50102. * @returns a ray in the direction the controller is pointing
  50103. */
  50104. getForwardRay(length?: number): Ray;
  50105. /**
  50106. * Disposes of the controller
  50107. */
  50108. dispose(): void;
  50109. }
  50110. /**
  50111. * This class represents a new windows motion controller in XR.
  50112. */
  50113. export class XRWindowsMotionController extends WindowsMotionController {
  50114. /**
  50115. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50116. */
  50117. protected readonly _mapping: {
  50118. buttons: string[];
  50119. buttonMeshNames: {
  50120. 'trigger': string;
  50121. 'menu': string;
  50122. 'grip': string;
  50123. 'thumbstick': string;
  50124. 'trackpad': string;
  50125. };
  50126. buttonObservableNames: {
  50127. 'trigger': string;
  50128. 'menu': string;
  50129. 'grip': string;
  50130. 'thumbstick': string;
  50131. 'trackpad': string;
  50132. };
  50133. axisMeshNames: string[];
  50134. pointingPoseMeshName: string;
  50135. };
  50136. /**
  50137. * Construct a new XR-Based windows motion controller
  50138. *
  50139. * @param gamepadInfo the gamepad object from the browser
  50140. */
  50141. constructor(gamepadInfo: any);
  50142. /**
  50143. * holds the thumbstick values (X,Y)
  50144. */
  50145. thumbstickValues: StickValues;
  50146. /**
  50147. * Fired when the thumbstick on this controller is clicked
  50148. */
  50149. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50150. /**
  50151. * Fired when the thumbstick on this controller is modified
  50152. */
  50153. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50154. /**
  50155. * Fired when the touchpad button on this controller is modified
  50156. */
  50157. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50158. /**
  50159. * Fired when the touchpad values on this controller are modified
  50160. */
  50161. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50162. /**
  50163. * Fired when the thumbstick button on this controller is modified
  50164. * here to prevent breaking changes
  50165. */
  50166. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50167. /**
  50168. * updating the thumbstick(!) and not the trackpad.
  50169. * This is named this way due to the difference between WebVR and XR and to avoid
  50170. * changing the parent class.
  50171. */
  50172. protected _updateTrackpad(): void;
  50173. /**
  50174. * Disposes the class with joy
  50175. */
  50176. dispose(): void;
  50177. }
  50178. }
  50179. declare module "babylonjs/Gamepads/Controllers/index" {
  50180. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50181. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50182. export * from "babylonjs/Gamepads/Controllers/genericController";
  50183. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50184. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50185. export * from "babylonjs/Gamepads/Controllers/viveController";
  50186. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50187. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50188. }
  50189. declare module "babylonjs/Gamepads/index" {
  50190. export * from "babylonjs/Gamepads/Controllers/index";
  50191. export * from "babylonjs/Gamepads/gamepad";
  50192. export * from "babylonjs/Gamepads/gamepadManager";
  50193. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50194. export * from "babylonjs/Gamepads/xboxGamepad";
  50195. export * from "babylonjs/Gamepads/dualShockGamepad";
  50196. }
  50197. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50198. import { Scene } from "babylonjs/scene";
  50199. import { Vector4 } from "babylonjs/Maths/math.vector";
  50200. import { Color4 } from "babylonjs/Maths/math.color";
  50201. import { Mesh } from "babylonjs/Meshes/mesh";
  50202. import { Nullable } from "babylonjs/types";
  50203. /**
  50204. * Class containing static functions to help procedurally build meshes
  50205. */
  50206. export class PolyhedronBuilder {
  50207. /**
  50208. * Creates a polyhedron mesh
  50209. * * 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
  50210. * * The parameter `size` (positive float, default 1) sets the polygon size
  50211. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50212. * * 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`
  50213. * * 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
  50214. * * 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)`)
  50215. * * 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
  50216. * * 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
  50217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50220. * @param name defines the name of the mesh
  50221. * @param options defines the options used to create the mesh
  50222. * @param scene defines the hosting scene
  50223. * @returns the polyhedron mesh
  50224. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50225. */
  50226. static CreatePolyhedron(name: string, options: {
  50227. type?: number;
  50228. size?: number;
  50229. sizeX?: number;
  50230. sizeY?: number;
  50231. sizeZ?: number;
  50232. custom?: any;
  50233. faceUV?: Vector4[];
  50234. faceColors?: Color4[];
  50235. flat?: boolean;
  50236. updatable?: boolean;
  50237. sideOrientation?: number;
  50238. frontUVs?: Vector4;
  50239. backUVs?: Vector4;
  50240. }, scene?: Nullable<Scene>): Mesh;
  50241. }
  50242. }
  50243. declare module "babylonjs/Gizmos/scaleGizmo" {
  50244. import { Observable } from "babylonjs/Misc/observable";
  50245. import { Nullable } from "babylonjs/types";
  50246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50247. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50248. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50249. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50250. /**
  50251. * Gizmo that enables scaling a mesh along 3 axis
  50252. */
  50253. export class ScaleGizmo extends Gizmo {
  50254. /**
  50255. * Internal gizmo used for interactions on the x axis
  50256. */
  50257. xGizmo: AxisScaleGizmo;
  50258. /**
  50259. * Internal gizmo used for interactions on the y axis
  50260. */
  50261. yGizmo: AxisScaleGizmo;
  50262. /**
  50263. * Internal gizmo used for interactions on the z axis
  50264. */
  50265. zGizmo: AxisScaleGizmo;
  50266. /**
  50267. * Internal gizmo used to scale all axis equally
  50268. */
  50269. uniformScaleGizmo: AxisScaleGizmo;
  50270. private _meshAttached;
  50271. private _updateGizmoRotationToMatchAttachedMesh;
  50272. private _snapDistance;
  50273. private _scaleRatio;
  50274. private _uniformScalingMesh;
  50275. private _octahedron;
  50276. private _sensitivity;
  50277. /** Fires an event when any of it's sub gizmos are dragged */
  50278. onDragStartObservable: Observable<unknown>;
  50279. /** Fires an event when any of it's sub gizmos are released from dragging */
  50280. onDragEndObservable: Observable<unknown>;
  50281. get attachedMesh(): Nullable<AbstractMesh>;
  50282. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50283. /**
  50284. * Creates a ScaleGizmo
  50285. * @param gizmoLayer The utility layer the gizmo will be added to
  50286. */
  50287. constructor(gizmoLayer?: UtilityLayerRenderer);
  50288. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50289. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50290. /**
  50291. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50292. */
  50293. set snapDistance(value: number);
  50294. get snapDistance(): number;
  50295. /**
  50296. * Ratio for the scale of the gizmo (Default: 1)
  50297. */
  50298. set scaleRatio(value: number);
  50299. get scaleRatio(): number;
  50300. /**
  50301. * Sensitivity factor for dragging (Default: 1)
  50302. */
  50303. set sensitivity(value: number);
  50304. get sensitivity(): number;
  50305. /**
  50306. * Disposes of the gizmo
  50307. */
  50308. dispose(): void;
  50309. }
  50310. }
  50311. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50312. import { Observable } from "babylonjs/Misc/observable";
  50313. import { Nullable } from "babylonjs/types";
  50314. import { Vector3 } from "babylonjs/Maths/math.vector";
  50315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50316. import { Mesh } from "babylonjs/Meshes/mesh";
  50317. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50318. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50319. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50320. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50321. import { Color3 } from "babylonjs/Maths/math.color";
  50322. /**
  50323. * Single axis scale gizmo
  50324. */
  50325. export class AxisScaleGizmo extends Gizmo {
  50326. /**
  50327. * Drag behavior responsible for the gizmos dragging interactions
  50328. */
  50329. dragBehavior: PointerDragBehavior;
  50330. private _pointerObserver;
  50331. /**
  50332. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50333. */
  50334. snapDistance: number;
  50335. /**
  50336. * Event that fires each time the gizmo snaps to a new location.
  50337. * * snapDistance is the the change in distance
  50338. */
  50339. onSnapObservable: Observable<{
  50340. snapDistance: number;
  50341. }>;
  50342. /**
  50343. * If the scaling operation should be done on all axis (default: false)
  50344. */
  50345. uniformScaling: boolean;
  50346. /**
  50347. * Custom sensitivity value for the drag strength
  50348. */
  50349. sensitivity: number;
  50350. private _isEnabled;
  50351. private _parent;
  50352. private _arrow;
  50353. private _coloredMaterial;
  50354. private _hoverMaterial;
  50355. /**
  50356. * Creates an AxisScaleGizmo
  50357. * @param gizmoLayer The utility layer the gizmo will be added to
  50358. * @param dragAxis The axis which the gizmo will be able to scale on
  50359. * @param color The color of the gizmo
  50360. */
  50361. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50362. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50363. /**
  50364. * If the gizmo is enabled
  50365. */
  50366. set isEnabled(value: boolean);
  50367. get isEnabled(): boolean;
  50368. /**
  50369. * Disposes of the gizmo
  50370. */
  50371. dispose(): void;
  50372. /**
  50373. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50374. * @param mesh The mesh to replace the default mesh of the gizmo
  50375. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50376. */
  50377. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50378. }
  50379. }
  50380. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50381. import { Observable } from "babylonjs/Misc/observable";
  50382. import { Nullable } from "babylonjs/types";
  50383. import { Vector3 } from "babylonjs/Maths/math.vector";
  50384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50385. import { Mesh } from "babylonjs/Meshes/mesh";
  50386. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50387. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50388. import { Color3 } from "babylonjs/Maths/math.color";
  50389. import "babylonjs/Meshes/Builders/boxBuilder";
  50390. /**
  50391. * Bounding box gizmo
  50392. */
  50393. export class BoundingBoxGizmo extends Gizmo {
  50394. private _lineBoundingBox;
  50395. private _rotateSpheresParent;
  50396. private _scaleBoxesParent;
  50397. private _boundingDimensions;
  50398. private _renderObserver;
  50399. private _pointerObserver;
  50400. private _scaleDragSpeed;
  50401. private _tmpQuaternion;
  50402. private _tmpVector;
  50403. private _tmpRotationMatrix;
  50404. /**
  50405. * 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)
  50406. */
  50407. ignoreChildren: boolean;
  50408. /**
  50409. * 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)
  50410. */
  50411. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50412. /**
  50413. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50414. */
  50415. rotationSphereSize: number;
  50416. /**
  50417. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50418. */
  50419. scaleBoxSize: number;
  50420. /**
  50421. * 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)
  50422. */
  50423. fixedDragMeshScreenSize: boolean;
  50424. /**
  50425. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50426. */
  50427. fixedDragMeshScreenSizeDistanceFactor: number;
  50428. /**
  50429. * Fired when a rotation sphere or scale box is dragged
  50430. */
  50431. onDragStartObservable: Observable<{}>;
  50432. /**
  50433. * Fired when a scale box is dragged
  50434. */
  50435. onScaleBoxDragObservable: Observable<{}>;
  50436. /**
  50437. * Fired when a scale box drag is ended
  50438. */
  50439. onScaleBoxDragEndObservable: Observable<{}>;
  50440. /**
  50441. * Fired when a rotation sphere is dragged
  50442. */
  50443. onRotationSphereDragObservable: Observable<{}>;
  50444. /**
  50445. * Fired when a rotation sphere drag is ended
  50446. */
  50447. onRotationSphereDragEndObservable: Observable<{}>;
  50448. /**
  50449. * 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)
  50450. */
  50451. scalePivot: Nullable<Vector3>;
  50452. /**
  50453. * Mesh used as a pivot to rotate the attached mesh
  50454. */
  50455. private _anchorMesh;
  50456. private _existingMeshScale;
  50457. private _dragMesh;
  50458. private pointerDragBehavior;
  50459. private coloredMaterial;
  50460. private hoverColoredMaterial;
  50461. /**
  50462. * Sets the color of the bounding box gizmo
  50463. * @param color the color to set
  50464. */
  50465. setColor(color: Color3): void;
  50466. /**
  50467. * Creates an BoundingBoxGizmo
  50468. * @param gizmoLayer The utility layer the gizmo will be added to
  50469. * @param color The color of the gizmo
  50470. */
  50471. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50472. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50473. private _selectNode;
  50474. /**
  50475. * Updates the bounding box information for the Gizmo
  50476. */
  50477. updateBoundingBox(): void;
  50478. private _updateRotationSpheres;
  50479. private _updateScaleBoxes;
  50480. /**
  50481. * Enables rotation on the specified axis and disables rotation on the others
  50482. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50483. */
  50484. setEnabledRotationAxis(axis: string): void;
  50485. /**
  50486. * Enables/disables scaling
  50487. * @param enable if scaling should be enabled
  50488. */
  50489. setEnabledScaling(enable: boolean): void;
  50490. private _updateDummy;
  50491. /**
  50492. * Enables a pointer drag behavior on the bounding box of the gizmo
  50493. */
  50494. enableDragBehavior(): void;
  50495. /**
  50496. * Disposes of the gizmo
  50497. */
  50498. dispose(): void;
  50499. /**
  50500. * 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)
  50501. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50502. * @returns the bounding box mesh with the passed in mesh as a child
  50503. */
  50504. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50505. /**
  50506. * CustomMeshes are not supported by this gizmo
  50507. * @param mesh The mesh to replace the default mesh of the gizmo
  50508. */
  50509. setCustomMesh(mesh: Mesh): void;
  50510. }
  50511. }
  50512. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50513. import { Observable } from "babylonjs/Misc/observable";
  50514. import { Nullable } from "babylonjs/types";
  50515. import { Vector3 } from "babylonjs/Maths/math.vector";
  50516. import { Color3 } from "babylonjs/Maths/math.color";
  50517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50518. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50519. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50520. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50521. import "babylonjs/Meshes/Builders/linesBuilder";
  50522. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50523. /**
  50524. * Single plane rotation gizmo
  50525. */
  50526. export class PlaneRotationGizmo extends Gizmo {
  50527. /**
  50528. * Drag behavior responsible for the gizmos dragging interactions
  50529. */
  50530. dragBehavior: PointerDragBehavior;
  50531. private _pointerObserver;
  50532. /**
  50533. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50534. */
  50535. snapDistance: number;
  50536. /**
  50537. * Event that fires each time the gizmo snaps to a new location.
  50538. * * snapDistance is the the change in distance
  50539. */
  50540. onSnapObservable: Observable<{
  50541. snapDistance: number;
  50542. }>;
  50543. private _isEnabled;
  50544. private _parent;
  50545. /**
  50546. * Creates a PlaneRotationGizmo
  50547. * @param gizmoLayer The utility layer the gizmo will be added to
  50548. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50549. * @param color The color of the gizmo
  50550. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50551. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50552. */
  50553. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50554. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50555. /**
  50556. * If the gizmo is enabled
  50557. */
  50558. set isEnabled(value: boolean);
  50559. get isEnabled(): boolean;
  50560. /**
  50561. * Disposes of the gizmo
  50562. */
  50563. dispose(): void;
  50564. }
  50565. }
  50566. declare module "babylonjs/Gizmos/rotationGizmo" {
  50567. import { Observable } from "babylonjs/Misc/observable";
  50568. import { Nullable } from "babylonjs/types";
  50569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50570. import { Mesh } from "babylonjs/Meshes/mesh";
  50571. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50572. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50573. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50574. /**
  50575. * Gizmo that enables rotating a mesh along 3 axis
  50576. */
  50577. export class RotationGizmo extends Gizmo {
  50578. /**
  50579. * Internal gizmo used for interactions on the x axis
  50580. */
  50581. xGizmo: PlaneRotationGizmo;
  50582. /**
  50583. * Internal gizmo used for interactions on the y axis
  50584. */
  50585. yGizmo: PlaneRotationGizmo;
  50586. /**
  50587. * Internal gizmo used for interactions on the z axis
  50588. */
  50589. zGizmo: PlaneRotationGizmo;
  50590. /** Fires an event when any of it's sub gizmos are dragged */
  50591. onDragStartObservable: Observable<unknown>;
  50592. /** Fires an event when any of it's sub gizmos are released from dragging */
  50593. onDragEndObservable: Observable<unknown>;
  50594. private _meshAttached;
  50595. get attachedMesh(): Nullable<AbstractMesh>;
  50596. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50597. /**
  50598. * Creates a RotationGizmo
  50599. * @param gizmoLayer The utility layer the gizmo will be added to
  50600. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50601. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50602. */
  50603. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50604. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50605. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50606. /**
  50607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50608. */
  50609. set snapDistance(value: number);
  50610. get snapDistance(): number;
  50611. /**
  50612. * Ratio for the scale of the gizmo (Default: 1)
  50613. */
  50614. set scaleRatio(value: number);
  50615. get scaleRatio(): number;
  50616. /**
  50617. * Disposes of the gizmo
  50618. */
  50619. dispose(): void;
  50620. /**
  50621. * CustomMeshes are not supported by this gizmo
  50622. * @param mesh The mesh to replace the default mesh of the gizmo
  50623. */
  50624. setCustomMesh(mesh: Mesh): void;
  50625. }
  50626. }
  50627. declare module "babylonjs/Gizmos/gizmoManager" {
  50628. import { Observable } from "babylonjs/Misc/observable";
  50629. import { Nullable } from "babylonjs/types";
  50630. import { Scene, IDisposable } from "babylonjs/scene";
  50631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50632. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50633. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50634. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50635. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50636. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50637. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50638. /**
  50639. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50640. */
  50641. export class GizmoManager implements IDisposable {
  50642. private scene;
  50643. /**
  50644. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50645. */
  50646. gizmos: {
  50647. positionGizmo: Nullable<PositionGizmo>;
  50648. rotationGizmo: Nullable<RotationGizmo>;
  50649. scaleGizmo: Nullable<ScaleGizmo>;
  50650. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50651. };
  50652. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50653. clearGizmoOnEmptyPointerEvent: boolean;
  50654. /** Fires an event when the manager is attached to a mesh */
  50655. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50656. private _gizmosEnabled;
  50657. private _pointerObserver;
  50658. private _attachedMesh;
  50659. private _boundingBoxColor;
  50660. private _defaultUtilityLayer;
  50661. private _defaultKeepDepthUtilityLayer;
  50662. /**
  50663. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50664. */
  50665. boundingBoxDragBehavior: SixDofDragBehavior;
  50666. /**
  50667. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50668. */
  50669. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50670. /**
  50671. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50672. */
  50673. usePointerToAttachGizmos: boolean;
  50674. /**
  50675. * Utility layer that the bounding box gizmo belongs to
  50676. */
  50677. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50678. /**
  50679. * Utility layer that all gizmos besides bounding box belong to
  50680. */
  50681. get utilityLayer(): UtilityLayerRenderer;
  50682. /**
  50683. * Instatiates a gizmo manager
  50684. * @param scene the scene to overlay the gizmos on top of
  50685. */
  50686. constructor(scene: Scene);
  50687. /**
  50688. * Attaches a set of gizmos to the specified mesh
  50689. * @param mesh The mesh the gizmo's should be attached to
  50690. */
  50691. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50692. /**
  50693. * If the position gizmo is enabled
  50694. */
  50695. set positionGizmoEnabled(value: boolean);
  50696. get positionGizmoEnabled(): boolean;
  50697. /**
  50698. * If the rotation gizmo is enabled
  50699. */
  50700. set rotationGizmoEnabled(value: boolean);
  50701. get rotationGizmoEnabled(): boolean;
  50702. /**
  50703. * If the scale gizmo is enabled
  50704. */
  50705. set scaleGizmoEnabled(value: boolean);
  50706. get scaleGizmoEnabled(): boolean;
  50707. /**
  50708. * If the boundingBox gizmo is enabled
  50709. */
  50710. set boundingBoxGizmoEnabled(value: boolean);
  50711. get boundingBoxGizmoEnabled(): boolean;
  50712. /**
  50713. * Disposes of the gizmo manager
  50714. */
  50715. dispose(): void;
  50716. }
  50717. }
  50718. declare module "babylonjs/Lights/directionalLight" {
  50719. import { Camera } from "babylonjs/Cameras/camera";
  50720. import { Scene } from "babylonjs/scene";
  50721. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50723. import { Light } from "babylonjs/Lights/light";
  50724. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50725. import { Effect } from "babylonjs/Materials/effect";
  50726. /**
  50727. * A directional light is defined by a direction (what a surprise!).
  50728. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50729. * 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.
  50730. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50731. */
  50732. export class DirectionalLight extends ShadowLight {
  50733. private _shadowFrustumSize;
  50734. /**
  50735. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50736. */
  50737. get shadowFrustumSize(): number;
  50738. /**
  50739. * Specifies a fix frustum size for the shadow generation.
  50740. */
  50741. set shadowFrustumSize(value: number);
  50742. private _shadowOrthoScale;
  50743. /**
  50744. * Gets the shadow projection scale against the optimal computed one.
  50745. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50746. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50747. */
  50748. get shadowOrthoScale(): number;
  50749. /**
  50750. * Sets the shadow projection scale against the optimal computed one.
  50751. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50752. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50753. */
  50754. set shadowOrthoScale(value: number);
  50755. /**
  50756. * Automatically compute the projection matrix to best fit (including all the casters)
  50757. * on each frame.
  50758. */
  50759. autoUpdateExtends: boolean;
  50760. /**
  50761. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50762. * on each frame. autoUpdateExtends must be set to true for this to work
  50763. */
  50764. autoCalcShadowZBounds: boolean;
  50765. private _orthoLeft;
  50766. private _orthoRight;
  50767. private _orthoTop;
  50768. private _orthoBottom;
  50769. /**
  50770. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50771. * The directional light is emitted from everywhere in the given direction.
  50772. * It can cast shadows.
  50773. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50774. * @param name The friendly name of the light
  50775. * @param direction The direction of the light
  50776. * @param scene The scene the light belongs to
  50777. */
  50778. constructor(name: string, direction: Vector3, scene: Scene);
  50779. /**
  50780. * Returns the string "DirectionalLight".
  50781. * @return The class name
  50782. */
  50783. getClassName(): string;
  50784. /**
  50785. * Returns the integer 1.
  50786. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50787. */
  50788. getTypeID(): number;
  50789. /**
  50790. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50791. * Returns the DirectionalLight Shadow projection matrix.
  50792. */
  50793. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50794. /**
  50795. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50796. * Returns the DirectionalLight Shadow projection matrix.
  50797. */
  50798. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50799. /**
  50800. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50801. * Returns the DirectionalLight Shadow projection matrix.
  50802. */
  50803. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50804. protected _buildUniformLayout(): void;
  50805. /**
  50806. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50807. * @param effect The effect to update
  50808. * @param lightIndex The index of the light in the effect to update
  50809. * @returns The directional light
  50810. */
  50811. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50812. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50813. /**
  50814. * Gets the minZ used for shadow according to both the scene and the light.
  50815. *
  50816. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50817. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50818. * @param activeCamera The camera we are returning the min for
  50819. * @returns the depth min z
  50820. */
  50821. getDepthMinZ(activeCamera: Camera): number;
  50822. /**
  50823. * Gets the maxZ used for shadow according to both the scene and the light.
  50824. *
  50825. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50826. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50827. * @param activeCamera The camera we are returning the max for
  50828. * @returns the depth max z
  50829. */
  50830. getDepthMaxZ(activeCamera: Camera): number;
  50831. /**
  50832. * Prepares the list of defines specific to the light type.
  50833. * @param defines the list of defines
  50834. * @param lightIndex defines the index of the light for the effect
  50835. */
  50836. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50837. }
  50838. }
  50839. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50840. import { Mesh } from "babylonjs/Meshes/mesh";
  50841. /**
  50842. * Class containing static functions to help procedurally build meshes
  50843. */
  50844. export class HemisphereBuilder {
  50845. /**
  50846. * Creates a hemisphere mesh
  50847. * @param name defines the name of the mesh
  50848. * @param options defines the options used to create the mesh
  50849. * @param scene defines the hosting scene
  50850. * @returns the hemisphere mesh
  50851. */
  50852. static CreateHemisphere(name: string, options: {
  50853. segments?: number;
  50854. diameter?: number;
  50855. sideOrientation?: number;
  50856. }, scene: any): Mesh;
  50857. }
  50858. }
  50859. declare module "babylonjs/Lights/spotLight" {
  50860. import { Nullable } from "babylonjs/types";
  50861. import { Scene } from "babylonjs/scene";
  50862. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50864. import { Effect } from "babylonjs/Materials/effect";
  50865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50866. import { Light } from "babylonjs/Lights/light";
  50867. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50868. /**
  50869. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50870. * These values define a cone of light starting from the position, emitting toward the direction.
  50871. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50872. * and the exponent defines the speed of the decay of the light with distance (reach).
  50873. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50874. */
  50875. export class SpotLight extends ShadowLight {
  50876. private _angle;
  50877. private _innerAngle;
  50878. private _cosHalfAngle;
  50879. private _lightAngleScale;
  50880. private _lightAngleOffset;
  50881. /**
  50882. * Gets the cone angle of the spot light in Radians.
  50883. */
  50884. get angle(): number;
  50885. /**
  50886. * Sets the cone angle of the spot light in Radians.
  50887. */
  50888. set angle(value: number);
  50889. /**
  50890. * Only used in gltf falloff mode, this defines the angle where
  50891. * the directional falloff will start before cutting at angle which could be seen
  50892. * as outer angle.
  50893. */
  50894. get innerAngle(): number;
  50895. /**
  50896. * Only used in gltf falloff mode, this defines the angle where
  50897. * the directional falloff will start before cutting at angle which could be seen
  50898. * as outer angle.
  50899. */
  50900. set innerAngle(value: number);
  50901. private _shadowAngleScale;
  50902. /**
  50903. * Allows scaling the angle of the light for shadow generation only.
  50904. */
  50905. get shadowAngleScale(): number;
  50906. /**
  50907. * Allows scaling the angle of the light for shadow generation only.
  50908. */
  50909. set shadowAngleScale(value: number);
  50910. /**
  50911. * The light decay speed with the distance from the emission spot.
  50912. */
  50913. exponent: number;
  50914. private _projectionTextureMatrix;
  50915. /**
  50916. * Allows reading the projecton texture
  50917. */
  50918. get projectionTextureMatrix(): Matrix;
  50919. protected _projectionTextureLightNear: number;
  50920. /**
  50921. * Gets the near clip of the Spotlight for texture projection.
  50922. */
  50923. get projectionTextureLightNear(): number;
  50924. /**
  50925. * Sets the near clip of the Spotlight for texture projection.
  50926. */
  50927. set projectionTextureLightNear(value: number);
  50928. protected _projectionTextureLightFar: number;
  50929. /**
  50930. * Gets the far clip of the Spotlight for texture projection.
  50931. */
  50932. get projectionTextureLightFar(): number;
  50933. /**
  50934. * Sets the far clip of the Spotlight for texture projection.
  50935. */
  50936. set projectionTextureLightFar(value: number);
  50937. protected _projectionTextureUpDirection: Vector3;
  50938. /**
  50939. * Gets the Up vector of the Spotlight for texture projection.
  50940. */
  50941. get projectionTextureUpDirection(): Vector3;
  50942. /**
  50943. * Sets the Up vector of the Spotlight for texture projection.
  50944. */
  50945. set projectionTextureUpDirection(value: Vector3);
  50946. private _projectionTexture;
  50947. /**
  50948. * Gets the projection texture of the light.
  50949. */
  50950. get projectionTexture(): Nullable<BaseTexture>;
  50951. /**
  50952. * Sets the projection texture of the light.
  50953. */
  50954. set projectionTexture(value: Nullable<BaseTexture>);
  50955. private _projectionTextureViewLightDirty;
  50956. private _projectionTextureProjectionLightDirty;
  50957. private _projectionTextureDirty;
  50958. private _projectionTextureViewTargetVector;
  50959. private _projectionTextureViewLightMatrix;
  50960. private _projectionTextureProjectionLightMatrix;
  50961. private _projectionTextureScalingMatrix;
  50962. /**
  50963. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50964. * It can cast shadows.
  50965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50966. * @param name The light friendly name
  50967. * @param position The position of the spot light in the scene
  50968. * @param direction The direction of the light in the scene
  50969. * @param angle The cone angle of the light in Radians
  50970. * @param exponent The light decay speed with the distance from the emission spot
  50971. * @param scene The scene the lights belongs to
  50972. */
  50973. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50974. /**
  50975. * Returns the string "SpotLight".
  50976. * @returns the class name
  50977. */
  50978. getClassName(): string;
  50979. /**
  50980. * Returns the integer 2.
  50981. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50982. */
  50983. getTypeID(): number;
  50984. /**
  50985. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50986. */
  50987. protected _setDirection(value: Vector3): void;
  50988. /**
  50989. * Overrides the position setter to recompute the projection texture view light Matrix.
  50990. */
  50991. protected _setPosition(value: Vector3): void;
  50992. /**
  50993. * 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.
  50994. * Returns the SpotLight.
  50995. */
  50996. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50997. protected _computeProjectionTextureViewLightMatrix(): void;
  50998. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50999. /**
  51000. * Main function for light texture projection matrix computing.
  51001. */
  51002. protected _computeProjectionTextureMatrix(): void;
  51003. protected _buildUniformLayout(): void;
  51004. private _computeAngleValues;
  51005. /**
  51006. * Sets the passed Effect "effect" with the Light textures.
  51007. * @param effect The effect to update
  51008. * @param lightIndex The index of the light in the effect to update
  51009. * @returns The light
  51010. */
  51011. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51012. /**
  51013. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51014. * @param effect The effect to update
  51015. * @param lightIndex The index of the light in the effect to update
  51016. * @returns The spot light
  51017. */
  51018. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51019. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51020. /**
  51021. * Disposes the light and the associated resources.
  51022. */
  51023. dispose(): void;
  51024. /**
  51025. * Prepares the list of defines specific to the light type.
  51026. * @param defines the list of defines
  51027. * @param lightIndex defines the index of the light for the effect
  51028. */
  51029. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51030. }
  51031. }
  51032. declare module "babylonjs/Gizmos/lightGizmo" {
  51033. import { Nullable } from "babylonjs/types";
  51034. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51035. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51036. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51037. import { Light } from "babylonjs/Lights/light";
  51038. /**
  51039. * Gizmo that enables viewing a light
  51040. */
  51041. export class LightGizmo extends Gizmo {
  51042. private _lightMesh;
  51043. private _material;
  51044. private _cachedPosition;
  51045. private _cachedForward;
  51046. private _attachedMeshParent;
  51047. /**
  51048. * Creates a LightGizmo
  51049. * @param gizmoLayer The utility layer the gizmo will be added to
  51050. */
  51051. constructor(gizmoLayer?: UtilityLayerRenderer);
  51052. private _light;
  51053. /**
  51054. * The light that the gizmo is attached to
  51055. */
  51056. set light(light: Nullable<Light>);
  51057. get light(): Nullable<Light>;
  51058. /**
  51059. * Gets the material used to render the light gizmo
  51060. */
  51061. get material(): StandardMaterial;
  51062. /**
  51063. * @hidden
  51064. * Updates the gizmo to match the attached mesh's position/rotation
  51065. */
  51066. protected _update(): void;
  51067. private static _Scale;
  51068. /**
  51069. * Creates the lines for a light mesh
  51070. */
  51071. private static _CreateLightLines;
  51072. /**
  51073. * Disposes of the light gizmo
  51074. */
  51075. dispose(): void;
  51076. private static _CreateHemisphericLightMesh;
  51077. private static _CreatePointLightMesh;
  51078. private static _CreateSpotLightMesh;
  51079. private static _CreateDirectionalLightMesh;
  51080. }
  51081. }
  51082. declare module "babylonjs/Gizmos/index" {
  51083. export * from "babylonjs/Gizmos/axisDragGizmo";
  51084. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51085. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51086. export * from "babylonjs/Gizmos/gizmo";
  51087. export * from "babylonjs/Gizmos/gizmoManager";
  51088. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51089. export * from "babylonjs/Gizmos/positionGizmo";
  51090. export * from "babylonjs/Gizmos/rotationGizmo";
  51091. export * from "babylonjs/Gizmos/scaleGizmo";
  51092. export * from "babylonjs/Gizmos/lightGizmo";
  51093. export * from "babylonjs/Gizmos/planeDragGizmo";
  51094. }
  51095. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51096. /** @hidden */
  51097. export var backgroundFragmentDeclaration: {
  51098. name: string;
  51099. shader: string;
  51100. };
  51101. }
  51102. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51103. /** @hidden */
  51104. export var backgroundUboDeclaration: {
  51105. name: string;
  51106. shader: string;
  51107. };
  51108. }
  51109. declare module "babylonjs/Shaders/background.fragment" {
  51110. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51111. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51113. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51114. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51115. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51117. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51118. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51119. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51120. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51121. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51122. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51123. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51124. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51125. /** @hidden */
  51126. export var backgroundPixelShader: {
  51127. name: string;
  51128. shader: string;
  51129. };
  51130. }
  51131. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51132. /** @hidden */
  51133. export var backgroundVertexDeclaration: {
  51134. name: string;
  51135. shader: string;
  51136. };
  51137. }
  51138. declare module "babylonjs/Shaders/background.vertex" {
  51139. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51140. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51141. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51142. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51143. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51145. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51146. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51147. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51148. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51149. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51150. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51151. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51152. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51153. /** @hidden */
  51154. export var backgroundVertexShader: {
  51155. name: string;
  51156. shader: string;
  51157. };
  51158. }
  51159. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51160. import { Nullable, int, float } from "babylonjs/types";
  51161. import { Scene } from "babylonjs/scene";
  51162. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51165. import { Mesh } from "babylonjs/Meshes/mesh";
  51166. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51167. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51168. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51170. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51171. import { Color3 } from "babylonjs/Maths/math.color";
  51172. import "babylonjs/Shaders/background.fragment";
  51173. import "babylonjs/Shaders/background.vertex";
  51174. /**
  51175. * Background material used to create an efficient environement around your scene.
  51176. */
  51177. export class BackgroundMaterial extends PushMaterial {
  51178. /**
  51179. * Standard reflectance value at parallel view angle.
  51180. */
  51181. static StandardReflectance0: number;
  51182. /**
  51183. * Standard reflectance value at grazing angle.
  51184. */
  51185. static StandardReflectance90: number;
  51186. protected _primaryColor: Color3;
  51187. /**
  51188. * Key light Color (multiply against the environement texture)
  51189. */
  51190. primaryColor: Color3;
  51191. protected __perceptualColor: Nullable<Color3>;
  51192. /**
  51193. * Experimental Internal Use Only.
  51194. *
  51195. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51196. * This acts as a helper to set the primary color to a more "human friendly" value.
  51197. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51198. * output color as close as possible from the chosen value.
  51199. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51200. * part of lighting setup.)
  51201. */
  51202. get _perceptualColor(): Nullable<Color3>;
  51203. set _perceptualColor(value: Nullable<Color3>);
  51204. protected _primaryColorShadowLevel: float;
  51205. /**
  51206. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51207. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51208. */
  51209. get primaryColorShadowLevel(): float;
  51210. set primaryColorShadowLevel(value: float);
  51211. protected _primaryColorHighlightLevel: float;
  51212. /**
  51213. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51214. * The primary color is used at the level chosen to define what the white area would look.
  51215. */
  51216. get primaryColorHighlightLevel(): float;
  51217. set primaryColorHighlightLevel(value: float);
  51218. protected _reflectionTexture: Nullable<BaseTexture>;
  51219. /**
  51220. * Reflection Texture used in the material.
  51221. * Should be author in a specific way for the best result (refer to the documentation).
  51222. */
  51223. reflectionTexture: Nullable<BaseTexture>;
  51224. protected _reflectionBlur: float;
  51225. /**
  51226. * Reflection Texture level of blur.
  51227. *
  51228. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51229. * texture twice.
  51230. */
  51231. reflectionBlur: float;
  51232. protected _diffuseTexture: Nullable<BaseTexture>;
  51233. /**
  51234. * Diffuse Texture used in the material.
  51235. * Should be author in a specific way for the best result (refer to the documentation).
  51236. */
  51237. diffuseTexture: Nullable<BaseTexture>;
  51238. protected _shadowLights: Nullable<IShadowLight[]>;
  51239. /**
  51240. * Specify the list of lights casting shadow on the material.
  51241. * All scene shadow lights will be included if null.
  51242. */
  51243. shadowLights: Nullable<IShadowLight[]>;
  51244. protected _shadowLevel: float;
  51245. /**
  51246. * Helps adjusting the shadow to a softer level if required.
  51247. * 0 means black shadows and 1 means no shadows.
  51248. */
  51249. shadowLevel: float;
  51250. protected _sceneCenter: Vector3;
  51251. /**
  51252. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51253. * It is usually zero but might be interesting to modify according to your setup.
  51254. */
  51255. sceneCenter: Vector3;
  51256. protected _opacityFresnel: boolean;
  51257. /**
  51258. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51259. * This helps ensuring a nice transition when the camera goes under the ground.
  51260. */
  51261. opacityFresnel: boolean;
  51262. protected _reflectionFresnel: boolean;
  51263. /**
  51264. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51265. * This helps adding a mirror texture on the ground.
  51266. */
  51267. reflectionFresnel: boolean;
  51268. protected _reflectionFalloffDistance: number;
  51269. /**
  51270. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51271. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51272. */
  51273. reflectionFalloffDistance: number;
  51274. protected _reflectionAmount: number;
  51275. /**
  51276. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51277. */
  51278. reflectionAmount: number;
  51279. protected _reflectionReflectance0: number;
  51280. /**
  51281. * This specifies the weight of the reflection at grazing angle.
  51282. */
  51283. reflectionReflectance0: number;
  51284. protected _reflectionReflectance90: number;
  51285. /**
  51286. * This specifies the weight of the reflection at a perpendicular point of view.
  51287. */
  51288. reflectionReflectance90: number;
  51289. /**
  51290. * Sets the reflection reflectance fresnel values according to the default standard
  51291. * empirically know to work well :-)
  51292. */
  51293. set reflectionStandardFresnelWeight(value: number);
  51294. protected _useRGBColor: boolean;
  51295. /**
  51296. * Helps to directly use the maps channels instead of their level.
  51297. */
  51298. useRGBColor: boolean;
  51299. protected _enableNoise: boolean;
  51300. /**
  51301. * This helps reducing the banding effect that could occur on the background.
  51302. */
  51303. enableNoise: boolean;
  51304. /**
  51305. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51306. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51307. * Recommended to be keep at 1.0 except for special cases.
  51308. */
  51309. get fovMultiplier(): number;
  51310. set fovMultiplier(value: number);
  51311. private _fovMultiplier;
  51312. /**
  51313. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51314. */
  51315. useEquirectangularFOV: boolean;
  51316. private _maxSimultaneousLights;
  51317. /**
  51318. * Number of Simultaneous lights allowed on the material.
  51319. */
  51320. maxSimultaneousLights: int;
  51321. /**
  51322. * Default configuration related to image processing available in the Background Material.
  51323. */
  51324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51325. /**
  51326. * Keep track of the image processing observer to allow dispose and replace.
  51327. */
  51328. private _imageProcessingObserver;
  51329. /**
  51330. * Attaches a new image processing configuration to the PBR Material.
  51331. * @param configuration (if null the scene configuration will be use)
  51332. */
  51333. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51334. /**
  51335. * Gets the image processing configuration used either in this material.
  51336. */
  51337. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51338. /**
  51339. * Sets the Default image processing configuration used either in the this material.
  51340. *
  51341. * If sets to null, the scene one is in use.
  51342. */
  51343. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51344. /**
  51345. * Gets wether the color curves effect is enabled.
  51346. */
  51347. get cameraColorCurvesEnabled(): boolean;
  51348. /**
  51349. * Sets wether the color curves effect is enabled.
  51350. */
  51351. set cameraColorCurvesEnabled(value: boolean);
  51352. /**
  51353. * Gets wether the color grading effect is enabled.
  51354. */
  51355. get cameraColorGradingEnabled(): boolean;
  51356. /**
  51357. * Gets wether the color grading effect is enabled.
  51358. */
  51359. set cameraColorGradingEnabled(value: boolean);
  51360. /**
  51361. * Gets wether tonemapping is enabled or not.
  51362. */
  51363. get cameraToneMappingEnabled(): boolean;
  51364. /**
  51365. * Sets wether tonemapping is enabled or not
  51366. */
  51367. set cameraToneMappingEnabled(value: boolean);
  51368. /**
  51369. * The camera exposure used on this material.
  51370. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51371. * This corresponds to a photographic exposure.
  51372. */
  51373. get cameraExposure(): float;
  51374. /**
  51375. * The camera exposure used on this material.
  51376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51377. * This corresponds to a photographic exposure.
  51378. */
  51379. set cameraExposure(value: float);
  51380. /**
  51381. * Gets The camera contrast used on this material.
  51382. */
  51383. get cameraContrast(): float;
  51384. /**
  51385. * Sets The camera contrast used on this material.
  51386. */
  51387. set cameraContrast(value: float);
  51388. /**
  51389. * Gets the Color Grading 2D Lookup Texture.
  51390. */
  51391. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51392. /**
  51393. * Sets the Color Grading 2D Lookup Texture.
  51394. */
  51395. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51396. /**
  51397. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51398. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51399. * 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;
  51400. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51401. */
  51402. get cameraColorCurves(): Nullable<ColorCurves>;
  51403. /**
  51404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51406. * 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;
  51407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51408. */
  51409. set cameraColorCurves(value: Nullable<ColorCurves>);
  51410. /**
  51411. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51412. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51413. */
  51414. switchToBGR: boolean;
  51415. private _renderTargets;
  51416. private _reflectionControls;
  51417. private _white;
  51418. private _primaryShadowColor;
  51419. private _primaryHighlightColor;
  51420. /**
  51421. * Instantiates a Background Material in the given scene
  51422. * @param name The friendly name of the material
  51423. * @param scene The scene to add the material to
  51424. */
  51425. constructor(name: string, scene: Scene);
  51426. /**
  51427. * Gets a boolean indicating that current material needs to register RTT
  51428. */
  51429. get hasRenderTargetTextures(): boolean;
  51430. /**
  51431. * The entire material has been created in order to prevent overdraw.
  51432. * @returns false
  51433. */
  51434. needAlphaTesting(): boolean;
  51435. /**
  51436. * The entire material has been created in order to prevent overdraw.
  51437. * @returns true if blending is enable
  51438. */
  51439. needAlphaBlending(): boolean;
  51440. /**
  51441. * Checks wether the material is ready to be rendered for a given mesh.
  51442. * @param mesh The mesh to render
  51443. * @param subMesh The submesh to check against
  51444. * @param useInstances Specify wether or not the material is used with instances
  51445. * @returns true if all the dependencies are ready (Textures, Effects...)
  51446. */
  51447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51448. /**
  51449. * Compute the primary color according to the chosen perceptual color.
  51450. */
  51451. private _computePrimaryColorFromPerceptualColor;
  51452. /**
  51453. * Compute the highlights and shadow colors according to their chosen levels.
  51454. */
  51455. private _computePrimaryColors;
  51456. /**
  51457. * Build the uniform buffer used in the material.
  51458. */
  51459. buildUniformLayout(): void;
  51460. /**
  51461. * Unbind the material.
  51462. */
  51463. unbind(): void;
  51464. /**
  51465. * Bind only the world matrix to the material.
  51466. * @param world The world matrix to bind.
  51467. */
  51468. bindOnlyWorldMatrix(world: Matrix): void;
  51469. /**
  51470. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51471. * @param world The world matrix to bind.
  51472. * @param subMesh The submesh to bind for.
  51473. */
  51474. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51475. /**
  51476. * Checks to see if a texture is used in the material.
  51477. * @param texture - Base texture to use.
  51478. * @returns - Boolean specifying if a texture is used in the material.
  51479. */
  51480. hasTexture(texture: BaseTexture): boolean;
  51481. /**
  51482. * Dispose the material.
  51483. * @param forceDisposeEffect Force disposal of the associated effect.
  51484. * @param forceDisposeTextures Force disposal of the associated textures.
  51485. */
  51486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51487. /**
  51488. * Clones the material.
  51489. * @param name The cloned name.
  51490. * @returns The cloned material.
  51491. */
  51492. clone(name: string): BackgroundMaterial;
  51493. /**
  51494. * Serializes the current material to its JSON representation.
  51495. * @returns The JSON representation.
  51496. */
  51497. serialize(): any;
  51498. /**
  51499. * Gets the class name of the material
  51500. * @returns "BackgroundMaterial"
  51501. */
  51502. getClassName(): string;
  51503. /**
  51504. * Parse a JSON input to create back a background material.
  51505. * @param source The JSON data to parse
  51506. * @param scene The scene to create the parsed material in
  51507. * @param rootUrl The root url of the assets the material depends upon
  51508. * @returns the instantiated BackgroundMaterial.
  51509. */
  51510. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51511. }
  51512. }
  51513. declare module "babylonjs/Helpers/environmentHelper" {
  51514. import { Observable } from "babylonjs/Misc/observable";
  51515. import { Nullable } from "babylonjs/types";
  51516. import { Scene } from "babylonjs/scene";
  51517. import { Vector3 } from "babylonjs/Maths/math.vector";
  51518. import { Color3 } from "babylonjs/Maths/math.color";
  51519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51520. import { Mesh } from "babylonjs/Meshes/mesh";
  51521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51522. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51523. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51524. import "babylonjs/Meshes/Builders/planeBuilder";
  51525. import "babylonjs/Meshes/Builders/boxBuilder";
  51526. /**
  51527. * Represents the different options available during the creation of
  51528. * a Environment helper.
  51529. *
  51530. * This can control the default ground, skybox and image processing setup of your scene.
  51531. */
  51532. export interface IEnvironmentHelperOptions {
  51533. /**
  51534. * Specifies whether or not to create a ground.
  51535. * True by default.
  51536. */
  51537. createGround: boolean;
  51538. /**
  51539. * Specifies the ground size.
  51540. * 15 by default.
  51541. */
  51542. groundSize: number;
  51543. /**
  51544. * The texture used on the ground for the main color.
  51545. * Comes from the BabylonJS CDN by default.
  51546. *
  51547. * Remarks: Can be either a texture or a url.
  51548. */
  51549. groundTexture: string | BaseTexture;
  51550. /**
  51551. * The color mixed in the ground texture by default.
  51552. * BabylonJS clearColor by default.
  51553. */
  51554. groundColor: Color3;
  51555. /**
  51556. * Specifies the ground opacity.
  51557. * 1 by default.
  51558. */
  51559. groundOpacity: number;
  51560. /**
  51561. * Enables the ground to receive shadows.
  51562. * True by default.
  51563. */
  51564. enableGroundShadow: boolean;
  51565. /**
  51566. * Helps preventing the shadow to be fully black on the ground.
  51567. * 0.5 by default.
  51568. */
  51569. groundShadowLevel: number;
  51570. /**
  51571. * Creates a mirror texture attach to the ground.
  51572. * false by default.
  51573. */
  51574. enableGroundMirror: boolean;
  51575. /**
  51576. * Specifies the ground mirror size ratio.
  51577. * 0.3 by default as the default kernel is 64.
  51578. */
  51579. groundMirrorSizeRatio: number;
  51580. /**
  51581. * Specifies the ground mirror blur kernel size.
  51582. * 64 by default.
  51583. */
  51584. groundMirrorBlurKernel: number;
  51585. /**
  51586. * Specifies the ground mirror visibility amount.
  51587. * 1 by default
  51588. */
  51589. groundMirrorAmount: number;
  51590. /**
  51591. * Specifies the ground mirror reflectance weight.
  51592. * This uses the standard weight of the background material to setup the fresnel effect
  51593. * of the mirror.
  51594. * 1 by default.
  51595. */
  51596. groundMirrorFresnelWeight: number;
  51597. /**
  51598. * Specifies the ground mirror Falloff distance.
  51599. * This can helps reducing the size of the reflection.
  51600. * 0 by Default.
  51601. */
  51602. groundMirrorFallOffDistance: number;
  51603. /**
  51604. * Specifies the ground mirror texture type.
  51605. * Unsigned Int by Default.
  51606. */
  51607. groundMirrorTextureType: number;
  51608. /**
  51609. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51610. * the shown objects.
  51611. */
  51612. groundYBias: number;
  51613. /**
  51614. * Specifies whether or not to create a skybox.
  51615. * True by default.
  51616. */
  51617. createSkybox: boolean;
  51618. /**
  51619. * Specifies the skybox size.
  51620. * 20 by default.
  51621. */
  51622. skyboxSize: number;
  51623. /**
  51624. * The texture used on the skybox for the main color.
  51625. * Comes from the BabylonJS CDN by default.
  51626. *
  51627. * Remarks: Can be either a texture or a url.
  51628. */
  51629. skyboxTexture: string | BaseTexture;
  51630. /**
  51631. * The color mixed in the skybox texture by default.
  51632. * BabylonJS clearColor by default.
  51633. */
  51634. skyboxColor: Color3;
  51635. /**
  51636. * The background rotation around the Y axis of the scene.
  51637. * This helps aligning the key lights of your scene with the background.
  51638. * 0 by default.
  51639. */
  51640. backgroundYRotation: number;
  51641. /**
  51642. * Compute automatically the size of the elements to best fit with the scene.
  51643. */
  51644. sizeAuto: boolean;
  51645. /**
  51646. * Default position of the rootMesh if autoSize is not true.
  51647. */
  51648. rootPosition: Vector3;
  51649. /**
  51650. * Sets up the image processing in the scene.
  51651. * true by default.
  51652. */
  51653. setupImageProcessing: boolean;
  51654. /**
  51655. * The texture used as your environment texture in the scene.
  51656. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51657. *
  51658. * Remarks: Can be either a texture or a url.
  51659. */
  51660. environmentTexture: string | BaseTexture;
  51661. /**
  51662. * The value of the exposure to apply to the scene.
  51663. * 0.6 by default if setupImageProcessing is true.
  51664. */
  51665. cameraExposure: number;
  51666. /**
  51667. * The value of the contrast to apply to the scene.
  51668. * 1.6 by default if setupImageProcessing is true.
  51669. */
  51670. cameraContrast: number;
  51671. /**
  51672. * Specifies whether or not tonemapping should be enabled in the scene.
  51673. * true by default if setupImageProcessing is true.
  51674. */
  51675. toneMappingEnabled: boolean;
  51676. }
  51677. /**
  51678. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51679. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51680. * It also helps with the default setup of your imageProcessing configuration.
  51681. */
  51682. export class EnvironmentHelper {
  51683. /**
  51684. * Default ground texture URL.
  51685. */
  51686. private static _groundTextureCDNUrl;
  51687. /**
  51688. * Default skybox texture URL.
  51689. */
  51690. private static _skyboxTextureCDNUrl;
  51691. /**
  51692. * Default environment texture URL.
  51693. */
  51694. private static _environmentTextureCDNUrl;
  51695. /**
  51696. * Creates the default options for the helper.
  51697. */
  51698. private static _getDefaultOptions;
  51699. private _rootMesh;
  51700. /**
  51701. * Gets the root mesh created by the helper.
  51702. */
  51703. get rootMesh(): Mesh;
  51704. private _skybox;
  51705. /**
  51706. * Gets the skybox created by the helper.
  51707. */
  51708. get skybox(): Nullable<Mesh>;
  51709. private _skyboxTexture;
  51710. /**
  51711. * Gets the skybox texture created by the helper.
  51712. */
  51713. get skyboxTexture(): Nullable<BaseTexture>;
  51714. private _skyboxMaterial;
  51715. /**
  51716. * Gets the skybox material created by the helper.
  51717. */
  51718. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51719. private _ground;
  51720. /**
  51721. * Gets the ground mesh created by the helper.
  51722. */
  51723. get ground(): Nullable<Mesh>;
  51724. private _groundTexture;
  51725. /**
  51726. * Gets the ground texture created by the helper.
  51727. */
  51728. get groundTexture(): Nullable<BaseTexture>;
  51729. private _groundMirror;
  51730. /**
  51731. * Gets the ground mirror created by the helper.
  51732. */
  51733. get groundMirror(): Nullable<MirrorTexture>;
  51734. /**
  51735. * Gets the ground mirror render list to helps pushing the meshes
  51736. * you wish in the ground reflection.
  51737. */
  51738. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51739. private _groundMaterial;
  51740. /**
  51741. * Gets the ground material created by the helper.
  51742. */
  51743. get groundMaterial(): Nullable<BackgroundMaterial>;
  51744. /**
  51745. * Stores the creation options.
  51746. */
  51747. private readonly _scene;
  51748. private _options;
  51749. /**
  51750. * This observable will be notified with any error during the creation of the environment,
  51751. * mainly texture creation errors.
  51752. */
  51753. onErrorObservable: Observable<{
  51754. message?: string;
  51755. exception?: any;
  51756. }>;
  51757. /**
  51758. * constructor
  51759. * @param options Defines the options we want to customize the helper
  51760. * @param scene The scene to add the material to
  51761. */
  51762. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51763. /**
  51764. * Updates the background according to the new options
  51765. * @param options
  51766. */
  51767. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51768. /**
  51769. * Sets the primary color of all the available elements.
  51770. * @param color the main color to affect to the ground and the background
  51771. */
  51772. setMainColor(color: Color3): void;
  51773. /**
  51774. * Setup the image processing according to the specified options.
  51775. */
  51776. private _setupImageProcessing;
  51777. /**
  51778. * Setup the environment texture according to the specified options.
  51779. */
  51780. private _setupEnvironmentTexture;
  51781. /**
  51782. * Setup the background according to the specified options.
  51783. */
  51784. private _setupBackground;
  51785. /**
  51786. * Get the scene sizes according to the setup.
  51787. */
  51788. private _getSceneSize;
  51789. /**
  51790. * Setup the ground according to the specified options.
  51791. */
  51792. private _setupGround;
  51793. /**
  51794. * Setup the ground material according to the specified options.
  51795. */
  51796. private _setupGroundMaterial;
  51797. /**
  51798. * Setup the ground diffuse texture according to the specified options.
  51799. */
  51800. private _setupGroundDiffuseTexture;
  51801. /**
  51802. * Setup the ground mirror texture according to the specified options.
  51803. */
  51804. private _setupGroundMirrorTexture;
  51805. /**
  51806. * Setup the ground to receive the mirror texture.
  51807. */
  51808. private _setupMirrorInGroundMaterial;
  51809. /**
  51810. * Setup the skybox according to the specified options.
  51811. */
  51812. private _setupSkybox;
  51813. /**
  51814. * Setup the skybox material according to the specified options.
  51815. */
  51816. private _setupSkyboxMaterial;
  51817. /**
  51818. * Setup the skybox reflection texture according to the specified options.
  51819. */
  51820. private _setupSkyboxReflectionTexture;
  51821. private _errorHandler;
  51822. /**
  51823. * Dispose all the elements created by the Helper.
  51824. */
  51825. dispose(): void;
  51826. }
  51827. }
  51828. declare module "babylonjs/Helpers/photoDome" {
  51829. import { Observable } from "babylonjs/Misc/observable";
  51830. import { Nullable } from "babylonjs/types";
  51831. import { Scene } from "babylonjs/scene";
  51832. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51833. import { Mesh } from "babylonjs/Meshes/mesh";
  51834. import { Texture } from "babylonjs/Materials/Textures/texture";
  51835. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51836. import "babylonjs/Meshes/Builders/sphereBuilder";
  51837. /**
  51838. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51839. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51840. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51841. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51842. */
  51843. export class PhotoDome extends TransformNode {
  51844. /**
  51845. * Define the image as a Monoscopic panoramic 360 image.
  51846. */
  51847. static readonly MODE_MONOSCOPIC: number;
  51848. /**
  51849. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51850. */
  51851. static readonly MODE_TOPBOTTOM: number;
  51852. /**
  51853. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51854. */
  51855. static readonly MODE_SIDEBYSIDE: number;
  51856. private _useDirectMapping;
  51857. /**
  51858. * The texture being displayed on the sphere
  51859. */
  51860. protected _photoTexture: Texture;
  51861. /**
  51862. * Gets or sets the texture being displayed on the sphere
  51863. */
  51864. get photoTexture(): Texture;
  51865. set photoTexture(value: Texture);
  51866. /**
  51867. * Observable raised when an error occured while loading the 360 image
  51868. */
  51869. onLoadErrorObservable: Observable<string>;
  51870. /**
  51871. * The skybox material
  51872. */
  51873. protected _material: BackgroundMaterial;
  51874. /**
  51875. * The surface used for the skybox
  51876. */
  51877. protected _mesh: Mesh;
  51878. /**
  51879. * Gets the mesh used for the skybox.
  51880. */
  51881. get mesh(): Mesh;
  51882. /**
  51883. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51884. * Also see the options.resolution property.
  51885. */
  51886. get fovMultiplier(): number;
  51887. set fovMultiplier(value: number);
  51888. private _imageMode;
  51889. /**
  51890. * Gets or set the current video mode for the video. It can be:
  51891. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51892. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51893. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51894. */
  51895. get imageMode(): number;
  51896. set imageMode(value: number);
  51897. /**
  51898. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51899. * @param name Element's name, child elements will append suffixes for their own names.
  51900. * @param urlsOfPhoto defines the url of the photo to display
  51901. * @param options defines an object containing optional or exposed sub element properties
  51902. * @param onError defines a callback called when an error occured while loading the texture
  51903. */
  51904. constructor(name: string, urlOfPhoto: string, options: {
  51905. resolution?: number;
  51906. size?: number;
  51907. useDirectMapping?: boolean;
  51908. faceForward?: boolean;
  51909. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51910. private _onBeforeCameraRenderObserver;
  51911. private _changeImageMode;
  51912. /**
  51913. * Releases resources associated with this node.
  51914. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51915. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51916. */
  51917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51918. }
  51919. }
  51920. declare module "babylonjs/Misc/rgbdTextureTools" {
  51921. import "babylonjs/Shaders/rgbdDecode.fragment";
  51922. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51923. import { Texture } from "babylonjs/Materials/Textures/texture";
  51924. /**
  51925. * Class used to host RGBD texture specific utilities
  51926. */
  51927. export class RGBDTextureTools {
  51928. /**
  51929. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51930. * @param texture the texture to expand.
  51931. */
  51932. static ExpandRGBDTexture(texture: Texture): void;
  51933. }
  51934. }
  51935. declare module "babylonjs/Misc/brdfTextureTools" {
  51936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51937. import { Scene } from "babylonjs/scene";
  51938. /**
  51939. * Class used to host texture specific utilities
  51940. */
  51941. export class BRDFTextureTools {
  51942. /**
  51943. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51944. * @param scene defines the hosting scene
  51945. * @returns the environment BRDF texture
  51946. */
  51947. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51948. private static _environmentBRDFBase64Texture;
  51949. }
  51950. }
  51951. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51952. import { Nullable } from "babylonjs/types";
  51953. import { Color3 } from "babylonjs/Maths/math.color";
  51954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51955. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51956. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51957. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51958. import { Engine } from "babylonjs/Engines/engine";
  51959. import { Scene } from "babylonjs/scene";
  51960. /**
  51961. * @hidden
  51962. */
  51963. export interface IMaterialClearCoatDefines {
  51964. CLEARCOAT: boolean;
  51965. CLEARCOAT_DEFAULTIOR: boolean;
  51966. CLEARCOAT_TEXTURE: boolean;
  51967. CLEARCOAT_TEXTUREDIRECTUV: number;
  51968. CLEARCOAT_BUMP: boolean;
  51969. CLEARCOAT_BUMPDIRECTUV: number;
  51970. CLEARCOAT_TINT: boolean;
  51971. CLEARCOAT_TINT_TEXTURE: boolean;
  51972. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51973. /** @hidden */
  51974. _areTexturesDirty: boolean;
  51975. }
  51976. /**
  51977. * Define the code related to the clear coat parameters of the pbr material.
  51978. */
  51979. export class PBRClearCoatConfiguration {
  51980. /**
  51981. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51982. * The default fits with a polyurethane material.
  51983. */
  51984. private static readonly _DefaultIndexOfRefraction;
  51985. private _isEnabled;
  51986. /**
  51987. * Defines if the clear coat is enabled in the material.
  51988. */
  51989. isEnabled: boolean;
  51990. /**
  51991. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51992. */
  51993. intensity: number;
  51994. /**
  51995. * Defines the clear coat layer roughness.
  51996. */
  51997. roughness: number;
  51998. private _indexOfRefraction;
  51999. /**
  52000. * Defines the index of refraction of the clear coat.
  52001. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52002. * The default fits with a polyurethane material.
  52003. * Changing the default value is more performance intensive.
  52004. */
  52005. indexOfRefraction: number;
  52006. private _texture;
  52007. /**
  52008. * Stores the clear coat values in a texture.
  52009. */
  52010. texture: Nullable<BaseTexture>;
  52011. private _bumpTexture;
  52012. /**
  52013. * Define the clear coat specific bump texture.
  52014. */
  52015. bumpTexture: Nullable<BaseTexture>;
  52016. private _isTintEnabled;
  52017. /**
  52018. * Defines if the clear coat tint is enabled in the material.
  52019. */
  52020. isTintEnabled: boolean;
  52021. /**
  52022. * Defines the clear coat tint of the material.
  52023. * This is only use if tint is enabled
  52024. */
  52025. tintColor: Color3;
  52026. /**
  52027. * Defines the distance at which the tint color should be found in the
  52028. * clear coat media.
  52029. * This is only use if tint is enabled
  52030. */
  52031. tintColorAtDistance: number;
  52032. /**
  52033. * Defines the clear coat layer thickness.
  52034. * This is only use if tint is enabled
  52035. */
  52036. tintThickness: number;
  52037. private _tintTexture;
  52038. /**
  52039. * Stores the clear tint values in a texture.
  52040. * rgb is tint
  52041. * a is a thickness factor
  52042. */
  52043. tintTexture: Nullable<BaseTexture>;
  52044. /** @hidden */
  52045. private _internalMarkAllSubMeshesAsTexturesDirty;
  52046. /** @hidden */
  52047. _markAllSubMeshesAsTexturesDirty(): void;
  52048. /**
  52049. * Instantiate a new istance of clear coat configuration.
  52050. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52051. */
  52052. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52053. /**
  52054. * Gets wehter the submesh is ready to be used or not.
  52055. * @param defines the list of "defines" to update.
  52056. * @param scene defines the scene the material belongs to.
  52057. * @param engine defines the engine the material belongs to.
  52058. * @param disableBumpMap defines wether the material disables bump or not.
  52059. * @returns - boolean indicating that the submesh is ready or not.
  52060. */
  52061. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52062. /**
  52063. * Checks to see if a texture is used in the material.
  52064. * @param defines the list of "defines" to update.
  52065. * @param scene defines the scene to the material belongs to.
  52066. */
  52067. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52068. /**
  52069. * Binds the material data.
  52070. * @param uniformBuffer defines the Uniform buffer to fill in.
  52071. * @param scene defines the scene the material belongs to.
  52072. * @param engine defines the engine the material belongs to.
  52073. * @param disableBumpMap defines wether the material disables bump or not.
  52074. * @param isFrozen defines wether the material is frozen or not.
  52075. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52076. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52077. */
  52078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52079. /**
  52080. * Checks to see if a texture is used in the material.
  52081. * @param texture - Base texture to use.
  52082. * @returns - Boolean specifying if a texture is used in the material.
  52083. */
  52084. hasTexture(texture: BaseTexture): boolean;
  52085. /**
  52086. * Returns an array of the actively used textures.
  52087. * @param activeTextures Array of BaseTextures
  52088. */
  52089. getActiveTextures(activeTextures: BaseTexture[]): void;
  52090. /**
  52091. * Returns the animatable textures.
  52092. * @param animatables Array of animatable textures.
  52093. */
  52094. getAnimatables(animatables: IAnimatable[]): void;
  52095. /**
  52096. * Disposes the resources of the material.
  52097. * @param forceDisposeTextures - Forces the disposal of all textures.
  52098. */
  52099. dispose(forceDisposeTextures?: boolean): void;
  52100. /**
  52101. * Get the current class name of the texture useful for serialization or dynamic coding.
  52102. * @returns "PBRClearCoatConfiguration"
  52103. */
  52104. getClassName(): string;
  52105. /**
  52106. * Add fallbacks to the effect fallbacks list.
  52107. * @param defines defines the Base texture to use.
  52108. * @param fallbacks defines the current fallback list.
  52109. * @param currentRank defines the current fallback rank.
  52110. * @returns the new fallback rank.
  52111. */
  52112. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52113. /**
  52114. * Add the required uniforms to the current list.
  52115. * @param uniforms defines the current uniform list.
  52116. */
  52117. static AddUniforms(uniforms: string[]): void;
  52118. /**
  52119. * Add the required samplers to the current list.
  52120. * @param samplers defines the current sampler list.
  52121. */
  52122. static AddSamplers(samplers: string[]): void;
  52123. /**
  52124. * Add the required uniforms to the current buffer.
  52125. * @param uniformBuffer defines the current uniform buffer.
  52126. */
  52127. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52128. /**
  52129. * Makes a duplicate of the current configuration into another one.
  52130. * @param clearCoatConfiguration define the config where to copy the info
  52131. */
  52132. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52133. /**
  52134. * Serializes this clear coat configuration.
  52135. * @returns - An object with the serialized config.
  52136. */
  52137. serialize(): any;
  52138. /**
  52139. * Parses a anisotropy Configuration from a serialized object.
  52140. * @param source - Serialized object.
  52141. * @param scene Defines the scene we are parsing for
  52142. * @param rootUrl Defines the rootUrl to load from
  52143. */
  52144. parse(source: any, scene: Scene, rootUrl: string): void;
  52145. }
  52146. }
  52147. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52148. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52150. import { Vector2 } from "babylonjs/Maths/math.vector";
  52151. import { Scene } from "babylonjs/scene";
  52152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52153. import { Nullable } from "babylonjs/types";
  52154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52155. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52156. /**
  52157. * @hidden
  52158. */
  52159. export interface IMaterialAnisotropicDefines {
  52160. ANISOTROPIC: boolean;
  52161. ANISOTROPIC_TEXTURE: boolean;
  52162. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52163. MAINUV1: boolean;
  52164. _areTexturesDirty: boolean;
  52165. _needUVs: boolean;
  52166. }
  52167. /**
  52168. * Define the code related to the anisotropic parameters of the pbr material.
  52169. */
  52170. export class PBRAnisotropicConfiguration {
  52171. private _isEnabled;
  52172. /**
  52173. * Defines if the anisotropy is enabled in the material.
  52174. */
  52175. isEnabled: boolean;
  52176. /**
  52177. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52178. */
  52179. intensity: number;
  52180. /**
  52181. * Defines if the effect is along the tangents, bitangents or in between.
  52182. * By default, the effect is "strectching" the highlights along the tangents.
  52183. */
  52184. direction: Vector2;
  52185. private _texture;
  52186. /**
  52187. * Stores the anisotropy values in a texture.
  52188. * rg is direction (like normal from -1 to 1)
  52189. * b is a intensity
  52190. */
  52191. texture: Nullable<BaseTexture>;
  52192. /** @hidden */
  52193. private _internalMarkAllSubMeshesAsTexturesDirty;
  52194. /** @hidden */
  52195. _markAllSubMeshesAsTexturesDirty(): void;
  52196. /**
  52197. * Instantiate a new istance of anisotropy configuration.
  52198. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52199. */
  52200. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52201. /**
  52202. * Specifies that the submesh is ready to be used.
  52203. * @param defines the list of "defines" to update.
  52204. * @param scene defines the scene the material belongs to.
  52205. * @returns - boolean indicating that the submesh is ready or not.
  52206. */
  52207. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52208. /**
  52209. * Checks to see if a texture is used in the material.
  52210. * @param defines the list of "defines" to update.
  52211. * @param mesh the mesh we are preparing the defines for.
  52212. * @param scene defines the scene the material belongs to.
  52213. */
  52214. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52215. /**
  52216. * Binds the material data.
  52217. * @param uniformBuffer defines the Uniform buffer to fill in.
  52218. * @param scene defines the scene the material belongs to.
  52219. * @param isFrozen defines wether the material is frozen or not.
  52220. */
  52221. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52222. /**
  52223. * Checks to see if a texture is used in the material.
  52224. * @param texture - Base texture to use.
  52225. * @returns - Boolean specifying if a texture is used in the material.
  52226. */
  52227. hasTexture(texture: BaseTexture): boolean;
  52228. /**
  52229. * Returns an array of the actively used textures.
  52230. * @param activeTextures Array of BaseTextures
  52231. */
  52232. getActiveTextures(activeTextures: BaseTexture[]): void;
  52233. /**
  52234. * Returns the animatable textures.
  52235. * @param animatables Array of animatable textures.
  52236. */
  52237. getAnimatables(animatables: IAnimatable[]): void;
  52238. /**
  52239. * Disposes the resources of the material.
  52240. * @param forceDisposeTextures - Forces the disposal of all textures.
  52241. */
  52242. dispose(forceDisposeTextures?: boolean): void;
  52243. /**
  52244. * Get the current class name of the texture useful for serialization or dynamic coding.
  52245. * @returns "PBRAnisotropicConfiguration"
  52246. */
  52247. getClassName(): string;
  52248. /**
  52249. * Add fallbacks to the effect fallbacks list.
  52250. * @param defines defines the Base texture to use.
  52251. * @param fallbacks defines the current fallback list.
  52252. * @param currentRank defines the current fallback rank.
  52253. * @returns the new fallback rank.
  52254. */
  52255. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52256. /**
  52257. * Add the required uniforms to the current list.
  52258. * @param uniforms defines the current uniform list.
  52259. */
  52260. static AddUniforms(uniforms: string[]): void;
  52261. /**
  52262. * Add the required uniforms to the current buffer.
  52263. * @param uniformBuffer defines the current uniform buffer.
  52264. */
  52265. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52266. /**
  52267. * Add the required samplers to the current list.
  52268. * @param samplers defines the current sampler list.
  52269. */
  52270. static AddSamplers(samplers: string[]): void;
  52271. /**
  52272. * Makes a duplicate of the current configuration into another one.
  52273. * @param anisotropicConfiguration define the config where to copy the info
  52274. */
  52275. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52276. /**
  52277. * Serializes this anisotropy configuration.
  52278. * @returns - An object with the serialized config.
  52279. */
  52280. serialize(): any;
  52281. /**
  52282. * Parses a anisotropy Configuration from a serialized object.
  52283. * @param source - Serialized object.
  52284. * @param scene Defines the scene we are parsing for
  52285. * @param rootUrl Defines the rootUrl to load from
  52286. */
  52287. parse(source: any, scene: Scene, rootUrl: string): void;
  52288. }
  52289. }
  52290. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52291. import { Scene } from "babylonjs/scene";
  52292. /**
  52293. * @hidden
  52294. */
  52295. export interface IMaterialBRDFDefines {
  52296. BRDF_V_HEIGHT_CORRELATED: boolean;
  52297. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52298. SPHERICAL_HARMONICS: boolean;
  52299. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52300. /** @hidden */
  52301. _areMiscDirty: boolean;
  52302. }
  52303. /**
  52304. * Define the code related to the BRDF parameters of the pbr material.
  52305. */
  52306. export class PBRBRDFConfiguration {
  52307. /**
  52308. * Default value used for the energy conservation.
  52309. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52310. */
  52311. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52312. /**
  52313. * Default value used for the Smith Visibility Height Correlated mode.
  52314. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52315. */
  52316. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52317. /**
  52318. * Default value used for the IBL diffuse part.
  52319. * This can help switching back to the polynomials mode globally which is a tiny bit
  52320. * less GPU intensive at the drawback of a lower quality.
  52321. */
  52322. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52323. /**
  52324. * Default value used for activating energy conservation for the specular workflow.
  52325. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52326. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52327. */
  52328. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52329. private _useEnergyConservation;
  52330. /**
  52331. * Defines if the material uses energy conservation.
  52332. */
  52333. useEnergyConservation: boolean;
  52334. private _useSmithVisibilityHeightCorrelated;
  52335. /**
  52336. * LEGACY Mode set to false
  52337. * Defines if the material uses height smith correlated visibility term.
  52338. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52339. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52340. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52341. * Not relying on height correlated will also disable energy conservation.
  52342. */
  52343. useSmithVisibilityHeightCorrelated: boolean;
  52344. private _useSphericalHarmonics;
  52345. /**
  52346. * LEGACY Mode set to false
  52347. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52348. * diffuse part of the IBL.
  52349. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52350. * to the ground truth.
  52351. */
  52352. useSphericalHarmonics: boolean;
  52353. private _useSpecularGlossinessInputEnergyConservation;
  52354. /**
  52355. * Defines if the material uses energy conservation, when the specular workflow is active.
  52356. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52357. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52358. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52359. */
  52360. useSpecularGlossinessInputEnergyConservation: boolean;
  52361. /** @hidden */
  52362. private _internalMarkAllSubMeshesAsMiscDirty;
  52363. /** @hidden */
  52364. _markAllSubMeshesAsMiscDirty(): void;
  52365. /**
  52366. * Instantiate a new istance of clear coat configuration.
  52367. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52368. */
  52369. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52370. /**
  52371. * Checks to see if a texture is used in the material.
  52372. * @param defines the list of "defines" to update.
  52373. */
  52374. prepareDefines(defines: IMaterialBRDFDefines): void;
  52375. /**
  52376. * Get the current class name of the texture useful for serialization or dynamic coding.
  52377. * @returns "PBRClearCoatConfiguration"
  52378. */
  52379. getClassName(): string;
  52380. /**
  52381. * Makes a duplicate of the current configuration into another one.
  52382. * @param brdfConfiguration define the config where to copy the info
  52383. */
  52384. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52385. /**
  52386. * Serializes this BRDF configuration.
  52387. * @returns - An object with the serialized config.
  52388. */
  52389. serialize(): any;
  52390. /**
  52391. * Parses a anisotropy Configuration from a serialized object.
  52392. * @param source - Serialized object.
  52393. * @param scene Defines the scene we are parsing for
  52394. * @param rootUrl Defines the rootUrl to load from
  52395. */
  52396. parse(source: any, scene: Scene, rootUrl: string): void;
  52397. }
  52398. }
  52399. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52401. import { Color3 } from "babylonjs/Maths/math.color";
  52402. import { Scene } from "babylonjs/scene";
  52403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52404. import { Nullable } from "babylonjs/types";
  52405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52406. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52407. /**
  52408. * @hidden
  52409. */
  52410. export interface IMaterialSheenDefines {
  52411. SHEEN: boolean;
  52412. SHEEN_TEXTURE: boolean;
  52413. SHEEN_TEXTUREDIRECTUV: number;
  52414. SHEEN_LINKWITHALBEDO: boolean;
  52415. /** @hidden */
  52416. _areTexturesDirty: boolean;
  52417. }
  52418. /**
  52419. * Define the code related to the Sheen parameters of the pbr material.
  52420. */
  52421. export class PBRSheenConfiguration {
  52422. private _isEnabled;
  52423. /**
  52424. * Defines if the material uses sheen.
  52425. */
  52426. isEnabled: boolean;
  52427. private _linkSheenWithAlbedo;
  52428. /**
  52429. * Defines if the sheen is linked to the sheen color.
  52430. */
  52431. linkSheenWithAlbedo: boolean;
  52432. /**
  52433. * Defines the sheen intensity.
  52434. */
  52435. intensity: number;
  52436. /**
  52437. * Defines the sheen color.
  52438. */
  52439. color: Color3;
  52440. private _texture;
  52441. /**
  52442. * Stores the sheen tint values in a texture.
  52443. * rgb is tint
  52444. * a is a intensity
  52445. */
  52446. texture: Nullable<BaseTexture>;
  52447. /** @hidden */
  52448. private _internalMarkAllSubMeshesAsTexturesDirty;
  52449. /** @hidden */
  52450. _markAllSubMeshesAsTexturesDirty(): void;
  52451. /**
  52452. * Instantiate a new istance of clear coat configuration.
  52453. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52454. */
  52455. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52456. /**
  52457. * Specifies that the submesh is ready to be used.
  52458. * @param defines the list of "defines" to update.
  52459. * @param scene defines the scene the material belongs to.
  52460. * @returns - boolean indicating that the submesh is ready or not.
  52461. */
  52462. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52463. /**
  52464. * Checks to see if a texture is used in the material.
  52465. * @param defines the list of "defines" to update.
  52466. * @param scene defines the scene the material belongs to.
  52467. */
  52468. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52469. /**
  52470. * Binds the material data.
  52471. * @param uniformBuffer defines the Uniform buffer to fill in.
  52472. * @param scene defines the scene the material belongs to.
  52473. * @param isFrozen defines wether the material is frozen or not.
  52474. */
  52475. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52476. /**
  52477. * Checks to see if a texture is used in the material.
  52478. * @param texture - Base texture to use.
  52479. * @returns - Boolean specifying if a texture is used in the material.
  52480. */
  52481. hasTexture(texture: BaseTexture): boolean;
  52482. /**
  52483. * Returns an array of the actively used textures.
  52484. * @param activeTextures Array of BaseTextures
  52485. */
  52486. getActiveTextures(activeTextures: BaseTexture[]): void;
  52487. /**
  52488. * Returns the animatable textures.
  52489. * @param animatables Array of animatable textures.
  52490. */
  52491. getAnimatables(animatables: IAnimatable[]): void;
  52492. /**
  52493. * Disposes the resources of the material.
  52494. * @param forceDisposeTextures - Forces the disposal of all textures.
  52495. */
  52496. dispose(forceDisposeTextures?: boolean): void;
  52497. /**
  52498. * Get the current class name of the texture useful for serialization or dynamic coding.
  52499. * @returns "PBRSheenConfiguration"
  52500. */
  52501. getClassName(): string;
  52502. /**
  52503. * Add fallbacks to the effect fallbacks list.
  52504. * @param defines defines the Base texture to use.
  52505. * @param fallbacks defines the current fallback list.
  52506. * @param currentRank defines the current fallback rank.
  52507. * @returns the new fallback rank.
  52508. */
  52509. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52510. /**
  52511. * Add the required uniforms to the current list.
  52512. * @param uniforms defines the current uniform list.
  52513. */
  52514. static AddUniforms(uniforms: string[]): void;
  52515. /**
  52516. * Add the required uniforms to the current buffer.
  52517. * @param uniformBuffer defines the current uniform buffer.
  52518. */
  52519. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52520. /**
  52521. * Add the required samplers to the current list.
  52522. * @param samplers defines the current sampler list.
  52523. */
  52524. static AddSamplers(samplers: string[]): void;
  52525. /**
  52526. * Makes a duplicate of the current configuration into another one.
  52527. * @param sheenConfiguration define the config where to copy the info
  52528. */
  52529. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52530. /**
  52531. * Serializes this BRDF configuration.
  52532. * @returns - An object with the serialized config.
  52533. */
  52534. serialize(): any;
  52535. /**
  52536. * Parses a anisotropy Configuration from a serialized object.
  52537. * @param source - Serialized object.
  52538. * @param scene Defines the scene we are parsing for
  52539. * @param rootUrl Defines the rootUrl to load from
  52540. */
  52541. parse(source: any, scene: Scene, rootUrl: string): void;
  52542. }
  52543. }
  52544. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52545. import { Nullable } from "babylonjs/types";
  52546. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52547. import { Color3 } from "babylonjs/Maths/math.color";
  52548. import { SmartArray } from "babylonjs/Misc/smartArray";
  52549. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52551. import { Effect } from "babylonjs/Materials/effect";
  52552. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52553. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52554. import { Engine } from "babylonjs/Engines/engine";
  52555. import { Scene } from "babylonjs/scene";
  52556. /**
  52557. * @hidden
  52558. */
  52559. export interface IMaterialSubSurfaceDefines {
  52560. SUBSURFACE: boolean;
  52561. SS_REFRACTION: boolean;
  52562. SS_TRANSLUCENCY: boolean;
  52563. SS_SCATERRING: boolean;
  52564. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52565. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52566. SS_REFRACTIONMAP_3D: boolean;
  52567. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52568. SS_LODINREFRACTIONALPHA: boolean;
  52569. SS_GAMMAREFRACTION: boolean;
  52570. SS_RGBDREFRACTION: boolean;
  52571. SS_LINEARSPECULARREFRACTION: boolean;
  52572. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52573. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52574. /** @hidden */
  52575. _areTexturesDirty: boolean;
  52576. }
  52577. /**
  52578. * Define the code related to the sub surface parameters of the pbr material.
  52579. */
  52580. export class PBRSubSurfaceConfiguration {
  52581. private _isRefractionEnabled;
  52582. /**
  52583. * Defines if the refraction is enabled in the material.
  52584. */
  52585. isRefractionEnabled: boolean;
  52586. private _isTranslucencyEnabled;
  52587. /**
  52588. * Defines if the translucency is enabled in the material.
  52589. */
  52590. isTranslucencyEnabled: boolean;
  52591. private _isScatteringEnabled;
  52592. /**
  52593. * Defines the refraction intensity of the material.
  52594. * The refraction when enabled replaces the Diffuse part of the material.
  52595. * The intensity helps transitionning between diffuse and refraction.
  52596. */
  52597. refractionIntensity: number;
  52598. /**
  52599. * Defines the translucency intensity of the material.
  52600. * When translucency has been enabled, this defines how much of the "translucency"
  52601. * is addded to the diffuse part of the material.
  52602. */
  52603. translucencyIntensity: number;
  52604. /**
  52605. * Defines the scattering intensity of the material.
  52606. * When scattering has been enabled, this defines how much of the "scattered light"
  52607. * is addded to the diffuse part of the material.
  52608. */
  52609. scatteringIntensity: number;
  52610. private _thicknessTexture;
  52611. /**
  52612. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52613. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52614. * 0 would mean minimumThickness
  52615. * 1 would mean maximumThickness
  52616. * The other channels might be use as a mask to vary the different effects intensity.
  52617. */
  52618. thicknessTexture: Nullable<BaseTexture>;
  52619. private _refractionTexture;
  52620. /**
  52621. * Defines the texture to use for refraction.
  52622. */
  52623. refractionTexture: Nullable<BaseTexture>;
  52624. private _indexOfRefraction;
  52625. /**
  52626. * Defines the index of refraction used in the material.
  52627. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52628. */
  52629. indexOfRefraction: number;
  52630. private _invertRefractionY;
  52631. /**
  52632. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52633. */
  52634. invertRefractionY: boolean;
  52635. private _linkRefractionWithTransparency;
  52636. /**
  52637. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52638. * Materials half opaque for instance using refraction could benefit from this control.
  52639. */
  52640. linkRefractionWithTransparency: boolean;
  52641. /**
  52642. * Defines the minimum thickness stored in the thickness map.
  52643. * If no thickness map is defined, this value will be used to simulate thickness.
  52644. */
  52645. minimumThickness: number;
  52646. /**
  52647. * Defines the maximum thickness stored in the thickness map.
  52648. */
  52649. maximumThickness: number;
  52650. /**
  52651. * Defines the volume tint of the material.
  52652. * This is used for both translucency and scattering.
  52653. */
  52654. tintColor: Color3;
  52655. /**
  52656. * Defines the distance at which the tint color should be found in the media.
  52657. * This is used for refraction only.
  52658. */
  52659. tintColorAtDistance: number;
  52660. /**
  52661. * Defines how far each channel transmit through the media.
  52662. * It is defined as a color to simplify it selection.
  52663. */
  52664. diffusionDistance: Color3;
  52665. private _useMaskFromThicknessTexture;
  52666. /**
  52667. * Stores the intensity of the different subsurface effects in the thickness texture.
  52668. * * the green channel is the translucency intensity.
  52669. * * the blue channel is the scattering intensity.
  52670. * * the alpha channel is the refraction intensity.
  52671. */
  52672. useMaskFromThicknessTexture: boolean;
  52673. /** @hidden */
  52674. private _internalMarkAllSubMeshesAsTexturesDirty;
  52675. /** @hidden */
  52676. _markAllSubMeshesAsTexturesDirty(): void;
  52677. /**
  52678. * Instantiate a new istance of sub surface configuration.
  52679. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52680. */
  52681. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52682. /**
  52683. * Gets wehter the submesh is ready to be used or not.
  52684. * @param defines the list of "defines" to update.
  52685. * @param scene defines the scene the material belongs to.
  52686. * @returns - boolean indicating that the submesh is ready or not.
  52687. */
  52688. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52689. /**
  52690. * Checks to see if a texture is used in the material.
  52691. * @param defines the list of "defines" to update.
  52692. * @param scene defines the scene to the material belongs to.
  52693. */
  52694. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52695. /**
  52696. * Binds the material data.
  52697. * @param uniformBuffer defines the Uniform buffer to fill in.
  52698. * @param scene defines the scene the material belongs to.
  52699. * @param engine defines the engine the material belongs to.
  52700. * @param isFrozen defines wether the material is frozen or not.
  52701. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52702. */
  52703. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52704. /**
  52705. * Unbinds the material from the mesh.
  52706. * @param activeEffect defines the effect that should be unbound from.
  52707. * @returns true if unbound, otherwise false
  52708. */
  52709. unbind(activeEffect: Effect): boolean;
  52710. /**
  52711. * Returns the texture used for refraction or null if none is used.
  52712. * @param scene defines the scene the material belongs to.
  52713. * @returns - Refraction texture if present. If no refraction texture and refraction
  52714. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52715. */
  52716. private _getRefractionTexture;
  52717. /**
  52718. * Returns true if alpha blending should be disabled.
  52719. */
  52720. get disableAlphaBlending(): boolean;
  52721. /**
  52722. * Fills the list of render target textures.
  52723. * @param renderTargets the list of render targets to update
  52724. */
  52725. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52726. /**
  52727. * Checks to see if a texture is used in the material.
  52728. * @param texture - Base texture to use.
  52729. * @returns - Boolean specifying if a texture is used in the material.
  52730. */
  52731. hasTexture(texture: BaseTexture): boolean;
  52732. /**
  52733. * Gets a boolean indicating that current material needs to register RTT
  52734. * @returns true if this uses a render target otherwise false.
  52735. */
  52736. hasRenderTargetTextures(): boolean;
  52737. /**
  52738. * Returns an array of the actively used textures.
  52739. * @param activeTextures Array of BaseTextures
  52740. */
  52741. getActiveTextures(activeTextures: BaseTexture[]): void;
  52742. /**
  52743. * Returns the animatable textures.
  52744. * @param animatables Array of animatable textures.
  52745. */
  52746. getAnimatables(animatables: IAnimatable[]): void;
  52747. /**
  52748. * Disposes the resources of the material.
  52749. * @param forceDisposeTextures - Forces the disposal of all textures.
  52750. */
  52751. dispose(forceDisposeTextures?: boolean): void;
  52752. /**
  52753. * Get the current class name of the texture useful for serialization or dynamic coding.
  52754. * @returns "PBRSubSurfaceConfiguration"
  52755. */
  52756. getClassName(): string;
  52757. /**
  52758. * Add fallbacks to the effect fallbacks list.
  52759. * @param defines defines the Base texture to use.
  52760. * @param fallbacks defines the current fallback list.
  52761. * @param currentRank defines the current fallback rank.
  52762. * @returns the new fallback rank.
  52763. */
  52764. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52765. /**
  52766. * Add the required uniforms to the current list.
  52767. * @param uniforms defines the current uniform list.
  52768. */
  52769. static AddUniforms(uniforms: string[]): void;
  52770. /**
  52771. * Add the required samplers to the current list.
  52772. * @param samplers defines the current sampler list.
  52773. */
  52774. static AddSamplers(samplers: string[]): void;
  52775. /**
  52776. * Add the required uniforms to the current buffer.
  52777. * @param uniformBuffer defines the current uniform buffer.
  52778. */
  52779. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52780. /**
  52781. * Makes a duplicate of the current configuration into another one.
  52782. * @param configuration define the config where to copy the info
  52783. */
  52784. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52785. /**
  52786. * Serializes this Sub Surface configuration.
  52787. * @returns - An object with the serialized config.
  52788. */
  52789. serialize(): any;
  52790. /**
  52791. * Parses a anisotropy Configuration from a serialized object.
  52792. * @param source - Serialized object.
  52793. * @param scene Defines the scene we are parsing for
  52794. * @param rootUrl Defines the rootUrl to load from
  52795. */
  52796. parse(source: any, scene: Scene, rootUrl: string): void;
  52797. }
  52798. }
  52799. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52800. /** @hidden */
  52801. export var pbrFragmentDeclaration: {
  52802. name: string;
  52803. shader: string;
  52804. };
  52805. }
  52806. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52807. /** @hidden */
  52808. export var pbrUboDeclaration: {
  52809. name: string;
  52810. shader: string;
  52811. };
  52812. }
  52813. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52814. /** @hidden */
  52815. export var pbrFragmentExtraDeclaration: {
  52816. name: string;
  52817. shader: string;
  52818. };
  52819. }
  52820. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52821. /** @hidden */
  52822. export var pbrFragmentSamplersDeclaration: {
  52823. name: string;
  52824. shader: string;
  52825. };
  52826. }
  52827. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52828. /** @hidden */
  52829. export var pbrHelperFunctions: {
  52830. name: string;
  52831. shader: string;
  52832. };
  52833. }
  52834. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52835. /** @hidden */
  52836. export var harmonicsFunctions: {
  52837. name: string;
  52838. shader: string;
  52839. };
  52840. }
  52841. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52842. /** @hidden */
  52843. export var pbrDirectLightingSetupFunctions: {
  52844. name: string;
  52845. shader: string;
  52846. };
  52847. }
  52848. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52849. /** @hidden */
  52850. export var pbrDirectLightingFalloffFunctions: {
  52851. name: string;
  52852. shader: string;
  52853. };
  52854. }
  52855. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52856. /** @hidden */
  52857. export var pbrBRDFFunctions: {
  52858. name: string;
  52859. shader: string;
  52860. };
  52861. }
  52862. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52863. /** @hidden */
  52864. export var pbrDirectLightingFunctions: {
  52865. name: string;
  52866. shader: string;
  52867. };
  52868. }
  52869. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52870. /** @hidden */
  52871. export var pbrIBLFunctions: {
  52872. name: string;
  52873. shader: string;
  52874. };
  52875. }
  52876. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52877. /** @hidden */
  52878. export var pbrDebug: {
  52879. name: string;
  52880. shader: string;
  52881. };
  52882. }
  52883. declare module "babylonjs/Shaders/pbr.fragment" {
  52884. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52885. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52886. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52887. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52888. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52889. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52890. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52891. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52892. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52893. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52894. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52895. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52896. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52897. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52898. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52899. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52900. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52901. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52902. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52903. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52904. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52905. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52906. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52907. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52908. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52909. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52910. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52911. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52912. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52913. /** @hidden */
  52914. export var pbrPixelShader: {
  52915. name: string;
  52916. shader: string;
  52917. };
  52918. }
  52919. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52920. /** @hidden */
  52921. export var pbrVertexDeclaration: {
  52922. name: string;
  52923. shader: string;
  52924. };
  52925. }
  52926. declare module "babylonjs/Shaders/pbr.vertex" {
  52927. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52928. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52929. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52930. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52931. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52932. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52933. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52934. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52935. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52936. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52937. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52940. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52941. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52942. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52943. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52944. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52945. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52946. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52947. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52948. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52949. /** @hidden */
  52950. export var pbrVertexShader: {
  52951. name: string;
  52952. shader: string;
  52953. };
  52954. }
  52955. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52956. import { Nullable } from "babylonjs/types";
  52957. import { Scene } from "babylonjs/scene";
  52958. import { Matrix } from "babylonjs/Maths/math.vector";
  52959. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52961. import { Mesh } from "babylonjs/Meshes/mesh";
  52962. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52963. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52964. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52965. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52966. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52967. import { Color3 } from "babylonjs/Maths/math.color";
  52968. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52969. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52970. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52971. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52973. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52974. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52975. import "babylonjs/Shaders/pbr.fragment";
  52976. import "babylonjs/Shaders/pbr.vertex";
  52977. /**
  52978. * Manages the defines for the PBR Material.
  52979. * @hidden
  52980. */
  52981. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52982. PBR: boolean;
  52983. MAINUV1: boolean;
  52984. MAINUV2: boolean;
  52985. UV1: boolean;
  52986. UV2: boolean;
  52987. ALBEDO: boolean;
  52988. GAMMAALBEDO: boolean;
  52989. ALBEDODIRECTUV: number;
  52990. VERTEXCOLOR: boolean;
  52991. AMBIENT: boolean;
  52992. AMBIENTDIRECTUV: number;
  52993. AMBIENTINGRAYSCALE: boolean;
  52994. OPACITY: boolean;
  52995. VERTEXALPHA: boolean;
  52996. OPACITYDIRECTUV: number;
  52997. OPACITYRGB: boolean;
  52998. ALPHATEST: boolean;
  52999. DEPTHPREPASS: boolean;
  53000. ALPHABLEND: boolean;
  53001. ALPHAFROMALBEDO: boolean;
  53002. ALPHATESTVALUE: string;
  53003. SPECULAROVERALPHA: boolean;
  53004. RADIANCEOVERALPHA: boolean;
  53005. ALPHAFRESNEL: boolean;
  53006. LINEARALPHAFRESNEL: boolean;
  53007. PREMULTIPLYALPHA: boolean;
  53008. EMISSIVE: boolean;
  53009. EMISSIVEDIRECTUV: number;
  53010. REFLECTIVITY: boolean;
  53011. REFLECTIVITYDIRECTUV: number;
  53012. SPECULARTERM: boolean;
  53013. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53014. MICROSURFACEAUTOMATIC: boolean;
  53015. LODBASEDMICROSFURACE: boolean;
  53016. MICROSURFACEMAP: boolean;
  53017. MICROSURFACEMAPDIRECTUV: number;
  53018. METALLICWORKFLOW: boolean;
  53019. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53020. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53021. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53022. AOSTOREINMETALMAPRED: boolean;
  53023. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53024. ENVIRONMENTBRDF: boolean;
  53025. ENVIRONMENTBRDF_RGBD: boolean;
  53026. NORMAL: boolean;
  53027. TANGENT: boolean;
  53028. BUMP: boolean;
  53029. BUMPDIRECTUV: number;
  53030. OBJECTSPACE_NORMALMAP: boolean;
  53031. PARALLAX: boolean;
  53032. PARALLAXOCCLUSION: boolean;
  53033. NORMALXYSCALE: boolean;
  53034. LIGHTMAP: boolean;
  53035. LIGHTMAPDIRECTUV: number;
  53036. USELIGHTMAPASSHADOWMAP: boolean;
  53037. GAMMALIGHTMAP: boolean;
  53038. RGBDLIGHTMAP: boolean;
  53039. REFLECTION: boolean;
  53040. REFLECTIONMAP_3D: boolean;
  53041. REFLECTIONMAP_SPHERICAL: boolean;
  53042. REFLECTIONMAP_PLANAR: boolean;
  53043. REFLECTIONMAP_CUBIC: boolean;
  53044. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53045. REFLECTIONMAP_PROJECTION: boolean;
  53046. REFLECTIONMAP_SKYBOX: boolean;
  53047. REFLECTIONMAP_EXPLICIT: boolean;
  53048. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53049. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53050. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53051. INVERTCUBICMAP: boolean;
  53052. USESPHERICALFROMREFLECTIONMAP: boolean;
  53053. USEIRRADIANCEMAP: boolean;
  53054. SPHERICAL_HARMONICS: boolean;
  53055. USESPHERICALINVERTEX: boolean;
  53056. REFLECTIONMAP_OPPOSITEZ: boolean;
  53057. LODINREFLECTIONALPHA: boolean;
  53058. GAMMAREFLECTION: boolean;
  53059. RGBDREFLECTION: boolean;
  53060. LINEARSPECULARREFLECTION: boolean;
  53061. RADIANCEOCCLUSION: boolean;
  53062. HORIZONOCCLUSION: boolean;
  53063. INSTANCES: boolean;
  53064. NUM_BONE_INFLUENCERS: number;
  53065. BonesPerMesh: number;
  53066. BONETEXTURE: boolean;
  53067. NONUNIFORMSCALING: boolean;
  53068. MORPHTARGETS: boolean;
  53069. MORPHTARGETS_NORMAL: boolean;
  53070. MORPHTARGETS_TANGENT: boolean;
  53071. MORPHTARGETS_UV: boolean;
  53072. NUM_MORPH_INFLUENCERS: number;
  53073. IMAGEPROCESSING: boolean;
  53074. VIGNETTE: boolean;
  53075. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53076. VIGNETTEBLENDMODEOPAQUE: boolean;
  53077. TONEMAPPING: boolean;
  53078. TONEMAPPING_ACES: boolean;
  53079. CONTRAST: boolean;
  53080. COLORCURVES: boolean;
  53081. COLORGRADING: boolean;
  53082. COLORGRADING3D: boolean;
  53083. SAMPLER3DGREENDEPTH: boolean;
  53084. SAMPLER3DBGRMAP: boolean;
  53085. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53086. EXPOSURE: boolean;
  53087. MULTIVIEW: boolean;
  53088. USEPHYSICALLIGHTFALLOFF: boolean;
  53089. USEGLTFLIGHTFALLOFF: boolean;
  53090. TWOSIDEDLIGHTING: boolean;
  53091. SHADOWFLOAT: boolean;
  53092. CLIPPLANE: boolean;
  53093. CLIPPLANE2: boolean;
  53094. CLIPPLANE3: boolean;
  53095. CLIPPLANE4: boolean;
  53096. CLIPPLANE5: boolean;
  53097. CLIPPLANE6: boolean;
  53098. POINTSIZE: boolean;
  53099. FOG: boolean;
  53100. LOGARITHMICDEPTH: boolean;
  53101. FORCENORMALFORWARD: boolean;
  53102. SPECULARAA: boolean;
  53103. CLEARCOAT: boolean;
  53104. CLEARCOAT_DEFAULTIOR: boolean;
  53105. CLEARCOAT_TEXTURE: boolean;
  53106. CLEARCOAT_TEXTUREDIRECTUV: number;
  53107. CLEARCOAT_BUMP: boolean;
  53108. CLEARCOAT_BUMPDIRECTUV: number;
  53109. CLEARCOAT_TINT: boolean;
  53110. CLEARCOAT_TINT_TEXTURE: boolean;
  53111. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53112. ANISOTROPIC: boolean;
  53113. ANISOTROPIC_TEXTURE: boolean;
  53114. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53115. BRDF_V_HEIGHT_CORRELATED: boolean;
  53116. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53117. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53118. SHEEN: boolean;
  53119. SHEEN_TEXTURE: boolean;
  53120. SHEEN_TEXTUREDIRECTUV: number;
  53121. SHEEN_LINKWITHALBEDO: boolean;
  53122. SUBSURFACE: boolean;
  53123. SS_REFRACTION: boolean;
  53124. SS_TRANSLUCENCY: boolean;
  53125. SS_SCATERRING: boolean;
  53126. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53127. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53128. SS_REFRACTIONMAP_3D: boolean;
  53129. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53130. SS_LODINREFRACTIONALPHA: boolean;
  53131. SS_GAMMAREFRACTION: boolean;
  53132. SS_RGBDREFRACTION: boolean;
  53133. SS_LINEARSPECULARREFRACTION: boolean;
  53134. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53135. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53136. UNLIT: boolean;
  53137. DEBUGMODE: number;
  53138. /**
  53139. * Initializes the PBR Material defines.
  53140. */
  53141. constructor();
  53142. /**
  53143. * Resets the PBR Material defines.
  53144. */
  53145. reset(): void;
  53146. }
  53147. /**
  53148. * The Physically based material base class of BJS.
  53149. *
  53150. * This offers the main features of a standard PBR material.
  53151. * For more information, please refer to the documentation :
  53152. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53153. */
  53154. export abstract class PBRBaseMaterial extends PushMaterial {
  53155. /**
  53156. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53157. */
  53158. static readonly PBRMATERIAL_OPAQUE: number;
  53159. /**
  53160. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53161. */
  53162. static readonly PBRMATERIAL_ALPHATEST: number;
  53163. /**
  53164. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53165. */
  53166. static readonly PBRMATERIAL_ALPHABLEND: number;
  53167. /**
  53168. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53169. * They are also discarded below the alpha cutoff threshold to improve performances.
  53170. */
  53171. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53172. /**
  53173. * Defines the default value of how much AO map is occluding the analytical lights
  53174. * (point spot...).
  53175. */
  53176. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53177. /**
  53178. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53179. */
  53180. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53181. /**
  53182. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53183. * to enhance interoperability with other engines.
  53184. */
  53185. static readonly LIGHTFALLOFF_GLTF: number;
  53186. /**
  53187. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53188. * to enhance interoperability with other materials.
  53189. */
  53190. static readonly LIGHTFALLOFF_STANDARD: number;
  53191. /**
  53192. * Intensity of the direct lights e.g. the four lights available in your scene.
  53193. * This impacts both the direct diffuse and specular highlights.
  53194. */
  53195. protected _directIntensity: number;
  53196. /**
  53197. * Intensity of the emissive part of the material.
  53198. * This helps controlling the emissive effect without modifying the emissive color.
  53199. */
  53200. protected _emissiveIntensity: number;
  53201. /**
  53202. * Intensity of the environment e.g. how much the environment will light the object
  53203. * either through harmonics for rough material or through the refelction for shiny ones.
  53204. */
  53205. protected _environmentIntensity: number;
  53206. /**
  53207. * This is a special control allowing the reduction of the specular highlights coming from the
  53208. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53209. */
  53210. protected _specularIntensity: number;
  53211. /**
  53212. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53213. */
  53214. private _lightingInfos;
  53215. /**
  53216. * Debug Control allowing disabling the bump map on this material.
  53217. */
  53218. protected _disableBumpMap: boolean;
  53219. /**
  53220. * AKA Diffuse Texture in standard nomenclature.
  53221. */
  53222. protected _albedoTexture: Nullable<BaseTexture>;
  53223. /**
  53224. * AKA Occlusion Texture in other nomenclature.
  53225. */
  53226. protected _ambientTexture: Nullable<BaseTexture>;
  53227. /**
  53228. * AKA Occlusion Texture Intensity in other nomenclature.
  53229. */
  53230. protected _ambientTextureStrength: number;
  53231. /**
  53232. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53233. * 1 means it completely occludes it
  53234. * 0 mean it has no impact
  53235. */
  53236. protected _ambientTextureImpactOnAnalyticalLights: number;
  53237. /**
  53238. * Stores the alpha values in a texture.
  53239. */
  53240. protected _opacityTexture: Nullable<BaseTexture>;
  53241. /**
  53242. * Stores the reflection values in a texture.
  53243. */
  53244. protected _reflectionTexture: Nullable<BaseTexture>;
  53245. /**
  53246. * Stores the emissive values in a texture.
  53247. */
  53248. protected _emissiveTexture: Nullable<BaseTexture>;
  53249. /**
  53250. * AKA Specular texture in other nomenclature.
  53251. */
  53252. protected _reflectivityTexture: Nullable<BaseTexture>;
  53253. /**
  53254. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53255. */
  53256. protected _metallicTexture: Nullable<BaseTexture>;
  53257. /**
  53258. * Specifies the metallic scalar of the metallic/roughness workflow.
  53259. * Can also be used to scale the metalness values of the metallic texture.
  53260. */
  53261. protected _metallic: Nullable<number>;
  53262. /**
  53263. * Specifies the roughness scalar of the metallic/roughness workflow.
  53264. * Can also be used to scale the roughness values of the metallic texture.
  53265. */
  53266. protected _roughness: Nullable<number>;
  53267. /**
  53268. * Specifies the an F0 factor to help configuring the material F0.
  53269. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53270. * to 0.5 the previously hard coded value stays the same.
  53271. * Can also be used to scale the F0 values of the metallic texture.
  53272. */
  53273. protected _metallicF0Factor: number;
  53274. /**
  53275. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53276. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53277. * your expectation as it multiplies with the texture data.
  53278. */
  53279. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53280. /**
  53281. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53282. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53283. */
  53284. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53285. /**
  53286. * Stores surface normal data used to displace a mesh in a texture.
  53287. */
  53288. protected _bumpTexture: Nullable<BaseTexture>;
  53289. /**
  53290. * Stores the pre-calculated light information of a mesh in a texture.
  53291. */
  53292. protected _lightmapTexture: Nullable<BaseTexture>;
  53293. /**
  53294. * The color of a material in ambient lighting.
  53295. */
  53296. protected _ambientColor: Color3;
  53297. /**
  53298. * AKA Diffuse Color in other nomenclature.
  53299. */
  53300. protected _albedoColor: Color3;
  53301. /**
  53302. * AKA Specular Color in other nomenclature.
  53303. */
  53304. protected _reflectivityColor: Color3;
  53305. /**
  53306. * The color applied when light is reflected from a material.
  53307. */
  53308. protected _reflectionColor: Color3;
  53309. /**
  53310. * The color applied when light is emitted from a material.
  53311. */
  53312. protected _emissiveColor: Color3;
  53313. /**
  53314. * AKA Glossiness in other nomenclature.
  53315. */
  53316. protected _microSurface: number;
  53317. /**
  53318. * Specifies that the material will use the light map as a show map.
  53319. */
  53320. protected _useLightmapAsShadowmap: boolean;
  53321. /**
  53322. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53323. * makes the reflect vector face the model (under horizon).
  53324. */
  53325. protected _useHorizonOcclusion: boolean;
  53326. /**
  53327. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53328. * too much the area relying on ambient texture to define their ambient occlusion.
  53329. */
  53330. protected _useRadianceOcclusion: boolean;
  53331. /**
  53332. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53333. */
  53334. protected _useAlphaFromAlbedoTexture: boolean;
  53335. /**
  53336. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53337. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53338. */
  53339. protected _useSpecularOverAlpha: boolean;
  53340. /**
  53341. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53342. */
  53343. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53344. /**
  53345. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53346. */
  53347. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53348. /**
  53349. * Specifies if the metallic texture contains the roughness information in its green channel.
  53350. */
  53351. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53352. /**
  53353. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53354. */
  53355. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53356. /**
  53357. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53358. */
  53359. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53360. /**
  53361. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53362. */
  53363. protected _useAmbientInGrayScale: boolean;
  53364. /**
  53365. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53366. * The material will try to infer what glossiness each pixel should be.
  53367. */
  53368. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53369. /**
  53370. * Defines the falloff type used in this material.
  53371. * It by default is Physical.
  53372. */
  53373. protected _lightFalloff: number;
  53374. /**
  53375. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53376. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53377. */
  53378. protected _useRadianceOverAlpha: boolean;
  53379. /**
  53380. * Allows using an object space normal map (instead of tangent space).
  53381. */
  53382. protected _useObjectSpaceNormalMap: boolean;
  53383. /**
  53384. * Allows using the bump map in parallax mode.
  53385. */
  53386. protected _useParallax: boolean;
  53387. /**
  53388. * Allows using the bump map in parallax occlusion mode.
  53389. */
  53390. protected _useParallaxOcclusion: boolean;
  53391. /**
  53392. * Controls the scale bias of the parallax mode.
  53393. */
  53394. protected _parallaxScaleBias: number;
  53395. /**
  53396. * If sets to true, disables all the lights affecting the material.
  53397. */
  53398. protected _disableLighting: boolean;
  53399. /**
  53400. * Number of Simultaneous lights allowed on the material.
  53401. */
  53402. protected _maxSimultaneousLights: number;
  53403. /**
  53404. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53405. */
  53406. protected _invertNormalMapX: boolean;
  53407. /**
  53408. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53409. */
  53410. protected _invertNormalMapY: boolean;
  53411. /**
  53412. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53413. */
  53414. protected _twoSidedLighting: boolean;
  53415. /**
  53416. * Defines the alpha limits in alpha test mode.
  53417. */
  53418. protected _alphaCutOff: number;
  53419. /**
  53420. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53421. */
  53422. protected _forceAlphaTest: boolean;
  53423. /**
  53424. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53425. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53426. */
  53427. protected _useAlphaFresnel: boolean;
  53428. /**
  53429. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53430. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53431. */
  53432. protected _useLinearAlphaFresnel: boolean;
  53433. /**
  53434. * The transparency mode of the material.
  53435. */
  53436. protected _transparencyMode: Nullable<number>;
  53437. /**
  53438. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53439. * from cos thetav and roughness:
  53440. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53441. */
  53442. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53443. /**
  53444. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53445. */
  53446. protected _forceIrradianceInFragment: boolean;
  53447. /**
  53448. * Force normal to face away from face.
  53449. */
  53450. protected _forceNormalForward: boolean;
  53451. /**
  53452. * Enables specular anti aliasing in the PBR shader.
  53453. * It will both interacts on the Geometry for analytical and IBL lighting.
  53454. * It also prefilter the roughness map based on the bump values.
  53455. */
  53456. protected _enableSpecularAntiAliasing: boolean;
  53457. /**
  53458. * Default configuration related to image processing available in the PBR Material.
  53459. */
  53460. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53461. /**
  53462. * Keep track of the image processing observer to allow dispose and replace.
  53463. */
  53464. private _imageProcessingObserver;
  53465. /**
  53466. * Attaches a new image processing configuration to the PBR Material.
  53467. * @param configuration
  53468. */
  53469. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53470. /**
  53471. * Stores the available render targets.
  53472. */
  53473. private _renderTargets;
  53474. /**
  53475. * Sets the global ambient color for the material used in lighting calculations.
  53476. */
  53477. private _globalAmbientColor;
  53478. /**
  53479. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53480. */
  53481. private _useLogarithmicDepth;
  53482. /**
  53483. * If set to true, no lighting calculations will be applied.
  53484. */
  53485. private _unlit;
  53486. private _debugMode;
  53487. /**
  53488. * @hidden
  53489. * This is reserved for the inspector.
  53490. * Defines the material debug mode.
  53491. * It helps seeing only some components of the material while troubleshooting.
  53492. */
  53493. debugMode: number;
  53494. /**
  53495. * @hidden
  53496. * This is reserved for the inspector.
  53497. * Specify from where on screen the debug mode should start.
  53498. * The value goes from -1 (full screen) to 1 (not visible)
  53499. * It helps with side by side comparison against the final render
  53500. * This defaults to -1
  53501. */
  53502. private debugLimit;
  53503. /**
  53504. * @hidden
  53505. * This is reserved for the inspector.
  53506. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53507. * You can use the factor to better multiply the final value.
  53508. */
  53509. private debugFactor;
  53510. /**
  53511. * Defines the clear coat layer parameters for the material.
  53512. */
  53513. readonly clearCoat: PBRClearCoatConfiguration;
  53514. /**
  53515. * Defines the anisotropic parameters for the material.
  53516. */
  53517. readonly anisotropy: PBRAnisotropicConfiguration;
  53518. /**
  53519. * Defines the BRDF parameters for the material.
  53520. */
  53521. readonly brdf: PBRBRDFConfiguration;
  53522. /**
  53523. * Defines the Sheen parameters for the material.
  53524. */
  53525. readonly sheen: PBRSheenConfiguration;
  53526. /**
  53527. * Defines the SubSurface parameters for the material.
  53528. */
  53529. readonly subSurface: PBRSubSurfaceConfiguration;
  53530. /**
  53531. * Custom callback helping to override the default shader used in the material.
  53532. */
  53533. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53534. protected _rebuildInParallel: boolean;
  53535. /**
  53536. * Instantiates a new PBRMaterial instance.
  53537. *
  53538. * @param name The material name
  53539. * @param scene The scene the material will be use in.
  53540. */
  53541. constructor(name: string, scene: Scene);
  53542. /**
  53543. * Gets a boolean indicating that current material needs to register RTT
  53544. */
  53545. get hasRenderTargetTextures(): boolean;
  53546. /**
  53547. * Gets the name of the material class.
  53548. */
  53549. getClassName(): string;
  53550. /**
  53551. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53552. */
  53553. get useLogarithmicDepth(): boolean;
  53554. /**
  53555. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53556. */
  53557. set useLogarithmicDepth(value: boolean);
  53558. /**
  53559. * Gets the current transparency mode.
  53560. */
  53561. get transparencyMode(): Nullable<number>;
  53562. /**
  53563. * Sets the transparency mode of the material.
  53564. *
  53565. * | Value | Type | Description |
  53566. * | ----- | ----------------------------------- | ----------- |
  53567. * | 0 | OPAQUE | |
  53568. * | 1 | ALPHATEST | |
  53569. * | 2 | ALPHABLEND | |
  53570. * | 3 | ALPHATESTANDBLEND | |
  53571. *
  53572. */
  53573. set transparencyMode(value: Nullable<number>);
  53574. /**
  53575. * Returns true if alpha blending should be disabled.
  53576. */
  53577. private get _disableAlphaBlending();
  53578. /**
  53579. * Specifies whether or not this material should be rendered in alpha blend mode.
  53580. */
  53581. needAlphaBlending(): boolean;
  53582. /**
  53583. * Specifies if the mesh will require alpha blending.
  53584. * @param mesh - BJS mesh.
  53585. */
  53586. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53587. /**
  53588. * Specifies whether or not this material should be rendered in alpha test mode.
  53589. */
  53590. needAlphaTesting(): boolean;
  53591. /**
  53592. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53593. */
  53594. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53595. /**
  53596. * Gets the texture used for the alpha test.
  53597. */
  53598. getAlphaTestTexture(): Nullable<BaseTexture>;
  53599. /**
  53600. * Specifies that the submesh is ready to be used.
  53601. * @param mesh - BJS mesh.
  53602. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53603. * @param useInstances - Specifies that instances should be used.
  53604. * @returns - boolean indicating that the submesh is ready or not.
  53605. */
  53606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53607. /**
  53608. * Specifies if the material uses metallic roughness workflow.
  53609. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53610. */
  53611. isMetallicWorkflow(): boolean;
  53612. private _prepareEffect;
  53613. private _prepareDefines;
  53614. /**
  53615. * Force shader compilation
  53616. */
  53617. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53618. /**
  53619. * Initializes the uniform buffer layout for the shader.
  53620. */
  53621. buildUniformLayout(): void;
  53622. /**
  53623. * Unbinds the material from the mesh
  53624. */
  53625. unbind(): void;
  53626. /**
  53627. * Binds the submesh data.
  53628. * @param world - The world matrix.
  53629. * @param mesh - The BJS mesh.
  53630. * @param subMesh - A submesh of the BJS mesh.
  53631. */
  53632. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53633. /**
  53634. * Returns the animatable textures.
  53635. * @returns - Array of animatable textures.
  53636. */
  53637. getAnimatables(): IAnimatable[];
  53638. /**
  53639. * Returns the texture used for reflections.
  53640. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53641. */
  53642. private _getReflectionTexture;
  53643. /**
  53644. * Returns an array of the actively used textures.
  53645. * @returns - Array of BaseTextures
  53646. */
  53647. getActiveTextures(): BaseTexture[];
  53648. /**
  53649. * Checks to see if a texture is used in the material.
  53650. * @param texture - Base texture to use.
  53651. * @returns - Boolean specifying if a texture is used in the material.
  53652. */
  53653. hasTexture(texture: BaseTexture): boolean;
  53654. /**
  53655. * Disposes the resources of the material.
  53656. * @param forceDisposeEffect - Forces the disposal of effects.
  53657. * @param forceDisposeTextures - Forces the disposal of all textures.
  53658. */
  53659. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53660. }
  53661. }
  53662. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53663. import { Nullable } from "babylonjs/types";
  53664. import { Scene } from "babylonjs/scene";
  53665. import { Color3 } from "babylonjs/Maths/math.color";
  53666. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53667. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53669. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53670. /**
  53671. * The Physically based material of BJS.
  53672. *
  53673. * This offers the main features of a standard PBR material.
  53674. * For more information, please refer to the documentation :
  53675. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53676. */
  53677. export class PBRMaterial extends PBRBaseMaterial {
  53678. /**
  53679. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53680. */
  53681. static readonly PBRMATERIAL_OPAQUE: number;
  53682. /**
  53683. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53684. */
  53685. static readonly PBRMATERIAL_ALPHATEST: number;
  53686. /**
  53687. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53688. */
  53689. static readonly PBRMATERIAL_ALPHABLEND: number;
  53690. /**
  53691. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53692. * They are also discarded below the alpha cutoff threshold to improve performances.
  53693. */
  53694. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53695. /**
  53696. * Defines the default value of how much AO map is occluding the analytical lights
  53697. * (point spot...).
  53698. */
  53699. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53700. /**
  53701. * Intensity of the direct lights e.g. the four lights available in your scene.
  53702. * This impacts both the direct diffuse and specular highlights.
  53703. */
  53704. directIntensity: number;
  53705. /**
  53706. * Intensity of the emissive part of the material.
  53707. * This helps controlling the emissive effect without modifying the emissive color.
  53708. */
  53709. emissiveIntensity: number;
  53710. /**
  53711. * Intensity of the environment e.g. how much the environment will light the object
  53712. * either through harmonics for rough material or through the refelction for shiny ones.
  53713. */
  53714. environmentIntensity: number;
  53715. /**
  53716. * This is a special control allowing the reduction of the specular highlights coming from the
  53717. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53718. */
  53719. specularIntensity: number;
  53720. /**
  53721. * Debug Control allowing disabling the bump map on this material.
  53722. */
  53723. disableBumpMap: boolean;
  53724. /**
  53725. * AKA Diffuse Texture in standard nomenclature.
  53726. */
  53727. albedoTexture: BaseTexture;
  53728. /**
  53729. * AKA Occlusion Texture in other nomenclature.
  53730. */
  53731. ambientTexture: BaseTexture;
  53732. /**
  53733. * AKA Occlusion Texture Intensity in other nomenclature.
  53734. */
  53735. ambientTextureStrength: number;
  53736. /**
  53737. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53738. * 1 means it completely occludes it
  53739. * 0 mean it has no impact
  53740. */
  53741. ambientTextureImpactOnAnalyticalLights: number;
  53742. /**
  53743. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53744. */
  53745. opacityTexture: BaseTexture;
  53746. /**
  53747. * Stores the reflection values in a texture.
  53748. */
  53749. reflectionTexture: Nullable<BaseTexture>;
  53750. /**
  53751. * Stores the emissive values in a texture.
  53752. */
  53753. emissiveTexture: BaseTexture;
  53754. /**
  53755. * AKA Specular texture in other nomenclature.
  53756. */
  53757. reflectivityTexture: BaseTexture;
  53758. /**
  53759. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53760. */
  53761. metallicTexture: BaseTexture;
  53762. /**
  53763. * Specifies the metallic scalar of the metallic/roughness workflow.
  53764. * Can also be used to scale the metalness values of the metallic texture.
  53765. */
  53766. metallic: Nullable<number>;
  53767. /**
  53768. * Specifies the roughness scalar of the metallic/roughness workflow.
  53769. * Can also be used to scale the roughness values of the metallic texture.
  53770. */
  53771. roughness: Nullable<number>;
  53772. /**
  53773. * Specifies the an F0 factor to help configuring the material F0.
  53774. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53775. * to 0.5 the previously hard coded value stays the same.
  53776. * Can also be used to scale the F0 values of the metallic texture.
  53777. */
  53778. metallicF0Factor: number;
  53779. /**
  53780. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53781. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53782. * your expectation as it multiplies with the texture data.
  53783. */
  53784. useMetallicF0FactorFromMetallicTexture: boolean;
  53785. /**
  53786. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53787. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53788. */
  53789. microSurfaceTexture: BaseTexture;
  53790. /**
  53791. * Stores surface normal data used to displace a mesh in a texture.
  53792. */
  53793. bumpTexture: BaseTexture;
  53794. /**
  53795. * Stores the pre-calculated light information of a mesh in a texture.
  53796. */
  53797. lightmapTexture: BaseTexture;
  53798. /**
  53799. * Stores the refracted light information in a texture.
  53800. */
  53801. get refractionTexture(): Nullable<BaseTexture>;
  53802. set refractionTexture(value: Nullable<BaseTexture>);
  53803. /**
  53804. * The color of a material in ambient lighting.
  53805. */
  53806. ambientColor: Color3;
  53807. /**
  53808. * AKA Diffuse Color in other nomenclature.
  53809. */
  53810. albedoColor: Color3;
  53811. /**
  53812. * AKA Specular Color in other nomenclature.
  53813. */
  53814. reflectivityColor: Color3;
  53815. /**
  53816. * The color reflected from the material.
  53817. */
  53818. reflectionColor: Color3;
  53819. /**
  53820. * The color emitted from the material.
  53821. */
  53822. emissiveColor: Color3;
  53823. /**
  53824. * AKA Glossiness in other nomenclature.
  53825. */
  53826. microSurface: number;
  53827. /**
  53828. * source material index of refraction (IOR)' / 'destination material IOR.
  53829. */
  53830. get indexOfRefraction(): number;
  53831. set indexOfRefraction(value: number);
  53832. /**
  53833. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53834. */
  53835. get invertRefractionY(): boolean;
  53836. set invertRefractionY(value: boolean);
  53837. /**
  53838. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53839. * Materials half opaque for instance using refraction could benefit from this control.
  53840. */
  53841. get linkRefractionWithTransparency(): boolean;
  53842. set linkRefractionWithTransparency(value: boolean);
  53843. /**
  53844. * If true, the light map contains occlusion information instead of lighting info.
  53845. */
  53846. useLightmapAsShadowmap: boolean;
  53847. /**
  53848. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53849. */
  53850. useAlphaFromAlbedoTexture: boolean;
  53851. /**
  53852. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53853. */
  53854. forceAlphaTest: boolean;
  53855. /**
  53856. * Defines the alpha limits in alpha test mode.
  53857. */
  53858. alphaCutOff: number;
  53859. /**
  53860. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53861. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53862. */
  53863. useSpecularOverAlpha: boolean;
  53864. /**
  53865. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53866. */
  53867. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53868. /**
  53869. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53870. */
  53871. useRoughnessFromMetallicTextureAlpha: boolean;
  53872. /**
  53873. * Specifies if the metallic texture contains the roughness information in its green channel.
  53874. */
  53875. useRoughnessFromMetallicTextureGreen: boolean;
  53876. /**
  53877. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53878. */
  53879. useMetallnessFromMetallicTextureBlue: boolean;
  53880. /**
  53881. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53882. */
  53883. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53884. /**
  53885. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53886. */
  53887. useAmbientInGrayScale: boolean;
  53888. /**
  53889. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53890. * The material will try to infer what glossiness each pixel should be.
  53891. */
  53892. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53893. /**
  53894. * BJS is using an harcoded light falloff based on a manually sets up range.
  53895. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53896. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53897. */
  53898. get usePhysicalLightFalloff(): boolean;
  53899. /**
  53900. * BJS is using an harcoded light falloff based on a manually sets up range.
  53901. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53902. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53903. */
  53904. set usePhysicalLightFalloff(value: boolean);
  53905. /**
  53906. * In order to support the falloff compatibility with gltf, a special mode has been added
  53907. * to reproduce the gltf light falloff.
  53908. */
  53909. get useGLTFLightFalloff(): boolean;
  53910. /**
  53911. * In order to support the falloff compatibility with gltf, a special mode has been added
  53912. * to reproduce the gltf light falloff.
  53913. */
  53914. set useGLTFLightFalloff(value: boolean);
  53915. /**
  53916. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53917. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53918. */
  53919. useRadianceOverAlpha: boolean;
  53920. /**
  53921. * Allows using an object space normal map (instead of tangent space).
  53922. */
  53923. useObjectSpaceNormalMap: boolean;
  53924. /**
  53925. * Allows using the bump map in parallax mode.
  53926. */
  53927. useParallax: boolean;
  53928. /**
  53929. * Allows using the bump map in parallax occlusion mode.
  53930. */
  53931. useParallaxOcclusion: boolean;
  53932. /**
  53933. * Controls the scale bias of the parallax mode.
  53934. */
  53935. parallaxScaleBias: number;
  53936. /**
  53937. * If sets to true, disables all the lights affecting the material.
  53938. */
  53939. disableLighting: boolean;
  53940. /**
  53941. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53942. */
  53943. forceIrradianceInFragment: boolean;
  53944. /**
  53945. * Number of Simultaneous lights allowed on the material.
  53946. */
  53947. maxSimultaneousLights: number;
  53948. /**
  53949. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53950. */
  53951. invertNormalMapX: boolean;
  53952. /**
  53953. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53954. */
  53955. invertNormalMapY: boolean;
  53956. /**
  53957. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53958. */
  53959. twoSidedLighting: boolean;
  53960. /**
  53961. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53962. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53963. */
  53964. useAlphaFresnel: boolean;
  53965. /**
  53966. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53967. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53968. */
  53969. useLinearAlphaFresnel: boolean;
  53970. /**
  53971. * Let user defines the brdf lookup texture used for IBL.
  53972. * A default 8bit version is embedded but you could point at :
  53973. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53974. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53975. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53976. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53977. */
  53978. environmentBRDFTexture: Nullable<BaseTexture>;
  53979. /**
  53980. * Force normal to face away from face.
  53981. */
  53982. forceNormalForward: boolean;
  53983. /**
  53984. * Enables specular anti aliasing in the PBR shader.
  53985. * It will both interacts on the Geometry for analytical and IBL lighting.
  53986. * It also prefilter the roughness map based on the bump values.
  53987. */
  53988. enableSpecularAntiAliasing: boolean;
  53989. /**
  53990. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53991. * makes the reflect vector face the model (under horizon).
  53992. */
  53993. useHorizonOcclusion: boolean;
  53994. /**
  53995. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53996. * too much the area relying on ambient texture to define their ambient occlusion.
  53997. */
  53998. useRadianceOcclusion: boolean;
  53999. /**
  54000. * If set to true, no lighting calculations will be applied.
  54001. */
  54002. unlit: boolean;
  54003. /**
  54004. * Gets the image processing configuration used either in this material.
  54005. */
  54006. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54007. /**
  54008. * Sets the Default image processing configuration used either in the this material.
  54009. *
  54010. * If sets to null, the scene one is in use.
  54011. */
  54012. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54013. /**
  54014. * Gets wether the color curves effect is enabled.
  54015. */
  54016. get cameraColorCurvesEnabled(): boolean;
  54017. /**
  54018. * Sets wether the color curves effect is enabled.
  54019. */
  54020. set cameraColorCurvesEnabled(value: boolean);
  54021. /**
  54022. * Gets wether the color grading effect is enabled.
  54023. */
  54024. get cameraColorGradingEnabled(): boolean;
  54025. /**
  54026. * Gets wether the color grading effect is enabled.
  54027. */
  54028. set cameraColorGradingEnabled(value: boolean);
  54029. /**
  54030. * Gets wether tonemapping is enabled or not.
  54031. */
  54032. get cameraToneMappingEnabled(): boolean;
  54033. /**
  54034. * Sets wether tonemapping is enabled or not
  54035. */
  54036. set cameraToneMappingEnabled(value: boolean);
  54037. /**
  54038. * The camera exposure used on this material.
  54039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54040. * This corresponds to a photographic exposure.
  54041. */
  54042. get cameraExposure(): number;
  54043. /**
  54044. * The camera exposure used on this material.
  54045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54046. * This corresponds to a photographic exposure.
  54047. */
  54048. set cameraExposure(value: number);
  54049. /**
  54050. * Gets The camera contrast used on this material.
  54051. */
  54052. get cameraContrast(): number;
  54053. /**
  54054. * Sets The camera contrast used on this material.
  54055. */
  54056. set cameraContrast(value: number);
  54057. /**
  54058. * Gets the Color Grading 2D Lookup Texture.
  54059. */
  54060. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54061. /**
  54062. * Sets the Color Grading 2D Lookup Texture.
  54063. */
  54064. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54065. /**
  54066. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54067. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54068. * 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;
  54069. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54070. */
  54071. get cameraColorCurves(): Nullable<ColorCurves>;
  54072. /**
  54073. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54074. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54075. * 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;
  54076. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54077. */
  54078. set cameraColorCurves(value: Nullable<ColorCurves>);
  54079. /**
  54080. * Instantiates a new PBRMaterial instance.
  54081. *
  54082. * @param name The material name
  54083. * @param scene The scene the material will be use in.
  54084. */
  54085. constructor(name: string, scene: Scene);
  54086. /**
  54087. * Returns the name of this material class.
  54088. */
  54089. getClassName(): string;
  54090. /**
  54091. * Makes a duplicate of the current material.
  54092. * @param name - name to use for the new material.
  54093. */
  54094. clone(name: string): PBRMaterial;
  54095. /**
  54096. * Serializes this PBR Material.
  54097. * @returns - An object with the serialized material.
  54098. */
  54099. serialize(): any;
  54100. /**
  54101. * Parses a PBR Material from a serialized object.
  54102. * @param source - Serialized object.
  54103. * @param scene - BJS scene instance.
  54104. * @param rootUrl - url for the scene object
  54105. * @returns - PBRMaterial
  54106. */
  54107. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54108. }
  54109. }
  54110. declare module "babylonjs/Misc/dds" {
  54111. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54113. import { Nullable } from "babylonjs/types";
  54114. import { Scene } from "babylonjs/scene";
  54115. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54116. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54117. /**
  54118. * Direct draw surface info
  54119. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54120. */
  54121. export interface DDSInfo {
  54122. /**
  54123. * Width of the texture
  54124. */
  54125. width: number;
  54126. /**
  54127. * Width of the texture
  54128. */
  54129. height: number;
  54130. /**
  54131. * Number of Mipmaps for the texture
  54132. * @see https://en.wikipedia.org/wiki/Mipmap
  54133. */
  54134. mipmapCount: number;
  54135. /**
  54136. * If the textures format is a known fourCC format
  54137. * @see https://www.fourcc.org/
  54138. */
  54139. isFourCC: boolean;
  54140. /**
  54141. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54142. */
  54143. isRGB: boolean;
  54144. /**
  54145. * If the texture is a lumincance format
  54146. */
  54147. isLuminance: boolean;
  54148. /**
  54149. * If this is a cube texture
  54150. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54151. */
  54152. isCube: boolean;
  54153. /**
  54154. * If the texture is a compressed format eg. FOURCC_DXT1
  54155. */
  54156. isCompressed: boolean;
  54157. /**
  54158. * The dxgiFormat of the texture
  54159. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54160. */
  54161. dxgiFormat: number;
  54162. /**
  54163. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54164. */
  54165. textureType: number;
  54166. /**
  54167. * Sphericle polynomial created for the dds texture
  54168. */
  54169. sphericalPolynomial?: SphericalPolynomial;
  54170. }
  54171. /**
  54172. * Class used to provide DDS decompression tools
  54173. */
  54174. export class DDSTools {
  54175. /**
  54176. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54177. */
  54178. static StoreLODInAlphaChannel: boolean;
  54179. /**
  54180. * Gets DDS information from an array buffer
  54181. * @param data defines the array buffer view to read data from
  54182. * @returns the DDS information
  54183. */
  54184. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54185. private static _FloatView;
  54186. private static _Int32View;
  54187. private static _ToHalfFloat;
  54188. private static _FromHalfFloat;
  54189. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54190. private static _GetHalfFloatRGBAArrayBuffer;
  54191. private static _GetFloatRGBAArrayBuffer;
  54192. private static _GetFloatAsUIntRGBAArrayBuffer;
  54193. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54194. private static _GetRGBAArrayBuffer;
  54195. private static _ExtractLongWordOrder;
  54196. private static _GetRGBArrayBuffer;
  54197. private static _GetLuminanceArrayBuffer;
  54198. /**
  54199. * Uploads DDS Levels to a Babylon Texture
  54200. * @hidden
  54201. */
  54202. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54203. }
  54204. module "babylonjs/Engines/thinEngine" {
  54205. interface ThinEngine {
  54206. /**
  54207. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54208. * @param rootUrl defines the url where the file to load is located
  54209. * @param scene defines the current scene
  54210. * @param lodScale defines scale to apply to the mip map selection
  54211. * @param lodOffset defines offset to apply to the mip map selection
  54212. * @param onLoad defines an optional callback raised when the texture is loaded
  54213. * @param onError defines an optional callback raised if there is an issue to load the texture
  54214. * @param format defines the format of the data
  54215. * @param forcedExtension defines the extension to use to pick the right loader
  54216. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54217. * @returns the cube texture as an InternalTexture
  54218. */
  54219. 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;
  54220. }
  54221. }
  54222. }
  54223. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54224. import { Nullable } from "babylonjs/types";
  54225. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54226. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54227. /**
  54228. * Implementation of the DDS Texture Loader.
  54229. * @hidden
  54230. */
  54231. export class _DDSTextureLoader implements IInternalTextureLoader {
  54232. /**
  54233. * Defines wether the loader supports cascade loading the different faces.
  54234. */
  54235. readonly supportCascades: boolean;
  54236. /**
  54237. * This returns if the loader support the current file information.
  54238. * @param extension defines the file extension of the file being loaded
  54239. * @returns true if the loader can load the specified file
  54240. */
  54241. canLoad(extension: string): boolean;
  54242. /**
  54243. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54244. * @param data contains the texture data
  54245. * @param texture defines the BabylonJS internal texture
  54246. * @param createPolynomials will be true if polynomials have been requested
  54247. * @param onLoad defines the callback to trigger once the texture is ready
  54248. * @param onError defines the callback to trigger in case of error
  54249. */
  54250. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54251. /**
  54252. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54253. * @param data contains the texture data
  54254. * @param texture defines the BabylonJS internal texture
  54255. * @param callback defines the method to call once ready to upload
  54256. */
  54257. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54258. }
  54259. }
  54260. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54261. import { Nullable } from "babylonjs/types";
  54262. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54263. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54264. /**
  54265. * Implementation of the ENV Texture Loader.
  54266. * @hidden
  54267. */
  54268. export class _ENVTextureLoader implements IInternalTextureLoader {
  54269. /**
  54270. * Defines wether the loader supports cascade loading the different faces.
  54271. */
  54272. readonly supportCascades: boolean;
  54273. /**
  54274. * This returns if the loader support the current file information.
  54275. * @param extension defines the file extension of the file being loaded
  54276. * @returns true if the loader can load the specified file
  54277. */
  54278. canLoad(extension: string): boolean;
  54279. /**
  54280. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54281. * @param data contains the texture data
  54282. * @param texture defines the BabylonJS internal texture
  54283. * @param createPolynomials will be true if polynomials have been requested
  54284. * @param onLoad defines the callback to trigger once the texture is ready
  54285. * @param onError defines the callback to trigger in case of error
  54286. */
  54287. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54288. /**
  54289. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54290. * @param data contains the texture data
  54291. * @param texture defines the BabylonJS internal texture
  54292. * @param callback defines the method to call once ready to upload
  54293. */
  54294. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54295. }
  54296. }
  54297. declare module "babylonjs/Misc/khronosTextureContainer" {
  54298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54299. /**
  54300. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54301. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54302. */
  54303. export class KhronosTextureContainer {
  54304. /** contents of the KTX container file */
  54305. data: ArrayBufferView;
  54306. private static HEADER_LEN;
  54307. private static COMPRESSED_2D;
  54308. private static COMPRESSED_3D;
  54309. private static TEX_2D;
  54310. private static TEX_3D;
  54311. /**
  54312. * Gets the openGL type
  54313. */
  54314. glType: number;
  54315. /**
  54316. * Gets the openGL type size
  54317. */
  54318. glTypeSize: number;
  54319. /**
  54320. * Gets the openGL format
  54321. */
  54322. glFormat: number;
  54323. /**
  54324. * Gets the openGL internal format
  54325. */
  54326. glInternalFormat: number;
  54327. /**
  54328. * Gets the base internal format
  54329. */
  54330. glBaseInternalFormat: number;
  54331. /**
  54332. * Gets image width in pixel
  54333. */
  54334. pixelWidth: number;
  54335. /**
  54336. * Gets image height in pixel
  54337. */
  54338. pixelHeight: number;
  54339. /**
  54340. * Gets image depth in pixels
  54341. */
  54342. pixelDepth: number;
  54343. /**
  54344. * Gets the number of array elements
  54345. */
  54346. numberOfArrayElements: number;
  54347. /**
  54348. * Gets the number of faces
  54349. */
  54350. numberOfFaces: number;
  54351. /**
  54352. * Gets the number of mipmap levels
  54353. */
  54354. numberOfMipmapLevels: number;
  54355. /**
  54356. * Gets the bytes of key value data
  54357. */
  54358. bytesOfKeyValueData: number;
  54359. /**
  54360. * Gets the load type
  54361. */
  54362. loadType: number;
  54363. /**
  54364. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54365. */
  54366. isInvalid: boolean;
  54367. /**
  54368. * Creates a new KhronosTextureContainer
  54369. * @param data contents of the KTX container file
  54370. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54371. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54372. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54373. */
  54374. constructor(
  54375. /** contents of the KTX container file */
  54376. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54377. /**
  54378. * Uploads KTX content to a Babylon Texture.
  54379. * It is assumed that the texture has already been created & is currently bound
  54380. * @hidden
  54381. */
  54382. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54383. private _upload2DCompressedLevels;
  54384. /**
  54385. * Checks if the given data starts with a KTX file identifier.
  54386. * @param data the data to check
  54387. * @returns true if the data is a KTX file or false otherwise
  54388. */
  54389. static IsValid(data: ArrayBufferView): boolean;
  54390. }
  54391. }
  54392. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54393. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54394. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54395. /**
  54396. * Class for loading KTX2 files
  54397. * !!! Experimental Extension Subject to Changes !!!
  54398. * @hidden
  54399. */
  54400. export class KhronosTextureContainer2 {
  54401. private static _ModulePromise;
  54402. private static _TranscodeFormat;
  54403. constructor(engine: ThinEngine);
  54404. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54405. private _determineTranscodeFormat;
  54406. /**
  54407. * Checks if the given data starts with a KTX2 file identifier.
  54408. * @param data the data to check
  54409. * @returns true if the data is a KTX2 file or false otherwise
  54410. */
  54411. static IsValid(data: ArrayBufferView): boolean;
  54412. }
  54413. }
  54414. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54415. import { Nullable } from "babylonjs/types";
  54416. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54417. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54418. /**
  54419. * Implementation of the KTX Texture Loader.
  54420. * @hidden
  54421. */
  54422. export class _KTXTextureLoader implements IInternalTextureLoader {
  54423. /**
  54424. * Defines wether the loader supports cascade loading the different faces.
  54425. */
  54426. readonly supportCascades: boolean;
  54427. /**
  54428. * This returns if the loader support the current file information.
  54429. * @param extension defines the file extension of the file being loaded
  54430. * @returns true if the loader can load the specified file
  54431. */
  54432. canLoad(extension: string): boolean;
  54433. /**
  54434. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54435. * @param data contains the texture data
  54436. * @param texture defines the BabylonJS internal texture
  54437. * @param createPolynomials will be true if polynomials have been requested
  54438. * @param onLoad defines the callback to trigger once the texture is ready
  54439. * @param onError defines the callback to trigger in case of error
  54440. */
  54441. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54442. /**
  54443. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54444. * @param data contains the texture data
  54445. * @param texture defines the BabylonJS internal texture
  54446. * @param callback defines the method to call once ready to upload
  54447. */
  54448. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54449. }
  54450. }
  54451. declare module "babylonjs/Helpers/sceneHelpers" {
  54452. import { Nullable } from "babylonjs/types";
  54453. import { Mesh } from "babylonjs/Meshes/mesh";
  54454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54455. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54456. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54457. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54458. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54459. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54460. import "babylonjs/Meshes/Builders/boxBuilder";
  54461. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54462. /** @hidden */
  54463. export var _forceSceneHelpersToBundle: boolean;
  54464. module "babylonjs/scene" {
  54465. interface Scene {
  54466. /**
  54467. * Creates a default light for the scene.
  54468. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54469. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54470. */
  54471. createDefaultLight(replace?: boolean): void;
  54472. /**
  54473. * Creates a default camera for the scene.
  54474. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54475. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54476. * @param replace has default false, when true replaces the active camera in the scene
  54477. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54478. */
  54479. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54480. /**
  54481. * Creates a default camera and a default light.
  54482. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54483. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54484. * @param replace has the default false, when true replaces the active camera/light in the scene
  54485. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54486. */
  54487. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54488. /**
  54489. * Creates a new sky box
  54490. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54491. * @param environmentTexture defines the texture to use as environment texture
  54492. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54493. * @param scale defines the overall scale of the skybox
  54494. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54495. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54496. * @returns a new mesh holding the sky box
  54497. */
  54498. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54499. /**
  54500. * Creates a new environment
  54501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54502. * @param options defines the options you can use to configure the environment
  54503. * @returns the new EnvironmentHelper
  54504. */
  54505. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54506. /**
  54507. * Creates a new VREXperienceHelper
  54508. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54509. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54510. * @returns a new VREXperienceHelper
  54511. */
  54512. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54513. /**
  54514. * Creates a new WebXRDefaultExperience
  54515. * @see http://doc.babylonjs.com/how_to/webxr
  54516. * @param options experience options
  54517. * @returns a promise for a new WebXRDefaultExperience
  54518. */
  54519. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54520. }
  54521. }
  54522. }
  54523. declare module "babylonjs/Helpers/videoDome" {
  54524. import { Scene } from "babylonjs/scene";
  54525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54526. import { Mesh } from "babylonjs/Meshes/mesh";
  54527. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54528. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54529. import "babylonjs/Meshes/Builders/sphereBuilder";
  54530. /**
  54531. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54532. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54533. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54535. */
  54536. export class VideoDome extends TransformNode {
  54537. /**
  54538. * Define the video source as a Monoscopic panoramic 360 video.
  54539. */
  54540. static readonly MODE_MONOSCOPIC: number;
  54541. /**
  54542. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54543. */
  54544. static readonly MODE_TOPBOTTOM: number;
  54545. /**
  54546. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54547. */
  54548. static readonly MODE_SIDEBYSIDE: number;
  54549. private _halfDome;
  54550. private _useDirectMapping;
  54551. /**
  54552. * The video texture being displayed on the sphere
  54553. */
  54554. protected _videoTexture: VideoTexture;
  54555. /**
  54556. * Gets the video texture being displayed on the sphere
  54557. */
  54558. get videoTexture(): VideoTexture;
  54559. /**
  54560. * The skybox material
  54561. */
  54562. protected _material: BackgroundMaterial;
  54563. /**
  54564. * The surface used for the skybox
  54565. */
  54566. protected _mesh: Mesh;
  54567. /**
  54568. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54569. */
  54570. private _halfDomeMask;
  54571. /**
  54572. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54573. * Also see the options.resolution property.
  54574. */
  54575. get fovMultiplier(): number;
  54576. set fovMultiplier(value: number);
  54577. private _videoMode;
  54578. /**
  54579. * Gets or set the current video mode for the video. It can be:
  54580. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54581. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54582. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54583. */
  54584. get videoMode(): number;
  54585. set videoMode(value: number);
  54586. /**
  54587. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54588. *
  54589. */
  54590. get halfDome(): boolean;
  54591. /**
  54592. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54593. */
  54594. set halfDome(enabled: boolean);
  54595. /**
  54596. * Oberserver used in Stereoscopic VR Mode.
  54597. */
  54598. private _onBeforeCameraRenderObserver;
  54599. /**
  54600. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54601. * @param name Element's name, child elements will append suffixes for their own names.
  54602. * @param urlsOrVideo defines the url(s) or the video element to use
  54603. * @param options An object containing optional or exposed sub element properties
  54604. */
  54605. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54606. resolution?: number;
  54607. clickToPlay?: boolean;
  54608. autoPlay?: boolean;
  54609. loop?: boolean;
  54610. size?: number;
  54611. poster?: string;
  54612. faceForward?: boolean;
  54613. useDirectMapping?: boolean;
  54614. halfDomeMode?: boolean;
  54615. }, scene: Scene);
  54616. private _changeVideoMode;
  54617. /**
  54618. * Releases resources associated with this node.
  54619. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54620. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54621. */
  54622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54623. }
  54624. }
  54625. declare module "babylonjs/Helpers/index" {
  54626. export * from "babylonjs/Helpers/environmentHelper";
  54627. export * from "babylonjs/Helpers/photoDome";
  54628. export * from "babylonjs/Helpers/sceneHelpers";
  54629. export * from "babylonjs/Helpers/videoDome";
  54630. }
  54631. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54632. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54633. import { IDisposable } from "babylonjs/scene";
  54634. import { Engine } from "babylonjs/Engines/engine";
  54635. /**
  54636. * This class can be used to get instrumentation data from a Babylon engine
  54637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54638. */
  54639. export class EngineInstrumentation implements IDisposable {
  54640. /**
  54641. * Define the instrumented engine.
  54642. */
  54643. engine: Engine;
  54644. private _captureGPUFrameTime;
  54645. private _gpuFrameTimeToken;
  54646. private _gpuFrameTime;
  54647. private _captureShaderCompilationTime;
  54648. private _shaderCompilationTime;
  54649. private _onBeginFrameObserver;
  54650. private _onEndFrameObserver;
  54651. private _onBeforeShaderCompilationObserver;
  54652. private _onAfterShaderCompilationObserver;
  54653. /**
  54654. * Gets the perf counter used for GPU frame time
  54655. */
  54656. get gpuFrameTimeCounter(): PerfCounter;
  54657. /**
  54658. * Gets the GPU frame time capture status
  54659. */
  54660. get captureGPUFrameTime(): boolean;
  54661. /**
  54662. * Enable or disable the GPU frame time capture
  54663. */
  54664. set captureGPUFrameTime(value: boolean);
  54665. /**
  54666. * Gets the perf counter used for shader compilation time
  54667. */
  54668. get shaderCompilationTimeCounter(): PerfCounter;
  54669. /**
  54670. * Gets the shader compilation time capture status
  54671. */
  54672. get captureShaderCompilationTime(): boolean;
  54673. /**
  54674. * Enable or disable the shader compilation time capture
  54675. */
  54676. set captureShaderCompilationTime(value: boolean);
  54677. /**
  54678. * Instantiates a new engine instrumentation.
  54679. * This class can be used to get instrumentation data from a Babylon engine
  54680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54681. * @param engine Defines the engine to instrument
  54682. */
  54683. constructor(
  54684. /**
  54685. * Define the instrumented engine.
  54686. */
  54687. engine: Engine);
  54688. /**
  54689. * Dispose and release associated resources.
  54690. */
  54691. dispose(): void;
  54692. }
  54693. }
  54694. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54695. import { Scene, IDisposable } from "babylonjs/scene";
  54696. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54697. /**
  54698. * This class can be used to get instrumentation data from a Babylon engine
  54699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54700. */
  54701. export class SceneInstrumentation implements IDisposable {
  54702. /**
  54703. * Defines the scene to instrument
  54704. */
  54705. scene: Scene;
  54706. private _captureActiveMeshesEvaluationTime;
  54707. private _activeMeshesEvaluationTime;
  54708. private _captureRenderTargetsRenderTime;
  54709. private _renderTargetsRenderTime;
  54710. private _captureFrameTime;
  54711. private _frameTime;
  54712. private _captureRenderTime;
  54713. private _renderTime;
  54714. private _captureInterFrameTime;
  54715. private _interFrameTime;
  54716. private _captureParticlesRenderTime;
  54717. private _particlesRenderTime;
  54718. private _captureSpritesRenderTime;
  54719. private _spritesRenderTime;
  54720. private _capturePhysicsTime;
  54721. private _physicsTime;
  54722. private _captureAnimationsTime;
  54723. private _animationsTime;
  54724. private _captureCameraRenderTime;
  54725. private _cameraRenderTime;
  54726. private _onBeforeActiveMeshesEvaluationObserver;
  54727. private _onAfterActiveMeshesEvaluationObserver;
  54728. private _onBeforeRenderTargetsRenderObserver;
  54729. private _onAfterRenderTargetsRenderObserver;
  54730. private _onAfterRenderObserver;
  54731. private _onBeforeDrawPhaseObserver;
  54732. private _onAfterDrawPhaseObserver;
  54733. private _onBeforeAnimationsObserver;
  54734. private _onBeforeParticlesRenderingObserver;
  54735. private _onAfterParticlesRenderingObserver;
  54736. private _onBeforeSpritesRenderingObserver;
  54737. private _onAfterSpritesRenderingObserver;
  54738. private _onBeforePhysicsObserver;
  54739. private _onAfterPhysicsObserver;
  54740. private _onAfterAnimationsObserver;
  54741. private _onBeforeCameraRenderObserver;
  54742. private _onAfterCameraRenderObserver;
  54743. /**
  54744. * Gets the perf counter used for active meshes evaluation time
  54745. */
  54746. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54747. /**
  54748. * Gets the active meshes evaluation time capture status
  54749. */
  54750. get captureActiveMeshesEvaluationTime(): boolean;
  54751. /**
  54752. * Enable or disable the active meshes evaluation time capture
  54753. */
  54754. set captureActiveMeshesEvaluationTime(value: boolean);
  54755. /**
  54756. * Gets the perf counter used for render targets render time
  54757. */
  54758. get renderTargetsRenderTimeCounter(): PerfCounter;
  54759. /**
  54760. * Gets the render targets render time capture status
  54761. */
  54762. get captureRenderTargetsRenderTime(): boolean;
  54763. /**
  54764. * Enable or disable the render targets render time capture
  54765. */
  54766. set captureRenderTargetsRenderTime(value: boolean);
  54767. /**
  54768. * Gets the perf counter used for particles render time
  54769. */
  54770. get particlesRenderTimeCounter(): PerfCounter;
  54771. /**
  54772. * Gets the particles render time capture status
  54773. */
  54774. get captureParticlesRenderTime(): boolean;
  54775. /**
  54776. * Enable or disable the particles render time capture
  54777. */
  54778. set captureParticlesRenderTime(value: boolean);
  54779. /**
  54780. * Gets the perf counter used for sprites render time
  54781. */
  54782. get spritesRenderTimeCounter(): PerfCounter;
  54783. /**
  54784. * Gets the sprites render time capture status
  54785. */
  54786. get captureSpritesRenderTime(): boolean;
  54787. /**
  54788. * Enable or disable the sprites render time capture
  54789. */
  54790. set captureSpritesRenderTime(value: boolean);
  54791. /**
  54792. * Gets the perf counter used for physics time
  54793. */
  54794. get physicsTimeCounter(): PerfCounter;
  54795. /**
  54796. * Gets the physics time capture status
  54797. */
  54798. get capturePhysicsTime(): boolean;
  54799. /**
  54800. * Enable or disable the physics time capture
  54801. */
  54802. set capturePhysicsTime(value: boolean);
  54803. /**
  54804. * Gets the perf counter used for animations time
  54805. */
  54806. get animationsTimeCounter(): PerfCounter;
  54807. /**
  54808. * Gets the animations time capture status
  54809. */
  54810. get captureAnimationsTime(): boolean;
  54811. /**
  54812. * Enable or disable the animations time capture
  54813. */
  54814. set captureAnimationsTime(value: boolean);
  54815. /**
  54816. * Gets the perf counter used for frame time capture
  54817. */
  54818. get frameTimeCounter(): PerfCounter;
  54819. /**
  54820. * Gets the frame time capture status
  54821. */
  54822. get captureFrameTime(): boolean;
  54823. /**
  54824. * Enable or disable the frame time capture
  54825. */
  54826. set captureFrameTime(value: boolean);
  54827. /**
  54828. * Gets the perf counter used for inter-frames time capture
  54829. */
  54830. get interFrameTimeCounter(): PerfCounter;
  54831. /**
  54832. * Gets the inter-frames time capture status
  54833. */
  54834. get captureInterFrameTime(): boolean;
  54835. /**
  54836. * Enable or disable the inter-frames time capture
  54837. */
  54838. set captureInterFrameTime(value: boolean);
  54839. /**
  54840. * Gets the perf counter used for render time capture
  54841. */
  54842. get renderTimeCounter(): PerfCounter;
  54843. /**
  54844. * Gets the render time capture status
  54845. */
  54846. get captureRenderTime(): boolean;
  54847. /**
  54848. * Enable or disable the render time capture
  54849. */
  54850. set captureRenderTime(value: boolean);
  54851. /**
  54852. * Gets the perf counter used for camera render time capture
  54853. */
  54854. get cameraRenderTimeCounter(): PerfCounter;
  54855. /**
  54856. * Gets the camera render time capture status
  54857. */
  54858. get captureCameraRenderTime(): boolean;
  54859. /**
  54860. * Enable or disable the camera render time capture
  54861. */
  54862. set captureCameraRenderTime(value: boolean);
  54863. /**
  54864. * Gets the perf counter used for draw calls
  54865. */
  54866. get drawCallsCounter(): PerfCounter;
  54867. /**
  54868. * Instantiates a new scene instrumentation.
  54869. * This class can be used to get instrumentation data from a Babylon engine
  54870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54871. * @param scene Defines the scene to instrument
  54872. */
  54873. constructor(
  54874. /**
  54875. * Defines the scene to instrument
  54876. */
  54877. scene: Scene);
  54878. /**
  54879. * Dispose and release associated resources.
  54880. */
  54881. dispose(): void;
  54882. }
  54883. }
  54884. declare module "babylonjs/Instrumentation/index" {
  54885. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54886. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54887. export * from "babylonjs/Instrumentation/timeToken";
  54888. }
  54889. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54890. /** @hidden */
  54891. export var glowMapGenerationPixelShader: {
  54892. name: string;
  54893. shader: string;
  54894. };
  54895. }
  54896. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54897. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54898. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54899. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54900. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54901. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54902. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54903. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54904. /** @hidden */
  54905. export var glowMapGenerationVertexShader: {
  54906. name: string;
  54907. shader: string;
  54908. };
  54909. }
  54910. declare module "babylonjs/Layers/effectLayer" {
  54911. import { Observable } from "babylonjs/Misc/observable";
  54912. import { Nullable } from "babylonjs/types";
  54913. import { Camera } from "babylonjs/Cameras/camera";
  54914. import { Scene } from "babylonjs/scene";
  54915. import { ISize } from "babylonjs/Maths/math.size";
  54916. import { Color4 } from "babylonjs/Maths/math.color";
  54917. import { Engine } from "babylonjs/Engines/engine";
  54918. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54920. import { Mesh } from "babylonjs/Meshes/mesh";
  54921. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54924. import { Effect } from "babylonjs/Materials/effect";
  54925. import { Material } from "babylonjs/Materials/material";
  54926. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54927. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54928. /**
  54929. * Effect layer options. This helps customizing the behaviour
  54930. * of the effect layer.
  54931. */
  54932. export interface IEffectLayerOptions {
  54933. /**
  54934. * Multiplication factor apply to the canvas size to compute the render target size
  54935. * used to generated the objects (the smaller the faster).
  54936. */
  54937. mainTextureRatio: number;
  54938. /**
  54939. * Enforces a fixed size texture to ensure effect stability across devices.
  54940. */
  54941. mainTextureFixedSize?: number;
  54942. /**
  54943. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54944. */
  54945. alphaBlendingMode: number;
  54946. /**
  54947. * The camera attached to the layer.
  54948. */
  54949. camera: Nullable<Camera>;
  54950. /**
  54951. * The rendering group to draw the layer in.
  54952. */
  54953. renderingGroupId: number;
  54954. }
  54955. /**
  54956. * The effect layer Helps adding post process effect blended with the main pass.
  54957. *
  54958. * This can be for instance use to generate glow or higlight effects on the scene.
  54959. *
  54960. * The effect layer class can not be used directly and is intented to inherited from to be
  54961. * customized per effects.
  54962. */
  54963. export abstract class EffectLayer {
  54964. private _vertexBuffers;
  54965. private _indexBuffer;
  54966. private _cachedDefines;
  54967. private _effectLayerMapGenerationEffect;
  54968. private _effectLayerOptions;
  54969. private _mergeEffect;
  54970. protected _scene: Scene;
  54971. protected _engine: Engine;
  54972. protected _maxSize: number;
  54973. protected _mainTextureDesiredSize: ISize;
  54974. protected _mainTexture: RenderTargetTexture;
  54975. protected _shouldRender: boolean;
  54976. protected _postProcesses: PostProcess[];
  54977. protected _textures: BaseTexture[];
  54978. protected _emissiveTextureAndColor: {
  54979. texture: Nullable<BaseTexture>;
  54980. color: Color4;
  54981. };
  54982. /**
  54983. * The name of the layer
  54984. */
  54985. name: string;
  54986. /**
  54987. * The clear color of the texture used to generate the glow map.
  54988. */
  54989. neutralColor: Color4;
  54990. /**
  54991. * Specifies whether the highlight layer is enabled or not.
  54992. */
  54993. isEnabled: boolean;
  54994. /**
  54995. * Gets the camera attached to the layer.
  54996. */
  54997. get camera(): Nullable<Camera>;
  54998. /**
  54999. * Gets the rendering group id the layer should render in.
  55000. */
  55001. get renderingGroupId(): number;
  55002. set renderingGroupId(renderingGroupId: number);
  55003. /**
  55004. * An event triggered when the effect layer has been disposed.
  55005. */
  55006. onDisposeObservable: Observable<EffectLayer>;
  55007. /**
  55008. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55009. */
  55010. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55011. /**
  55012. * An event triggered when the generated texture is being merged in the scene.
  55013. */
  55014. onBeforeComposeObservable: Observable<EffectLayer>;
  55015. /**
  55016. * An event triggered when the mesh is rendered into the effect render target.
  55017. */
  55018. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55019. /**
  55020. * An event triggered after the mesh has been rendered into the effect render target.
  55021. */
  55022. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55023. /**
  55024. * An event triggered when the generated texture has been merged in the scene.
  55025. */
  55026. onAfterComposeObservable: Observable<EffectLayer>;
  55027. /**
  55028. * An event triggered when the efffect layer changes its size.
  55029. */
  55030. onSizeChangedObservable: Observable<EffectLayer>;
  55031. /** @hidden */
  55032. static _SceneComponentInitialization: (scene: Scene) => void;
  55033. /**
  55034. * Instantiates a new effect Layer and references it in the scene.
  55035. * @param name The name of the layer
  55036. * @param scene The scene to use the layer in
  55037. */
  55038. constructor(
  55039. /** The Friendly of the effect in the scene */
  55040. name: string, scene: Scene);
  55041. /**
  55042. * Get the effect name of the layer.
  55043. * @return The effect name
  55044. */
  55045. abstract getEffectName(): string;
  55046. /**
  55047. * Checks for the readiness of the element composing the layer.
  55048. * @param subMesh the mesh to check for
  55049. * @param useInstances specify whether or not to use instances to render the mesh
  55050. * @return true if ready otherwise, false
  55051. */
  55052. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55053. /**
  55054. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55055. * @returns true if the effect requires stencil during the main canvas render pass.
  55056. */
  55057. abstract needStencil(): boolean;
  55058. /**
  55059. * Create the merge effect. This is the shader use to blit the information back
  55060. * to the main canvas at the end of the scene rendering.
  55061. * @returns The effect containing the shader used to merge the effect on the main canvas
  55062. */
  55063. protected abstract _createMergeEffect(): Effect;
  55064. /**
  55065. * Creates the render target textures and post processes used in the effect layer.
  55066. */
  55067. protected abstract _createTextureAndPostProcesses(): void;
  55068. /**
  55069. * Implementation specific of rendering the generating effect on the main canvas.
  55070. * @param effect The effect used to render through
  55071. */
  55072. protected abstract _internalRender(effect: Effect): void;
  55073. /**
  55074. * Sets the required values for both the emissive texture and and the main color.
  55075. */
  55076. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55077. /**
  55078. * Free any resources and references associated to a mesh.
  55079. * Internal use
  55080. * @param mesh The mesh to free.
  55081. */
  55082. abstract _disposeMesh(mesh: Mesh): void;
  55083. /**
  55084. * Serializes this layer (Glow or Highlight for example)
  55085. * @returns a serialized layer object
  55086. */
  55087. abstract serialize?(): any;
  55088. /**
  55089. * Initializes the effect layer with the required options.
  55090. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55091. */
  55092. protected _init(options: Partial<IEffectLayerOptions>): void;
  55093. /**
  55094. * Generates the index buffer of the full screen quad blending to the main canvas.
  55095. */
  55096. private _generateIndexBuffer;
  55097. /**
  55098. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55099. */
  55100. private _generateVertexBuffer;
  55101. /**
  55102. * Sets the main texture desired size which is the closest power of two
  55103. * of the engine canvas size.
  55104. */
  55105. private _setMainTextureSize;
  55106. /**
  55107. * Creates the main texture for the effect layer.
  55108. */
  55109. protected _createMainTexture(): void;
  55110. /**
  55111. * Adds specific effects defines.
  55112. * @param defines The defines to add specifics to.
  55113. */
  55114. protected _addCustomEffectDefines(defines: string[]): void;
  55115. /**
  55116. * Checks for the readiness of the element composing the layer.
  55117. * @param subMesh the mesh to check for
  55118. * @param useInstances specify whether or not to use instances to render the mesh
  55119. * @param emissiveTexture the associated emissive texture used to generate the glow
  55120. * @return true if ready otherwise, false
  55121. */
  55122. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55123. /**
  55124. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55125. */
  55126. render(): void;
  55127. /**
  55128. * Determine if a given mesh will be used in the current effect.
  55129. * @param mesh mesh to test
  55130. * @returns true if the mesh will be used
  55131. */
  55132. hasMesh(mesh: AbstractMesh): boolean;
  55133. /**
  55134. * Returns true if the layer contains information to display, otherwise false.
  55135. * @returns true if the glow layer should be rendered
  55136. */
  55137. shouldRender(): boolean;
  55138. /**
  55139. * Returns true if the mesh should render, otherwise false.
  55140. * @param mesh The mesh to render
  55141. * @returns true if it should render otherwise false
  55142. */
  55143. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55144. /**
  55145. * Returns true if the mesh can be rendered, otherwise false.
  55146. * @param mesh The mesh to render
  55147. * @param material The material used on the mesh
  55148. * @returns true if it can be rendered otherwise false
  55149. */
  55150. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55151. /**
  55152. * Returns true if the mesh should render, otherwise false.
  55153. * @param mesh The mesh to render
  55154. * @returns true if it should render otherwise false
  55155. */
  55156. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55157. /**
  55158. * Renders the submesh passed in parameter to the generation map.
  55159. */
  55160. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55161. /**
  55162. * Defines whether the current material of the mesh should be use to render the effect.
  55163. * @param mesh defines the current mesh to render
  55164. */
  55165. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55166. /**
  55167. * Rebuild the required buffers.
  55168. * @hidden Internal use only.
  55169. */
  55170. _rebuild(): void;
  55171. /**
  55172. * Dispose only the render target textures and post process.
  55173. */
  55174. private _disposeTextureAndPostProcesses;
  55175. /**
  55176. * Dispose the highlight layer and free resources.
  55177. */
  55178. dispose(): void;
  55179. /**
  55180. * Gets the class name of the effect layer
  55181. * @returns the string with the class name of the effect layer
  55182. */
  55183. getClassName(): string;
  55184. /**
  55185. * Creates an effect layer from parsed effect layer data
  55186. * @param parsedEffectLayer defines effect layer data
  55187. * @param scene defines the current scene
  55188. * @param rootUrl defines the root URL containing the effect layer information
  55189. * @returns a parsed effect Layer
  55190. */
  55191. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55192. }
  55193. }
  55194. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55195. import { Scene } from "babylonjs/scene";
  55196. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55197. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55198. import { AbstractScene } from "babylonjs/abstractScene";
  55199. module "babylonjs/abstractScene" {
  55200. interface AbstractScene {
  55201. /**
  55202. * The list of effect layers (highlights/glow) added to the scene
  55203. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55204. * @see http://doc.babylonjs.com/how_to/glow_layer
  55205. */
  55206. effectLayers: Array<EffectLayer>;
  55207. /**
  55208. * Removes the given effect layer from this scene.
  55209. * @param toRemove defines the effect layer to remove
  55210. * @returns the index of the removed effect layer
  55211. */
  55212. removeEffectLayer(toRemove: EffectLayer): number;
  55213. /**
  55214. * Adds the given effect layer to this scene
  55215. * @param newEffectLayer defines the effect layer to add
  55216. */
  55217. addEffectLayer(newEffectLayer: EffectLayer): void;
  55218. }
  55219. }
  55220. /**
  55221. * Defines the layer scene component responsible to manage any effect layers
  55222. * in a given scene.
  55223. */
  55224. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55225. /**
  55226. * The component name helpfull to identify the component in the list of scene components.
  55227. */
  55228. readonly name: string;
  55229. /**
  55230. * The scene the component belongs to.
  55231. */
  55232. scene: Scene;
  55233. private _engine;
  55234. private _renderEffects;
  55235. private _needStencil;
  55236. private _previousStencilState;
  55237. /**
  55238. * Creates a new instance of the component for the given scene
  55239. * @param scene Defines the scene to register the component in
  55240. */
  55241. constructor(scene: Scene);
  55242. /**
  55243. * Registers the component in a given scene
  55244. */
  55245. register(): void;
  55246. /**
  55247. * Rebuilds the elements related to this component in case of
  55248. * context lost for instance.
  55249. */
  55250. rebuild(): void;
  55251. /**
  55252. * Serializes the component data to the specified json object
  55253. * @param serializationObject The object to serialize to
  55254. */
  55255. serialize(serializationObject: any): void;
  55256. /**
  55257. * Adds all the elements from the container to the scene
  55258. * @param container the container holding the elements
  55259. */
  55260. addFromContainer(container: AbstractScene): void;
  55261. /**
  55262. * Removes all the elements in the container from the scene
  55263. * @param container contains the elements to remove
  55264. * @param dispose if the removed element should be disposed (default: false)
  55265. */
  55266. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55267. /**
  55268. * Disposes the component and the associated ressources.
  55269. */
  55270. dispose(): void;
  55271. private _isReadyForMesh;
  55272. private _renderMainTexture;
  55273. private _setStencil;
  55274. private _setStencilBack;
  55275. private _draw;
  55276. private _drawCamera;
  55277. private _drawRenderingGroup;
  55278. }
  55279. }
  55280. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55281. /** @hidden */
  55282. export var glowMapMergePixelShader: {
  55283. name: string;
  55284. shader: string;
  55285. };
  55286. }
  55287. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55288. /** @hidden */
  55289. export var glowMapMergeVertexShader: {
  55290. name: string;
  55291. shader: string;
  55292. };
  55293. }
  55294. declare module "babylonjs/Layers/glowLayer" {
  55295. import { Nullable } from "babylonjs/types";
  55296. import { Camera } from "babylonjs/Cameras/camera";
  55297. import { Scene } from "babylonjs/scene";
  55298. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55300. import { Mesh } from "babylonjs/Meshes/mesh";
  55301. import { Texture } from "babylonjs/Materials/Textures/texture";
  55302. import { Effect } from "babylonjs/Materials/effect";
  55303. import { Material } from "babylonjs/Materials/material";
  55304. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55305. import { Color4 } from "babylonjs/Maths/math.color";
  55306. import "babylonjs/Shaders/glowMapMerge.fragment";
  55307. import "babylonjs/Shaders/glowMapMerge.vertex";
  55308. import "babylonjs/Layers/effectLayerSceneComponent";
  55309. module "babylonjs/abstractScene" {
  55310. interface AbstractScene {
  55311. /**
  55312. * Return a the first highlight layer of the scene with a given name.
  55313. * @param name The name of the highlight layer to look for.
  55314. * @return The highlight layer if found otherwise null.
  55315. */
  55316. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55317. }
  55318. }
  55319. /**
  55320. * Glow layer options. This helps customizing the behaviour
  55321. * of the glow layer.
  55322. */
  55323. export interface IGlowLayerOptions {
  55324. /**
  55325. * Multiplication factor apply to the canvas size to compute the render target size
  55326. * used to generated the glowing objects (the smaller the faster).
  55327. */
  55328. mainTextureRatio: number;
  55329. /**
  55330. * Enforces a fixed size texture to ensure resize independant blur.
  55331. */
  55332. mainTextureFixedSize?: number;
  55333. /**
  55334. * How big is the kernel of the blur texture.
  55335. */
  55336. blurKernelSize: number;
  55337. /**
  55338. * The camera attached to the layer.
  55339. */
  55340. camera: Nullable<Camera>;
  55341. /**
  55342. * Enable MSAA by chosing the number of samples.
  55343. */
  55344. mainTextureSamples?: number;
  55345. /**
  55346. * The rendering group to draw the layer in.
  55347. */
  55348. renderingGroupId: number;
  55349. }
  55350. /**
  55351. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55352. *
  55353. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55354. *
  55355. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55356. */
  55357. export class GlowLayer extends EffectLayer {
  55358. /**
  55359. * Effect Name of the layer.
  55360. */
  55361. static readonly EffectName: string;
  55362. /**
  55363. * The default blur kernel size used for the glow.
  55364. */
  55365. static DefaultBlurKernelSize: number;
  55366. /**
  55367. * The default texture size ratio used for the glow.
  55368. */
  55369. static DefaultTextureRatio: number;
  55370. /**
  55371. * Sets the kernel size of the blur.
  55372. */
  55373. set blurKernelSize(value: number);
  55374. /**
  55375. * Gets the kernel size of the blur.
  55376. */
  55377. get blurKernelSize(): number;
  55378. /**
  55379. * Sets the glow intensity.
  55380. */
  55381. set intensity(value: number);
  55382. /**
  55383. * Gets the glow intensity.
  55384. */
  55385. get intensity(): number;
  55386. private _options;
  55387. private _intensity;
  55388. private _horizontalBlurPostprocess1;
  55389. private _verticalBlurPostprocess1;
  55390. private _horizontalBlurPostprocess2;
  55391. private _verticalBlurPostprocess2;
  55392. private _blurTexture1;
  55393. private _blurTexture2;
  55394. private _postProcesses1;
  55395. private _postProcesses2;
  55396. private _includedOnlyMeshes;
  55397. private _excludedMeshes;
  55398. private _meshesUsingTheirOwnMaterials;
  55399. /**
  55400. * Callback used to let the user override the color selection on a per mesh basis
  55401. */
  55402. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55403. /**
  55404. * Callback used to let the user override the texture selection on a per mesh basis
  55405. */
  55406. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55407. /**
  55408. * Instantiates a new glow Layer and references it to the scene.
  55409. * @param name The name of the layer
  55410. * @param scene The scene to use the layer in
  55411. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55412. */
  55413. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55414. /**
  55415. * Get the effect name of the layer.
  55416. * @return The effect name
  55417. */
  55418. getEffectName(): string;
  55419. /**
  55420. * Create the merge effect. This is the shader use to blit the information back
  55421. * to the main canvas at the end of the scene rendering.
  55422. */
  55423. protected _createMergeEffect(): Effect;
  55424. /**
  55425. * Creates the render target textures and post processes used in the glow layer.
  55426. */
  55427. protected _createTextureAndPostProcesses(): void;
  55428. /**
  55429. * Checks for the readiness of the element composing the layer.
  55430. * @param subMesh the mesh to check for
  55431. * @param useInstances specify wether or not to use instances to render the mesh
  55432. * @param emissiveTexture the associated emissive texture used to generate the glow
  55433. * @return true if ready otherwise, false
  55434. */
  55435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55436. /**
  55437. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55438. */
  55439. needStencil(): boolean;
  55440. /**
  55441. * Returns true if the mesh can be rendered, otherwise false.
  55442. * @param mesh The mesh to render
  55443. * @param material The material used on the mesh
  55444. * @returns true if it can be rendered otherwise false
  55445. */
  55446. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55447. /**
  55448. * Implementation specific of rendering the generating effect on the main canvas.
  55449. * @param effect The effect used to render through
  55450. */
  55451. protected _internalRender(effect: Effect): void;
  55452. /**
  55453. * Sets the required values for both the emissive texture and and the main color.
  55454. */
  55455. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55456. /**
  55457. * Returns true if the mesh should render, otherwise false.
  55458. * @param mesh The mesh to render
  55459. * @returns true if it should render otherwise false
  55460. */
  55461. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55462. /**
  55463. * Adds specific effects defines.
  55464. * @param defines The defines to add specifics to.
  55465. */
  55466. protected _addCustomEffectDefines(defines: string[]): void;
  55467. /**
  55468. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55469. * @param mesh The mesh to exclude from the glow layer
  55470. */
  55471. addExcludedMesh(mesh: Mesh): void;
  55472. /**
  55473. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55474. * @param mesh The mesh to remove
  55475. */
  55476. removeExcludedMesh(mesh: Mesh): void;
  55477. /**
  55478. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55479. * @param mesh The mesh to include in the glow layer
  55480. */
  55481. addIncludedOnlyMesh(mesh: Mesh): void;
  55482. /**
  55483. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55484. * @param mesh The mesh to remove
  55485. */
  55486. removeIncludedOnlyMesh(mesh: Mesh): void;
  55487. /**
  55488. * Determine if a given mesh will be used in the glow layer
  55489. * @param mesh The mesh to test
  55490. * @returns true if the mesh will be highlighted by the current glow layer
  55491. */
  55492. hasMesh(mesh: AbstractMesh): boolean;
  55493. /**
  55494. * Defines whether the current material of the mesh should be use to render the effect.
  55495. * @param mesh defines the current mesh to render
  55496. */
  55497. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55498. /**
  55499. * Add a mesh to be rendered through its own material and not with emissive only.
  55500. * @param mesh The mesh for which we need to use its material
  55501. */
  55502. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55503. /**
  55504. * Remove a mesh from being rendered through its own material and not with emissive only.
  55505. * @param mesh The mesh for which we need to not use its material
  55506. */
  55507. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55508. /**
  55509. * Free any resources and references associated to a mesh.
  55510. * Internal use
  55511. * @param mesh The mesh to free.
  55512. * @hidden
  55513. */
  55514. _disposeMesh(mesh: Mesh): void;
  55515. /**
  55516. * Gets the class name of the effect layer
  55517. * @returns the string with the class name of the effect layer
  55518. */
  55519. getClassName(): string;
  55520. /**
  55521. * Serializes this glow layer
  55522. * @returns a serialized glow layer object
  55523. */
  55524. serialize(): any;
  55525. /**
  55526. * Creates a Glow Layer from parsed glow layer data
  55527. * @param parsedGlowLayer defines glow layer data
  55528. * @param scene defines the current scene
  55529. * @param rootUrl defines the root URL containing the glow layer information
  55530. * @returns a parsed Glow Layer
  55531. */
  55532. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55533. }
  55534. }
  55535. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55536. /** @hidden */
  55537. export var glowBlurPostProcessPixelShader: {
  55538. name: string;
  55539. shader: string;
  55540. };
  55541. }
  55542. declare module "babylonjs/Layers/highlightLayer" {
  55543. import { Observable } from "babylonjs/Misc/observable";
  55544. import { Nullable } from "babylonjs/types";
  55545. import { Camera } from "babylonjs/Cameras/camera";
  55546. import { Scene } from "babylonjs/scene";
  55547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55549. import { Mesh } from "babylonjs/Meshes/mesh";
  55550. import { Effect } from "babylonjs/Materials/effect";
  55551. import { Material } from "babylonjs/Materials/material";
  55552. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55553. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55554. import "babylonjs/Shaders/glowMapMerge.fragment";
  55555. import "babylonjs/Shaders/glowMapMerge.vertex";
  55556. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55557. module "babylonjs/abstractScene" {
  55558. interface AbstractScene {
  55559. /**
  55560. * Return a the first highlight layer of the scene with a given name.
  55561. * @param name The name of the highlight layer to look for.
  55562. * @return The highlight layer if found otherwise null.
  55563. */
  55564. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55565. }
  55566. }
  55567. /**
  55568. * Highlight layer options. This helps customizing the behaviour
  55569. * of the highlight layer.
  55570. */
  55571. export interface IHighlightLayerOptions {
  55572. /**
  55573. * Multiplication factor apply to the canvas size to compute the render target size
  55574. * used to generated the glowing objects (the smaller the faster).
  55575. */
  55576. mainTextureRatio: number;
  55577. /**
  55578. * Enforces a fixed size texture to ensure resize independant blur.
  55579. */
  55580. mainTextureFixedSize?: number;
  55581. /**
  55582. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55583. * of the picture to blur (the smaller the faster).
  55584. */
  55585. blurTextureSizeRatio: number;
  55586. /**
  55587. * How big in texel of the blur texture is the vertical blur.
  55588. */
  55589. blurVerticalSize: number;
  55590. /**
  55591. * How big in texel of the blur texture is the horizontal blur.
  55592. */
  55593. blurHorizontalSize: number;
  55594. /**
  55595. * Alpha blending mode used to apply the blur. Default is combine.
  55596. */
  55597. alphaBlendingMode: number;
  55598. /**
  55599. * The camera attached to the layer.
  55600. */
  55601. camera: Nullable<Camera>;
  55602. /**
  55603. * Should we display highlight as a solid stroke?
  55604. */
  55605. isStroke?: boolean;
  55606. /**
  55607. * The rendering group to draw the layer in.
  55608. */
  55609. renderingGroupId: number;
  55610. }
  55611. /**
  55612. * The highlight layer Helps adding a glow effect around a mesh.
  55613. *
  55614. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55615. * glowy meshes to your scene.
  55616. *
  55617. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55618. */
  55619. export class HighlightLayer extends EffectLayer {
  55620. name: string;
  55621. /**
  55622. * Effect Name of the highlight layer.
  55623. */
  55624. static readonly EffectName: string;
  55625. /**
  55626. * The neutral color used during the preparation of the glow effect.
  55627. * This is black by default as the blend operation is a blend operation.
  55628. */
  55629. static NeutralColor: Color4;
  55630. /**
  55631. * Stencil value used for glowing meshes.
  55632. */
  55633. static GlowingMeshStencilReference: number;
  55634. /**
  55635. * Stencil value used for the other meshes in the scene.
  55636. */
  55637. static NormalMeshStencilReference: number;
  55638. /**
  55639. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55640. */
  55641. innerGlow: boolean;
  55642. /**
  55643. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55644. */
  55645. outerGlow: boolean;
  55646. /**
  55647. * Specifies the horizontal size of the blur.
  55648. */
  55649. set blurHorizontalSize(value: number);
  55650. /**
  55651. * Specifies the vertical size of the blur.
  55652. */
  55653. set blurVerticalSize(value: number);
  55654. /**
  55655. * Gets the horizontal size of the blur.
  55656. */
  55657. get blurHorizontalSize(): number;
  55658. /**
  55659. * Gets the vertical size of the blur.
  55660. */
  55661. get blurVerticalSize(): number;
  55662. /**
  55663. * An event triggered when the highlight layer is being blurred.
  55664. */
  55665. onBeforeBlurObservable: Observable<HighlightLayer>;
  55666. /**
  55667. * An event triggered when the highlight layer has been blurred.
  55668. */
  55669. onAfterBlurObservable: Observable<HighlightLayer>;
  55670. private _instanceGlowingMeshStencilReference;
  55671. private _options;
  55672. private _downSamplePostprocess;
  55673. private _horizontalBlurPostprocess;
  55674. private _verticalBlurPostprocess;
  55675. private _blurTexture;
  55676. private _meshes;
  55677. private _excludedMeshes;
  55678. /**
  55679. * Instantiates a new highlight Layer and references it to the scene..
  55680. * @param name The name of the layer
  55681. * @param scene The scene to use the layer in
  55682. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55683. */
  55684. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55685. /**
  55686. * Get the effect name of the layer.
  55687. * @return The effect name
  55688. */
  55689. getEffectName(): string;
  55690. /**
  55691. * Create the merge effect. This is the shader use to blit the information back
  55692. * to the main canvas at the end of the scene rendering.
  55693. */
  55694. protected _createMergeEffect(): Effect;
  55695. /**
  55696. * Creates the render target textures and post processes used in the highlight layer.
  55697. */
  55698. protected _createTextureAndPostProcesses(): void;
  55699. /**
  55700. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55701. */
  55702. needStencil(): boolean;
  55703. /**
  55704. * Checks for the readiness of the element composing the layer.
  55705. * @param subMesh the mesh to check for
  55706. * @param useInstances specify wether or not to use instances to render the mesh
  55707. * @param emissiveTexture the associated emissive texture used to generate the glow
  55708. * @return true if ready otherwise, false
  55709. */
  55710. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55711. /**
  55712. * Implementation specific of rendering the generating effect on the main canvas.
  55713. * @param effect The effect used to render through
  55714. */
  55715. protected _internalRender(effect: Effect): void;
  55716. /**
  55717. * Returns true if the layer contains information to display, otherwise false.
  55718. */
  55719. shouldRender(): boolean;
  55720. /**
  55721. * Returns true if the mesh should render, otherwise false.
  55722. * @param mesh The mesh to render
  55723. * @returns true if it should render otherwise false
  55724. */
  55725. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55726. /**
  55727. * Sets the required values for both the emissive texture and and the main color.
  55728. */
  55729. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55730. /**
  55731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55732. * @param mesh The mesh to exclude from the highlight layer
  55733. */
  55734. addExcludedMesh(mesh: Mesh): void;
  55735. /**
  55736. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55737. * @param mesh The mesh to highlight
  55738. */
  55739. removeExcludedMesh(mesh: Mesh): void;
  55740. /**
  55741. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55742. * @param mesh mesh to test
  55743. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55744. */
  55745. hasMesh(mesh: AbstractMesh): boolean;
  55746. /**
  55747. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55748. * @param mesh The mesh to highlight
  55749. * @param color The color of the highlight
  55750. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55751. */
  55752. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55753. /**
  55754. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55755. * @param mesh The mesh to highlight
  55756. */
  55757. removeMesh(mesh: Mesh): void;
  55758. /**
  55759. * Remove all the meshes currently referenced in the highlight layer
  55760. */
  55761. removeAllMeshes(): void;
  55762. /**
  55763. * Force the stencil to the normal expected value for none glowing parts
  55764. */
  55765. private _defaultStencilReference;
  55766. /**
  55767. * Free any resources and references associated to a mesh.
  55768. * Internal use
  55769. * @param mesh The mesh to free.
  55770. * @hidden
  55771. */
  55772. _disposeMesh(mesh: Mesh): void;
  55773. /**
  55774. * Dispose the highlight layer and free resources.
  55775. */
  55776. dispose(): void;
  55777. /**
  55778. * Gets the class name of the effect layer
  55779. * @returns the string with the class name of the effect layer
  55780. */
  55781. getClassName(): string;
  55782. /**
  55783. * Serializes this Highlight layer
  55784. * @returns a serialized Highlight layer object
  55785. */
  55786. serialize(): any;
  55787. /**
  55788. * Creates a Highlight layer from parsed Highlight layer data
  55789. * @param parsedHightlightLayer defines the Highlight layer data
  55790. * @param scene defines the current scene
  55791. * @param rootUrl defines the root URL containing the Highlight layer information
  55792. * @returns a parsed Highlight layer
  55793. */
  55794. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55795. }
  55796. }
  55797. declare module "babylonjs/Layers/layerSceneComponent" {
  55798. import { Scene } from "babylonjs/scene";
  55799. import { ISceneComponent } from "babylonjs/sceneComponent";
  55800. import { Layer } from "babylonjs/Layers/layer";
  55801. import { AbstractScene } from "babylonjs/abstractScene";
  55802. module "babylonjs/abstractScene" {
  55803. interface AbstractScene {
  55804. /**
  55805. * The list of layers (background and foreground) of the scene
  55806. */
  55807. layers: Array<Layer>;
  55808. }
  55809. }
  55810. /**
  55811. * Defines the layer scene component responsible to manage any layers
  55812. * in a given scene.
  55813. */
  55814. export class LayerSceneComponent implements ISceneComponent {
  55815. /**
  55816. * The component name helpfull to identify the component in the list of scene components.
  55817. */
  55818. readonly name: string;
  55819. /**
  55820. * The scene the component belongs to.
  55821. */
  55822. scene: Scene;
  55823. private _engine;
  55824. /**
  55825. * Creates a new instance of the component for the given scene
  55826. * @param scene Defines the scene to register the component in
  55827. */
  55828. constructor(scene: Scene);
  55829. /**
  55830. * Registers the component in a given scene
  55831. */
  55832. register(): void;
  55833. /**
  55834. * Rebuilds the elements related to this component in case of
  55835. * context lost for instance.
  55836. */
  55837. rebuild(): void;
  55838. /**
  55839. * Disposes the component and the associated ressources.
  55840. */
  55841. dispose(): void;
  55842. private _draw;
  55843. private _drawCameraPredicate;
  55844. private _drawCameraBackground;
  55845. private _drawCameraForeground;
  55846. private _drawRenderTargetPredicate;
  55847. private _drawRenderTargetBackground;
  55848. private _drawRenderTargetForeground;
  55849. /**
  55850. * Adds all the elements from the container to the scene
  55851. * @param container the container holding the elements
  55852. */
  55853. addFromContainer(container: AbstractScene): void;
  55854. /**
  55855. * Removes all the elements in the container from the scene
  55856. * @param container contains the elements to remove
  55857. * @param dispose if the removed element should be disposed (default: false)
  55858. */
  55859. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55860. }
  55861. }
  55862. declare module "babylonjs/Shaders/layer.fragment" {
  55863. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55864. /** @hidden */
  55865. export var layerPixelShader: {
  55866. name: string;
  55867. shader: string;
  55868. };
  55869. }
  55870. declare module "babylonjs/Shaders/layer.vertex" {
  55871. /** @hidden */
  55872. export var layerVertexShader: {
  55873. name: string;
  55874. shader: string;
  55875. };
  55876. }
  55877. declare module "babylonjs/Layers/layer" {
  55878. import { Observable } from "babylonjs/Misc/observable";
  55879. import { Nullable } from "babylonjs/types";
  55880. import { Scene } from "babylonjs/scene";
  55881. import { Vector2 } from "babylonjs/Maths/math.vector";
  55882. import { Color4 } from "babylonjs/Maths/math.color";
  55883. import { Texture } from "babylonjs/Materials/Textures/texture";
  55884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55885. import "babylonjs/Shaders/layer.fragment";
  55886. import "babylonjs/Shaders/layer.vertex";
  55887. /**
  55888. * This represents a full screen 2d layer.
  55889. * This can be useful to display a picture in the background of your scene for instance.
  55890. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55891. */
  55892. export class Layer {
  55893. /**
  55894. * Define the name of the layer.
  55895. */
  55896. name: string;
  55897. /**
  55898. * Define the texture the layer should display.
  55899. */
  55900. texture: Nullable<Texture>;
  55901. /**
  55902. * Is the layer in background or foreground.
  55903. */
  55904. isBackground: boolean;
  55905. /**
  55906. * Define the color of the layer (instead of texture).
  55907. */
  55908. color: Color4;
  55909. /**
  55910. * Define the scale of the layer in order to zoom in out of the texture.
  55911. */
  55912. scale: Vector2;
  55913. /**
  55914. * Define an offset for the layer in order to shift the texture.
  55915. */
  55916. offset: Vector2;
  55917. /**
  55918. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55919. */
  55920. alphaBlendingMode: number;
  55921. /**
  55922. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55923. * Alpha test will not mix with the background color in case of transparency.
  55924. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55925. */
  55926. alphaTest: boolean;
  55927. /**
  55928. * Define a mask to restrict the layer to only some of the scene cameras.
  55929. */
  55930. layerMask: number;
  55931. /**
  55932. * Define the list of render target the layer is visible into.
  55933. */
  55934. renderTargetTextures: RenderTargetTexture[];
  55935. /**
  55936. * Define if the layer is only used in renderTarget or if it also
  55937. * renders in the main frame buffer of the canvas.
  55938. */
  55939. renderOnlyInRenderTargetTextures: boolean;
  55940. private _scene;
  55941. private _vertexBuffers;
  55942. private _indexBuffer;
  55943. private _effect;
  55944. private _previousDefines;
  55945. /**
  55946. * An event triggered when the layer is disposed.
  55947. */
  55948. onDisposeObservable: Observable<Layer>;
  55949. private _onDisposeObserver;
  55950. /**
  55951. * Back compatibility with callback before the onDisposeObservable existed.
  55952. * The set callback will be triggered when the layer has been disposed.
  55953. */
  55954. set onDispose(callback: () => void);
  55955. /**
  55956. * An event triggered before rendering the scene
  55957. */
  55958. onBeforeRenderObservable: Observable<Layer>;
  55959. private _onBeforeRenderObserver;
  55960. /**
  55961. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55962. * The set callback will be triggered just before rendering the layer.
  55963. */
  55964. set onBeforeRender(callback: () => void);
  55965. /**
  55966. * An event triggered after rendering the scene
  55967. */
  55968. onAfterRenderObservable: Observable<Layer>;
  55969. private _onAfterRenderObserver;
  55970. /**
  55971. * Back compatibility with callback before the onAfterRenderObservable existed.
  55972. * The set callback will be triggered just after rendering the layer.
  55973. */
  55974. set onAfterRender(callback: () => void);
  55975. /**
  55976. * Instantiates a new layer.
  55977. * This represents a full screen 2d layer.
  55978. * This can be useful to display a picture in the background of your scene for instance.
  55979. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55980. * @param name Define the name of the layer in the scene
  55981. * @param imgUrl Define the url of the texture to display in the layer
  55982. * @param scene Define the scene the layer belongs to
  55983. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55984. * @param color Defines a color for the layer
  55985. */
  55986. constructor(
  55987. /**
  55988. * Define the name of the layer.
  55989. */
  55990. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55991. private _createIndexBuffer;
  55992. /** @hidden */
  55993. _rebuild(): void;
  55994. /**
  55995. * Renders the layer in the scene.
  55996. */
  55997. render(): void;
  55998. /**
  55999. * Disposes and releases the associated ressources.
  56000. */
  56001. dispose(): void;
  56002. }
  56003. }
  56004. declare module "babylonjs/Layers/index" {
  56005. export * from "babylonjs/Layers/effectLayer";
  56006. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56007. export * from "babylonjs/Layers/glowLayer";
  56008. export * from "babylonjs/Layers/highlightLayer";
  56009. export * from "babylonjs/Layers/layer";
  56010. export * from "babylonjs/Layers/layerSceneComponent";
  56011. }
  56012. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56013. /** @hidden */
  56014. export var lensFlarePixelShader: {
  56015. name: string;
  56016. shader: string;
  56017. };
  56018. }
  56019. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56020. /** @hidden */
  56021. export var lensFlareVertexShader: {
  56022. name: string;
  56023. shader: string;
  56024. };
  56025. }
  56026. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56027. import { Scene } from "babylonjs/scene";
  56028. import { Vector3 } from "babylonjs/Maths/math.vector";
  56029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56030. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56031. import "babylonjs/Shaders/lensFlare.fragment";
  56032. import "babylonjs/Shaders/lensFlare.vertex";
  56033. import { Viewport } from "babylonjs/Maths/math.viewport";
  56034. /**
  56035. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56036. * It is usually composed of several `lensFlare`.
  56037. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56038. */
  56039. export class LensFlareSystem {
  56040. /**
  56041. * Define the name of the lens flare system
  56042. */
  56043. name: string;
  56044. /**
  56045. * List of lens flares used in this system.
  56046. */
  56047. lensFlares: LensFlare[];
  56048. /**
  56049. * Define a limit from the border the lens flare can be visible.
  56050. */
  56051. borderLimit: number;
  56052. /**
  56053. * Define a viewport border we do not want to see the lens flare in.
  56054. */
  56055. viewportBorder: number;
  56056. /**
  56057. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56058. */
  56059. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56060. /**
  56061. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56062. */
  56063. layerMask: number;
  56064. /**
  56065. * Define the id of the lens flare system in the scene.
  56066. * (equal to name by default)
  56067. */
  56068. id: string;
  56069. private _scene;
  56070. private _emitter;
  56071. private _vertexBuffers;
  56072. private _indexBuffer;
  56073. private _effect;
  56074. private _positionX;
  56075. private _positionY;
  56076. private _isEnabled;
  56077. /** @hidden */
  56078. static _SceneComponentInitialization: (scene: Scene) => void;
  56079. /**
  56080. * Instantiates a lens flare system.
  56081. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56082. * It is usually composed of several `lensFlare`.
  56083. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56084. * @param name Define the name of the lens flare system in the scene
  56085. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56086. * @param scene Define the scene the lens flare system belongs to
  56087. */
  56088. constructor(
  56089. /**
  56090. * Define the name of the lens flare system
  56091. */
  56092. name: string, emitter: any, scene: Scene);
  56093. /**
  56094. * Define if the lens flare system is enabled.
  56095. */
  56096. get isEnabled(): boolean;
  56097. set isEnabled(value: boolean);
  56098. /**
  56099. * Get the scene the effects belongs to.
  56100. * @returns the scene holding the lens flare system
  56101. */
  56102. getScene(): Scene;
  56103. /**
  56104. * Get the emitter of the lens flare system.
  56105. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56106. * @returns the emitter of the lens flare system
  56107. */
  56108. getEmitter(): any;
  56109. /**
  56110. * Set the emitter of the lens flare system.
  56111. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56112. * @param newEmitter Define the new emitter of the system
  56113. */
  56114. setEmitter(newEmitter: any): void;
  56115. /**
  56116. * Get the lens flare system emitter position.
  56117. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56118. * @returns the position
  56119. */
  56120. getEmitterPosition(): Vector3;
  56121. /**
  56122. * @hidden
  56123. */
  56124. computeEffectivePosition(globalViewport: Viewport): boolean;
  56125. /** @hidden */
  56126. _isVisible(): boolean;
  56127. /**
  56128. * @hidden
  56129. */
  56130. render(): boolean;
  56131. /**
  56132. * Dispose and release the lens flare with its associated resources.
  56133. */
  56134. dispose(): void;
  56135. /**
  56136. * Parse a lens flare system from a JSON repressentation
  56137. * @param parsedLensFlareSystem Define the JSON to parse
  56138. * @param scene Define the scene the parsed system should be instantiated in
  56139. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56140. * @returns the parsed system
  56141. */
  56142. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56143. /**
  56144. * Serialize the current Lens Flare System into a JSON representation.
  56145. * @returns the serialized JSON
  56146. */
  56147. serialize(): any;
  56148. }
  56149. }
  56150. declare module "babylonjs/LensFlares/lensFlare" {
  56151. import { Nullable } from "babylonjs/types";
  56152. import { Color3 } from "babylonjs/Maths/math.color";
  56153. import { Texture } from "babylonjs/Materials/Textures/texture";
  56154. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56155. /**
  56156. * This represents one of the lens effect in a `lensFlareSystem`.
  56157. * It controls one of the indiviual texture used in the effect.
  56158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56159. */
  56160. export class LensFlare {
  56161. /**
  56162. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56163. */
  56164. size: number;
  56165. /**
  56166. * 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.
  56167. */
  56168. position: number;
  56169. /**
  56170. * Define the lens color.
  56171. */
  56172. color: Color3;
  56173. /**
  56174. * Define the lens texture.
  56175. */
  56176. texture: Nullable<Texture>;
  56177. /**
  56178. * Define the alpha mode to render this particular lens.
  56179. */
  56180. alphaMode: number;
  56181. private _system;
  56182. /**
  56183. * Creates a new Lens Flare.
  56184. * This represents one of the lens effect in a `lensFlareSystem`.
  56185. * It controls one of the indiviual texture used in the effect.
  56186. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56187. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56188. * @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.
  56189. * @param color Define the lens color
  56190. * @param imgUrl Define the lens texture url
  56191. * @param system Define the `lensFlareSystem` this flare is part of
  56192. * @returns The newly created Lens Flare
  56193. */
  56194. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56195. /**
  56196. * Instantiates a new Lens Flare.
  56197. * This represents one of the lens effect in a `lensFlareSystem`.
  56198. * It controls one of the indiviual texture used in the effect.
  56199. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56200. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56201. * @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.
  56202. * @param color Define the lens color
  56203. * @param imgUrl Define the lens texture url
  56204. * @param system Define the `lensFlareSystem` this flare is part of
  56205. */
  56206. constructor(
  56207. /**
  56208. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56209. */
  56210. size: number,
  56211. /**
  56212. * 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.
  56213. */
  56214. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56215. /**
  56216. * Dispose and release the lens flare with its associated resources.
  56217. */
  56218. dispose(): void;
  56219. }
  56220. }
  56221. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56222. import { Nullable } from "babylonjs/types";
  56223. import { Scene } from "babylonjs/scene";
  56224. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56225. import { AbstractScene } from "babylonjs/abstractScene";
  56226. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56227. module "babylonjs/abstractScene" {
  56228. interface AbstractScene {
  56229. /**
  56230. * The list of lens flare system added to the scene
  56231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56232. */
  56233. lensFlareSystems: Array<LensFlareSystem>;
  56234. /**
  56235. * Removes the given lens flare system from this scene.
  56236. * @param toRemove The lens flare system to remove
  56237. * @returns The index of the removed lens flare system
  56238. */
  56239. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56240. /**
  56241. * Adds the given lens flare system to this scene
  56242. * @param newLensFlareSystem The lens flare system to add
  56243. */
  56244. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56245. /**
  56246. * Gets a lens flare system using its name
  56247. * @param name defines the name to look for
  56248. * @returns the lens flare system or null if not found
  56249. */
  56250. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56251. /**
  56252. * Gets a lens flare system using its id
  56253. * @param id defines the id to look for
  56254. * @returns the lens flare system or null if not found
  56255. */
  56256. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56257. }
  56258. }
  56259. /**
  56260. * Defines the lens flare scene component responsible to manage any lens flares
  56261. * in a given scene.
  56262. */
  56263. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56264. /**
  56265. * The component name helpfull to identify the component in the list of scene components.
  56266. */
  56267. readonly name: string;
  56268. /**
  56269. * The scene the component belongs to.
  56270. */
  56271. scene: Scene;
  56272. /**
  56273. * Creates a new instance of the component for the given scene
  56274. * @param scene Defines the scene to register the component in
  56275. */
  56276. constructor(scene: Scene);
  56277. /**
  56278. * Registers the component in a given scene
  56279. */
  56280. register(): void;
  56281. /**
  56282. * Rebuilds the elements related to this component in case of
  56283. * context lost for instance.
  56284. */
  56285. rebuild(): void;
  56286. /**
  56287. * Adds all the elements from the container to the scene
  56288. * @param container the container holding the elements
  56289. */
  56290. addFromContainer(container: AbstractScene): void;
  56291. /**
  56292. * Removes all the elements in the container from the scene
  56293. * @param container contains the elements to remove
  56294. * @param dispose if the removed element should be disposed (default: false)
  56295. */
  56296. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56297. /**
  56298. * Serializes the component data to the specified json object
  56299. * @param serializationObject The object to serialize to
  56300. */
  56301. serialize(serializationObject: any): void;
  56302. /**
  56303. * Disposes the component and the associated ressources.
  56304. */
  56305. dispose(): void;
  56306. private _draw;
  56307. }
  56308. }
  56309. declare module "babylonjs/LensFlares/index" {
  56310. export * from "babylonjs/LensFlares/lensFlare";
  56311. export * from "babylonjs/LensFlares/lensFlareSystem";
  56312. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56313. }
  56314. declare module "babylonjs/Shaders/depth.fragment" {
  56315. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56316. /** @hidden */
  56317. export var depthPixelShader: {
  56318. name: string;
  56319. shader: string;
  56320. };
  56321. }
  56322. declare module "babylonjs/Shaders/depth.vertex" {
  56323. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56326. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56328. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56330. /** @hidden */
  56331. export var depthVertexShader: {
  56332. name: string;
  56333. shader: string;
  56334. };
  56335. }
  56336. declare module "babylonjs/Rendering/depthRenderer" {
  56337. import { Nullable } from "babylonjs/types";
  56338. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56339. import { Scene } from "babylonjs/scene";
  56340. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56341. import { Camera } from "babylonjs/Cameras/camera";
  56342. import "babylonjs/Shaders/depth.fragment";
  56343. import "babylonjs/Shaders/depth.vertex";
  56344. /**
  56345. * This represents a depth renderer in Babylon.
  56346. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56347. */
  56348. export class DepthRenderer {
  56349. private _scene;
  56350. private _depthMap;
  56351. private _effect;
  56352. private readonly _storeNonLinearDepth;
  56353. private readonly _clearColor;
  56354. /** Get if the depth renderer is using packed depth or not */
  56355. readonly isPacked: boolean;
  56356. private _cachedDefines;
  56357. private _camera;
  56358. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56359. enabled: boolean;
  56360. /**
  56361. * Specifiess that the depth renderer will only be used within
  56362. * the camera it is created for.
  56363. * This can help forcing its rendering during the camera processing.
  56364. */
  56365. useOnlyInActiveCamera: boolean;
  56366. /** @hidden */
  56367. static _SceneComponentInitialization: (scene: Scene) => void;
  56368. /**
  56369. * Instantiates a depth renderer
  56370. * @param scene The scene the renderer belongs to
  56371. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56372. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56373. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56374. */
  56375. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56376. /**
  56377. * Creates the depth rendering effect and checks if the effect is ready.
  56378. * @param subMesh The submesh to be used to render the depth map of
  56379. * @param useInstances If multiple world instances should be used
  56380. * @returns if the depth renderer is ready to render the depth map
  56381. */
  56382. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56383. /**
  56384. * Gets the texture which the depth map will be written to.
  56385. * @returns The depth map texture
  56386. */
  56387. getDepthMap(): RenderTargetTexture;
  56388. /**
  56389. * Disposes of the depth renderer.
  56390. */
  56391. dispose(): void;
  56392. }
  56393. }
  56394. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56395. /** @hidden */
  56396. export var minmaxReduxPixelShader: {
  56397. name: string;
  56398. shader: string;
  56399. };
  56400. }
  56401. declare module "babylonjs/Misc/minMaxReducer" {
  56402. import { Nullable } from "babylonjs/types";
  56403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56404. import { Camera } from "babylonjs/Cameras/camera";
  56405. import { Observer } from "babylonjs/Misc/observable";
  56406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56407. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56408. import { Observable } from "babylonjs/Misc/observable";
  56409. import "babylonjs/Shaders/minmaxRedux.fragment";
  56410. /**
  56411. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56412. * and maximum values from all values of the texture.
  56413. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56414. * The source values are read from the red channel of the texture.
  56415. */
  56416. export class MinMaxReducer {
  56417. /**
  56418. * Observable triggered when the computation has been performed
  56419. */
  56420. onAfterReductionPerformed: Observable<{
  56421. min: number;
  56422. max: number;
  56423. }>;
  56424. protected _camera: Camera;
  56425. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56426. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56427. protected _postProcessManager: PostProcessManager;
  56428. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56429. protected _forceFullscreenViewport: boolean;
  56430. /**
  56431. * Creates a min/max reducer
  56432. * @param camera The camera to use for the post processes
  56433. */
  56434. constructor(camera: Camera);
  56435. /**
  56436. * Gets the texture used to read the values from.
  56437. */
  56438. get sourceTexture(): Nullable<RenderTargetTexture>;
  56439. /**
  56440. * Sets the source texture to read the values from.
  56441. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56442. * because in such textures '1' value must not be taken into account to compute the maximum
  56443. * as this value is used to clear the texture.
  56444. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56445. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56446. * @param depthRedux Indicates if the texture is a depth texture or not
  56447. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56448. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56449. */
  56450. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56451. /**
  56452. * Defines the refresh rate of the computation.
  56453. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56454. */
  56455. get refreshRate(): number;
  56456. set refreshRate(value: number);
  56457. protected _activated: boolean;
  56458. /**
  56459. * Gets the activation status of the reducer
  56460. */
  56461. get activated(): boolean;
  56462. /**
  56463. * Activates the reduction computation.
  56464. * When activated, the observers registered in onAfterReductionPerformed are
  56465. * called after the compuation is performed
  56466. */
  56467. activate(): void;
  56468. /**
  56469. * Deactivates the reduction computation.
  56470. */
  56471. deactivate(): void;
  56472. /**
  56473. * Disposes the min/max reducer
  56474. * @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.
  56475. */
  56476. dispose(disposeAll?: boolean): void;
  56477. }
  56478. }
  56479. declare module "babylonjs/Misc/depthReducer" {
  56480. import { Nullable } from "babylonjs/types";
  56481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56482. import { Camera } from "babylonjs/Cameras/camera";
  56483. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56484. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56485. /**
  56486. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56487. */
  56488. export class DepthReducer extends MinMaxReducer {
  56489. private _depthRenderer;
  56490. private _depthRendererId;
  56491. /**
  56492. * Gets the depth renderer used for the computation.
  56493. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56494. */
  56495. get depthRenderer(): Nullable<DepthRenderer>;
  56496. /**
  56497. * Creates a depth reducer
  56498. * @param camera The camera used to render the depth texture
  56499. */
  56500. constructor(camera: Camera);
  56501. /**
  56502. * Sets the depth renderer to use to generate the depth map
  56503. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56504. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56505. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56506. */
  56507. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56508. /** @hidden */
  56509. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56510. /**
  56511. * Activates the reduction computation.
  56512. * When activated, the observers registered in onAfterReductionPerformed are
  56513. * called after the compuation is performed
  56514. */
  56515. activate(): void;
  56516. /**
  56517. * Deactivates the reduction computation.
  56518. */
  56519. deactivate(): void;
  56520. /**
  56521. * Disposes the depth reducer
  56522. * @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.
  56523. */
  56524. dispose(disposeAll?: boolean): void;
  56525. }
  56526. }
  56527. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56528. import { Nullable } from "babylonjs/types";
  56529. import { Scene } from "babylonjs/scene";
  56530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56531. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56532. import { Effect } from "babylonjs/Materials/effect";
  56533. import "babylonjs/Shaders/shadowMap.fragment";
  56534. import "babylonjs/Shaders/shadowMap.vertex";
  56535. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56536. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56537. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56538. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56539. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56540. /**
  56541. * A CSM implementation allowing casting shadows on large scenes.
  56542. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56543. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56544. */
  56545. export class CascadedShadowGenerator extends ShadowGenerator {
  56546. private static readonly frustumCornersNDCSpace;
  56547. /**
  56548. * Name of the CSM class
  56549. */
  56550. static CLASSNAME: string;
  56551. /**
  56552. * Defines the default number of cascades used by the CSM.
  56553. */
  56554. static readonly DEFAULT_CASCADES_COUNT: number;
  56555. /**
  56556. * Defines the minimum number of cascades used by the CSM.
  56557. */
  56558. static readonly MIN_CASCADES_COUNT: number;
  56559. /**
  56560. * Defines the maximum number of cascades used by the CSM.
  56561. */
  56562. static readonly MAX_CASCADES_COUNT: number;
  56563. protected _validateFilter(filter: number): number;
  56564. /**
  56565. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56566. */
  56567. penumbraDarkness: number;
  56568. private _numCascades;
  56569. /**
  56570. * Gets or set the number of cascades used by the CSM.
  56571. */
  56572. get numCascades(): number;
  56573. set numCascades(value: number);
  56574. /**
  56575. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56576. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56577. */
  56578. stabilizeCascades: boolean;
  56579. private _freezeShadowCastersBoundingInfo;
  56580. private _freezeShadowCastersBoundingInfoObservable;
  56581. /**
  56582. * Enables or disables the shadow casters bounding info computation.
  56583. * If your shadow casters don't move, you can disable this feature.
  56584. * If it is enabled, the bounding box computation is done every frame.
  56585. */
  56586. get freezeShadowCastersBoundingInfo(): boolean;
  56587. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56588. private _scbiMin;
  56589. private _scbiMax;
  56590. protected _computeShadowCastersBoundingInfo(): void;
  56591. protected _shadowCastersBoundingInfo: BoundingInfo;
  56592. /**
  56593. * Gets or sets the shadow casters bounding info.
  56594. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56595. * so that the system won't overwrite the bounds you provide
  56596. */
  56597. get shadowCastersBoundingInfo(): BoundingInfo;
  56598. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56599. protected _breaksAreDirty: boolean;
  56600. protected _minDistance: number;
  56601. protected _maxDistance: number;
  56602. /**
  56603. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56604. *
  56605. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56606. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56607. * @param min minimal distance for the breaks (default to 0.)
  56608. * @param max maximal distance for the breaks (default to 1.)
  56609. */
  56610. setMinMaxDistance(min: number, max: number): void;
  56611. /** Gets the minimal distance used in the cascade break computation */
  56612. get minDistance(): number;
  56613. /** Gets the maximal distance used in the cascade break computation */
  56614. get maxDistance(): number;
  56615. /**
  56616. * Gets the class name of that object
  56617. * @returns "CascadedShadowGenerator"
  56618. */
  56619. getClassName(): string;
  56620. private _cascadeMinExtents;
  56621. private _cascadeMaxExtents;
  56622. /**
  56623. * Gets a cascade minimum extents
  56624. * @param cascadeIndex index of the cascade
  56625. * @returns the minimum cascade extents
  56626. */
  56627. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56628. /**
  56629. * Gets a cascade maximum extents
  56630. * @param cascadeIndex index of the cascade
  56631. * @returns the maximum cascade extents
  56632. */
  56633. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56634. private _cascades;
  56635. private _currentLayer;
  56636. private _viewSpaceFrustumsZ;
  56637. private _viewMatrices;
  56638. private _projectionMatrices;
  56639. private _transformMatrices;
  56640. private _transformMatricesAsArray;
  56641. private _frustumLengths;
  56642. private _lightSizeUVCorrection;
  56643. private _depthCorrection;
  56644. private _frustumCornersWorldSpace;
  56645. private _frustumCenter;
  56646. private _shadowCameraPos;
  56647. private _shadowMaxZ;
  56648. /**
  56649. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56650. * It defaults to camera.maxZ
  56651. */
  56652. get shadowMaxZ(): number;
  56653. /**
  56654. * Sets the shadow max z distance.
  56655. */
  56656. set shadowMaxZ(value: number);
  56657. protected _debug: boolean;
  56658. /**
  56659. * Gets or sets the debug flag.
  56660. * When enabled, the cascades are materialized by different colors on the screen.
  56661. */
  56662. get debug(): boolean;
  56663. set debug(dbg: boolean);
  56664. private _depthClamp;
  56665. /**
  56666. * Gets or sets the depth clamping value.
  56667. *
  56668. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56669. * to account for the shadow casters far away.
  56670. *
  56671. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56672. */
  56673. get depthClamp(): boolean;
  56674. set depthClamp(value: boolean);
  56675. private _cascadeBlendPercentage;
  56676. /**
  56677. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56678. * It defaults to 0.1 (10% blending).
  56679. */
  56680. get cascadeBlendPercentage(): number;
  56681. set cascadeBlendPercentage(value: number);
  56682. private _lambda;
  56683. /**
  56684. * Gets or set the lambda parameter.
  56685. * This parameter is used to split the camera frustum and create the cascades.
  56686. * 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.
  56687. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56688. */
  56689. get lambda(): number;
  56690. set lambda(value: number);
  56691. /**
  56692. * Gets the view matrix corresponding to a given cascade
  56693. * @param cascadeNum cascade to retrieve the view matrix from
  56694. * @returns the cascade view matrix
  56695. */
  56696. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56697. /**
  56698. * Gets the projection matrix corresponding to a given cascade
  56699. * @param cascadeNum cascade to retrieve the projection matrix from
  56700. * @returns the cascade projection matrix
  56701. */
  56702. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56703. /**
  56704. * Gets the transformation matrix corresponding to a given cascade
  56705. * @param cascadeNum cascade to retrieve the transformation matrix from
  56706. * @returns the cascade transformation matrix
  56707. */
  56708. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56709. private _depthRenderer;
  56710. /**
  56711. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56712. *
  56713. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56714. *
  56715. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56716. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56717. * @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
  56718. */
  56719. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56720. private _depthReducer;
  56721. private _autoCalcDepthBounds;
  56722. /**
  56723. * Gets or sets the autoCalcDepthBounds property.
  56724. *
  56725. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56726. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56727. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56728. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56729. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56730. */
  56731. get autoCalcDepthBounds(): boolean;
  56732. set autoCalcDepthBounds(value: boolean);
  56733. /**
  56734. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56735. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56736. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56737. * for setting the refresh rate on the renderer yourself!
  56738. */
  56739. get autoCalcDepthBoundsRefreshRate(): number;
  56740. set autoCalcDepthBoundsRefreshRate(value: number);
  56741. /**
  56742. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56743. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56744. * you change the camera near/far planes!
  56745. */
  56746. splitFrustum(): void;
  56747. private _splitFrustum;
  56748. private _computeMatrices;
  56749. private _computeFrustumInWorldSpace;
  56750. private _computeCascadeFrustum;
  56751. /** @hidden */
  56752. static _SceneComponentInitialization: (scene: Scene) => void;
  56753. /**
  56754. * Creates a Cascaded Shadow Generator object.
  56755. * A ShadowGenerator is the required tool to use the shadows.
  56756. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56757. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56758. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56759. * @param light The directional light object generating the shadows.
  56760. * @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.
  56761. */
  56762. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56763. protected _initializeGenerator(): void;
  56764. protected _createTargetRenderTexture(): void;
  56765. protected _initializeShadowMap(): void;
  56766. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56767. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56768. /**
  56769. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56770. * @param defines Defines of the material we want to update
  56771. * @param lightIndex Index of the light in the enabled light list of the material
  56772. */
  56773. prepareDefines(defines: any, lightIndex: number): void;
  56774. /**
  56775. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56776. * defined in the generator but impacting the effect).
  56777. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56778. * @param effect The effect we are binfing the information for
  56779. */
  56780. bindShadowLight(lightIndex: string, effect: Effect): void;
  56781. /**
  56782. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56783. * (eq to view projection * shadow projection matrices)
  56784. * @returns The transform matrix used to create the shadow map
  56785. */
  56786. getTransformMatrix(): Matrix;
  56787. /**
  56788. * Disposes the ShadowGenerator.
  56789. * Returns nothing.
  56790. */
  56791. dispose(): void;
  56792. /**
  56793. * Serializes the shadow generator setup to a json object.
  56794. * @returns The serialized JSON object
  56795. */
  56796. serialize(): any;
  56797. /**
  56798. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56799. * @param parsedShadowGenerator The JSON object to parse
  56800. * @param scene The scene to create the shadow map for
  56801. * @returns The parsed shadow generator
  56802. */
  56803. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56804. }
  56805. }
  56806. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56807. import { Scene } from "babylonjs/scene";
  56808. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56809. import { AbstractScene } from "babylonjs/abstractScene";
  56810. /**
  56811. * Defines the shadow generator component responsible to manage any shadow generators
  56812. * in a given scene.
  56813. */
  56814. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56815. /**
  56816. * The component name helpfull to identify the component in the list of scene components.
  56817. */
  56818. readonly name: string;
  56819. /**
  56820. * The scene the component belongs to.
  56821. */
  56822. scene: Scene;
  56823. /**
  56824. * Creates a new instance of the component for the given scene
  56825. * @param scene Defines the scene to register the component in
  56826. */
  56827. constructor(scene: Scene);
  56828. /**
  56829. * Registers the component in a given scene
  56830. */
  56831. register(): void;
  56832. /**
  56833. * Rebuilds the elements related to this component in case of
  56834. * context lost for instance.
  56835. */
  56836. rebuild(): void;
  56837. /**
  56838. * Serializes the component data to the specified json object
  56839. * @param serializationObject The object to serialize to
  56840. */
  56841. serialize(serializationObject: any): void;
  56842. /**
  56843. * Adds all the elements from the container to the scene
  56844. * @param container the container holding the elements
  56845. */
  56846. addFromContainer(container: AbstractScene): void;
  56847. /**
  56848. * Removes all the elements in the container from the scene
  56849. * @param container contains the elements to remove
  56850. * @param dispose if the removed element should be disposed (default: false)
  56851. */
  56852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56853. /**
  56854. * Rebuilds the elements related to this component in case of
  56855. * context lost for instance.
  56856. */
  56857. dispose(): void;
  56858. private _gatherRenderTargets;
  56859. }
  56860. }
  56861. declare module "babylonjs/Lights/Shadows/index" {
  56862. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56863. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56864. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56865. }
  56866. declare module "babylonjs/Lights/pointLight" {
  56867. import { Scene } from "babylonjs/scene";
  56868. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56870. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56871. import { Effect } from "babylonjs/Materials/effect";
  56872. /**
  56873. * A point light is a light defined by an unique point in world space.
  56874. * The light is emitted in every direction from this point.
  56875. * A good example of a point light is a standard light bulb.
  56876. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56877. */
  56878. export class PointLight extends ShadowLight {
  56879. private _shadowAngle;
  56880. /**
  56881. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56882. * This specifies what angle the shadow will use to be created.
  56883. *
  56884. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56885. */
  56886. get shadowAngle(): number;
  56887. /**
  56888. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56889. * This specifies what angle the shadow will use to be created.
  56890. *
  56891. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56892. */
  56893. set shadowAngle(value: number);
  56894. /**
  56895. * Gets the direction if it has been set.
  56896. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56897. */
  56898. get direction(): Vector3;
  56899. /**
  56900. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56901. */
  56902. set direction(value: Vector3);
  56903. /**
  56904. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56905. * A PointLight emits the light in every direction.
  56906. * It can cast shadows.
  56907. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56908. * ```javascript
  56909. * var pointLight = new PointLight("pl", camera.position, scene);
  56910. * ```
  56911. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56912. * @param name The light friendly name
  56913. * @param position The position of the point light in the scene
  56914. * @param scene The scene the lights belongs to
  56915. */
  56916. constructor(name: string, position: Vector3, scene: Scene);
  56917. /**
  56918. * Returns the string "PointLight"
  56919. * @returns the class name
  56920. */
  56921. getClassName(): string;
  56922. /**
  56923. * Returns the integer 0.
  56924. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56925. */
  56926. getTypeID(): number;
  56927. /**
  56928. * Specifies wether or not the shadowmap should be a cube texture.
  56929. * @returns true if the shadowmap needs to be a cube texture.
  56930. */
  56931. needCube(): boolean;
  56932. /**
  56933. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56934. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56935. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56936. */
  56937. getShadowDirection(faceIndex?: number): Vector3;
  56938. /**
  56939. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56940. * - fov = PI / 2
  56941. * - aspect ratio : 1.0
  56942. * - z-near and far equal to the active camera minZ and maxZ.
  56943. * Returns the PointLight.
  56944. */
  56945. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56946. protected _buildUniformLayout(): void;
  56947. /**
  56948. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56949. * @param effect The effect to update
  56950. * @param lightIndex The index of the light in the effect to update
  56951. * @returns The point light
  56952. */
  56953. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56954. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56955. /**
  56956. * Prepares the list of defines specific to the light type.
  56957. * @param defines the list of defines
  56958. * @param lightIndex defines the index of the light for the effect
  56959. */
  56960. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56961. }
  56962. }
  56963. declare module "babylonjs/Lights/index" {
  56964. export * from "babylonjs/Lights/light";
  56965. export * from "babylonjs/Lights/shadowLight";
  56966. export * from "babylonjs/Lights/Shadows/index";
  56967. export * from "babylonjs/Lights/directionalLight";
  56968. export * from "babylonjs/Lights/hemisphericLight";
  56969. export * from "babylonjs/Lights/pointLight";
  56970. export * from "babylonjs/Lights/spotLight";
  56971. }
  56972. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56973. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56974. /**
  56975. * Header information of HDR texture files.
  56976. */
  56977. export interface HDRInfo {
  56978. /**
  56979. * The height of the texture in pixels.
  56980. */
  56981. height: number;
  56982. /**
  56983. * The width of the texture in pixels.
  56984. */
  56985. width: number;
  56986. /**
  56987. * The index of the beginning of the data in the binary file.
  56988. */
  56989. dataPosition: number;
  56990. }
  56991. /**
  56992. * This groups tools to convert HDR texture to native colors array.
  56993. */
  56994. export class HDRTools {
  56995. private static Ldexp;
  56996. private static Rgbe2float;
  56997. private static readStringLine;
  56998. /**
  56999. * Reads header information from an RGBE texture stored in a native array.
  57000. * More information on this format are available here:
  57001. * https://en.wikipedia.org/wiki/RGBE_image_format
  57002. *
  57003. * @param uint8array The binary file stored in native array.
  57004. * @return The header information.
  57005. */
  57006. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57007. /**
  57008. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57009. * This RGBE texture needs to store the information as a panorama.
  57010. *
  57011. * More information on this format are available here:
  57012. * https://en.wikipedia.org/wiki/RGBE_image_format
  57013. *
  57014. * @param buffer The binary file stored in an array buffer.
  57015. * @param size The expected size of the extracted cubemap.
  57016. * @return The Cube Map information.
  57017. */
  57018. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57019. /**
  57020. * Returns the pixels data extracted from an RGBE texture.
  57021. * This pixels will be stored left to right up to down in the R G B order in one array.
  57022. *
  57023. * More information on this format are available here:
  57024. * https://en.wikipedia.org/wiki/RGBE_image_format
  57025. *
  57026. * @param uint8array The binary file stored in an array buffer.
  57027. * @param hdrInfo The header information of the file.
  57028. * @return The pixels data in RGB right to left up to down order.
  57029. */
  57030. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57031. private static RGBE_ReadPixels_RLE;
  57032. }
  57033. }
  57034. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57035. import { Nullable } from "babylonjs/types";
  57036. import { Scene } from "babylonjs/scene";
  57037. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57038. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57039. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57040. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57041. /**
  57042. * This represents a texture coming from an HDR input.
  57043. *
  57044. * The only supported format is currently panorama picture stored in RGBE format.
  57045. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57046. */
  57047. export class HDRCubeTexture extends BaseTexture {
  57048. private static _facesMapping;
  57049. private _generateHarmonics;
  57050. private _noMipmap;
  57051. private _textureMatrix;
  57052. private _size;
  57053. private _onLoad;
  57054. private _onError;
  57055. /**
  57056. * The texture URL.
  57057. */
  57058. url: string;
  57059. /**
  57060. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57061. */
  57062. coordinatesMode: number;
  57063. protected _isBlocking: boolean;
  57064. /**
  57065. * Sets wether or not the texture is blocking during loading.
  57066. */
  57067. set isBlocking(value: boolean);
  57068. /**
  57069. * Gets wether or not the texture is blocking during loading.
  57070. */
  57071. get isBlocking(): boolean;
  57072. protected _rotationY: number;
  57073. /**
  57074. * Sets texture matrix rotation angle around Y axis in radians.
  57075. */
  57076. set rotationY(value: number);
  57077. /**
  57078. * Gets texture matrix rotation angle around Y axis radians.
  57079. */
  57080. get rotationY(): number;
  57081. /**
  57082. * Gets or sets the center of the bounding box associated with the cube texture
  57083. * It must define where the camera used to render the texture was set
  57084. */
  57085. boundingBoxPosition: Vector3;
  57086. private _boundingBoxSize;
  57087. /**
  57088. * Gets or sets the size of the bounding box associated with the cube texture
  57089. * When defined, the cubemap will switch to local mode
  57090. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57091. * @example https://www.babylonjs-playground.com/#RNASML
  57092. */
  57093. set boundingBoxSize(value: Vector3);
  57094. get boundingBoxSize(): Vector3;
  57095. /**
  57096. * Instantiates an HDRTexture from the following parameters.
  57097. *
  57098. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57099. * @param scene The scene the texture will be used in
  57100. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57101. * @param noMipmap Forces to not generate the mipmap if true
  57102. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57103. * @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)
  57104. * @param reserved Reserved flag for internal use.
  57105. */
  57106. 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>);
  57107. /**
  57108. * Get the current class name of the texture useful for serialization or dynamic coding.
  57109. * @returns "HDRCubeTexture"
  57110. */
  57111. getClassName(): string;
  57112. /**
  57113. * Occurs when the file is raw .hdr file.
  57114. */
  57115. private loadTexture;
  57116. clone(): HDRCubeTexture;
  57117. delayLoad(): void;
  57118. /**
  57119. * Get the texture reflection matrix used to rotate/transform the reflection.
  57120. * @returns the reflection matrix
  57121. */
  57122. getReflectionTextureMatrix(): Matrix;
  57123. /**
  57124. * Set the texture reflection matrix used to rotate/transform the reflection.
  57125. * @param value Define the reflection matrix to set
  57126. */
  57127. setReflectionTextureMatrix(value: Matrix): void;
  57128. /**
  57129. * Parses a JSON representation of an HDR Texture in order to create the texture
  57130. * @param parsedTexture Define the JSON representation
  57131. * @param scene Define the scene the texture should be created in
  57132. * @param rootUrl Define the root url in case we need to load relative dependencies
  57133. * @returns the newly created texture after parsing
  57134. */
  57135. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57136. serialize(): any;
  57137. }
  57138. }
  57139. declare module "babylonjs/Physics/physicsEngine" {
  57140. import { Nullable } from "babylonjs/types";
  57141. import { Vector3 } from "babylonjs/Maths/math.vector";
  57142. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57143. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57144. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57145. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57146. /**
  57147. * Class used to control physics engine
  57148. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57149. */
  57150. export class PhysicsEngine implements IPhysicsEngine {
  57151. private _physicsPlugin;
  57152. /**
  57153. * Global value used to control the smallest number supported by the simulation
  57154. */
  57155. static Epsilon: number;
  57156. private _impostors;
  57157. private _joints;
  57158. private _subTimeStep;
  57159. /**
  57160. * Gets the gravity vector used by the simulation
  57161. */
  57162. gravity: Vector3;
  57163. /**
  57164. * Factory used to create the default physics plugin.
  57165. * @returns The default physics plugin
  57166. */
  57167. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57168. /**
  57169. * Creates a new Physics Engine
  57170. * @param gravity defines the gravity vector used by the simulation
  57171. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57172. */
  57173. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57174. /**
  57175. * Sets the gravity vector used by the simulation
  57176. * @param gravity defines the gravity vector to use
  57177. */
  57178. setGravity(gravity: Vector3): void;
  57179. /**
  57180. * Set the time step of the physics engine.
  57181. * Default is 1/60.
  57182. * To slow it down, enter 1/600 for example.
  57183. * To speed it up, 1/30
  57184. * @param newTimeStep defines the new timestep to apply to this world.
  57185. */
  57186. setTimeStep(newTimeStep?: number): void;
  57187. /**
  57188. * Get the time step of the physics engine.
  57189. * @returns the current time step
  57190. */
  57191. getTimeStep(): number;
  57192. /**
  57193. * Set the sub time step of the physics engine.
  57194. * Default is 0 meaning there is no sub steps
  57195. * To increase physics resolution precision, set a small value (like 1 ms)
  57196. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57197. */
  57198. setSubTimeStep(subTimeStep?: number): void;
  57199. /**
  57200. * Get the sub time step of the physics engine.
  57201. * @returns the current sub time step
  57202. */
  57203. getSubTimeStep(): number;
  57204. /**
  57205. * Release all resources
  57206. */
  57207. dispose(): void;
  57208. /**
  57209. * Gets the name of the current physics plugin
  57210. * @returns the name of the plugin
  57211. */
  57212. getPhysicsPluginName(): string;
  57213. /**
  57214. * Adding a new impostor for the impostor tracking.
  57215. * This will be done by the impostor itself.
  57216. * @param impostor the impostor to add
  57217. */
  57218. addImpostor(impostor: PhysicsImpostor): void;
  57219. /**
  57220. * Remove an impostor from the engine.
  57221. * This impostor and its mesh will not longer be updated by the physics engine.
  57222. * @param impostor the impostor to remove
  57223. */
  57224. removeImpostor(impostor: PhysicsImpostor): void;
  57225. /**
  57226. * Add a joint to the physics engine
  57227. * @param mainImpostor defines the main impostor to which the joint is added.
  57228. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57229. * @param joint defines the joint that will connect both impostors.
  57230. */
  57231. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57232. /**
  57233. * Removes a joint from the simulation
  57234. * @param mainImpostor defines the impostor used with the joint
  57235. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57236. * @param joint defines the joint to remove
  57237. */
  57238. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57239. /**
  57240. * Called by the scene. No need to call it.
  57241. * @param delta defines the timespam between frames
  57242. */
  57243. _step(delta: number): void;
  57244. /**
  57245. * Gets the current plugin used to run the simulation
  57246. * @returns current plugin
  57247. */
  57248. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57249. /**
  57250. * Gets the list of physic impostors
  57251. * @returns an array of PhysicsImpostor
  57252. */
  57253. getImpostors(): Array<PhysicsImpostor>;
  57254. /**
  57255. * Gets the impostor for a physics enabled object
  57256. * @param object defines the object impersonated by the impostor
  57257. * @returns the PhysicsImpostor or null if not found
  57258. */
  57259. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57260. /**
  57261. * Gets the impostor for a physics body object
  57262. * @param body defines physics body used by the impostor
  57263. * @returns the PhysicsImpostor or null if not found
  57264. */
  57265. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57266. /**
  57267. * Does a raycast in the physics world
  57268. * @param from when should the ray start?
  57269. * @param to when should the ray end?
  57270. * @returns PhysicsRaycastResult
  57271. */
  57272. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57273. }
  57274. }
  57275. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57276. import { Nullable } from "babylonjs/types";
  57277. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57279. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57280. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57281. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57282. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57283. /** @hidden */
  57284. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57285. private _useDeltaForWorldStep;
  57286. world: any;
  57287. name: string;
  57288. private _physicsMaterials;
  57289. private _fixedTimeStep;
  57290. private _cannonRaycastResult;
  57291. private _raycastResult;
  57292. private _physicsBodysToRemoveAfterStep;
  57293. BJSCANNON: any;
  57294. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57295. setGravity(gravity: Vector3): void;
  57296. setTimeStep(timeStep: number): void;
  57297. getTimeStep(): number;
  57298. executeStep(delta: number): void;
  57299. private _removeMarkedPhysicsBodiesFromWorld;
  57300. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57301. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57302. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57303. private _processChildMeshes;
  57304. removePhysicsBody(impostor: PhysicsImpostor): void;
  57305. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57306. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57307. private _addMaterial;
  57308. private _checkWithEpsilon;
  57309. private _createShape;
  57310. private _createHeightmap;
  57311. private _minus90X;
  57312. private _plus90X;
  57313. private _tmpPosition;
  57314. private _tmpDeltaPosition;
  57315. private _tmpUnityRotation;
  57316. private _updatePhysicsBodyTransformation;
  57317. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57318. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57319. isSupported(): boolean;
  57320. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57321. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57322. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57323. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57324. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57325. getBodyMass(impostor: PhysicsImpostor): number;
  57326. getBodyFriction(impostor: PhysicsImpostor): number;
  57327. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57328. getBodyRestitution(impostor: PhysicsImpostor): number;
  57329. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57330. sleepBody(impostor: PhysicsImpostor): void;
  57331. wakeUpBody(impostor: PhysicsImpostor): void;
  57332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57333. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57334. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57335. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57336. getRadius(impostor: PhysicsImpostor): number;
  57337. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57338. dispose(): void;
  57339. private _extendNamespace;
  57340. /**
  57341. * Does a raycast in the physics world
  57342. * @param from when should the ray start?
  57343. * @param to when should the ray end?
  57344. * @returns PhysicsRaycastResult
  57345. */
  57346. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57347. }
  57348. }
  57349. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57350. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57351. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57352. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57354. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57355. import { Nullable } from "babylonjs/types";
  57356. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57357. /** @hidden */
  57358. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57359. world: any;
  57360. name: string;
  57361. BJSOIMO: any;
  57362. private _raycastResult;
  57363. constructor(iterations?: number, oimoInjection?: any);
  57364. setGravity(gravity: Vector3): void;
  57365. setTimeStep(timeStep: number): void;
  57366. getTimeStep(): number;
  57367. private _tmpImpostorsArray;
  57368. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57369. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57370. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57371. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57372. private _tmpPositionVector;
  57373. removePhysicsBody(impostor: PhysicsImpostor): void;
  57374. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57375. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57376. isSupported(): boolean;
  57377. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57379. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57380. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57381. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57382. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57383. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57384. getBodyMass(impostor: PhysicsImpostor): number;
  57385. getBodyFriction(impostor: PhysicsImpostor): number;
  57386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57387. getBodyRestitution(impostor: PhysicsImpostor): number;
  57388. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57389. sleepBody(impostor: PhysicsImpostor): void;
  57390. wakeUpBody(impostor: PhysicsImpostor): void;
  57391. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57392. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57393. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57394. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57395. getRadius(impostor: PhysicsImpostor): number;
  57396. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57397. dispose(): void;
  57398. /**
  57399. * Does a raycast in the physics world
  57400. * @param from when should the ray start?
  57401. * @param to when should the ray end?
  57402. * @returns PhysicsRaycastResult
  57403. */
  57404. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57405. }
  57406. }
  57407. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57408. import { Nullable } from "babylonjs/types";
  57409. import { Scene } from "babylonjs/scene";
  57410. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57411. import { Color4 } from "babylonjs/Maths/math.color";
  57412. import { Mesh } from "babylonjs/Meshes/mesh";
  57413. /**
  57414. * Class containing static functions to help procedurally build meshes
  57415. */
  57416. export class RibbonBuilder {
  57417. /**
  57418. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57419. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57420. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57421. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57422. * * 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
  57423. * * 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
  57424. * * 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
  57425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57428. * * 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
  57429. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57430. * * 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
  57431. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57433. * @param name defines the name of the mesh
  57434. * @param options defines the options used to create the mesh
  57435. * @param scene defines the hosting scene
  57436. * @returns the ribbon mesh
  57437. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57439. */
  57440. static CreateRibbon(name: string, options: {
  57441. pathArray: Vector3[][];
  57442. closeArray?: boolean;
  57443. closePath?: boolean;
  57444. offset?: number;
  57445. updatable?: boolean;
  57446. sideOrientation?: number;
  57447. frontUVs?: Vector4;
  57448. backUVs?: Vector4;
  57449. instance?: Mesh;
  57450. invertUV?: boolean;
  57451. uvs?: Vector2[];
  57452. colors?: Color4[];
  57453. }, scene?: Nullable<Scene>): Mesh;
  57454. }
  57455. }
  57456. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57457. import { Nullable } from "babylonjs/types";
  57458. import { Scene } from "babylonjs/scene";
  57459. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57460. import { Mesh } from "babylonjs/Meshes/mesh";
  57461. /**
  57462. * Class containing static functions to help procedurally build meshes
  57463. */
  57464. export class ShapeBuilder {
  57465. /**
  57466. * 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.
  57467. * * 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.
  57468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57469. * * 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.
  57470. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57471. * * 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
  57472. * * 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
  57473. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57478. * @param name defines the name of the mesh
  57479. * @param options defines the options used to create the mesh
  57480. * @param scene defines the hosting scene
  57481. * @returns the extruded shape mesh
  57482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57484. */
  57485. static ExtrudeShape(name: string, options: {
  57486. shape: Vector3[];
  57487. path: Vector3[];
  57488. scale?: number;
  57489. rotation?: number;
  57490. cap?: number;
  57491. updatable?: boolean;
  57492. sideOrientation?: number;
  57493. frontUVs?: Vector4;
  57494. backUVs?: Vector4;
  57495. instance?: Mesh;
  57496. invertUV?: boolean;
  57497. }, scene?: Nullable<Scene>): Mesh;
  57498. /**
  57499. * Creates an custom extruded shape mesh.
  57500. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57501. * * 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.
  57502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57503. * * 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
  57504. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57505. * * 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
  57506. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57507. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57508. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57509. * * 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
  57510. * * 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
  57511. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57516. * @param name defines the name of the mesh
  57517. * @param options defines the options used to create the mesh
  57518. * @param scene defines the hosting scene
  57519. * @returns the custom extruded shape mesh
  57520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57523. */
  57524. static ExtrudeShapeCustom(name: string, options: {
  57525. shape: Vector3[];
  57526. path: Vector3[];
  57527. scaleFunction?: any;
  57528. rotationFunction?: any;
  57529. ribbonCloseArray?: boolean;
  57530. ribbonClosePath?: boolean;
  57531. cap?: number;
  57532. updatable?: boolean;
  57533. sideOrientation?: number;
  57534. frontUVs?: Vector4;
  57535. backUVs?: Vector4;
  57536. instance?: Mesh;
  57537. invertUV?: boolean;
  57538. }, scene?: Nullable<Scene>): Mesh;
  57539. private static _ExtrudeShapeGeneric;
  57540. }
  57541. }
  57542. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57543. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57544. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57545. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57546. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57547. import { Nullable } from "babylonjs/types";
  57548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57549. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57550. /**
  57551. * AmmoJS Physics plugin
  57552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57553. * @see https://github.com/kripken/ammo.js/
  57554. */
  57555. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57556. private _useDeltaForWorldStep;
  57557. /**
  57558. * Reference to the Ammo library
  57559. */
  57560. bjsAMMO: any;
  57561. /**
  57562. * Created ammoJS world which physics bodies are added to
  57563. */
  57564. world: any;
  57565. /**
  57566. * Name of the plugin
  57567. */
  57568. name: string;
  57569. private _timeStep;
  57570. private _fixedTimeStep;
  57571. private _maxSteps;
  57572. private _tmpQuaternion;
  57573. private _tmpAmmoTransform;
  57574. private _tmpAmmoQuaternion;
  57575. private _tmpAmmoConcreteContactResultCallback;
  57576. private _collisionConfiguration;
  57577. private _dispatcher;
  57578. private _overlappingPairCache;
  57579. private _solver;
  57580. private _softBodySolver;
  57581. private _tmpAmmoVectorA;
  57582. private _tmpAmmoVectorB;
  57583. private _tmpAmmoVectorC;
  57584. private _tmpAmmoVectorD;
  57585. private _tmpContactCallbackResult;
  57586. private _tmpAmmoVectorRCA;
  57587. private _tmpAmmoVectorRCB;
  57588. private _raycastResult;
  57589. private static readonly DISABLE_COLLISION_FLAG;
  57590. private static readonly KINEMATIC_FLAG;
  57591. private static readonly DISABLE_DEACTIVATION_FLAG;
  57592. /**
  57593. * Initializes the ammoJS plugin
  57594. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57595. * @param ammoInjection can be used to inject your own ammo reference
  57596. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57597. */
  57598. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57599. /**
  57600. * Sets the gravity of the physics world (m/(s^2))
  57601. * @param gravity Gravity to set
  57602. */
  57603. setGravity(gravity: Vector3): void;
  57604. /**
  57605. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57606. * @param timeStep timestep to use in seconds
  57607. */
  57608. setTimeStep(timeStep: number): void;
  57609. /**
  57610. * 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)
  57611. * @param fixedTimeStep fixedTimeStep to use in seconds
  57612. */
  57613. setFixedTimeStep(fixedTimeStep: number): void;
  57614. /**
  57615. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57616. * @param maxSteps the maximum number of steps by the physics engine per frame
  57617. */
  57618. setMaxSteps(maxSteps: number): void;
  57619. /**
  57620. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57621. * @returns the current timestep in seconds
  57622. */
  57623. getTimeStep(): number;
  57624. /**
  57625. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57626. */
  57627. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57628. private _isImpostorInContact;
  57629. private _isImpostorPairInContact;
  57630. private _stepSimulation;
  57631. /**
  57632. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57633. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57634. * After the step the babylon meshes are set to the position of the physics imposters
  57635. * @param delta amount of time to step forward
  57636. * @param impostors array of imposters to update before/after the step
  57637. */
  57638. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57639. /**
  57640. * Update babylon mesh to match physics world object
  57641. * @param impostor imposter to match
  57642. */
  57643. private _afterSoftStep;
  57644. /**
  57645. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57646. * @param impostor imposter to match
  57647. */
  57648. private _ropeStep;
  57649. /**
  57650. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57651. * @param impostor imposter to match
  57652. */
  57653. private _softbodyOrClothStep;
  57654. private _tmpVector;
  57655. private _tmpMatrix;
  57656. /**
  57657. * Applies an impulse on the imposter
  57658. * @param impostor imposter to apply impulse to
  57659. * @param force amount of force to be applied to the imposter
  57660. * @param contactPoint the location to apply the impulse on the imposter
  57661. */
  57662. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57663. /**
  57664. * Applies a force on the imposter
  57665. * @param impostor imposter to apply force
  57666. * @param force amount of force to be applied to the imposter
  57667. * @param contactPoint the location to apply the force on the imposter
  57668. */
  57669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57670. /**
  57671. * Creates a physics body using the plugin
  57672. * @param impostor the imposter to create the physics body on
  57673. */
  57674. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57675. /**
  57676. * Removes the physics body from the imposter and disposes of the body's memory
  57677. * @param impostor imposter to remove the physics body from
  57678. */
  57679. removePhysicsBody(impostor: PhysicsImpostor): void;
  57680. /**
  57681. * Generates a joint
  57682. * @param impostorJoint the imposter joint to create the joint with
  57683. */
  57684. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57685. /**
  57686. * Removes a joint
  57687. * @param impostorJoint the imposter joint to remove the joint from
  57688. */
  57689. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57690. private _addMeshVerts;
  57691. /**
  57692. * Initialise the soft body vertices to match its object's (mesh) vertices
  57693. * Softbody vertices (nodes) are in world space and to match this
  57694. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57695. * @param impostor to create the softbody for
  57696. */
  57697. private _softVertexData;
  57698. /**
  57699. * Create an impostor's soft body
  57700. * @param impostor to create the softbody for
  57701. */
  57702. private _createSoftbody;
  57703. /**
  57704. * Create cloth for an impostor
  57705. * @param impostor to create the softbody for
  57706. */
  57707. private _createCloth;
  57708. /**
  57709. * Create rope for an impostor
  57710. * @param impostor to create the softbody for
  57711. */
  57712. private _createRope;
  57713. /**
  57714. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57715. * @param impostor to create the custom physics shape for
  57716. */
  57717. private _createCustom;
  57718. private _addHullVerts;
  57719. private _createShape;
  57720. /**
  57721. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57722. * @param impostor imposter containing the physics body and babylon object
  57723. */
  57724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57725. /**
  57726. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57727. * @param impostor imposter containing the physics body and babylon object
  57728. * @param newPosition new position
  57729. * @param newRotation new rotation
  57730. */
  57731. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57732. /**
  57733. * If this plugin is supported
  57734. * @returns true if its supported
  57735. */
  57736. isSupported(): boolean;
  57737. /**
  57738. * Sets the linear velocity of the physics body
  57739. * @param impostor imposter to set the velocity on
  57740. * @param velocity velocity to set
  57741. */
  57742. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57743. /**
  57744. * Sets the angular velocity of the physics body
  57745. * @param impostor imposter to set the velocity on
  57746. * @param velocity velocity to set
  57747. */
  57748. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57749. /**
  57750. * gets the linear velocity
  57751. * @param impostor imposter to get linear velocity from
  57752. * @returns linear velocity
  57753. */
  57754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57755. /**
  57756. * gets the angular velocity
  57757. * @param impostor imposter to get angular velocity from
  57758. * @returns angular velocity
  57759. */
  57760. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57761. /**
  57762. * Sets the mass of physics body
  57763. * @param impostor imposter to set the mass on
  57764. * @param mass mass to set
  57765. */
  57766. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57767. /**
  57768. * Gets the mass of the physics body
  57769. * @param impostor imposter to get the mass from
  57770. * @returns mass
  57771. */
  57772. getBodyMass(impostor: PhysicsImpostor): number;
  57773. /**
  57774. * Gets friction of the impostor
  57775. * @param impostor impostor to get friction from
  57776. * @returns friction value
  57777. */
  57778. getBodyFriction(impostor: PhysicsImpostor): number;
  57779. /**
  57780. * Sets friction of the impostor
  57781. * @param impostor impostor to set friction on
  57782. * @param friction friction value
  57783. */
  57784. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57785. /**
  57786. * Gets restitution of the impostor
  57787. * @param impostor impostor to get restitution from
  57788. * @returns restitution value
  57789. */
  57790. getBodyRestitution(impostor: PhysicsImpostor): number;
  57791. /**
  57792. * Sets resitution of the impostor
  57793. * @param impostor impostor to set resitution on
  57794. * @param restitution resitution value
  57795. */
  57796. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57797. /**
  57798. * Gets pressure inside the impostor
  57799. * @param impostor impostor to get pressure from
  57800. * @returns pressure value
  57801. */
  57802. getBodyPressure(impostor: PhysicsImpostor): number;
  57803. /**
  57804. * Sets pressure inside a soft body impostor
  57805. * Cloth and rope must remain 0 pressure
  57806. * @param impostor impostor to set pressure on
  57807. * @param pressure pressure value
  57808. */
  57809. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57810. /**
  57811. * Gets stiffness of the impostor
  57812. * @param impostor impostor to get stiffness from
  57813. * @returns pressure value
  57814. */
  57815. getBodyStiffness(impostor: PhysicsImpostor): number;
  57816. /**
  57817. * Sets stiffness of the impostor
  57818. * @param impostor impostor to set stiffness on
  57819. * @param stiffness stiffness value from 0 to 1
  57820. */
  57821. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57822. /**
  57823. * Gets velocityIterations of the impostor
  57824. * @param impostor impostor to get velocity iterations from
  57825. * @returns velocityIterations value
  57826. */
  57827. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57828. /**
  57829. * Sets velocityIterations of the impostor
  57830. * @param impostor impostor to set velocity iterations on
  57831. * @param velocityIterations velocityIterations value
  57832. */
  57833. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57834. /**
  57835. * Gets positionIterations of the impostor
  57836. * @param impostor impostor to get position iterations from
  57837. * @returns positionIterations value
  57838. */
  57839. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57840. /**
  57841. * Sets positionIterations of the impostor
  57842. * @param impostor impostor to set position on
  57843. * @param positionIterations positionIterations value
  57844. */
  57845. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57846. /**
  57847. * Append an anchor to a cloth object
  57848. * @param impostor is the cloth impostor to add anchor to
  57849. * @param otherImpostor is the rigid impostor to anchor to
  57850. * @param width ratio across width from 0 to 1
  57851. * @param height ratio up height from 0 to 1
  57852. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57853. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57854. */
  57855. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57856. /**
  57857. * Append an hook to a rope object
  57858. * @param impostor is the rope impostor to add hook to
  57859. * @param otherImpostor is the rigid impostor to hook to
  57860. * @param length ratio along the rope from 0 to 1
  57861. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57862. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57863. */
  57864. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57865. /**
  57866. * Sleeps the physics body and stops it from being active
  57867. * @param impostor impostor to sleep
  57868. */
  57869. sleepBody(impostor: PhysicsImpostor): void;
  57870. /**
  57871. * Activates the physics body
  57872. * @param impostor impostor to activate
  57873. */
  57874. wakeUpBody(impostor: PhysicsImpostor): void;
  57875. /**
  57876. * Updates the distance parameters of the joint
  57877. * @param joint joint to update
  57878. * @param maxDistance maximum distance of the joint
  57879. * @param minDistance minimum distance of the joint
  57880. */
  57881. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57882. /**
  57883. * Sets a motor on the joint
  57884. * @param joint joint to set motor on
  57885. * @param speed speed of the motor
  57886. * @param maxForce maximum force of the motor
  57887. * @param motorIndex index of the motor
  57888. */
  57889. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57890. /**
  57891. * Sets the motors limit
  57892. * @param joint joint to set limit on
  57893. * @param upperLimit upper limit
  57894. * @param lowerLimit lower limit
  57895. */
  57896. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57897. /**
  57898. * Syncs the position and rotation of a mesh with the impostor
  57899. * @param mesh mesh to sync
  57900. * @param impostor impostor to update the mesh with
  57901. */
  57902. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57903. /**
  57904. * Gets the radius of the impostor
  57905. * @param impostor impostor to get radius from
  57906. * @returns the radius
  57907. */
  57908. getRadius(impostor: PhysicsImpostor): number;
  57909. /**
  57910. * Gets the box size of the impostor
  57911. * @param impostor impostor to get box size from
  57912. * @param result the resulting box size
  57913. */
  57914. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57915. /**
  57916. * Disposes of the impostor
  57917. */
  57918. dispose(): void;
  57919. /**
  57920. * Does a raycast in the physics world
  57921. * @param from when should the ray start?
  57922. * @param to when should the ray end?
  57923. * @returns PhysicsRaycastResult
  57924. */
  57925. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57926. }
  57927. }
  57928. declare module "babylonjs/Probes/reflectionProbe" {
  57929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57930. import { Vector3 } from "babylonjs/Maths/math.vector";
  57931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57932. import { Nullable } from "babylonjs/types";
  57933. import { Scene } from "babylonjs/scene";
  57934. module "babylonjs/abstractScene" {
  57935. interface AbstractScene {
  57936. /**
  57937. * The list of reflection probes added to the scene
  57938. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57939. */
  57940. reflectionProbes: Array<ReflectionProbe>;
  57941. /**
  57942. * Removes the given reflection probe from this scene.
  57943. * @param toRemove The reflection probe to remove
  57944. * @returns The index of the removed reflection probe
  57945. */
  57946. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57947. /**
  57948. * Adds the given reflection probe to this scene.
  57949. * @param newReflectionProbe The reflection probe to add
  57950. */
  57951. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57952. }
  57953. }
  57954. /**
  57955. * Class used to generate realtime reflection / refraction cube textures
  57956. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57957. */
  57958. export class ReflectionProbe {
  57959. /** defines the name of the probe */
  57960. name: string;
  57961. private _scene;
  57962. private _renderTargetTexture;
  57963. private _projectionMatrix;
  57964. private _viewMatrix;
  57965. private _target;
  57966. private _add;
  57967. private _attachedMesh;
  57968. private _invertYAxis;
  57969. /** Gets or sets probe position (center of the cube map) */
  57970. position: Vector3;
  57971. /**
  57972. * Creates a new reflection probe
  57973. * @param name defines the name of the probe
  57974. * @param size defines the texture resolution (for each face)
  57975. * @param scene defines the hosting scene
  57976. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57977. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57978. */
  57979. constructor(
  57980. /** defines the name of the probe */
  57981. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57982. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57983. get samples(): number;
  57984. set samples(value: number);
  57985. /** Gets or sets the refresh rate to use (on every frame by default) */
  57986. get refreshRate(): number;
  57987. set refreshRate(value: number);
  57988. /**
  57989. * Gets the hosting scene
  57990. * @returns a Scene
  57991. */
  57992. getScene(): Scene;
  57993. /** Gets the internal CubeTexture used to render to */
  57994. get cubeTexture(): RenderTargetTexture;
  57995. /** Gets the list of meshes to render */
  57996. get renderList(): Nullable<AbstractMesh[]>;
  57997. /**
  57998. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57999. * @param mesh defines the mesh to attach to
  58000. */
  58001. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58002. /**
  58003. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58004. * @param renderingGroupId The rendering group id corresponding to its index
  58005. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58006. */
  58007. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58008. /**
  58009. * Clean all associated resources
  58010. */
  58011. dispose(): void;
  58012. /**
  58013. * Converts the reflection probe information to a readable string for debug purpose.
  58014. * @param fullDetails Supports for multiple levels of logging within scene loading
  58015. * @returns the human readable reflection probe info
  58016. */
  58017. toString(fullDetails?: boolean): string;
  58018. /**
  58019. * Get the class name of the relfection probe.
  58020. * @returns "ReflectionProbe"
  58021. */
  58022. getClassName(): string;
  58023. /**
  58024. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58025. * @returns The JSON representation of the texture
  58026. */
  58027. serialize(): any;
  58028. /**
  58029. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58030. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58031. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58032. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58033. * @returns The parsed reflection probe if successful
  58034. */
  58035. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58036. }
  58037. }
  58038. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58039. /** @hidden */
  58040. export var _BabylonLoaderRegistered: boolean;
  58041. /**
  58042. * Helps setting up some configuration for the babylon file loader.
  58043. */
  58044. export class BabylonFileLoaderConfiguration {
  58045. /**
  58046. * The loader does not allow injecting custom physix engine into the plugins.
  58047. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58048. * So you could set this variable to your engine import to make it work.
  58049. */
  58050. static LoaderInjectedPhysicsEngine: any;
  58051. }
  58052. }
  58053. declare module "babylonjs/Loading/Plugins/index" {
  58054. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58055. }
  58056. declare module "babylonjs/Loading/index" {
  58057. export * from "babylonjs/Loading/loadingScreen";
  58058. export * from "babylonjs/Loading/Plugins/index";
  58059. export * from "babylonjs/Loading/sceneLoader";
  58060. export * from "babylonjs/Loading/sceneLoaderFlags";
  58061. }
  58062. declare module "babylonjs/Materials/Background/index" {
  58063. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58064. }
  58065. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58066. import { Scene } from "babylonjs/scene";
  58067. import { Color3 } from "babylonjs/Maths/math.color";
  58068. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58070. /**
  58071. * The Physically based simple base material of BJS.
  58072. *
  58073. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58074. * It is used as the base class for both the specGloss and metalRough conventions.
  58075. */
  58076. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58077. /**
  58078. * Number of Simultaneous lights allowed on the material.
  58079. */
  58080. maxSimultaneousLights: number;
  58081. /**
  58082. * If sets to true, disables all the lights affecting the material.
  58083. */
  58084. disableLighting: boolean;
  58085. /**
  58086. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58087. */
  58088. environmentTexture: BaseTexture;
  58089. /**
  58090. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58091. */
  58092. invertNormalMapX: boolean;
  58093. /**
  58094. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58095. */
  58096. invertNormalMapY: boolean;
  58097. /**
  58098. * Normal map used in the model.
  58099. */
  58100. normalTexture: BaseTexture;
  58101. /**
  58102. * Emissivie color used to self-illuminate the model.
  58103. */
  58104. emissiveColor: Color3;
  58105. /**
  58106. * Emissivie texture used to self-illuminate the model.
  58107. */
  58108. emissiveTexture: BaseTexture;
  58109. /**
  58110. * Occlusion Channel Strenght.
  58111. */
  58112. occlusionStrength: number;
  58113. /**
  58114. * Occlusion Texture of the material (adding extra occlusion effects).
  58115. */
  58116. occlusionTexture: BaseTexture;
  58117. /**
  58118. * Defines the alpha limits in alpha test mode.
  58119. */
  58120. alphaCutOff: number;
  58121. /**
  58122. * Gets the current double sided mode.
  58123. */
  58124. get doubleSided(): boolean;
  58125. /**
  58126. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58127. */
  58128. set doubleSided(value: boolean);
  58129. /**
  58130. * Stores the pre-calculated light information of a mesh in a texture.
  58131. */
  58132. lightmapTexture: BaseTexture;
  58133. /**
  58134. * If true, the light map contains occlusion information instead of lighting info.
  58135. */
  58136. useLightmapAsShadowmap: boolean;
  58137. /**
  58138. * Instantiates a new PBRMaterial instance.
  58139. *
  58140. * @param name The material name
  58141. * @param scene The scene the material will be use in.
  58142. */
  58143. constructor(name: string, scene: Scene);
  58144. getClassName(): string;
  58145. }
  58146. }
  58147. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58148. import { Scene } from "babylonjs/scene";
  58149. import { Color3 } from "babylonjs/Maths/math.color";
  58150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58151. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58152. /**
  58153. * The PBR material of BJS following the metal roughness convention.
  58154. *
  58155. * This fits to the PBR convention in the GLTF definition:
  58156. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58157. */
  58158. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58159. /**
  58160. * The base color has two different interpretations depending on the value of metalness.
  58161. * When the material is a metal, the base color is the specific measured reflectance value
  58162. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58163. * of the material.
  58164. */
  58165. baseColor: Color3;
  58166. /**
  58167. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58168. * well as opacity information in the alpha channel.
  58169. */
  58170. baseTexture: BaseTexture;
  58171. /**
  58172. * Specifies the metallic scalar value of the material.
  58173. * Can also be used to scale the metalness values of the metallic texture.
  58174. */
  58175. metallic: number;
  58176. /**
  58177. * Specifies the roughness scalar value of the material.
  58178. * Can also be used to scale the roughness values of the metallic texture.
  58179. */
  58180. roughness: number;
  58181. /**
  58182. * Texture containing both the metallic value in the B channel and the
  58183. * roughness value in the G channel to keep better precision.
  58184. */
  58185. metallicRoughnessTexture: BaseTexture;
  58186. /**
  58187. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58188. *
  58189. * @param name The material name
  58190. * @param scene The scene the material will be use in.
  58191. */
  58192. constructor(name: string, scene: Scene);
  58193. /**
  58194. * Return the currrent class name of the material.
  58195. */
  58196. getClassName(): string;
  58197. /**
  58198. * Makes a duplicate of the current material.
  58199. * @param name - name to use for the new material.
  58200. */
  58201. clone(name: string): PBRMetallicRoughnessMaterial;
  58202. /**
  58203. * Serialize the material to a parsable JSON object.
  58204. */
  58205. serialize(): any;
  58206. /**
  58207. * Parses a JSON object correponding to the serialize function.
  58208. */
  58209. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58210. }
  58211. }
  58212. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58213. import { Scene } from "babylonjs/scene";
  58214. import { Color3 } from "babylonjs/Maths/math.color";
  58215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58216. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58217. /**
  58218. * The PBR material of BJS following the specular glossiness convention.
  58219. *
  58220. * This fits to the PBR convention in the GLTF definition:
  58221. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58222. */
  58223. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58224. /**
  58225. * Specifies the diffuse color of the material.
  58226. */
  58227. diffuseColor: Color3;
  58228. /**
  58229. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58230. * channel.
  58231. */
  58232. diffuseTexture: BaseTexture;
  58233. /**
  58234. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58235. */
  58236. specularColor: Color3;
  58237. /**
  58238. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58239. */
  58240. glossiness: number;
  58241. /**
  58242. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58243. */
  58244. specularGlossinessTexture: BaseTexture;
  58245. /**
  58246. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58247. *
  58248. * @param name The material name
  58249. * @param scene The scene the material will be use in.
  58250. */
  58251. constructor(name: string, scene: Scene);
  58252. /**
  58253. * Return the currrent class name of the material.
  58254. */
  58255. getClassName(): string;
  58256. /**
  58257. * Makes a duplicate of the current material.
  58258. * @param name - name to use for the new material.
  58259. */
  58260. clone(name: string): PBRSpecularGlossinessMaterial;
  58261. /**
  58262. * Serialize the material to a parsable JSON object.
  58263. */
  58264. serialize(): any;
  58265. /**
  58266. * Parses a JSON object correponding to the serialize function.
  58267. */
  58268. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58269. }
  58270. }
  58271. declare module "babylonjs/Materials/PBR/index" {
  58272. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58273. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58274. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58275. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58276. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58277. }
  58278. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58279. import { Nullable } from "babylonjs/types";
  58280. import { Scene } from "babylonjs/scene";
  58281. import { Matrix } from "babylonjs/Maths/math.vector";
  58282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58283. /**
  58284. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58285. * It can help converting any input color in a desired output one. This can then be used to create effects
  58286. * from sepia, black and white to sixties or futuristic rendering...
  58287. *
  58288. * The only supported format is currently 3dl.
  58289. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58290. */
  58291. export class ColorGradingTexture extends BaseTexture {
  58292. /**
  58293. * The current texture matrix. (will always be identity in color grading texture)
  58294. */
  58295. private _textureMatrix;
  58296. /**
  58297. * The texture URL.
  58298. */
  58299. url: string;
  58300. /**
  58301. * Empty line regex stored for GC.
  58302. */
  58303. private static _noneEmptyLineRegex;
  58304. private _engine;
  58305. /**
  58306. * Instantiates a ColorGradingTexture from the following parameters.
  58307. *
  58308. * @param url The location of the color gradind data (currently only supporting 3dl)
  58309. * @param scene The scene the texture will be used in
  58310. */
  58311. constructor(url: string, scene: Scene);
  58312. /**
  58313. * Returns the texture matrix used in most of the material.
  58314. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58315. */
  58316. getTextureMatrix(): Matrix;
  58317. /**
  58318. * Occurs when the file being loaded is a .3dl LUT file.
  58319. */
  58320. private load3dlTexture;
  58321. /**
  58322. * Starts the loading process of the texture.
  58323. */
  58324. private loadTexture;
  58325. /**
  58326. * Clones the color gradind texture.
  58327. */
  58328. clone(): ColorGradingTexture;
  58329. /**
  58330. * Called during delayed load for textures.
  58331. */
  58332. delayLoad(): void;
  58333. /**
  58334. * Parses a color grading texture serialized by Babylon.
  58335. * @param parsedTexture The texture information being parsedTexture
  58336. * @param scene The scene to load the texture in
  58337. * @param rootUrl The root url of the data assets to load
  58338. * @return A color gradind texture
  58339. */
  58340. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58341. /**
  58342. * Serializes the LUT texture to json format.
  58343. */
  58344. serialize(): any;
  58345. }
  58346. }
  58347. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58349. import { Scene } from "babylonjs/scene";
  58350. import { Nullable } from "babylonjs/types";
  58351. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58352. /**
  58353. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58354. */
  58355. export class EquiRectangularCubeTexture extends BaseTexture {
  58356. /** The six faces of the cube. */
  58357. private static _FacesMapping;
  58358. private _noMipmap;
  58359. private _onLoad;
  58360. private _onError;
  58361. /** The size of the cubemap. */
  58362. private _size;
  58363. /** The buffer of the image. */
  58364. private _buffer;
  58365. /** The width of the input image. */
  58366. private _width;
  58367. /** The height of the input image. */
  58368. private _height;
  58369. /** The URL to the image. */
  58370. url: string;
  58371. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58372. coordinatesMode: number;
  58373. /**
  58374. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58375. * @param url The location of the image
  58376. * @param scene The scene the texture will be used in
  58377. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58378. * @param noMipmap Forces to not generate the mipmap if true
  58379. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58380. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58381. * @param onLoad — defines a callback called when texture is loaded
  58382. * @param onError — defines a callback called if there is an error
  58383. */
  58384. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58385. /**
  58386. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58387. */
  58388. private loadImage;
  58389. /**
  58390. * Convert the image buffer into a cubemap and create a CubeTexture.
  58391. */
  58392. private loadTexture;
  58393. /**
  58394. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58395. * @param buffer The ArrayBuffer that should be converted.
  58396. * @returns The buffer as Float32Array.
  58397. */
  58398. private getFloat32ArrayFromArrayBuffer;
  58399. /**
  58400. * Get the current class name of the texture useful for serialization or dynamic coding.
  58401. * @returns "EquiRectangularCubeTexture"
  58402. */
  58403. getClassName(): string;
  58404. /**
  58405. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58406. * @returns A clone of the current EquiRectangularCubeTexture.
  58407. */
  58408. clone(): EquiRectangularCubeTexture;
  58409. }
  58410. }
  58411. declare module "babylonjs/Misc/tga" {
  58412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58413. /**
  58414. * Based on jsTGALoader - Javascript loader for TGA file
  58415. * By Vincent Thibault
  58416. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58417. */
  58418. export class TGATools {
  58419. private static _TYPE_INDEXED;
  58420. private static _TYPE_RGB;
  58421. private static _TYPE_GREY;
  58422. private static _TYPE_RLE_INDEXED;
  58423. private static _TYPE_RLE_RGB;
  58424. private static _TYPE_RLE_GREY;
  58425. private static _ORIGIN_MASK;
  58426. private static _ORIGIN_SHIFT;
  58427. private static _ORIGIN_BL;
  58428. private static _ORIGIN_BR;
  58429. private static _ORIGIN_UL;
  58430. private static _ORIGIN_UR;
  58431. /**
  58432. * Gets the header of a TGA file
  58433. * @param data defines the TGA data
  58434. * @returns the header
  58435. */
  58436. static GetTGAHeader(data: Uint8Array): any;
  58437. /**
  58438. * Uploads TGA content to a Babylon Texture
  58439. * @hidden
  58440. */
  58441. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58442. /** @hidden */
  58443. 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;
  58444. /** @hidden */
  58445. 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;
  58446. /** @hidden */
  58447. 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;
  58448. /** @hidden */
  58449. 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;
  58450. /** @hidden */
  58451. 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;
  58452. /** @hidden */
  58453. 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;
  58454. }
  58455. }
  58456. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58457. import { Nullable } from "babylonjs/types";
  58458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58459. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58460. /**
  58461. * Implementation of the TGA Texture Loader.
  58462. * @hidden
  58463. */
  58464. export class _TGATextureLoader implements IInternalTextureLoader {
  58465. /**
  58466. * Defines wether the loader supports cascade loading the different faces.
  58467. */
  58468. readonly supportCascades: boolean;
  58469. /**
  58470. * This returns if the loader support the current file information.
  58471. * @param extension defines the file extension of the file being loaded
  58472. * @returns true if the loader can load the specified file
  58473. */
  58474. canLoad(extension: string): boolean;
  58475. /**
  58476. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58477. * @param data contains the texture data
  58478. * @param texture defines the BabylonJS internal texture
  58479. * @param createPolynomials will be true if polynomials have been requested
  58480. * @param onLoad defines the callback to trigger once the texture is ready
  58481. * @param onError defines the callback to trigger in case of error
  58482. */
  58483. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58484. /**
  58485. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58486. * @param data contains the texture data
  58487. * @param texture defines the BabylonJS internal texture
  58488. * @param callback defines the method to call once ready to upload
  58489. */
  58490. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58491. }
  58492. }
  58493. declare module "babylonjs/Misc/basis" {
  58494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58495. /**
  58496. * Info about the .basis files
  58497. */
  58498. class BasisFileInfo {
  58499. /**
  58500. * If the file has alpha
  58501. */
  58502. hasAlpha: boolean;
  58503. /**
  58504. * Info about each image of the basis file
  58505. */
  58506. images: Array<{
  58507. levels: Array<{
  58508. width: number;
  58509. height: number;
  58510. transcodedPixels: ArrayBufferView;
  58511. }>;
  58512. }>;
  58513. }
  58514. /**
  58515. * Result of transcoding a basis file
  58516. */
  58517. class TranscodeResult {
  58518. /**
  58519. * Info about the .basis file
  58520. */
  58521. fileInfo: BasisFileInfo;
  58522. /**
  58523. * Format to use when loading the file
  58524. */
  58525. format: number;
  58526. }
  58527. /**
  58528. * Configuration options for the Basis transcoder
  58529. */
  58530. export class BasisTranscodeConfiguration {
  58531. /**
  58532. * Supported compression formats used to determine the supported output format of the transcoder
  58533. */
  58534. supportedCompressionFormats?: {
  58535. /**
  58536. * etc1 compression format
  58537. */
  58538. etc1?: boolean;
  58539. /**
  58540. * s3tc compression format
  58541. */
  58542. s3tc?: boolean;
  58543. /**
  58544. * pvrtc compression format
  58545. */
  58546. pvrtc?: boolean;
  58547. /**
  58548. * etc2 compression format
  58549. */
  58550. etc2?: boolean;
  58551. };
  58552. /**
  58553. * If mipmap levels should be loaded for transcoded images (Default: true)
  58554. */
  58555. loadMipmapLevels?: boolean;
  58556. /**
  58557. * Index of a single image to load (Default: all images)
  58558. */
  58559. loadSingleImage?: number;
  58560. }
  58561. /**
  58562. * Used to load .Basis files
  58563. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58564. */
  58565. export class BasisTools {
  58566. private static _IgnoreSupportedFormats;
  58567. /**
  58568. * URL to use when loading the basis transcoder
  58569. */
  58570. static JSModuleURL: string;
  58571. /**
  58572. * URL to use when loading the wasm module for the transcoder
  58573. */
  58574. static WasmModuleURL: string;
  58575. /**
  58576. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58577. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58578. * @returns internal format corresponding to the Basis format
  58579. */
  58580. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58581. private static _WorkerPromise;
  58582. private static _Worker;
  58583. private static _actionId;
  58584. private static _CreateWorkerAsync;
  58585. /**
  58586. * Transcodes a loaded image file to compressed pixel data
  58587. * @param data image data to transcode
  58588. * @param config configuration options for the transcoding
  58589. * @returns a promise resulting in the transcoded image
  58590. */
  58591. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58592. /**
  58593. * Loads a texture from the transcode result
  58594. * @param texture texture load to
  58595. * @param transcodeResult the result of transcoding the basis file to load from
  58596. */
  58597. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58598. }
  58599. }
  58600. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58601. import { Nullable } from "babylonjs/types";
  58602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58603. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58604. /**
  58605. * Loader for .basis file format
  58606. */
  58607. export class _BasisTextureLoader implements IInternalTextureLoader {
  58608. /**
  58609. * Defines whether the loader supports cascade loading the different faces.
  58610. */
  58611. readonly supportCascades: boolean;
  58612. /**
  58613. * This returns if the loader support the current file information.
  58614. * @param extension defines the file extension of the file being loaded
  58615. * @returns true if the loader can load the specified file
  58616. */
  58617. canLoad(extension: string): boolean;
  58618. /**
  58619. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58620. * @param data contains the texture data
  58621. * @param texture defines the BabylonJS internal texture
  58622. * @param createPolynomials will be true if polynomials have been requested
  58623. * @param onLoad defines the callback to trigger once the texture is ready
  58624. * @param onError defines the callback to trigger in case of error
  58625. */
  58626. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58627. /**
  58628. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58629. * @param data contains the texture data
  58630. * @param texture defines the BabylonJS internal texture
  58631. * @param callback defines the method to call once ready to upload
  58632. */
  58633. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58634. }
  58635. }
  58636. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58637. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58638. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58639. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58640. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58641. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58642. }
  58643. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58644. import { Scene } from "babylonjs/scene";
  58645. import { Texture } from "babylonjs/Materials/Textures/texture";
  58646. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58647. /**
  58648. * 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.
  58649. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58651. */
  58652. export class CustomProceduralTexture extends ProceduralTexture {
  58653. private _animate;
  58654. private _time;
  58655. private _config;
  58656. private _texturePath;
  58657. /**
  58658. * Instantiates a new Custom Procedural Texture.
  58659. * 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.
  58660. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58661. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58662. * @param name Define the name of the texture
  58663. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58664. * @param size Define the size of the texture to create
  58665. * @param scene Define the scene the texture belongs to
  58666. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58667. * @param generateMipMaps Define if the texture should creates mip maps or not
  58668. */
  58669. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58670. private _loadJson;
  58671. /**
  58672. * Is the texture ready to be used ? (rendered at least once)
  58673. * @returns true if ready, otherwise, false.
  58674. */
  58675. isReady(): boolean;
  58676. /**
  58677. * Render the texture to its associated render target.
  58678. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58679. */
  58680. render(useCameraPostProcess?: boolean): void;
  58681. /**
  58682. * Update the list of dependant textures samplers in the shader.
  58683. */
  58684. updateTextures(): void;
  58685. /**
  58686. * Update the uniform values of the procedural texture in the shader.
  58687. */
  58688. updateShaderUniforms(): void;
  58689. /**
  58690. * Define if the texture animates or not.
  58691. */
  58692. get animate(): boolean;
  58693. set animate(value: boolean);
  58694. }
  58695. }
  58696. declare module "babylonjs/Shaders/noise.fragment" {
  58697. /** @hidden */
  58698. export var noisePixelShader: {
  58699. name: string;
  58700. shader: string;
  58701. };
  58702. }
  58703. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58704. import { Nullable } from "babylonjs/types";
  58705. import { Scene } from "babylonjs/scene";
  58706. import { Texture } from "babylonjs/Materials/Textures/texture";
  58707. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58708. import "babylonjs/Shaders/noise.fragment";
  58709. /**
  58710. * Class used to generate noise procedural textures
  58711. */
  58712. export class NoiseProceduralTexture extends ProceduralTexture {
  58713. private _time;
  58714. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58715. brightness: number;
  58716. /** Defines the number of octaves to process */
  58717. octaves: number;
  58718. /** Defines the level of persistence (0.8 by default) */
  58719. persistence: number;
  58720. /** Gets or sets animation speed factor (default is 1) */
  58721. animationSpeedFactor: number;
  58722. /**
  58723. * Creates a new NoiseProceduralTexture
  58724. * @param name defines the name fo the texture
  58725. * @param size defines the size of the texture (default is 256)
  58726. * @param scene defines the hosting scene
  58727. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58728. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58729. */
  58730. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58731. private _updateShaderUniforms;
  58732. protected _getDefines(): string;
  58733. /** Generate the current state of the procedural texture */
  58734. render(useCameraPostProcess?: boolean): void;
  58735. /**
  58736. * Serializes this noise procedural texture
  58737. * @returns a serialized noise procedural texture object
  58738. */
  58739. serialize(): any;
  58740. /**
  58741. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58742. * @param parsedTexture defines parsed texture data
  58743. * @param scene defines the current scene
  58744. * @param rootUrl defines the root URL containing noise procedural texture information
  58745. * @returns a parsed NoiseProceduralTexture
  58746. */
  58747. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58748. }
  58749. }
  58750. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58751. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58752. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58753. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58754. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58755. }
  58756. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58757. import { Nullable } from "babylonjs/types";
  58758. import { Scene } from "babylonjs/scene";
  58759. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58760. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58761. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58762. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58763. /**
  58764. * Raw cube texture where the raw buffers are passed in
  58765. */
  58766. export class RawCubeTexture extends CubeTexture {
  58767. /**
  58768. * Creates a cube texture where the raw buffers are passed in.
  58769. * @param scene defines the scene the texture is attached to
  58770. * @param data defines the array of data to use to create each face
  58771. * @param size defines the size of the textures
  58772. * @param format defines the format of the data
  58773. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58774. * @param generateMipMaps defines if the engine should generate the mip levels
  58775. * @param invertY defines if data must be stored with Y axis inverted
  58776. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58777. * @param compression defines the compression used (null by default)
  58778. */
  58779. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58780. /**
  58781. * Updates the raw cube texture.
  58782. * @param data defines the data to store
  58783. * @param format defines the data format
  58784. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58785. * @param invertY defines if data must be stored with Y axis inverted
  58786. * @param compression defines the compression used (null by default)
  58787. * @param level defines which level of the texture to update
  58788. */
  58789. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58790. /**
  58791. * Updates a raw cube texture with RGBD encoded data.
  58792. * @param data defines the array of data [mipmap][face] to use to create each face
  58793. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58796. * @returns a promsie that resolves when the operation is complete
  58797. */
  58798. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58799. /**
  58800. * Clones the raw cube texture.
  58801. * @return a new cube texture
  58802. */
  58803. clone(): CubeTexture;
  58804. /** @hidden */
  58805. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58806. }
  58807. }
  58808. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58809. import { Scene } from "babylonjs/scene";
  58810. import { Texture } from "babylonjs/Materials/Textures/texture";
  58811. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58812. /**
  58813. * Class used to store 3D textures containing user data
  58814. */
  58815. export class RawTexture3D extends Texture {
  58816. /** Gets or sets the texture format to use */
  58817. format: number;
  58818. private _engine;
  58819. /**
  58820. * Create a new RawTexture3D
  58821. * @param data defines the data of the texture
  58822. * @param width defines the width of the texture
  58823. * @param height defines the height of the texture
  58824. * @param depth defines the depth of the texture
  58825. * @param format defines the texture format to use
  58826. * @param scene defines the hosting scene
  58827. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58828. * @param invertY defines if texture must be stored with Y axis inverted
  58829. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58830. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58831. */
  58832. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58833. /** Gets or sets the texture format to use */
  58834. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58835. /**
  58836. * Update the texture with new data
  58837. * @param data defines the data to store in the texture
  58838. */
  58839. update(data: ArrayBufferView): void;
  58840. }
  58841. }
  58842. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58843. import { Scene } from "babylonjs/scene";
  58844. import { Texture } from "babylonjs/Materials/Textures/texture";
  58845. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58846. /**
  58847. * Class used to store 2D array textures containing user data
  58848. */
  58849. export class RawTexture2DArray extends Texture {
  58850. /** Gets or sets the texture format to use */
  58851. format: number;
  58852. private _engine;
  58853. /**
  58854. * Create a new RawTexture2DArray
  58855. * @param data defines the data of the texture
  58856. * @param width defines the width of the texture
  58857. * @param height defines the height of the texture
  58858. * @param depth defines the number of layers of the texture
  58859. * @param format defines the texture format to use
  58860. * @param scene defines the hosting scene
  58861. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58862. * @param invertY defines if texture must be stored with Y axis inverted
  58863. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58864. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58865. */
  58866. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58867. /** Gets or sets the texture format to use */
  58868. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58869. /**
  58870. * Update the texture with new data
  58871. * @param data defines the data to store in the texture
  58872. */
  58873. update(data: ArrayBufferView): void;
  58874. }
  58875. }
  58876. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58877. import { Scene } from "babylonjs/scene";
  58878. import { Plane } from "babylonjs/Maths/math.plane";
  58879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58880. /**
  58881. * Creates a refraction texture used by refraction channel of the standard material.
  58882. * It is like a mirror but to see through a material.
  58883. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58884. */
  58885. export class RefractionTexture extends RenderTargetTexture {
  58886. /**
  58887. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58888. * 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.
  58889. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58890. */
  58891. refractionPlane: Plane;
  58892. /**
  58893. * Define how deep under the surface we should see.
  58894. */
  58895. depth: number;
  58896. /**
  58897. * Creates a refraction texture used by refraction channel of the standard material.
  58898. * It is like a mirror but to see through a material.
  58899. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58900. * @param name Define the texture name
  58901. * @param size Define the size of the underlying texture
  58902. * @param scene Define the scene the refraction belongs to
  58903. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58904. */
  58905. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58906. /**
  58907. * Clone the refraction texture.
  58908. * @returns the cloned texture
  58909. */
  58910. clone(): RefractionTexture;
  58911. /**
  58912. * Serialize the texture to a JSON representation you could use in Parse later on
  58913. * @returns the serialized JSON representation
  58914. */
  58915. serialize(): any;
  58916. }
  58917. }
  58918. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58919. import { Nullable } from "babylonjs/types";
  58920. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58921. import { Matrix } from "babylonjs/Maths/math.vector";
  58922. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58923. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58924. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58925. import { Scene } from "babylonjs/scene";
  58926. /**
  58927. * Defines the options related to the creation of an HtmlElementTexture
  58928. */
  58929. export interface IHtmlElementTextureOptions {
  58930. /**
  58931. * Defines wether mip maps should be created or not.
  58932. */
  58933. generateMipMaps?: boolean;
  58934. /**
  58935. * Defines the sampling mode of the texture.
  58936. */
  58937. samplingMode?: number;
  58938. /**
  58939. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58940. */
  58941. engine: Nullable<ThinEngine>;
  58942. /**
  58943. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58944. */
  58945. scene: Nullable<Scene>;
  58946. }
  58947. /**
  58948. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58949. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58950. * is automatically managed.
  58951. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58952. * in your application.
  58953. *
  58954. * As the update is not automatic, you need to call them manually.
  58955. */
  58956. export class HtmlElementTexture extends BaseTexture {
  58957. /**
  58958. * The texture URL.
  58959. */
  58960. element: HTMLVideoElement | HTMLCanvasElement;
  58961. private static readonly DefaultOptions;
  58962. private _textureMatrix;
  58963. private _engine;
  58964. private _isVideo;
  58965. private _generateMipMaps;
  58966. private _samplingMode;
  58967. /**
  58968. * Instantiates a HtmlElementTexture from the following parameters.
  58969. *
  58970. * @param name Defines the name of the texture
  58971. * @param element Defines the video or canvas the texture is filled with
  58972. * @param options Defines the other none mandatory texture creation options
  58973. */
  58974. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58975. private _createInternalTexture;
  58976. /**
  58977. * Returns the texture matrix used in most of the material.
  58978. */
  58979. getTextureMatrix(): Matrix;
  58980. /**
  58981. * Updates the content of the texture.
  58982. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58983. */
  58984. update(invertY?: Nullable<boolean>): void;
  58985. }
  58986. }
  58987. declare module "babylonjs/Materials/Textures/Packer/frame" {
  58988. import { Vector2 } from "babylonjs/Maths/math.vector";
  58989. /**
  58990. * Defines the basic options interface of a TexturePacker Frame
  58991. */
  58992. export interface ITexturePackerFrame {
  58993. /**
  58994. * The frame ID
  58995. */
  58996. id: number;
  58997. /**
  58998. * The frames Scale
  58999. */
  59000. scale: Vector2;
  59001. /**
  59002. * The Frames offset
  59003. */
  59004. offset: Vector2;
  59005. }
  59006. /**
  59007. * This is a support class for frame Data on texture packer sets.
  59008. */
  59009. export class TexturePackerFrame implements ITexturePackerFrame {
  59010. /**
  59011. * The frame ID
  59012. */
  59013. id: number;
  59014. /**
  59015. * The frames Scale
  59016. */
  59017. scale: Vector2;
  59018. /**
  59019. * The Frames offset
  59020. */
  59021. offset: Vector2;
  59022. /**
  59023. * Initializes a texture package frame.
  59024. * @param id The numerical frame identifier
  59025. * @param scale Scalar Vector2 for UV frame
  59026. * @param offset Vector2 for the frame position in UV units.
  59027. * @returns TexturePackerFrame
  59028. */
  59029. constructor(id: number, scale: Vector2, offset: Vector2);
  59030. }
  59031. }
  59032. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59034. import { Scene } from "babylonjs/scene";
  59035. import { Nullable } from "babylonjs/types";
  59036. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59037. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59038. /**
  59039. * Defines the basic options interface of a TexturePacker
  59040. */
  59041. export interface ITexturePackerOptions {
  59042. /**
  59043. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59044. */
  59045. map?: string[];
  59046. /**
  59047. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59048. */
  59049. uvsIn?: string;
  59050. /**
  59051. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59052. */
  59053. uvsOut?: string;
  59054. /**
  59055. * number representing the layout style. Defaults to LAYOUT_STRIP
  59056. */
  59057. layout?: number;
  59058. /**
  59059. * number of columns if using custom column count layout(2). This defaults to 4.
  59060. */
  59061. colnum?: number;
  59062. /**
  59063. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59064. */
  59065. updateInputMeshes?: boolean;
  59066. /**
  59067. * boolean flag to dispose all the source textures. Defaults to true.
  59068. */
  59069. disposeSources?: boolean;
  59070. /**
  59071. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59072. */
  59073. fillBlanks?: boolean;
  59074. /**
  59075. * string value representing the context fill style color. Defaults to 'black'.
  59076. */
  59077. customFillColor?: string;
  59078. /**
  59079. * Width and Height Value of each Frame in the TexturePacker Sets
  59080. */
  59081. frameSize?: number;
  59082. /**
  59083. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59084. */
  59085. paddingRatio?: number;
  59086. /**
  59087. * Number that declares the fill method for the padding gutter.
  59088. */
  59089. paddingMode?: number;
  59090. /**
  59091. * If in SUBUV_COLOR padding mode what color to use.
  59092. */
  59093. paddingColor?: Color3 | Color4;
  59094. }
  59095. /**
  59096. * Defines the basic interface of a TexturePacker JSON File
  59097. */
  59098. export interface ITexturePackerJSON {
  59099. /**
  59100. * The frame ID
  59101. */
  59102. name: string;
  59103. /**
  59104. * The base64 channel data
  59105. */
  59106. sets: any;
  59107. /**
  59108. * The options of the Packer
  59109. */
  59110. options: ITexturePackerOptions;
  59111. /**
  59112. * The frame data of the Packer
  59113. */
  59114. frames: Array<number>;
  59115. }
  59116. /**
  59117. * This is a support class that generates a series of packed texture sets.
  59118. * @see https://doc.babylonjs.com/babylon101/materials
  59119. */
  59120. export class TexturePacker {
  59121. /** Packer Layout Constant 0 */
  59122. static readonly LAYOUT_STRIP: number;
  59123. /** Packer Layout Constant 1 */
  59124. static readonly LAYOUT_POWER2: number;
  59125. /** Packer Layout Constant 2 */
  59126. static readonly LAYOUT_COLNUM: number;
  59127. /** Packer Layout Constant 0 */
  59128. static readonly SUBUV_WRAP: number;
  59129. /** Packer Layout Constant 1 */
  59130. static readonly SUBUV_EXTEND: number;
  59131. /** Packer Layout Constant 2 */
  59132. static readonly SUBUV_COLOR: number;
  59133. /** The Name of the Texture Package */
  59134. name: string;
  59135. /** The scene scope of the TexturePacker */
  59136. scene: Scene;
  59137. /** The Meshes to target */
  59138. meshes: AbstractMesh[];
  59139. /** Arguments passed with the Constructor */
  59140. options: ITexturePackerOptions;
  59141. /** The promise that is started upon initialization */
  59142. promise: Nullable<Promise<TexturePacker | string>>;
  59143. /** The Container object for the channel sets that are generated */
  59144. sets: object;
  59145. /** The Container array for the frames that are generated */
  59146. frames: TexturePackerFrame[];
  59147. /** The expected number of textures the system is parsing. */
  59148. private _expecting;
  59149. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59150. private _paddingValue;
  59151. /**
  59152. * Initializes a texture package series from an array of meshes or a single mesh.
  59153. * @param name The name of the package
  59154. * @param meshes The target meshes to compose the package from
  59155. * @param options The arguments that texture packer should follow while building.
  59156. * @param scene The scene which the textures are scoped to.
  59157. * @returns TexturePacker
  59158. */
  59159. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59160. /**
  59161. * Starts the package process
  59162. * @param resolve The promises resolution function
  59163. * @returns TexturePacker
  59164. */
  59165. private _createFrames;
  59166. /**
  59167. * Calculates the Size of the Channel Sets
  59168. * @returns Vector2
  59169. */
  59170. private _calculateSize;
  59171. /**
  59172. * Calculates the UV data for the frames.
  59173. * @param baseSize the base frameSize
  59174. * @param padding the base frame padding
  59175. * @param dtSize size of the Dynamic Texture for that channel
  59176. * @param dtUnits is 1/dtSize
  59177. * @param update flag to update the input meshes
  59178. */
  59179. private _calculateMeshUVFrames;
  59180. /**
  59181. * Calculates the frames Offset.
  59182. * @param index of the frame
  59183. * @returns Vector2
  59184. */
  59185. private _getFrameOffset;
  59186. /**
  59187. * Updates a Mesh to the frame data
  59188. * @param mesh that is the target
  59189. * @param frameID or the frame index
  59190. */
  59191. private _updateMeshUV;
  59192. /**
  59193. * Updates a Meshes materials to use the texture packer channels
  59194. * @param m is the mesh to target
  59195. * @param force all channels on the packer to be set.
  59196. */
  59197. private _updateTextureReferences;
  59198. /**
  59199. * Public method to set a Mesh to a frame
  59200. * @param m that is the target
  59201. * @param frameID or the frame index
  59202. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59203. */
  59204. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59205. /**
  59206. * Starts the async promise to compile the texture packer.
  59207. * @returns Promise<void>
  59208. */
  59209. processAsync(): Promise<void>;
  59210. /**
  59211. * Disposes all textures associated with this packer
  59212. */
  59213. dispose(): void;
  59214. /**
  59215. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59216. * @param imageType is the image type to use.
  59217. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59218. */
  59219. download(imageType?: string, quality?: number): void;
  59220. /**
  59221. * Public method to load a texturePacker JSON file.
  59222. * @param data of the JSON file in string format.
  59223. */
  59224. updateFromJSON(data: string): void;
  59225. }
  59226. }
  59227. declare module "babylonjs/Materials/Textures/Packer/index" {
  59228. export * from "babylonjs/Materials/Textures/Packer/packer";
  59229. export * from "babylonjs/Materials/Textures/Packer/frame";
  59230. }
  59231. declare module "babylonjs/Materials/Textures/index" {
  59232. export * from "babylonjs/Materials/Textures/baseTexture";
  59233. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59234. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59235. export * from "babylonjs/Materials/Textures/cubeTexture";
  59236. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59237. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59238. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59239. export * from "babylonjs/Materials/Textures/internalTexture";
  59240. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59241. export * from "babylonjs/Materials/Textures/Loaders/index";
  59242. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59243. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59244. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59245. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59246. export * from "babylonjs/Materials/Textures/rawTexture";
  59247. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59248. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59249. export * from "babylonjs/Materials/Textures/refractionTexture";
  59250. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59251. export * from "babylonjs/Materials/Textures/texture";
  59252. export * from "babylonjs/Materials/Textures/videoTexture";
  59253. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59254. export * from "babylonjs/Materials/Textures/Packer/index";
  59255. }
  59256. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59257. /**
  59258. * Enum used to define the target of a block
  59259. */
  59260. export enum NodeMaterialBlockTargets {
  59261. /** Vertex shader */
  59262. Vertex = 1,
  59263. /** Fragment shader */
  59264. Fragment = 2,
  59265. /** Neutral */
  59266. Neutral = 4,
  59267. /** Vertex and Fragment */
  59268. VertexAndFragment = 3
  59269. }
  59270. }
  59271. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59272. /**
  59273. * Defines the kind of connection point for node based material
  59274. */
  59275. export enum NodeMaterialBlockConnectionPointTypes {
  59276. /** Float */
  59277. Float = 1,
  59278. /** Int */
  59279. Int = 2,
  59280. /** Vector2 */
  59281. Vector2 = 4,
  59282. /** Vector3 */
  59283. Vector3 = 8,
  59284. /** Vector4 */
  59285. Vector4 = 16,
  59286. /** Color3 */
  59287. Color3 = 32,
  59288. /** Color4 */
  59289. Color4 = 64,
  59290. /** Matrix */
  59291. Matrix = 128,
  59292. /** Detect type based on connection */
  59293. AutoDetect = 1024,
  59294. /** Output type that will be defined by input type */
  59295. BasedOnInput = 2048
  59296. }
  59297. }
  59298. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59299. /**
  59300. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59301. */
  59302. export enum NodeMaterialBlockConnectionPointMode {
  59303. /** Value is an uniform */
  59304. Uniform = 0,
  59305. /** Value is a mesh attribute */
  59306. Attribute = 1,
  59307. /** Value is a varying between vertex and fragment shaders */
  59308. Varying = 2,
  59309. /** Mode is undefined */
  59310. Undefined = 3
  59311. }
  59312. }
  59313. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59314. /**
  59315. * Enum used to define system values e.g. values automatically provided by the system
  59316. */
  59317. export enum NodeMaterialSystemValues {
  59318. /** World */
  59319. World = 1,
  59320. /** View */
  59321. View = 2,
  59322. /** Projection */
  59323. Projection = 3,
  59324. /** ViewProjection */
  59325. ViewProjection = 4,
  59326. /** WorldView */
  59327. WorldView = 5,
  59328. /** WorldViewProjection */
  59329. WorldViewProjection = 6,
  59330. /** CameraPosition */
  59331. CameraPosition = 7,
  59332. /** Fog Color */
  59333. FogColor = 8,
  59334. /** Delta time */
  59335. DeltaTime = 9
  59336. }
  59337. }
  59338. declare module "babylonjs/Materials/Node/Enums/index" {
  59339. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59340. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59341. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59342. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59343. }
  59344. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59346. /**
  59347. * Root class for all node material optimizers
  59348. */
  59349. export class NodeMaterialOptimizer {
  59350. /**
  59351. * Function used to optimize a NodeMaterial graph
  59352. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59353. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59354. */
  59355. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59356. }
  59357. }
  59358. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59362. import { Scene } from "babylonjs/scene";
  59363. /**
  59364. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59365. */
  59366. export class TransformBlock extends NodeMaterialBlock {
  59367. /**
  59368. * Defines the value to use to complement W value to transform it to a Vector4
  59369. */
  59370. complementW: number;
  59371. /**
  59372. * Defines the value to use to complement z value to transform it to a Vector4
  59373. */
  59374. complementZ: number;
  59375. /**
  59376. * Creates a new TransformBlock
  59377. * @param name defines the block name
  59378. */
  59379. constructor(name: string);
  59380. /**
  59381. * Gets the current class name
  59382. * @returns the class name
  59383. */
  59384. getClassName(): string;
  59385. /**
  59386. * Gets the vector input
  59387. */
  59388. get vector(): NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the output component
  59391. */
  59392. get output(): NodeMaterialConnectionPoint;
  59393. /**
  59394. * Gets the xyz output component
  59395. */
  59396. get xyz(): NodeMaterialConnectionPoint;
  59397. /**
  59398. * Gets the matrix transform input
  59399. */
  59400. get transform(): NodeMaterialConnectionPoint;
  59401. protected _buildBlock(state: NodeMaterialBuildState): this;
  59402. serialize(): any;
  59403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59404. protected _dumpPropertiesCode(): string;
  59405. }
  59406. }
  59407. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59411. /**
  59412. * Block used to output the vertex position
  59413. */
  59414. export class VertexOutputBlock extends NodeMaterialBlock {
  59415. /**
  59416. * Creates a new VertexOutputBlock
  59417. * @param name defines the block name
  59418. */
  59419. constructor(name: string);
  59420. /**
  59421. * Gets the current class name
  59422. * @returns the class name
  59423. */
  59424. getClassName(): string;
  59425. /**
  59426. * Gets the vector input component
  59427. */
  59428. get vector(): NodeMaterialConnectionPoint;
  59429. protected _buildBlock(state: NodeMaterialBuildState): this;
  59430. }
  59431. }
  59432. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59436. /**
  59437. * Block used to output the final color
  59438. */
  59439. export class FragmentOutputBlock extends NodeMaterialBlock {
  59440. /**
  59441. * Create a new FragmentOutputBlock
  59442. * @param name defines the block name
  59443. */
  59444. constructor(name: string);
  59445. /**
  59446. * Gets the current class name
  59447. * @returns the class name
  59448. */
  59449. getClassName(): string;
  59450. /**
  59451. * Gets the rgba input component
  59452. */
  59453. get rgba(): NodeMaterialConnectionPoint;
  59454. /**
  59455. * Gets the rgb input component
  59456. */
  59457. get rgb(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the a input component
  59460. */
  59461. get a(): NodeMaterialConnectionPoint;
  59462. protected _buildBlock(state: NodeMaterialBuildState): this;
  59463. }
  59464. }
  59465. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59471. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59472. import { Effect } from "babylonjs/Materials/effect";
  59473. import { Mesh } from "babylonjs/Meshes/mesh";
  59474. import { Nullable } from "babylonjs/types";
  59475. import { Scene } from "babylonjs/scene";
  59476. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59477. /**
  59478. * Block used to read a reflection texture from a sampler
  59479. */
  59480. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59481. private _define3DName;
  59482. private _defineCubicName;
  59483. private _defineExplicitName;
  59484. private _defineProjectionName;
  59485. private _defineLocalCubicName;
  59486. private _defineSphericalName;
  59487. private _definePlanarName;
  59488. private _defineEquirectangularName;
  59489. private _defineMirroredEquirectangularFixedName;
  59490. private _defineEquirectangularFixedName;
  59491. private _defineSkyboxName;
  59492. private _cubeSamplerName;
  59493. private _2DSamplerName;
  59494. private _positionUVWName;
  59495. private _directionWName;
  59496. private _reflectionCoordsName;
  59497. private _reflection2DCoordsName;
  59498. private _reflectionColorName;
  59499. private _reflectionMatrixName;
  59500. /**
  59501. * Gets or sets the texture associated with the node
  59502. */
  59503. texture: Nullable<BaseTexture>;
  59504. /**
  59505. * Create a new TextureBlock
  59506. * @param name defines the block name
  59507. */
  59508. constructor(name: string);
  59509. /**
  59510. * Gets the current class name
  59511. * @returns the class name
  59512. */
  59513. getClassName(): string;
  59514. /**
  59515. * Gets the world position input component
  59516. */
  59517. get position(): NodeMaterialConnectionPoint;
  59518. /**
  59519. * Gets the world position input component
  59520. */
  59521. get worldPosition(): NodeMaterialConnectionPoint;
  59522. /**
  59523. * Gets the world normal input component
  59524. */
  59525. get worldNormal(): NodeMaterialConnectionPoint;
  59526. /**
  59527. * Gets the world input component
  59528. */
  59529. get world(): NodeMaterialConnectionPoint;
  59530. /**
  59531. * Gets the camera (or eye) position component
  59532. */
  59533. get cameraPosition(): NodeMaterialConnectionPoint;
  59534. /**
  59535. * Gets the view input component
  59536. */
  59537. get view(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the rgb output component
  59540. */
  59541. get rgb(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the r output component
  59544. */
  59545. get r(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the g output component
  59548. */
  59549. get g(): NodeMaterialConnectionPoint;
  59550. /**
  59551. * Gets the b output component
  59552. */
  59553. get b(): NodeMaterialConnectionPoint;
  59554. autoConfigure(material: NodeMaterial): void;
  59555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59556. isReady(): boolean;
  59557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59558. private _injectVertexCode;
  59559. private _writeOutput;
  59560. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59561. protected _dumpPropertiesCode(): string;
  59562. serialize(): any;
  59563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59564. }
  59565. }
  59566. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59568. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59569. import { Scene } from "babylonjs/scene";
  59570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59571. import { Matrix } from "babylonjs/Maths/math.vector";
  59572. import { Mesh } from "babylonjs/Meshes/mesh";
  59573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59574. import { Observable } from "babylonjs/Misc/observable";
  59575. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59576. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59577. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59578. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59579. import { Nullable } from "babylonjs/types";
  59580. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59581. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59582. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59583. /**
  59584. * Interface used to configure the node material editor
  59585. */
  59586. export interface INodeMaterialEditorOptions {
  59587. /** Define the URl to load node editor script */
  59588. editorURL?: string;
  59589. }
  59590. /** @hidden */
  59591. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59592. NORMAL: boolean;
  59593. TANGENT: boolean;
  59594. UV1: boolean;
  59595. /** BONES */
  59596. NUM_BONE_INFLUENCERS: number;
  59597. BonesPerMesh: number;
  59598. BONETEXTURE: boolean;
  59599. /** MORPH TARGETS */
  59600. MORPHTARGETS: boolean;
  59601. MORPHTARGETS_NORMAL: boolean;
  59602. MORPHTARGETS_TANGENT: boolean;
  59603. MORPHTARGETS_UV: boolean;
  59604. NUM_MORPH_INFLUENCERS: number;
  59605. /** IMAGE PROCESSING */
  59606. IMAGEPROCESSING: boolean;
  59607. VIGNETTE: boolean;
  59608. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59609. VIGNETTEBLENDMODEOPAQUE: boolean;
  59610. TONEMAPPING: boolean;
  59611. TONEMAPPING_ACES: boolean;
  59612. CONTRAST: boolean;
  59613. EXPOSURE: boolean;
  59614. COLORCURVES: boolean;
  59615. COLORGRADING: boolean;
  59616. COLORGRADING3D: boolean;
  59617. SAMPLER3DGREENDEPTH: boolean;
  59618. SAMPLER3DBGRMAP: boolean;
  59619. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59620. /** MISC. */
  59621. BUMPDIRECTUV: number;
  59622. constructor();
  59623. setValue(name: string, value: boolean): void;
  59624. }
  59625. /**
  59626. * Class used to configure NodeMaterial
  59627. */
  59628. export interface INodeMaterialOptions {
  59629. /**
  59630. * Defines if blocks should emit comments
  59631. */
  59632. emitComments: boolean;
  59633. }
  59634. /**
  59635. * Class used to create a node based material built by assembling shader blocks
  59636. */
  59637. export class NodeMaterial extends PushMaterial {
  59638. private static _BuildIdGenerator;
  59639. private _options;
  59640. private _vertexCompilationState;
  59641. private _fragmentCompilationState;
  59642. private _sharedData;
  59643. private _buildId;
  59644. private _buildWasSuccessful;
  59645. private _cachedWorldViewMatrix;
  59646. private _cachedWorldViewProjectionMatrix;
  59647. private _optimizers;
  59648. private _animationFrame;
  59649. /** Define the Url to load node editor script */
  59650. static EditorURL: string;
  59651. /** Define the Url to load snippets */
  59652. static SnippetUrl: string;
  59653. private BJSNODEMATERIALEDITOR;
  59654. /** Get the inspector from bundle or global */
  59655. private _getGlobalNodeMaterialEditor;
  59656. /**
  59657. * Gets or sets data used by visual editor
  59658. * @see https://nme.babylonjs.com
  59659. */
  59660. editorData: any;
  59661. /**
  59662. * 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)
  59663. */
  59664. ignoreAlpha: boolean;
  59665. /**
  59666. * Defines the maximum number of lights that can be used in the material
  59667. */
  59668. maxSimultaneousLights: number;
  59669. /**
  59670. * Observable raised when the material is built
  59671. */
  59672. onBuildObservable: Observable<NodeMaterial>;
  59673. /**
  59674. * Gets or sets the root nodes of the material vertex shader
  59675. */
  59676. _vertexOutputNodes: NodeMaterialBlock[];
  59677. /**
  59678. * Gets or sets the root nodes of the material fragment (pixel) shader
  59679. */
  59680. _fragmentOutputNodes: NodeMaterialBlock[];
  59681. /** Gets or sets options to control the node material overall behavior */
  59682. get options(): INodeMaterialOptions;
  59683. set options(options: INodeMaterialOptions);
  59684. /**
  59685. * Default configuration related to image processing available in the standard Material.
  59686. */
  59687. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59688. /**
  59689. * Gets the image processing configuration used either in this material.
  59690. */
  59691. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59692. /**
  59693. * Sets the Default image processing configuration used either in the this material.
  59694. *
  59695. * If sets to null, the scene one is in use.
  59696. */
  59697. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59698. /**
  59699. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59700. */
  59701. attachedBlocks: NodeMaterialBlock[];
  59702. /**
  59703. * Create a new node based material
  59704. * @param name defines the material name
  59705. * @param scene defines the hosting scene
  59706. * @param options defines creation option
  59707. */
  59708. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59709. /**
  59710. * Gets the current class name of the material e.g. "NodeMaterial"
  59711. * @returns the class name
  59712. */
  59713. getClassName(): string;
  59714. /**
  59715. * Keep track of the image processing observer to allow dispose and replace.
  59716. */
  59717. private _imageProcessingObserver;
  59718. /**
  59719. * Attaches a new image processing configuration to the Standard Material.
  59720. * @param configuration
  59721. */
  59722. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59723. /**
  59724. * Get a block by its name
  59725. * @param name defines the name of the block to retrieve
  59726. * @returns the required block or null if not found
  59727. */
  59728. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59729. /**
  59730. * Get a block by its name
  59731. * @param predicate defines the predicate used to find the good candidate
  59732. * @returns the required block or null if not found
  59733. */
  59734. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59735. /**
  59736. * Get an input block by its name
  59737. * @param predicate defines the predicate used to find the good candidate
  59738. * @returns the required input block or null if not found
  59739. */
  59740. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59741. /**
  59742. * Gets the list of input blocks attached to this material
  59743. * @returns an array of InputBlocks
  59744. */
  59745. getInputBlocks(): InputBlock[];
  59746. /**
  59747. * Adds a new optimizer to the list of optimizers
  59748. * @param optimizer defines the optimizers to add
  59749. * @returns the current material
  59750. */
  59751. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59752. /**
  59753. * Remove an optimizer from the list of optimizers
  59754. * @param optimizer defines the optimizers to remove
  59755. * @returns the current material
  59756. */
  59757. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59758. /**
  59759. * Add a new block to the list of output nodes
  59760. * @param node defines the node to add
  59761. * @returns the current material
  59762. */
  59763. addOutputNode(node: NodeMaterialBlock): this;
  59764. /**
  59765. * Remove a block from the list of root nodes
  59766. * @param node defines the node to remove
  59767. * @returns the current material
  59768. */
  59769. removeOutputNode(node: NodeMaterialBlock): this;
  59770. private _addVertexOutputNode;
  59771. private _removeVertexOutputNode;
  59772. private _addFragmentOutputNode;
  59773. private _removeFragmentOutputNode;
  59774. /**
  59775. * Specifies if the material will require alpha blending
  59776. * @returns a boolean specifying if alpha blending is needed
  59777. */
  59778. needAlphaBlending(): boolean;
  59779. /**
  59780. * Specifies if this material should be rendered in alpha test mode
  59781. * @returns a boolean specifying if an alpha test is needed.
  59782. */
  59783. needAlphaTesting(): boolean;
  59784. private _initializeBlock;
  59785. private _resetDualBlocks;
  59786. /**
  59787. * Remove a block from the current node material
  59788. * @param block defines the block to remove
  59789. */
  59790. removeBlock(block: NodeMaterialBlock): void;
  59791. /**
  59792. * Build the material and generates the inner effect
  59793. * @param verbose defines if the build should log activity
  59794. */
  59795. build(verbose?: boolean): void;
  59796. /**
  59797. * Runs an otpimization phase to try to improve the shader code
  59798. */
  59799. optimize(): void;
  59800. private _prepareDefinesForAttributes;
  59801. /**
  59802. * Get if the submesh is ready to be used and all its information available.
  59803. * Child classes can use it to update shaders
  59804. * @param mesh defines the mesh to check
  59805. * @param subMesh defines which submesh to check
  59806. * @param useInstances specifies that instances should be used
  59807. * @returns a boolean indicating that the submesh is ready or not
  59808. */
  59809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59810. /**
  59811. * Get a string representing the shaders built by the current node graph
  59812. */
  59813. get compiledShaders(): string;
  59814. /**
  59815. * Binds the world matrix to the material
  59816. * @param world defines the world transformation matrix
  59817. */
  59818. bindOnlyWorldMatrix(world: Matrix): void;
  59819. /**
  59820. * Binds the submesh to this material by preparing the effect and shader to draw
  59821. * @param world defines the world transformation matrix
  59822. * @param mesh defines the mesh containing the submesh
  59823. * @param subMesh defines the submesh to bind the material to
  59824. */
  59825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59826. /**
  59827. * Gets the active textures from the material
  59828. * @returns an array of textures
  59829. */
  59830. getActiveTextures(): BaseTexture[];
  59831. /**
  59832. * Gets the list of texture blocks
  59833. * @returns an array of texture blocks
  59834. */
  59835. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59836. /**
  59837. * Specifies if the material uses a texture
  59838. * @param texture defines the texture to check against the material
  59839. * @returns a boolean specifying if the material uses the texture
  59840. */
  59841. hasTexture(texture: BaseTexture): boolean;
  59842. /**
  59843. * Disposes the material
  59844. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59845. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59846. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59847. */
  59848. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59849. /** Creates the node editor window. */
  59850. private _createNodeEditor;
  59851. /**
  59852. * Launch the node material editor
  59853. * @param config Define the configuration of the editor
  59854. * @return a promise fulfilled when the node editor is visible
  59855. */
  59856. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59857. /**
  59858. * Clear the current material
  59859. */
  59860. clear(): void;
  59861. /**
  59862. * Clear the current material and set it to a default state
  59863. */
  59864. setToDefault(): void;
  59865. /**
  59866. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59867. * @param url defines the url to load from
  59868. * @returns a promise that will fullfil when the material is fully loaded
  59869. */
  59870. loadAsync(url: string): Promise<void>;
  59871. private _gatherBlocks;
  59872. /**
  59873. * Generate a string containing the code declaration required to create an equivalent of this material
  59874. * @returns a string
  59875. */
  59876. generateCode(): string;
  59877. /**
  59878. * Serializes this material in a JSON representation
  59879. * @returns the serialized material object
  59880. */
  59881. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59882. private _restoreConnections;
  59883. /**
  59884. * Clear the current graph and load a new one from a serialization object
  59885. * @param source defines the JSON representation of the material
  59886. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59887. */
  59888. loadFromSerialization(source: any, rootUrl?: string): void;
  59889. /**
  59890. * Creates a node material from parsed material data
  59891. * @param source defines the JSON representation of the material
  59892. * @param scene defines the hosting scene
  59893. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59894. * @returns a new node material
  59895. */
  59896. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59897. /**
  59898. * Creates a node material from a snippet saved in a remote file
  59899. * @param name defines the name of the material to create
  59900. * @param url defines the url to load from
  59901. * @param scene defines the hosting scene
  59902. * @returns a promise that will resolve to the new node material
  59903. */
  59904. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59905. /**
  59906. * Creates a node material from a snippet saved by the node material editor
  59907. * @param snippetId defines the snippet to load
  59908. * @param scene defines the hosting scene
  59909. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59910. * @returns a promise that will resolve to the new node material
  59911. */
  59912. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59913. /**
  59914. * Creates a new node material set to default basic configuration
  59915. * @param name defines the name of the material
  59916. * @param scene defines the hosting scene
  59917. * @returns a new NodeMaterial
  59918. */
  59919. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59920. }
  59921. }
  59922. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59925. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59928. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59929. import { Effect } from "babylonjs/Materials/effect";
  59930. import { Mesh } from "babylonjs/Meshes/mesh";
  59931. import { Nullable } from "babylonjs/types";
  59932. import { Texture } from "babylonjs/Materials/Textures/texture";
  59933. import { Scene } from "babylonjs/scene";
  59934. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59935. /**
  59936. * Block used to read a texture from a sampler
  59937. */
  59938. export class TextureBlock extends NodeMaterialBlock {
  59939. private _defineName;
  59940. private _linearDefineName;
  59941. private _tempTextureRead;
  59942. private _samplerName;
  59943. private _transformedUVName;
  59944. private _textureTransformName;
  59945. private _textureInfoName;
  59946. private _mainUVName;
  59947. private _mainUVDefineName;
  59948. /**
  59949. * Gets or sets the texture associated with the node
  59950. */
  59951. texture: Nullable<Texture>;
  59952. /**
  59953. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59954. */
  59955. convertToGammaSpace: boolean;
  59956. /**
  59957. * Create a new TextureBlock
  59958. * @param name defines the block name
  59959. */
  59960. constructor(name: string);
  59961. /**
  59962. * Gets the current class name
  59963. * @returns the class name
  59964. */
  59965. getClassName(): string;
  59966. /**
  59967. * Gets the uv input component
  59968. */
  59969. get uv(): NodeMaterialConnectionPoint;
  59970. /**
  59971. * Gets the rgba output component
  59972. */
  59973. get rgba(): NodeMaterialConnectionPoint;
  59974. /**
  59975. * Gets the rgb output component
  59976. */
  59977. get rgb(): NodeMaterialConnectionPoint;
  59978. /**
  59979. * Gets the r output component
  59980. */
  59981. get r(): NodeMaterialConnectionPoint;
  59982. /**
  59983. * Gets the g output component
  59984. */
  59985. get g(): NodeMaterialConnectionPoint;
  59986. /**
  59987. * Gets the b output component
  59988. */
  59989. get b(): NodeMaterialConnectionPoint;
  59990. /**
  59991. * Gets the a output component
  59992. */
  59993. get a(): NodeMaterialConnectionPoint;
  59994. get target(): NodeMaterialBlockTargets;
  59995. autoConfigure(material: NodeMaterial): void;
  59996. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59998. isReady(): boolean;
  59999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60000. private get _isMixed();
  60001. private _injectVertexCode;
  60002. private _writeTextureRead;
  60003. private _writeOutput;
  60004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60005. protected _dumpPropertiesCode(): string;
  60006. serialize(): any;
  60007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60008. }
  60009. }
  60010. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60013. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60014. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60015. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60016. import { Scene } from "babylonjs/scene";
  60017. /**
  60018. * Class used to store shared data between 2 NodeMaterialBuildState
  60019. */
  60020. export class NodeMaterialBuildStateSharedData {
  60021. /**
  60022. * Gets the list of emitted varyings
  60023. */
  60024. temps: string[];
  60025. /**
  60026. * Gets the list of emitted varyings
  60027. */
  60028. varyings: string[];
  60029. /**
  60030. * Gets the varying declaration string
  60031. */
  60032. varyingDeclaration: string;
  60033. /**
  60034. * Input blocks
  60035. */
  60036. inputBlocks: InputBlock[];
  60037. /**
  60038. * Input blocks
  60039. */
  60040. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60041. /**
  60042. * Bindable blocks (Blocks that need to set data to the effect)
  60043. */
  60044. bindableBlocks: NodeMaterialBlock[];
  60045. /**
  60046. * List of blocks that can provide a compilation fallback
  60047. */
  60048. blocksWithFallbacks: NodeMaterialBlock[];
  60049. /**
  60050. * List of blocks that can provide a define update
  60051. */
  60052. blocksWithDefines: NodeMaterialBlock[];
  60053. /**
  60054. * List of blocks that can provide a repeatable content
  60055. */
  60056. repeatableContentBlocks: NodeMaterialBlock[];
  60057. /**
  60058. * List of blocks that can provide a dynamic list of uniforms
  60059. */
  60060. dynamicUniformBlocks: NodeMaterialBlock[];
  60061. /**
  60062. * List of blocks that can block the isReady function for the material
  60063. */
  60064. blockingBlocks: NodeMaterialBlock[];
  60065. /**
  60066. * Gets the list of animated inputs
  60067. */
  60068. animatedInputs: InputBlock[];
  60069. /**
  60070. * Build Id used to avoid multiple recompilations
  60071. */
  60072. buildId: number;
  60073. /** List of emitted variables */
  60074. variableNames: {
  60075. [key: string]: number;
  60076. };
  60077. /** List of emitted defines */
  60078. defineNames: {
  60079. [key: string]: number;
  60080. };
  60081. /** Should emit comments? */
  60082. emitComments: boolean;
  60083. /** Emit build activity */
  60084. verbose: boolean;
  60085. /** Gets or sets the hosting scene */
  60086. scene: Scene;
  60087. /**
  60088. * Gets the compilation hints emitted at compilation time
  60089. */
  60090. hints: {
  60091. needWorldViewMatrix: boolean;
  60092. needWorldViewProjectionMatrix: boolean;
  60093. needAlphaBlending: boolean;
  60094. needAlphaTesting: boolean;
  60095. };
  60096. /**
  60097. * List of compilation checks
  60098. */
  60099. checks: {
  60100. emitVertex: boolean;
  60101. emitFragment: boolean;
  60102. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60103. };
  60104. /** Creates a new shared data */
  60105. constructor();
  60106. /**
  60107. * Emits console errors and exceptions if there is a failing check
  60108. */
  60109. emitErrors(): void;
  60110. }
  60111. }
  60112. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60113. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60114. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60115. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60116. /**
  60117. * Class used to store node based material build state
  60118. */
  60119. export class NodeMaterialBuildState {
  60120. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60121. supportUniformBuffers: boolean;
  60122. /**
  60123. * Gets the list of emitted attributes
  60124. */
  60125. attributes: string[];
  60126. /**
  60127. * Gets the list of emitted uniforms
  60128. */
  60129. uniforms: string[];
  60130. /**
  60131. * Gets the list of emitted constants
  60132. */
  60133. constants: string[];
  60134. /**
  60135. * Gets the list of emitted samplers
  60136. */
  60137. samplers: string[];
  60138. /**
  60139. * Gets the list of emitted functions
  60140. */
  60141. functions: {
  60142. [key: string]: string;
  60143. };
  60144. /**
  60145. * Gets the list of emitted extensions
  60146. */
  60147. extensions: {
  60148. [key: string]: string;
  60149. };
  60150. /**
  60151. * Gets the target of the compilation state
  60152. */
  60153. target: NodeMaterialBlockTargets;
  60154. /**
  60155. * Gets the list of emitted counters
  60156. */
  60157. counters: {
  60158. [key: string]: number;
  60159. };
  60160. /**
  60161. * Shared data between multiple NodeMaterialBuildState instances
  60162. */
  60163. sharedData: NodeMaterialBuildStateSharedData;
  60164. /** @hidden */
  60165. _vertexState: NodeMaterialBuildState;
  60166. /** @hidden */
  60167. _attributeDeclaration: string;
  60168. /** @hidden */
  60169. _uniformDeclaration: string;
  60170. /** @hidden */
  60171. _constantDeclaration: string;
  60172. /** @hidden */
  60173. _samplerDeclaration: string;
  60174. /** @hidden */
  60175. _varyingTransfer: string;
  60176. private _repeatableContentAnchorIndex;
  60177. /** @hidden */
  60178. _builtCompilationString: string;
  60179. /**
  60180. * Gets the emitted compilation strings
  60181. */
  60182. compilationString: string;
  60183. /**
  60184. * Finalize the compilation strings
  60185. * @param state defines the current compilation state
  60186. */
  60187. finalize(state: NodeMaterialBuildState): void;
  60188. /** @hidden */
  60189. get _repeatableContentAnchor(): string;
  60190. /** @hidden */
  60191. _getFreeVariableName(prefix: string): string;
  60192. /** @hidden */
  60193. _getFreeDefineName(prefix: string): string;
  60194. /** @hidden */
  60195. _excludeVariableName(name: string): void;
  60196. /** @hidden */
  60197. _emit2DSampler(name: string): void;
  60198. /** @hidden */
  60199. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60200. /** @hidden */
  60201. _emitExtension(name: string, extension: string): void;
  60202. /** @hidden */
  60203. _emitFunction(name: string, code: string, comments: string): void;
  60204. /** @hidden */
  60205. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60206. replaceStrings?: {
  60207. search: RegExp;
  60208. replace: string;
  60209. }[];
  60210. repeatKey?: string;
  60211. }): string;
  60212. /** @hidden */
  60213. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60214. repeatKey?: string;
  60215. removeAttributes?: boolean;
  60216. removeUniforms?: boolean;
  60217. removeVaryings?: boolean;
  60218. removeIfDef?: boolean;
  60219. replaceStrings?: {
  60220. search: RegExp;
  60221. replace: string;
  60222. }[];
  60223. }, storeKey?: string): void;
  60224. /** @hidden */
  60225. _registerTempVariable(name: string): boolean;
  60226. /** @hidden */
  60227. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60228. /** @hidden */
  60229. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60230. /** @hidden */
  60231. _emitFloat(value: number): string;
  60232. }
  60233. }
  60234. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60235. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60237. import { Nullable } from "babylonjs/types";
  60238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60239. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60240. import { Effect } from "babylonjs/Materials/effect";
  60241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60242. import { Mesh } from "babylonjs/Meshes/mesh";
  60243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60244. import { Scene } from "babylonjs/scene";
  60245. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60246. /**
  60247. * Defines a block that can be used inside a node based material
  60248. */
  60249. export class NodeMaterialBlock {
  60250. private _buildId;
  60251. private _buildTarget;
  60252. private _target;
  60253. private _isFinalMerger;
  60254. private _isInput;
  60255. protected _isUnique: boolean;
  60256. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60257. inputsAreExclusive: boolean;
  60258. /** @hidden */
  60259. _codeVariableName: string;
  60260. /** @hidden */
  60261. _inputs: NodeMaterialConnectionPoint[];
  60262. /** @hidden */
  60263. _outputs: NodeMaterialConnectionPoint[];
  60264. /** @hidden */
  60265. _preparationId: number;
  60266. /**
  60267. * Gets or sets the name of the block
  60268. */
  60269. name: string;
  60270. /**
  60271. * Gets or sets the unique id of the node
  60272. */
  60273. uniqueId: number;
  60274. /**
  60275. * Gets or sets the comments associated with this block
  60276. */
  60277. comments: string;
  60278. /**
  60279. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60280. */
  60281. get isUnique(): boolean;
  60282. /**
  60283. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60284. */
  60285. get isFinalMerger(): boolean;
  60286. /**
  60287. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60288. */
  60289. get isInput(): boolean;
  60290. /**
  60291. * Gets or sets the build Id
  60292. */
  60293. get buildId(): number;
  60294. set buildId(value: number);
  60295. /**
  60296. * Gets or sets the target of the block
  60297. */
  60298. get target(): NodeMaterialBlockTargets;
  60299. set target(value: NodeMaterialBlockTargets);
  60300. /**
  60301. * Gets the list of input points
  60302. */
  60303. get inputs(): NodeMaterialConnectionPoint[];
  60304. /** Gets the list of output points */
  60305. get outputs(): NodeMaterialConnectionPoint[];
  60306. /**
  60307. * Find an input by its name
  60308. * @param name defines the name of the input to look for
  60309. * @returns the input or null if not found
  60310. */
  60311. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60312. /**
  60313. * Find an output by its name
  60314. * @param name defines the name of the outputto look for
  60315. * @returns the output or null if not found
  60316. */
  60317. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60318. /**
  60319. * Creates a new NodeMaterialBlock
  60320. * @param name defines the block name
  60321. * @param target defines the target of that block (Vertex by default)
  60322. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60323. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60324. */
  60325. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60326. /**
  60327. * Initialize the block and prepare the context for build
  60328. * @param state defines the state that will be used for the build
  60329. */
  60330. initialize(state: NodeMaterialBuildState): void;
  60331. /**
  60332. * Bind data to effect. Will only be called for blocks with isBindable === true
  60333. * @param effect defines the effect to bind data to
  60334. * @param nodeMaterial defines the hosting NodeMaterial
  60335. * @param mesh defines the mesh that will be rendered
  60336. */
  60337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60338. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60339. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60340. protected _writeFloat(value: number): string;
  60341. /**
  60342. * Gets the current class name e.g. "NodeMaterialBlock"
  60343. * @returns the class name
  60344. */
  60345. getClassName(): string;
  60346. /**
  60347. * Register a new input. Must be called inside a block constructor
  60348. * @param name defines the connection point name
  60349. * @param type defines the connection point type
  60350. * @param isOptional defines a boolean indicating that this input can be omitted
  60351. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60352. * @returns the current block
  60353. */
  60354. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60355. /**
  60356. * Register a new output. Must be called inside a block constructor
  60357. * @param name defines the connection point name
  60358. * @param type defines the connection point type
  60359. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60360. * @returns the current block
  60361. */
  60362. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60363. /**
  60364. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60365. * @param forOutput defines an optional connection point to check compatibility with
  60366. * @returns the first available input or null
  60367. */
  60368. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60369. /**
  60370. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60371. * @param forBlock defines an optional block to check compatibility with
  60372. * @returns the first available input or null
  60373. */
  60374. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60375. /**
  60376. * Gets the sibling of the given output
  60377. * @param current defines the current output
  60378. * @returns the next output in the list or null
  60379. */
  60380. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60381. /**
  60382. * Connect current block with another block
  60383. * @param other defines the block to connect with
  60384. * @param options define the various options to help pick the right connections
  60385. * @returns the current block
  60386. */
  60387. connectTo(other: NodeMaterialBlock, options?: {
  60388. input?: string;
  60389. output?: string;
  60390. outputSwizzle?: string;
  60391. }): this | undefined;
  60392. protected _buildBlock(state: NodeMaterialBuildState): void;
  60393. /**
  60394. * Add uniforms, samplers and uniform buffers at compilation time
  60395. * @param state defines the state to update
  60396. * @param nodeMaterial defines the node material requesting the update
  60397. * @param defines defines the material defines to update
  60398. * @param uniformBuffers defines the list of uniform buffer names
  60399. */
  60400. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60401. /**
  60402. * Add potential fallbacks if shader compilation fails
  60403. * @param mesh defines the mesh to be rendered
  60404. * @param fallbacks defines the current prioritized list of fallbacks
  60405. */
  60406. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60407. /**
  60408. * Initialize defines for shader compilation
  60409. * @param mesh defines the mesh to be rendered
  60410. * @param nodeMaterial defines the node material requesting the update
  60411. * @param defines defines the material defines to update
  60412. * @param useInstances specifies that instances should be used
  60413. */
  60414. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60415. /**
  60416. * Update defines for shader compilation
  60417. * @param mesh defines the mesh to be rendered
  60418. * @param nodeMaterial defines the node material requesting the update
  60419. * @param defines defines the material defines to update
  60420. * @param useInstances specifies that instances should be used
  60421. */
  60422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60423. /**
  60424. * Lets the block try to connect some inputs automatically
  60425. * @param material defines the hosting NodeMaterial
  60426. */
  60427. autoConfigure(material: NodeMaterial): void;
  60428. /**
  60429. * Function called when a block is declared as repeatable content generator
  60430. * @param vertexShaderState defines the current compilation state for the vertex shader
  60431. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60432. * @param mesh defines the mesh to be rendered
  60433. * @param defines defines the material defines to update
  60434. */
  60435. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60436. /**
  60437. * Checks if the block is ready
  60438. * @param mesh defines the mesh to be rendered
  60439. * @param nodeMaterial defines the node material requesting the update
  60440. * @param defines defines the material defines to update
  60441. * @param useInstances specifies that instances should be used
  60442. * @returns true if the block is ready
  60443. */
  60444. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60445. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60446. private _processBuild;
  60447. /**
  60448. * Compile the current node and generate the shader code
  60449. * @param state defines the current compilation state (uniforms, samplers, current string)
  60450. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60451. * @returns true if already built
  60452. */
  60453. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60454. protected _inputRename(name: string): string;
  60455. protected _outputRename(name: string): string;
  60456. protected _dumpPropertiesCode(): string;
  60457. /** @hidden */
  60458. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60459. /** @hidden */
  60460. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60461. /**
  60462. * Clone the current block to a new identical block
  60463. * @param scene defines the hosting scene
  60464. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60465. * @returns a copy of the current block
  60466. */
  60467. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60468. /**
  60469. * Serializes this block in a JSON representation
  60470. * @returns the serialized block object
  60471. */
  60472. serialize(): any;
  60473. /** @hidden */
  60474. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60475. /**
  60476. * Release resources
  60477. */
  60478. dispose(): void;
  60479. }
  60480. }
  60481. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60482. /**
  60483. * Enum defining the type of animations supported by InputBlock
  60484. */
  60485. export enum AnimatedInputBlockTypes {
  60486. /** No animation */
  60487. None = 0,
  60488. /** Time based animation. Will only work for floats */
  60489. Time = 1
  60490. }
  60491. }
  60492. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60494. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60495. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60496. import { Nullable } from "babylonjs/types";
  60497. import { Effect } from "babylonjs/Materials/effect";
  60498. import { Matrix } from "babylonjs/Maths/math.vector";
  60499. import { Scene } from "babylonjs/scene";
  60500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60502. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60503. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60504. import { Observable } from "babylonjs/Misc/observable";
  60505. /**
  60506. * Block used to expose an input value
  60507. */
  60508. export class InputBlock extends NodeMaterialBlock {
  60509. private _mode;
  60510. private _associatedVariableName;
  60511. private _storedValue;
  60512. private _valueCallback;
  60513. private _type;
  60514. private _animationType;
  60515. /** Gets or set a value used to limit the range of float values */
  60516. min: number;
  60517. /** Gets or set a value used to limit the range of float values */
  60518. max: number;
  60519. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60520. isBoolean: boolean;
  60521. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60522. matrixMode: number;
  60523. /** @hidden */
  60524. _systemValue: Nullable<NodeMaterialSystemValues>;
  60525. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60526. visibleInInspector: boolean;
  60527. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60528. isConstant: boolean;
  60529. /** Gets or sets the group to use to display this block in the Inspector */
  60530. groupInInspector: string;
  60531. /** Gets an observable raised when the value is changed */
  60532. onValueChangedObservable: Observable<InputBlock>;
  60533. /**
  60534. * Gets or sets the connection point type (default is float)
  60535. */
  60536. get type(): NodeMaterialBlockConnectionPointTypes;
  60537. /**
  60538. * Creates a new InputBlock
  60539. * @param name defines the block name
  60540. * @param target defines the target of that block (Vertex by default)
  60541. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60542. */
  60543. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60544. /**
  60545. * Gets the output component
  60546. */
  60547. get output(): NodeMaterialConnectionPoint;
  60548. /**
  60549. * Set the source of this connection point to a vertex attribute
  60550. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60551. * @returns the current connection point
  60552. */
  60553. setAsAttribute(attributeName?: string): InputBlock;
  60554. /**
  60555. * Set the source of this connection point to a system value
  60556. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60557. * @returns the current connection point
  60558. */
  60559. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60560. /**
  60561. * Gets or sets the value of that point.
  60562. * Please note that this value will be ignored if valueCallback is defined
  60563. */
  60564. get value(): any;
  60565. set value(value: any);
  60566. /**
  60567. * Gets or sets a callback used to get the value of that point.
  60568. * Please note that setting this value will force the connection point to ignore the value property
  60569. */
  60570. get valueCallback(): () => any;
  60571. set valueCallback(value: () => any);
  60572. /**
  60573. * Gets or sets the associated variable name in the shader
  60574. */
  60575. get associatedVariableName(): string;
  60576. set associatedVariableName(value: string);
  60577. /** Gets or sets the type of animation applied to the input */
  60578. get animationType(): AnimatedInputBlockTypes;
  60579. set animationType(value: AnimatedInputBlockTypes);
  60580. /**
  60581. * Gets a boolean indicating that this connection point not defined yet
  60582. */
  60583. get isUndefined(): boolean;
  60584. /**
  60585. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60586. * In this case the connection point name must be the name of the uniform to use.
  60587. * Can only be set on inputs
  60588. */
  60589. get isUniform(): boolean;
  60590. set isUniform(value: boolean);
  60591. /**
  60592. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60593. * In this case the connection point name must be the name of the attribute to use
  60594. * Can only be set on inputs
  60595. */
  60596. get isAttribute(): boolean;
  60597. set isAttribute(value: boolean);
  60598. /**
  60599. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60600. * Can only be set on exit points
  60601. */
  60602. get isVarying(): boolean;
  60603. set isVarying(value: boolean);
  60604. /**
  60605. * Gets a boolean indicating that the current connection point is a system value
  60606. */
  60607. get isSystemValue(): boolean;
  60608. /**
  60609. * Gets or sets the current well known value or null if not defined as a system value
  60610. */
  60611. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60612. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60613. /**
  60614. * Gets the current class name
  60615. * @returns the class name
  60616. */
  60617. getClassName(): string;
  60618. /**
  60619. * Animate the input if animationType !== None
  60620. * @param scene defines the rendering scene
  60621. */
  60622. animate(scene: Scene): void;
  60623. private _emitDefine;
  60624. initialize(state: NodeMaterialBuildState): void;
  60625. /**
  60626. * Set the input block to its default value (based on its type)
  60627. */
  60628. setDefaultValue(): void;
  60629. private _emitConstant;
  60630. private _emit;
  60631. /** @hidden */
  60632. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60633. /** @hidden */
  60634. _transmit(effect: Effect, scene: Scene): void;
  60635. protected _buildBlock(state: NodeMaterialBuildState): void;
  60636. protected _dumpPropertiesCode(): string;
  60637. dispose(): void;
  60638. serialize(): any;
  60639. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60640. }
  60641. }
  60642. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60643. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60644. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60645. import { Nullable } from "babylonjs/types";
  60646. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60647. import { Observable } from "babylonjs/Misc/observable";
  60648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60649. /**
  60650. * Enum used to define the compatibility state between two connection points
  60651. */
  60652. export enum NodeMaterialConnectionPointCompatibilityStates {
  60653. /** Points are compatibles */
  60654. Compatible = 0,
  60655. /** Points are incompatible because of their types */
  60656. TypeIncompatible = 1,
  60657. /** Points are incompatible because of their targets (vertex vs fragment) */
  60658. TargetIncompatible = 2
  60659. }
  60660. /**
  60661. * Defines the direction of a connection point
  60662. */
  60663. export enum NodeMaterialConnectionPointDirection {
  60664. /** Input */
  60665. Input = 0,
  60666. /** Output */
  60667. Output = 1
  60668. }
  60669. /**
  60670. * Defines a connection point for a block
  60671. */
  60672. export class NodeMaterialConnectionPoint {
  60673. /** @hidden */
  60674. _ownerBlock: NodeMaterialBlock;
  60675. /** @hidden */
  60676. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60677. private _endpoints;
  60678. private _associatedVariableName;
  60679. private _direction;
  60680. /** @hidden */
  60681. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60682. /** @hidden */
  60683. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60684. private _type;
  60685. /** @hidden */
  60686. _enforceAssociatedVariableName: boolean;
  60687. /** Gets the direction of the point */
  60688. get direction(): NodeMaterialConnectionPointDirection;
  60689. /**
  60690. * Gets or sets the additional types supported by this connection point
  60691. */
  60692. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60693. /**
  60694. * Gets or sets the additional types excluded by this connection point
  60695. */
  60696. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60697. /**
  60698. * Observable triggered when this point is connected
  60699. */
  60700. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60701. /**
  60702. * Gets or sets the associated variable name in the shader
  60703. */
  60704. get associatedVariableName(): string;
  60705. set associatedVariableName(value: string);
  60706. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60707. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60708. /**
  60709. * Gets or sets the connection point type (default is float)
  60710. */
  60711. get type(): NodeMaterialBlockConnectionPointTypes;
  60712. set type(value: NodeMaterialBlockConnectionPointTypes);
  60713. /**
  60714. * Gets or sets the connection point name
  60715. */
  60716. name: string;
  60717. /**
  60718. * Gets or sets a boolean indicating that this connection point can be omitted
  60719. */
  60720. isOptional: boolean;
  60721. /**
  60722. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60723. */
  60724. define: string;
  60725. /** @hidden */
  60726. _prioritizeVertex: boolean;
  60727. private _target;
  60728. /** Gets or sets the target of that connection point */
  60729. get target(): NodeMaterialBlockTargets;
  60730. set target(value: NodeMaterialBlockTargets);
  60731. /**
  60732. * Gets a boolean indicating that the current point is connected
  60733. */
  60734. get isConnected(): boolean;
  60735. /**
  60736. * Gets a boolean indicating that the current point is connected to an input block
  60737. */
  60738. get isConnectedToInputBlock(): boolean;
  60739. /**
  60740. * Gets a the connected input block (if any)
  60741. */
  60742. get connectInputBlock(): Nullable<InputBlock>;
  60743. /** Get the other side of the connection (if any) */
  60744. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60745. /** Get the block that owns this connection point */
  60746. get ownerBlock(): NodeMaterialBlock;
  60747. /** Get the block connected on the other side of this connection (if any) */
  60748. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60749. /** Get the block connected on the endpoints of this connection (if any) */
  60750. get connectedBlocks(): Array<NodeMaterialBlock>;
  60751. /** Gets the list of connected endpoints */
  60752. get endpoints(): NodeMaterialConnectionPoint[];
  60753. /** Gets a boolean indicating if that output point is connected to at least one input */
  60754. get hasEndpoints(): boolean;
  60755. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60756. get isConnectedInVertexShader(): boolean;
  60757. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60758. get isConnectedInFragmentShader(): boolean;
  60759. /**
  60760. * Creates a new connection point
  60761. * @param name defines the connection point name
  60762. * @param ownerBlock defines the block hosting this connection point
  60763. * @param direction defines the direction of the connection point
  60764. */
  60765. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60766. /**
  60767. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60768. * @returns the class name
  60769. */
  60770. getClassName(): string;
  60771. /**
  60772. * Gets a boolean indicating if the current point can be connected to another point
  60773. * @param connectionPoint defines the other connection point
  60774. * @returns a boolean
  60775. */
  60776. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60777. /**
  60778. * Gets a number indicating if the current point can be connected to another point
  60779. * @param connectionPoint defines the other connection point
  60780. * @returns a number defining the compatibility state
  60781. */
  60782. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60783. /**
  60784. * Connect this point to another connection point
  60785. * @param connectionPoint defines the other connection point
  60786. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60787. * @returns the current connection point
  60788. */
  60789. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60790. /**
  60791. * Disconnect this point from one of his endpoint
  60792. * @param endpoint defines the other connection point
  60793. * @returns the current connection point
  60794. */
  60795. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60796. /**
  60797. * Serializes this point in a JSON representation
  60798. * @returns the serialized point object
  60799. */
  60800. serialize(): any;
  60801. /**
  60802. * Release resources
  60803. */
  60804. dispose(): void;
  60805. }
  60806. }
  60807. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60811. import { Mesh } from "babylonjs/Meshes/mesh";
  60812. import { Effect } from "babylonjs/Materials/effect";
  60813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60814. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60815. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60816. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60817. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60818. /**
  60819. * Block used to add support for vertex skinning (bones)
  60820. */
  60821. export class BonesBlock extends NodeMaterialBlock {
  60822. /**
  60823. * Creates a new BonesBlock
  60824. * @param name defines the block name
  60825. */
  60826. constructor(name: string);
  60827. /**
  60828. * Initialize the block and prepare the context for build
  60829. * @param state defines the state that will be used for the build
  60830. */
  60831. initialize(state: NodeMaterialBuildState): void;
  60832. /**
  60833. * Gets the current class name
  60834. * @returns the class name
  60835. */
  60836. getClassName(): string;
  60837. /**
  60838. * Gets the matrix indices input component
  60839. */
  60840. get matricesIndices(): NodeMaterialConnectionPoint;
  60841. /**
  60842. * Gets the matrix weights input component
  60843. */
  60844. get matricesWeights(): NodeMaterialConnectionPoint;
  60845. /**
  60846. * Gets the extra matrix indices input component
  60847. */
  60848. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60849. /**
  60850. * Gets the extra matrix weights input component
  60851. */
  60852. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60853. /**
  60854. * Gets the world input component
  60855. */
  60856. get world(): NodeMaterialConnectionPoint;
  60857. /**
  60858. * Gets the output component
  60859. */
  60860. get output(): NodeMaterialConnectionPoint;
  60861. autoConfigure(material: NodeMaterial): void;
  60862. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60863. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60864. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60865. protected _buildBlock(state: NodeMaterialBuildState): this;
  60866. }
  60867. }
  60868. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60873. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60874. /**
  60875. * Block used to add support for instances
  60876. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60877. */
  60878. export class InstancesBlock extends NodeMaterialBlock {
  60879. /**
  60880. * Creates a new InstancesBlock
  60881. * @param name defines the block name
  60882. */
  60883. constructor(name: string);
  60884. /**
  60885. * Gets the current class name
  60886. * @returns the class name
  60887. */
  60888. getClassName(): string;
  60889. /**
  60890. * Gets the first world row input component
  60891. */
  60892. get world0(): NodeMaterialConnectionPoint;
  60893. /**
  60894. * Gets the second world row input component
  60895. */
  60896. get world1(): NodeMaterialConnectionPoint;
  60897. /**
  60898. * Gets the third world row input component
  60899. */
  60900. get world2(): NodeMaterialConnectionPoint;
  60901. /**
  60902. * Gets the forth world row input component
  60903. */
  60904. get world3(): NodeMaterialConnectionPoint;
  60905. /**
  60906. * Gets the world input component
  60907. */
  60908. get world(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the output component
  60911. */
  60912. get output(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the isntanceID component
  60915. */
  60916. get instanceID(): NodeMaterialConnectionPoint;
  60917. autoConfigure(material: NodeMaterial): void;
  60918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60919. protected _buildBlock(state: NodeMaterialBuildState): this;
  60920. }
  60921. }
  60922. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60927. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60928. import { Effect } from "babylonjs/Materials/effect";
  60929. import { Mesh } from "babylonjs/Meshes/mesh";
  60930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60931. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60932. /**
  60933. * Block used to add morph targets support to vertex shader
  60934. */
  60935. export class MorphTargetsBlock extends NodeMaterialBlock {
  60936. private _repeatableContentAnchor;
  60937. /**
  60938. * Create a new MorphTargetsBlock
  60939. * @param name defines the block name
  60940. */
  60941. constructor(name: string);
  60942. /**
  60943. * Gets the current class name
  60944. * @returns the class name
  60945. */
  60946. getClassName(): string;
  60947. /**
  60948. * Gets the position input component
  60949. */
  60950. get position(): NodeMaterialConnectionPoint;
  60951. /**
  60952. * Gets the normal input component
  60953. */
  60954. get normal(): NodeMaterialConnectionPoint;
  60955. /**
  60956. * Gets the tangent input component
  60957. */
  60958. get tangent(): NodeMaterialConnectionPoint;
  60959. /**
  60960. * Gets the tangent input component
  60961. */
  60962. get uv(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the position output component
  60965. */
  60966. get positionOutput(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the normal output component
  60969. */
  60970. get normalOutput(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the tangent output component
  60973. */
  60974. get tangentOutput(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the tangent output component
  60977. */
  60978. get uvOutput(): NodeMaterialConnectionPoint;
  60979. initialize(state: NodeMaterialBuildState): void;
  60980. autoConfigure(material: NodeMaterial): void;
  60981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60982. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60983. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60984. protected _buildBlock(state: NodeMaterialBuildState): this;
  60985. }
  60986. }
  60987. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60991. import { Nullable } from "babylonjs/types";
  60992. import { Scene } from "babylonjs/scene";
  60993. import { Effect } from "babylonjs/Materials/effect";
  60994. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60995. import { Mesh } from "babylonjs/Meshes/mesh";
  60996. import { Light } from "babylonjs/Lights/light";
  60997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60998. /**
  60999. * Block used to get data information from a light
  61000. */
  61001. export class LightInformationBlock extends NodeMaterialBlock {
  61002. private _lightDataUniformName;
  61003. private _lightColorUniformName;
  61004. private _lightTypeDefineName;
  61005. /**
  61006. * Gets or sets the light associated with this block
  61007. */
  61008. light: Nullable<Light>;
  61009. /**
  61010. * Creates a new LightInformationBlock
  61011. * @param name defines the block name
  61012. */
  61013. constructor(name: string);
  61014. /**
  61015. * Gets the current class name
  61016. * @returns the class name
  61017. */
  61018. getClassName(): string;
  61019. /**
  61020. * Gets the world position input component
  61021. */
  61022. get worldPosition(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the direction output component
  61025. */
  61026. get direction(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the direction output component
  61029. */
  61030. get color(): NodeMaterialConnectionPoint;
  61031. /**
  61032. * Gets the direction output component
  61033. */
  61034. get intensity(): NodeMaterialConnectionPoint;
  61035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61037. protected _buildBlock(state: NodeMaterialBuildState): this;
  61038. serialize(): any;
  61039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61040. }
  61041. }
  61042. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61043. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61044. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61045. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61046. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61047. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61048. }
  61049. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61054. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61055. import { Effect } from "babylonjs/Materials/effect";
  61056. import { Mesh } from "babylonjs/Meshes/mesh";
  61057. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61058. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61059. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61060. /**
  61061. * Block used to add image processing support to fragment shader
  61062. */
  61063. export class ImageProcessingBlock extends NodeMaterialBlock {
  61064. /**
  61065. * Create a new ImageProcessingBlock
  61066. * @param name defines the block name
  61067. */
  61068. constructor(name: string);
  61069. /**
  61070. * Gets the current class name
  61071. * @returns the class name
  61072. */
  61073. getClassName(): string;
  61074. /**
  61075. * Gets the color input component
  61076. */
  61077. get color(): NodeMaterialConnectionPoint;
  61078. /**
  61079. * Gets the output component
  61080. */
  61081. get output(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Initialize the block and prepare the context for build
  61084. * @param state defines the state that will be used for the build
  61085. */
  61086. initialize(state: NodeMaterialBuildState): void;
  61087. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61088. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61090. protected _buildBlock(state: NodeMaterialBuildState): this;
  61091. }
  61092. }
  61093. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61097. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61099. import { Effect } from "babylonjs/Materials/effect";
  61100. import { Mesh } from "babylonjs/Meshes/mesh";
  61101. import { Scene } from "babylonjs/scene";
  61102. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61103. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61104. /**
  61105. * Block used to pertub normals based on a normal map
  61106. */
  61107. export class PerturbNormalBlock extends NodeMaterialBlock {
  61108. private _tangentSpaceParameterName;
  61109. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61110. invertX: boolean;
  61111. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61112. invertY: boolean;
  61113. /**
  61114. * Create a new PerturbNormalBlock
  61115. * @param name defines the block name
  61116. */
  61117. constructor(name: string);
  61118. /**
  61119. * Gets the current class name
  61120. * @returns the class name
  61121. */
  61122. getClassName(): string;
  61123. /**
  61124. * Gets the world position input component
  61125. */
  61126. get worldPosition(): NodeMaterialConnectionPoint;
  61127. /**
  61128. * Gets the world normal input component
  61129. */
  61130. get worldNormal(): NodeMaterialConnectionPoint;
  61131. /**
  61132. * Gets the world tangent input component
  61133. */
  61134. get worldTangent(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the uv input component
  61137. */
  61138. get uv(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the normal map color input component
  61141. */
  61142. get normalMapColor(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the strength input component
  61145. */
  61146. get strength(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the output component
  61149. */
  61150. get output(): NodeMaterialConnectionPoint;
  61151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61152. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61153. autoConfigure(material: NodeMaterial): void;
  61154. protected _buildBlock(state: NodeMaterialBuildState): this;
  61155. protected _dumpPropertiesCode(): string;
  61156. serialize(): any;
  61157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61158. }
  61159. }
  61160. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61164. /**
  61165. * Block used to discard a pixel if a value is smaller than a cutoff
  61166. */
  61167. export class DiscardBlock extends NodeMaterialBlock {
  61168. /**
  61169. * Create a new DiscardBlock
  61170. * @param name defines the block name
  61171. */
  61172. constructor(name: string);
  61173. /**
  61174. * Gets the current class name
  61175. * @returns the class name
  61176. */
  61177. getClassName(): string;
  61178. /**
  61179. * Gets the color input component
  61180. */
  61181. get value(): NodeMaterialConnectionPoint;
  61182. /**
  61183. * Gets the cutoff input component
  61184. */
  61185. get cutoff(): NodeMaterialConnectionPoint;
  61186. protected _buildBlock(state: NodeMaterialBuildState): this;
  61187. }
  61188. }
  61189. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61193. /**
  61194. * Block used to test if the fragment shader is front facing
  61195. */
  61196. export class FrontFacingBlock extends NodeMaterialBlock {
  61197. /**
  61198. * Creates a new FrontFacingBlock
  61199. * @param name defines the block name
  61200. */
  61201. constructor(name: string);
  61202. /**
  61203. * Gets the current class name
  61204. * @returns the class name
  61205. */
  61206. getClassName(): string;
  61207. /**
  61208. * Gets the output component
  61209. */
  61210. get output(): NodeMaterialConnectionPoint;
  61211. protected _buildBlock(state: NodeMaterialBuildState): this;
  61212. }
  61213. }
  61214. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61218. /**
  61219. * Block used to get the derivative value on x and y of a given input
  61220. */
  61221. export class DerivativeBlock extends NodeMaterialBlock {
  61222. /**
  61223. * Create a new DerivativeBlock
  61224. * @param name defines the block name
  61225. */
  61226. constructor(name: string);
  61227. /**
  61228. * Gets the current class name
  61229. * @returns the class name
  61230. */
  61231. getClassName(): string;
  61232. /**
  61233. * Gets the input component
  61234. */
  61235. get input(): NodeMaterialConnectionPoint;
  61236. /**
  61237. * Gets the derivative output on x
  61238. */
  61239. get dx(): NodeMaterialConnectionPoint;
  61240. /**
  61241. * Gets the derivative output on y
  61242. */
  61243. get dy(): NodeMaterialConnectionPoint;
  61244. protected _buildBlock(state: NodeMaterialBuildState): this;
  61245. }
  61246. }
  61247. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61248. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61249. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61250. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61251. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61252. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61253. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61254. }
  61255. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61258. import { Mesh } from "babylonjs/Meshes/mesh";
  61259. import { Effect } from "babylonjs/Materials/effect";
  61260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61262. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61263. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61264. /**
  61265. * Block used to add support for scene fog
  61266. */
  61267. export class FogBlock extends NodeMaterialBlock {
  61268. private _fogDistanceName;
  61269. private _fogParameters;
  61270. /**
  61271. * Create a new FogBlock
  61272. * @param name defines the block name
  61273. */
  61274. constructor(name: string);
  61275. /**
  61276. * Gets the current class name
  61277. * @returns the class name
  61278. */
  61279. getClassName(): string;
  61280. /**
  61281. * Gets the world position input component
  61282. */
  61283. get worldPosition(): NodeMaterialConnectionPoint;
  61284. /**
  61285. * Gets the view input component
  61286. */
  61287. get view(): NodeMaterialConnectionPoint;
  61288. /**
  61289. * Gets the color input component
  61290. */
  61291. get input(): NodeMaterialConnectionPoint;
  61292. /**
  61293. * Gets the fog color input component
  61294. */
  61295. get fogColor(): NodeMaterialConnectionPoint;
  61296. /**
  61297. * Gets the output component
  61298. */
  61299. get output(): NodeMaterialConnectionPoint;
  61300. autoConfigure(material: NodeMaterial): void;
  61301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61302. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61303. protected _buildBlock(state: NodeMaterialBuildState): this;
  61304. }
  61305. }
  61306. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61311. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61312. import { Effect } from "babylonjs/Materials/effect";
  61313. import { Mesh } from "babylonjs/Meshes/mesh";
  61314. import { Light } from "babylonjs/Lights/light";
  61315. import { Nullable } from "babylonjs/types";
  61316. import { Scene } from "babylonjs/scene";
  61317. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61318. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61319. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61320. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61321. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61322. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61323. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61324. /**
  61325. * Block used to add light in the fragment shader
  61326. */
  61327. export class LightBlock extends NodeMaterialBlock {
  61328. private _lightId;
  61329. /**
  61330. * Gets or sets the light associated with this block
  61331. */
  61332. light: Nullable<Light>;
  61333. /**
  61334. * Create a new LightBlock
  61335. * @param name defines the block name
  61336. */
  61337. constructor(name: string);
  61338. /**
  61339. * Gets the current class name
  61340. * @returns the class name
  61341. */
  61342. getClassName(): string;
  61343. /**
  61344. * Gets the world position input component
  61345. */
  61346. get worldPosition(): NodeMaterialConnectionPoint;
  61347. /**
  61348. * Gets the world normal input component
  61349. */
  61350. get worldNormal(): NodeMaterialConnectionPoint;
  61351. /**
  61352. * Gets the camera (or eye) position component
  61353. */
  61354. get cameraPosition(): NodeMaterialConnectionPoint;
  61355. /**
  61356. * Gets the glossiness component
  61357. */
  61358. get glossiness(): NodeMaterialConnectionPoint;
  61359. /**
  61360. * Gets the glossinness power component
  61361. */
  61362. get glossPower(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the diffuse color component
  61365. */
  61366. get diffuseColor(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the specular color component
  61369. */
  61370. get specularColor(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the diffuse output component
  61373. */
  61374. get diffuseOutput(): NodeMaterialConnectionPoint;
  61375. /**
  61376. * Gets the specular output component
  61377. */
  61378. get specularOutput(): NodeMaterialConnectionPoint;
  61379. /**
  61380. * Gets the shadow output component
  61381. */
  61382. get shadow(): NodeMaterialConnectionPoint;
  61383. autoConfigure(material: NodeMaterial): void;
  61384. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61385. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61387. private _injectVertexCode;
  61388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61389. serialize(): any;
  61390. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61391. }
  61392. }
  61393. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61394. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61395. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61396. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61397. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61398. }
  61399. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61400. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61401. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61402. }
  61403. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61407. /**
  61408. * Block used to multiply 2 values
  61409. */
  61410. export class MultiplyBlock extends NodeMaterialBlock {
  61411. /**
  61412. * Creates a new MultiplyBlock
  61413. * @param name defines the block name
  61414. */
  61415. constructor(name: string);
  61416. /**
  61417. * Gets the current class name
  61418. * @returns the class name
  61419. */
  61420. getClassName(): string;
  61421. /**
  61422. * Gets the left operand input component
  61423. */
  61424. get left(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the right operand input component
  61427. */
  61428. get right(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the output component
  61431. */
  61432. get output(): NodeMaterialConnectionPoint;
  61433. protected _buildBlock(state: NodeMaterialBuildState): this;
  61434. }
  61435. }
  61436. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61440. /**
  61441. * Block used to add 2 vectors
  61442. */
  61443. export class AddBlock extends NodeMaterialBlock {
  61444. /**
  61445. * Creates a new AddBlock
  61446. * @param name defines the block name
  61447. */
  61448. constructor(name: string);
  61449. /**
  61450. * Gets the current class name
  61451. * @returns the class name
  61452. */
  61453. getClassName(): string;
  61454. /**
  61455. * Gets the left operand input component
  61456. */
  61457. get left(): NodeMaterialConnectionPoint;
  61458. /**
  61459. * Gets the right operand input component
  61460. */
  61461. get right(): NodeMaterialConnectionPoint;
  61462. /**
  61463. * Gets the output component
  61464. */
  61465. get output(): NodeMaterialConnectionPoint;
  61466. protected _buildBlock(state: NodeMaterialBuildState): this;
  61467. }
  61468. }
  61469. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61473. /**
  61474. * Block used to scale a vector by a float
  61475. */
  61476. export class ScaleBlock extends NodeMaterialBlock {
  61477. /**
  61478. * Creates a new ScaleBlock
  61479. * @param name defines the block name
  61480. */
  61481. constructor(name: string);
  61482. /**
  61483. * Gets the current class name
  61484. * @returns the class name
  61485. */
  61486. getClassName(): string;
  61487. /**
  61488. * Gets the input component
  61489. */
  61490. get input(): NodeMaterialConnectionPoint;
  61491. /**
  61492. * Gets the factor input component
  61493. */
  61494. get factor(): NodeMaterialConnectionPoint;
  61495. /**
  61496. * Gets the output component
  61497. */
  61498. get output(): NodeMaterialConnectionPoint;
  61499. protected _buildBlock(state: NodeMaterialBuildState): this;
  61500. }
  61501. }
  61502. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61506. import { Scene } from "babylonjs/scene";
  61507. /**
  61508. * Block used to clamp a float
  61509. */
  61510. export class ClampBlock extends NodeMaterialBlock {
  61511. /** Gets or sets the minimum range */
  61512. minimum: number;
  61513. /** Gets or sets the maximum range */
  61514. maximum: number;
  61515. /**
  61516. * Creates a new ClampBlock
  61517. * @param name defines the block name
  61518. */
  61519. constructor(name: string);
  61520. /**
  61521. * Gets the current class name
  61522. * @returns the class name
  61523. */
  61524. getClassName(): string;
  61525. /**
  61526. * Gets the value input component
  61527. */
  61528. get value(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the output component
  61531. */
  61532. get output(): NodeMaterialConnectionPoint;
  61533. protected _buildBlock(state: NodeMaterialBuildState): this;
  61534. protected _dumpPropertiesCode(): string;
  61535. serialize(): any;
  61536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61537. }
  61538. }
  61539. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61543. /**
  61544. * Block used to apply a cross product between 2 vectors
  61545. */
  61546. export class CrossBlock extends NodeMaterialBlock {
  61547. /**
  61548. * Creates a new CrossBlock
  61549. * @param name defines the block name
  61550. */
  61551. constructor(name: string);
  61552. /**
  61553. * Gets the current class name
  61554. * @returns the class name
  61555. */
  61556. getClassName(): string;
  61557. /**
  61558. * Gets the left operand input component
  61559. */
  61560. get left(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the right operand input component
  61563. */
  61564. get right(): NodeMaterialConnectionPoint;
  61565. /**
  61566. * Gets the output component
  61567. */
  61568. get output(): NodeMaterialConnectionPoint;
  61569. protected _buildBlock(state: NodeMaterialBuildState): this;
  61570. }
  61571. }
  61572. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61576. /**
  61577. * Block used to apply a dot product between 2 vectors
  61578. */
  61579. export class DotBlock extends NodeMaterialBlock {
  61580. /**
  61581. * Creates a new DotBlock
  61582. * @param name defines the block name
  61583. */
  61584. constructor(name: string);
  61585. /**
  61586. * Gets the current class name
  61587. * @returns the class name
  61588. */
  61589. getClassName(): string;
  61590. /**
  61591. * Gets the left operand input component
  61592. */
  61593. get left(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the right operand input component
  61596. */
  61597. get right(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the output component
  61600. */
  61601. get output(): NodeMaterialConnectionPoint;
  61602. protected _buildBlock(state: NodeMaterialBuildState): this;
  61603. }
  61604. }
  61605. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61609. import { Vector2 } from "babylonjs/Maths/math.vector";
  61610. import { Scene } from "babylonjs/scene";
  61611. /**
  61612. * Block used to remap a float from a range to a new one
  61613. */
  61614. export class RemapBlock extends NodeMaterialBlock {
  61615. /**
  61616. * Gets or sets the source range
  61617. */
  61618. sourceRange: Vector2;
  61619. /**
  61620. * Gets or sets the target range
  61621. */
  61622. targetRange: Vector2;
  61623. /**
  61624. * Creates a new RemapBlock
  61625. * @param name defines the block name
  61626. */
  61627. constructor(name: string);
  61628. /**
  61629. * Gets the current class name
  61630. * @returns the class name
  61631. */
  61632. getClassName(): string;
  61633. /**
  61634. * Gets the input component
  61635. */
  61636. get input(): NodeMaterialConnectionPoint;
  61637. /**
  61638. * Gets the source min input component
  61639. */
  61640. get sourceMin(): NodeMaterialConnectionPoint;
  61641. /**
  61642. * Gets the source max input component
  61643. */
  61644. get sourceMax(): NodeMaterialConnectionPoint;
  61645. /**
  61646. * Gets the target min input component
  61647. */
  61648. get targetMin(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the target max input component
  61651. */
  61652. get targetMax(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the output component
  61655. */
  61656. get output(): NodeMaterialConnectionPoint;
  61657. protected _buildBlock(state: NodeMaterialBuildState): this;
  61658. protected _dumpPropertiesCode(): string;
  61659. serialize(): any;
  61660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61661. }
  61662. }
  61663. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61667. /**
  61668. * Block used to normalize a vector
  61669. */
  61670. export class NormalizeBlock extends NodeMaterialBlock {
  61671. /**
  61672. * Creates a new NormalizeBlock
  61673. * @param name defines the block name
  61674. */
  61675. constructor(name: string);
  61676. /**
  61677. * Gets the current class name
  61678. * @returns the class name
  61679. */
  61680. getClassName(): string;
  61681. /**
  61682. * Gets the input component
  61683. */
  61684. get input(): NodeMaterialConnectionPoint;
  61685. /**
  61686. * Gets the output component
  61687. */
  61688. get output(): NodeMaterialConnectionPoint;
  61689. protected _buildBlock(state: NodeMaterialBuildState): this;
  61690. }
  61691. }
  61692. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61696. import { Scene } from "babylonjs/scene";
  61697. /**
  61698. * Operations supported by the Trigonometry block
  61699. */
  61700. export enum TrigonometryBlockOperations {
  61701. /** Cos */
  61702. Cos = 0,
  61703. /** Sin */
  61704. Sin = 1,
  61705. /** Abs */
  61706. Abs = 2,
  61707. /** Exp */
  61708. Exp = 3,
  61709. /** Exp2 */
  61710. Exp2 = 4,
  61711. /** Round */
  61712. Round = 5,
  61713. /** Floor */
  61714. Floor = 6,
  61715. /** Ceiling */
  61716. Ceiling = 7,
  61717. /** Square root */
  61718. Sqrt = 8,
  61719. /** Log */
  61720. Log = 9,
  61721. /** Tangent */
  61722. Tan = 10,
  61723. /** Arc tangent */
  61724. ArcTan = 11,
  61725. /** Arc cosinus */
  61726. ArcCos = 12,
  61727. /** Arc sinus */
  61728. ArcSin = 13,
  61729. /** Fraction */
  61730. Fract = 14,
  61731. /** Sign */
  61732. Sign = 15,
  61733. /** To radians (from degrees) */
  61734. Radians = 16,
  61735. /** To degrees (from radians) */
  61736. Degrees = 17
  61737. }
  61738. /**
  61739. * Block used to apply trigonometry operation to floats
  61740. */
  61741. export class TrigonometryBlock extends NodeMaterialBlock {
  61742. /**
  61743. * Gets or sets the operation applied by the block
  61744. */
  61745. operation: TrigonometryBlockOperations;
  61746. /**
  61747. * Creates a new TrigonometryBlock
  61748. * @param name defines the block name
  61749. */
  61750. constructor(name: string);
  61751. /**
  61752. * Gets the current class name
  61753. * @returns the class name
  61754. */
  61755. getClassName(): string;
  61756. /**
  61757. * Gets the input component
  61758. */
  61759. get input(): NodeMaterialConnectionPoint;
  61760. /**
  61761. * Gets the output component
  61762. */
  61763. get output(): NodeMaterialConnectionPoint;
  61764. protected _buildBlock(state: NodeMaterialBuildState): this;
  61765. serialize(): any;
  61766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61767. protected _dumpPropertiesCode(): string;
  61768. }
  61769. }
  61770. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61774. /**
  61775. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61776. */
  61777. export class ColorMergerBlock extends NodeMaterialBlock {
  61778. /**
  61779. * Create a new ColorMergerBlock
  61780. * @param name defines the block name
  61781. */
  61782. constructor(name: string);
  61783. /**
  61784. * Gets the current class name
  61785. * @returns the class name
  61786. */
  61787. getClassName(): string;
  61788. /**
  61789. * Gets the rgb component (input)
  61790. */
  61791. get rgbIn(): NodeMaterialConnectionPoint;
  61792. /**
  61793. * Gets the r component (input)
  61794. */
  61795. get r(): NodeMaterialConnectionPoint;
  61796. /**
  61797. * Gets the g component (input)
  61798. */
  61799. get g(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the b component (input)
  61802. */
  61803. get b(): NodeMaterialConnectionPoint;
  61804. /**
  61805. * Gets the a component (input)
  61806. */
  61807. get a(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the rgba component (output)
  61810. */
  61811. get rgba(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the rgb component (output)
  61814. */
  61815. get rgbOut(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the rgb component (output)
  61818. * @deprecated Please use rgbOut instead.
  61819. */
  61820. get rgb(): NodeMaterialConnectionPoint;
  61821. protected _buildBlock(state: NodeMaterialBuildState): this;
  61822. }
  61823. }
  61824. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61828. /**
  61829. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61830. */
  61831. export class VectorMergerBlock extends NodeMaterialBlock {
  61832. /**
  61833. * Create a new VectorMergerBlock
  61834. * @param name defines the block name
  61835. */
  61836. constructor(name: string);
  61837. /**
  61838. * Gets the current class name
  61839. * @returns the class name
  61840. */
  61841. getClassName(): string;
  61842. /**
  61843. * Gets the xyz component (input)
  61844. */
  61845. get xyzIn(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the xy component (input)
  61848. */
  61849. get xyIn(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the x component (input)
  61852. */
  61853. get x(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the y component (input)
  61856. */
  61857. get y(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the z component (input)
  61860. */
  61861. get z(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the w component (input)
  61864. */
  61865. get w(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the xyzw component (output)
  61868. */
  61869. get xyzw(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the xyz component (output)
  61872. */
  61873. get xyzOut(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the xy component (output)
  61876. */
  61877. get xyOut(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the xy component (output)
  61880. * @deprecated Please use xyOut instead.
  61881. */
  61882. get xy(): NodeMaterialConnectionPoint;
  61883. /**
  61884. * Gets the xyz component (output)
  61885. * @deprecated Please use xyzOut instead.
  61886. */
  61887. get xyz(): NodeMaterialConnectionPoint;
  61888. protected _buildBlock(state: NodeMaterialBuildState): this;
  61889. }
  61890. }
  61891. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61895. /**
  61896. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61897. */
  61898. export class ColorSplitterBlock extends NodeMaterialBlock {
  61899. /**
  61900. * Create a new ColorSplitterBlock
  61901. * @param name defines the block name
  61902. */
  61903. constructor(name: string);
  61904. /**
  61905. * Gets the current class name
  61906. * @returns the class name
  61907. */
  61908. getClassName(): string;
  61909. /**
  61910. * Gets the rgba component (input)
  61911. */
  61912. get rgba(): NodeMaterialConnectionPoint;
  61913. /**
  61914. * Gets the rgb component (input)
  61915. */
  61916. get rgbIn(): NodeMaterialConnectionPoint;
  61917. /**
  61918. * Gets the rgb component (output)
  61919. */
  61920. get rgbOut(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the r component (output)
  61923. */
  61924. get r(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the g component (output)
  61927. */
  61928. get g(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the b component (output)
  61931. */
  61932. get b(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the a component (output)
  61935. */
  61936. get a(): NodeMaterialConnectionPoint;
  61937. protected _inputRename(name: string): string;
  61938. protected _outputRename(name: string): string;
  61939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61940. }
  61941. }
  61942. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61946. /**
  61947. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61948. */
  61949. export class VectorSplitterBlock extends NodeMaterialBlock {
  61950. /**
  61951. * Create a new VectorSplitterBlock
  61952. * @param name defines the block name
  61953. */
  61954. constructor(name: string);
  61955. /**
  61956. * Gets the current class name
  61957. * @returns the class name
  61958. */
  61959. getClassName(): string;
  61960. /**
  61961. * Gets the xyzw component (input)
  61962. */
  61963. get xyzw(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the xyz component (input)
  61966. */
  61967. get xyzIn(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the xy component (input)
  61970. */
  61971. get xyIn(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the xyz component (output)
  61974. */
  61975. get xyzOut(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the xy component (output)
  61978. */
  61979. get xyOut(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the x component (output)
  61982. */
  61983. get x(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the y component (output)
  61986. */
  61987. get y(): NodeMaterialConnectionPoint;
  61988. /**
  61989. * Gets the z component (output)
  61990. */
  61991. get z(): NodeMaterialConnectionPoint;
  61992. /**
  61993. * Gets the w component (output)
  61994. */
  61995. get w(): NodeMaterialConnectionPoint;
  61996. protected _inputRename(name: string): string;
  61997. protected _outputRename(name: string): string;
  61998. protected _buildBlock(state: NodeMaterialBuildState): this;
  61999. }
  62000. }
  62001. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62005. /**
  62006. * Block used to lerp between 2 values
  62007. */
  62008. export class LerpBlock extends NodeMaterialBlock {
  62009. /**
  62010. * Creates a new LerpBlock
  62011. * @param name defines the block name
  62012. */
  62013. constructor(name: string);
  62014. /**
  62015. * Gets the current class name
  62016. * @returns the class name
  62017. */
  62018. getClassName(): string;
  62019. /**
  62020. * Gets the left operand input component
  62021. */
  62022. get left(): NodeMaterialConnectionPoint;
  62023. /**
  62024. * Gets the right operand input component
  62025. */
  62026. get right(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the gradient operand input component
  62029. */
  62030. get gradient(): NodeMaterialConnectionPoint;
  62031. /**
  62032. * Gets the output component
  62033. */
  62034. get output(): NodeMaterialConnectionPoint;
  62035. protected _buildBlock(state: NodeMaterialBuildState): this;
  62036. }
  62037. }
  62038. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62042. /**
  62043. * Block used to divide 2 vectors
  62044. */
  62045. export class DivideBlock extends NodeMaterialBlock {
  62046. /**
  62047. * Creates a new DivideBlock
  62048. * @param name defines the block name
  62049. */
  62050. constructor(name: string);
  62051. /**
  62052. * Gets the current class name
  62053. * @returns the class name
  62054. */
  62055. getClassName(): string;
  62056. /**
  62057. * Gets the left operand input component
  62058. */
  62059. get left(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the right operand input component
  62062. */
  62063. get right(): NodeMaterialConnectionPoint;
  62064. /**
  62065. * Gets the output component
  62066. */
  62067. get output(): NodeMaterialConnectionPoint;
  62068. protected _buildBlock(state: NodeMaterialBuildState): this;
  62069. }
  62070. }
  62071. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62075. /**
  62076. * Block used to subtract 2 vectors
  62077. */
  62078. export class SubtractBlock extends NodeMaterialBlock {
  62079. /**
  62080. * Creates a new SubtractBlock
  62081. * @param name defines the block name
  62082. */
  62083. constructor(name: string);
  62084. /**
  62085. * Gets the current class name
  62086. * @returns the class name
  62087. */
  62088. getClassName(): string;
  62089. /**
  62090. * Gets the left operand input component
  62091. */
  62092. get left(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the right operand input component
  62095. */
  62096. get right(): NodeMaterialConnectionPoint;
  62097. /**
  62098. * Gets the output component
  62099. */
  62100. get output(): NodeMaterialConnectionPoint;
  62101. protected _buildBlock(state: NodeMaterialBuildState): this;
  62102. }
  62103. }
  62104. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62108. /**
  62109. * Block used to step a value
  62110. */
  62111. export class StepBlock extends NodeMaterialBlock {
  62112. /**
  62113. * Creates a new StepBlock
  62114. * @param name defines the block name
  62115. */
  62116. constructor(name: string);
  62117. /**
  62118. * Gets the current class name
  62119. * @returns the class name
  62120. */
  62121. getClassName(): string;
  62122. /**
  62123. * Gets the value operand input component
  62124. */
  62125. get value(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the edge operand input component
  62128. */
  62129. get edge(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the output component
  62132. */
  62133. get output(): NodeMaterialConnectionPoint;
  62134. protected _buildBlock(state: NodeMaterialBuildState): this;
  62135. }
  62136. }
  62137. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62141. /**
  62142. * Block used to get the opposite (1 - x) of a value
  62143. */
  62144. export class OneMinusBlock extends NodeMaterialBlock {
  62145. /**
  62146. * Creates a new OneMinusBlock
  62147. * @param name defines the block name
  62148. */
  62149. constructor(name: string);
  62150. /**
  62151. * Gets the current class name
  62152. * @returns the class name
  62153. */
  62154. getClassName(): string;
  62155. /**
  62156. * Gets the input component
  62157. */
  62158. get input(): NodeMaterialConnectionPoint;
  62159. /**
  62160. * Gets the output component
  62161. */
  62162. get output(): NodeMaterialConnectionPoint;
  62163. protected _buildBlock(state: NodeMaterialBuildState): this;
  62164. }
  62165. }
  62166. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62170. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62171. /**
  62172. * Block used to get the view direction
  62173. */
  62174. export class ViewDirectionBlock extends NodeMaterialBlock {
  62175. /**
  62176. * Creates a new ViewDirectionBlock
  62177. * @param name defines the block name
  62178. */
  62179. constructor(name: string);
  62180. /**
  62181. * Gets the current class name
  62182. * @returns the class name
  62183. */
  62184. getClassName(): string;
  62185. /**
  62186. * Gets the world position component
  62187. */
  62188. get worldPosition(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the camera position component
  62191. */
  62192. get cameraPosition(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the output component
  62195. */
  62196. get output(): NodeMaterialConnectionPoint;
  62197. autoConfigure(material: NodeMaterial): void;
  62198. protected _buildBlock(state: NodeMaterialBuildState): this;
  62199. }
  62200. }
  62201. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62205. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62206. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62207. /**
  62208. * Block used to compute fresnel value
  62209. */
  62210. export class FresnelBlock extends NodeMaterialBlock {
  62211. /**
  62212. * Create a new FresnelBlock
  62213. * @param name defines the block name
  62214. */
  62215. constructor(name: string);
  62216. /**
  62217. * Gets the current class name
  62218. * @returns the class name
  62219. */
  62220. getClassName(): string;
  62221. /**
  62222. * Gets the world normal input component
  62223. */
  62224. get worldNormal(): NodeMaterialConnectionPoint;
  62225. /**
  62226. * Gets the view direction input component
  62227. */
  62228. get viewDirection(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the bias input component
  62231. */
  62232. get bias(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the camera (or eye) position component
  62235. */
  62236. get power(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the fresnel output component
  62239. */
  62240. get fresnel(): NodeMaterialConnectionPoint;
  62241. autoConfigure(material: NodeMaterial): void;
  62242. protected _buildBlock(state: NodeMaterialBuildState): this;
  62243. }
  62244. }
  62245. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62249. /**
  62250. * Block used to get the max of 2 values
  62251. */
  62252. export class MaxBlock extends NodeMaterialBlock {
  62253. /**
  62254. * Creates a new MaxBlock
  62255. * @param name defines the block name
  62256. */
  62257. constructor(name: string);
  62258. /**
  62259. * Gets the current class name
  62260. * @returns the class name
  62261. */
  62262. getClassName(): string;
  62263. /**
  62264. * Gets the left operand input component
  62265. */
  62266. get left(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the right operand input component
  62269. */
  62270. get right(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the output component
  62273. */
  62274. get output(): NodeMaterialConnectionPoint;
  62275. protected _buildBlock(state: NodeMaterialBuildState): this;
  62276. }
  62277. }
  62278. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62282. /**
  62283. * Block used to get the min of 2 values
  62284. */
  62285. export class MinBlock extends NodeMaterialBlock {
  62286. /**
  62287. * Creates a new MinBlock
  62288. * @param name defines the block name
  62289. */
  62290. constructor(name: string);
  62291. /**
  62292. * Gets the current class name
  62293. * @returns the class name
  62294. */
  62295. getClassName(): string;
  62296. /**
  62297. * Gets the left operand input component
  62298. */
  62299. get left(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the right operand input component
  62302. */
  62303. get right(): NodeMaterialConnectionPoint;
  62304. /**
  62305. * Gets the output component
  62306. */
  62307. get output(): NodeMaterialConnectionPoint;
  62308. protected _buildBlock(state: NodeMaterialBuildState): this;
  62309. }
  62310. }
  62311. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62315. /**
  62316. * Block used to get the distance between 2 values
  62317. */
  62318. export class DistanceBlock extends NodeMaterialBlock {
  62319. /**
  62320. * Creates a new DistanceBlock
  62321. * @param name defines the block name
  62322. */
  62323. constructor(name: string);
  62324. /**
  62325. * Gets the current class name
  62326. * @returns the class name
  62327. */
  62328. getClassName(): string;
  62329. /**
  62330. * Gets the left operand input component
  62331. */
  62332. get left(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the right operand input component
  62335. */
  62336. get right(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the output component
  62339. */
  62340. get output(): NodeMaterialConnectionPoint;
  62341. protected _buildBlock(state: NodeMaterialBuildState): this;
  62342. }
  62343. }
  62344. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62348. /**
  62349. * Block used to get the length of a vector
  62350. */
  62351. export class LengthBlock extends NodeMaterialBlock {
  62352. /**
  62353. * Creates a new LengthBlock
  62354. * @param name defines the block name
  62355. */
  62356. constructor(name: string);
  62357. /**
  62358. * Gets the current class name
  62359. * @returns the class name
  62360. */
  62361. getClassName(): string;
  62362. /**
  62363. * Gets the value input component
  62364. */
  62365. get value(): NodeMaterialConnectionPoint;
  62366. /**
  62367. * Gets the output component
  62368. */
  62369. get output(): NodeMaterialConnectionPoint;
  62370. protected _buildBlock(state: NodeMaterialBuildState): this;
  62371. }
  62372. }
  62373. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62377. /**
  62378. * Block used to get negative version of a value (i.e. x * -1)
  62379. */
  62380. export class NegateBlock extends NodeMaterialBlock {
  62381. /**
  62382. * Creates a new NegateBlock
  62383. * @param name defines the block name
  62384. */
  62385. constructor(name: string);
  62386. /**
  62387. * Gets the current class name
  62388. * @returns the class name
  62389. */
  62390. getClassName(): string;
  62391. /**
  62392. * Gets the value input component
  62393. */
  62394. get value(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the output component
  62397. */
  62398. get output(): NodeMaterialConnectionPoint;
  62399. protected _buildBlock(state: NodeMaterialBuildState): this;
  62400. }
  62401. }
  62402. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62406. /**
  62407. * Block used to get the value of the first parameter raised to the power of the second
  62408. */
  62409. export class PowBlock extends NodeMaterialBlock {
  62410. /**
  62411. * Creates a new PowBlock
  62412. * @param name defines the block name
  62413. */
  62414. constructor(name: string);
  62415. /**
  62416. * Gets the current class name
  62417. * @returns the class name
  62418. */
  62419. getClassName(): string;
  62420. /**
  62421. * Gets the value operand input component
  62422. */
  62423. get value(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the power operand input component
  62426. */
  62427. get power(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the output component
  62430. */
  62431. get output(): NodeMaterialConnectionPoint;
  62432. protected _buildBlock(state: NodeMaterialBuildState): this;
  62433. }
  62434. }
  62435. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62439. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62440. /**
  62441. * Block used to get a random number
  62442. */
  62443. export class RandomNumberBlock extends NodeMaterialBlock {
  62444. /**
  62445. * Creates a new RandomNumberBlock
  62446. * @param name defines the block name
  62447. */
  62448. constructor(name: string);
  62449. /**
  62450. * Gets the current class name
  62451. * @returns the class name
  62452. */
  62453. getClassName(): string;
  62454. /**
  62455. * Gets the seed input component
  62456. */
  62457. get seed(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the output component
  62460. */
  62461. get output(): NodeMaterialConnectionPoint;
  62462. protected _buildBlock(state: NodeMaterialBuildState): this;
  62463. }
  62464. }
  62465. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62469. /**
  62470. * Block used to compute arc tangent of 2 values
  62471. */
  62472. export class ArcTan2Block extends NodeMaterialBlock {
  62473. /**
  62474. * Creates a new ArcTan2Block
  62475. * @param name defines the block name
  62476. */
  62477. constructor(name: string);
  62478. /**
  62479. * Gets the current class name
  62480. * @returns the class name
  62481. */
  62482. getClassName(): string;
  62483. /**
  62484. * Gets the x operand input component
  62485. */
  62486. get x(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the y operand input component
  62489. */
  62490. get y(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the output component
  62493. */
  62494. get output(): NodeMaterialConnectionPoint;
  62495. protected _buildBlock(state: NodeMaterialBuildState): this;
  62496. }
  62497. }
  62498. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62502. /**
  62503. * Block used to smooth step a value
  62504. */
  62505. export class SmoothStepBlock extends NodeMaterialBlock {
  62506. /**
  62507. * Creates a new SmoothStepBlock
  62508. * @param name defines the block name
  62509. */
  62510. constructor(name: string);
  62511. /**
  62512. * Gets the current class name
  62513. * @returns the class name
  62514. */
  62515. getClassName(): string;
  62516. /**
  62517. * Gets the value operand input component
  62518. */
  62519. get value(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the first edge operand input component
  62522. */
  62523. get edge0(): NodeMaterialConnectionPoint;
  62524. /**
  62525. * Gets the second edge operand input component
  62526. */
  62527. get edge1(): NodeMaterialConnectionPoint;
  62528. /**
  62529. * Gets the output component
  62530. */
  62531. get output(): NodeMaterialConnectionPoint;
  62532. protected _buildBlock(state: NodeMaterialBuildState): this;
  62533. }
  62534. }
  62535. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62539. /**
  62540. * Block used to get the reciprocal (1 / x) of a value
  62541. */
  62542. export class ReciprocalBlock extends NodeMaterialBlock {
  62543. /**
  62544. * Creates a new ReciprocalBlock
  62545. * @param name defines the block name
  62546. */
  62547. constructor(name: string);
  62548. /**
  62549. * Gets the current class name
  62550. * @returns the class name
  62551. */
  62552. getClassName(): string;
  62553. /**
  62554. * Gets the input component
  62555. */
  62556. get input(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the output component
  62559. */
  62560. get output(): NodeMaterialConnectionPoint;
  62561. protected _buildBlock(state: NodeMaterialBuildState): this;
  62562. }
  62563. }
  62564. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62568. /**
  62569. * Block used to replace a color by another one
  62570. */
  62571. export class ReplaceColorBlock extends NodeMaterialBlock {
  62572. /**
  62573. * Creates a new ReplaceColorBlock
  62574. * @param name defines the block name
  62575. */
  62576. constructor(name: string);
  62577. /**
  62578. * Gets the current class name
  62579. * @returns the class name
  62580. */
  62581. getClassName(): string;
  62582. /**
  62583. * Gets the value input component
  62584. */
  62585. get value(): NodeMaterialConnectionPoint;
  62586. /**
  62587. * Gets the reference input component
  62588. */
  62589. get reference(): NodeMaterialConnectionPoint;
  62590. /**
  62591. * Gets the distance input component
  62592. */
  62593. get distance(): NodeMaterialConnectionPoint;
  62594. /**
  62595. * Gets the replacement input component
  62596. */
  62597. get replacement(): NodeMaterialConnectionPoint;
  62598. /**
  62599. * Gets the output component
  62600. */
  62601. get output(): NodeMaterialConnectionPoint;
  62602. protected _buildBlock(state: NodeMaterialBuildState): this;
  62603. }
  62604. }
  62605. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62609. /**
  62610. * Block used to posterize a value
  62611. * @see https://en.wikipedia.org/wiki/Posterization
  62612. */
  62613. export class PosterizeBlock extends NodeMaterialBlock {
  62614. /**
  62615. * Creates a new PosterizeBlock
  62616. * @param name defines the block name
  62617. */
  62618. constructor(name: string);
  62619. /**
  62620. * Gets the current class name
  62621. * @returns the class name
  62622. */
  62623. getClassName(): string;
  62624. /**
  62625. * Gets the value input component
  62626. */
  62627. get value(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the steps input component
  62630. */
  62631. get steps(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the output component
  62634. */
  62635. get output(): NodeMaterialConnectionPoint;
  62636. protected _buildBlock(state: NodeMaterialBuildState): this;
  62637. }
  62638. }
  62639. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62643. import { Scene } from "babylonjs/scene";
  62644. /**
  62645. * Operations supported by the Wave block
  62646. */
  62647. export enum WaveBlockKind {
  62648. /** SawTooth */
  62649. SawTooth = 0,
  62650. /** Square */
  62651. Square = 1,
  62652. /** Triangle */
  62653. Triangle = 2
  62654. }
  62655. /**
  62656. * Block used to apply wave operation to floats
  62657. */
  62658. export class WaveBlock extends NodeMaterialBlock {
  62659. /**
  62660. * Gets or sets the kibnd of wave to be applied by the block
  62661. */
  62662. kind: WaveBlockKind;
  62663. /**
  62664. * Creates a new WaveBlock
  62665. * @param name defines the block name
  62666. */
  62667. constructor(name: string);
  62668. /**
  62669. * Gets the current class name
  62670. * @returns the class name
  62671. */
  62672. getClassName(): string;
  62673. /**
  62674. * Gets the input component
  62675. */
  62676. get input(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the output component
  62679. */
  62680. get output(): NodeMaterialConnectionPoint;
  62681. protected _buildBlock(state: NodeMaterialBuildState): this;
  62682. serialize(): any;
  62683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62684. }
  62685. }
  62686. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  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 { Color3 } from "babylonjs/Maths/math.color";
  62691. import { Scene } from "babylonjs/scene";
  62692. /**
  62693. * Class used to store a color step for the GradientBlock
  62694. */
  62695. export class GradientBlockColorStep {
  62696. /**
  62697. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62698. */
  62699. step: number;
  62700. /**
  62701. * Gets or sets the color associated with this step
  62702. */
  62703. color: Color3;
  62704. /**
  62705. * Creates a new GradientBlockColorStep
  62706. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62707. * @param color defines the color associated with this step
  62708. */
  62709. constructor(
  62710. /**
  62711. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62712. */
  62713. step: number,
  62714. /**
  62715. * Gets or sets the color associated with this step
  62716. */
  62717. color: Color3);
  62718. }
  62719. /**
  62720. * Block used to return a color from a gradient based on an input value between 0 and 1
  62721. */
  62722. export class GradientBlock extends NodeMaterialBlock {
  62723. /**
  62724. * Gets or sets the list of color steps
  62725. */
  62726. colorSteps: GradientBlockColorStep[];
  62727. /**
  62728. * Creates a new GradientBlock
  62729. * @param name defines the block name
  62730. */
  62731. constructor(name: string);
  62732. /**
  62733. * Gets the current class name
  62734. * @returns the class name
  62735. */
  62736. getClassName(): string;
  62737. /**
  62738. * Gets the gradient input component
  62739. */
  62740. get gradient(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the output component
  62743. */
  62744. get output(): NodeMaterialConnectionPoint;
  62745. private _writeColorConstant;
  62746. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62747. serialize(): any;
  62748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62749. protected _dumpPropertiesCode(): string;
  62750. }
  62751. }
  62752. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62756. /**
  62757. * Block used to normalize lerp between 2 values
  62758. */
  62759. export class NLerpBlock extends NodeMaterialBlock {
  62760. /**
  62761. * Creates a new NLerpBlock
  62762. * @param name defines the block name
  62763. */
  62764. constructor(name: string);
  62765. /**
  62766. * Gets the current class name
  62767. * @returns the class name
  62768. */
  62769. getClassName(): string;
  62770. /**
  62771. * Gets the left operand input component
  62772. */
  62773. get left(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the right operand input component
  62776. */
  62777. get right(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the gradient operand input component
  62780. */
  62781. get gradient(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the output component
  62784. */
  62785. get output(): NodeMaterialConnectionPoint;
  62786. protected _buildBlock(state: NodeMaterialBuildState): this;
  62787. }
  62788. }
  62789. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62793. import { Scene } from "babylonjs/scene";
  62794. /**
  62795. * block used to Generate a Worley Noise 3D Noise Pattern
  62796. */
  62797. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62798. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62799. manhattanDistance: boolean;
  62800. /**
  62801. * Creates a new WorleyNoise3DBlock
  62802. * @param name defines the block name
  62803. */
  62804. constructor(name: string);
  62805. /**
  62806. * Gets the current class name
  62807. * @returns the class name
  62808. */
  62809. getClassName(): string;
  62810. /**
  62811. * Gets the seed input component
  62812. */
  62813. get seed(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the jitter input component
  62816. */
  62817. get jitter(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the output component
  62820. */
  62821. get output(): NodeMaterialConnectionPoint;
  62822. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62823. /**
  62824. * Exposes the properties to the UI?
  62825. */
  62826. protected _dumpPropertiesCode(): string;
  62827. /**
  62828. * Exposes the properties to the Seralize?
  62829. */
  62830. serialize(): any;
  62831. /**
  62832. * Exposes the properties to the deseralize?
  62833. */
  62834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62835. }
  62836. }
  62837. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62841. /**
  62842. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62843. */
  62844. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62845. /**
  62846. * Creates a new SimplexPerlin3DBlock
  62847. * @param name defines the block name
  62848. */
  62849. constructor(name: string);
  62850. /**
  62851. * Gets the current class name
  62852. * @returns the class name
  62853. */
  62854. getClassName(): string;
  62855. /**
  62856. * Gets the seed operand input component
  62857. */
  62858. get seed(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the output component
  62861. */
  62862. get output(): NodeMaterialConnectionPoint;
  62863. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62864. }
  62865. }
  62866. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62870. /**
  62871. * Block used to blend normals
  62872. */
  62873. export class NormalBlendBlock extends NodeMaterialBlock {
  62874. /**
  62875. * Creates a new NormalBlendBlock
  62876. * @param name defines the block name
  62877. */
  62878. constructor(name: string);
  62879. /**
  62880. * Gets the current class name
  62881. * @returns the class name
  62882. */
  62883. getClassName(): string;
  62884. /**
  62885. * Gets the first input component
  62886. */
  62887. get normalMap0(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Gets the second input component
  62890. */
  62891. get normalMap1(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the output component
  62894. */
  62895. get output(): NodeMaterialConnectionPoint;
  62896. protected _buildBlock(state: NodeMaterialBuildState): this;
  62897. }
  62898. }
  62899. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62903. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62904. /**
  62905. * Block used to rotate a 2d vector by a given angle
  62906. */
  62907. export class Rotate2dBlock extends NodeMaterialBlock {
  62908. /**
  62909. * Creates a new Rotate2dBlock
  62910. * @param name defines the block name
  62911. */
  62912. constructor(name: string);
  62913. /**
  62914. * Gets the current class name
  62915. * @returns the class name
  62916. */
  62917. getClassName(): string;
  62918. /**
  62919. * Gets the input vector
  62920. */
  62921. get input(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the input angle
  62924. */
  62925. get angle(): NodeMaterialConnectionPoint;
  62926. /**
  62927. * Gets the output component
  62928. */
  62929. get output(): NodeMaterialConnectionPoint;
  62930. autoConfigure(material: NodeMaterial): void;
  62931. protected _buildBlock(state: NodeMaterialBuildState): this;
  62932. }
  62933. }
  62934. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62938. /**
  62939. * Block used to get the reflected vector from a direction and a normal
  62940. */
  62941. export class ReflectBlock extends NodeMaterialBlock {
  62942. /**
  62943. * Creates a new ReflectBlock
  62944. * @param name defines the block name
  62945. */
  62946. constructor(name: string);
  62947. /**
  62948. * Gets the current class name
  62949. * @returns the class name
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * Gets the incident component
  62954. */
  62955. get incident(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the normal component
  62958. */
  62959. get normal(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the output component
  62962. */
  62963. get output(): NodeMaterialConnectionPoint;
  62964. protected _buildBlock(state: NodeMaterialBuildState): this;
  62965. }
  62966. }
  62967. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62971. /**
  62972. * Block used to get the refracted vector from a direction and a normal
  62973. */
  62974. export class RefractBlock extends NodeMaterialBlock {
  62975. /**
  62976. * Creates a new RefractBlock
  62977. * @param name defines the block name
  62978. */
  62979. constructor(name: string);
  62980. /**
  62981. * Gets the current class name
  62982. * @returns the class name
  62983. */
  62984. getClassName(): string;
  62985. /**
  62986. * Gets the incident component
  62987. */
  62988. get incident(): NodeMaterialConnectionPoint;
  62989. /**
  62990. * Gets the normal component
  62991. */
  62992. get normal(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the index of refraction component
  62995. */
  62996. get ior(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the output component
  62999. */
  63000. get output(): NodeMaterialConnectionPoint;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63008. /**
  63009. * Block used to desaturate a color
  63010. */
  63011. export class DesaturateBlock extends NodeMaterialBlock {
  63012. /**
  63013. * Creates a new DesaturateBlock
  63014. * @param name defines the block name
  63015. */
  63016. constructor(name: string);
  63017. /**
  63018. * Gets the current class name
  63019. * @returns the class name
  63020. */
  63021. getClassName(): string;
  63022. /**
  63023. * Gets the color operand input component
  63024. */
  63025. get color(): NodeMaterialConnectionPoint;
  63026. /**
  63027. * Gets the level operand input component
  63028. */
  63029. get level(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the output component
  63032. */
  63033. get output(): NodeMaterialConnectionPoint;
  63034. protected _buildBlock(state: NodeMaterialBuildState): this;
  63035. }
  63036. }
  63037. declare module "babylonjs/Materials/Node/Blocks/index" {
  63038. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63039. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63040. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63041. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63042. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63043. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63044. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63045. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63046. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63047. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63048. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63049. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63050. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63051. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63052. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63053. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63054. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63055. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63071. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63085. }
  63086. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63087. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63088. }
  63089. declare module "babylonjs/Materials/Node/index" {
  63090. export * from "babylonjs/Materials/Node/Enums/index";
  63091. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63092. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63093. export * from "babylonjs/Materials/Node/nodeMaterial";
  63094. export * from "babylonjs/Materials/Node/Blocks/index";
  63095. export * from "babylonjs/Materials/Node/Optimizers/index";
  63096. }
  63097. declare module "babylonjs/Materials/effectRenderer" {
  63098. import { Nullable } from "babylonjs/types";
  63099. import { Texture } from "babylonjs/Materials/Textures/texture";
  63100. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63101. import { Viewport } from "babylonjs/Maths/math.viewport";
  63102. import { Observable } from "babylonjs/Misc/observable";
  63103. import { Effect } from "babylonjs/Materials/effect";
  63104. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63105. import "babylonjs/Shaders/postprocess.vertex";
  63106. /**
  63107. * Effect Render Options
  63108. */
  63109. export interface IEffectRendererOptions {
  63110. /**
  63111. * Defines the vertices positions.
  63112. */
  63113. positions?: number[];
  63114. /**
  63115. * Defines the indices.
  63116. */
  63117. indices?: number[];
  63118. }
  63119. /**
  63120. * Helper class to render one or more effects
  63121. */
  63122. export class EffectRenderer {
  63123. private engine;
  63124. private static _DefaultOptions;
  63125. private _vertexBuffers;
  63126. private _indexBuffer;
  63127. private _ringBufferIndex;
  63128. private _ringScreenBuffer;
  63129. private _fullscreenViewport;
  63130. private _getNextFrameBuffer;
  63131. /**
  63132. * Creates an effect renderer
  63133. * @param engine the engine to use for rendering
  63134. * @param options defines the options of the effect renderer
  63135. */
  63136. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63137. /**
  63138. * Sets the current viewport in normalized coordinates 0-1
  63139. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63140. */
  63141. setViewport(viewport?: Viewport): void;
  63142. /**
  63143. * Binds the embedded attributes buffer to the effect.
  63144. * @param effect Defines the effect to bind the attributes for
  63145. */
  63146. bindBuffers(effect: Effect): void;
  63147. /**
  63148. * Sets the current effect wrapper to use during draw.
  63149. * The effect needs to be ready before calling this api.
  63150. * This also sets the default full screen position attribute.
  63151. * @param effectWrapper Defines the effect to draw with
  63152. */
  63153. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63154. /**
  63155. * Draws a full screen quad.
  63156. */
  63157. draw(): void;
  63158. /**
  63159. * renders one or more effects to a specified texture
  63160. * @param effectWrappers list of effects to renderer
  63161. * @param outputTexture texture to draw to, if null it will render to the screen
  63162. */
  63163. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63164. /**
  63165. * Disposes of the effect renderer
  63166. */
  63167. dispose(): void;
  63168. }
  63169. /**
  63170. * Options to create an EffectWrapper
  63171. */
  63172. interface EffectWrapperCreationOptions {
  63173. /**
  63174. * Engine to use to create the effect
  63175. */
  63176. engine: ThinEngine;
  63177. /**
  63178. * Fragment shader for the effect
  63179. */
  63180. fragmentShader: string;
  63181. /**
  63182. * Vertex shader for the effect
  63183. */
  63184. vertexShader?: string;
  63185. /**
  63186. * Attributes to use in the shader
  63187. */
  63188. attributeNames?: Array<string>;
  63189. /**
  63190. * Uniforms to use in the shader
  63191. */
  63192. uniformNames?: Array<string>;
  63193. /**
  63194. * Texture sampler names to use in the shader
  63195. */
  63196. samplerNames?: Array<string>;
  63197. /**
  63198. * The friendly name of the effect displayed in Spector.
  63199. */
  63200. name?: string;
  63201. }
  63202. /**
  63203. * Wraps an effect to be used for rendering
  63204. */
  63205. export class EffectWrapper {
  63206. /**
  63207. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63208. */
  63209. onApplyObservable: Observable<{}>;
  63210. /**
  63211. * The underlying effect
  63212. */
  63213. effect: Effect;
  63214. /**
  63215. * Creates an effect to be renderer
  63216. * @param creationOptions options to create the effect
  63217. */
  63218. constructor(creationOptions: EffectWrapperCreationOptions);
  63219. /**
  63220. * Disposes of the effect wrapper
  63221. */
  63222. dispose(): void;
  63223. }
  63224. }
  63225. declare module "babylonjs/Materials/index" {
  63226. export * from "babylonjs/Materials/Background/index";
  63227. export * from "babylonjs/Materials/colorCurves";
  63228. export * from "babylonjs/Materials/iEffectFallbacks";
  63229. export * from "babylonjs/Materials/effectFallbacks";
  63230. export * from "babylonjs/Materials/effect";
  63231. export * from "babylonjs/Materials/fresnelParameters";
  63232. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63233. export * from "babylonjs/Materials/material";
  63234. export * from "babylonjs/Materials/materialDefines";
  63235. export * from "babylonjs/Materials/materialHelper";
  63236. export * from "babylonjs/Materials/multiMaterial";
  63237. export * from "babylonjs/Materials/PBR/index";
  63238. export * from "babylonjs/Materials/pushMaterial";
  63239. export * from "babylonjs/Materials/shaderMaterial";
  63240. export * from "babylonjs/Materials/standardMaterial";
  63241. export * from "babylonjs/Materials/Textures/index";
  63242. export * from "babylonjs/Materials/uniformBuffer";
  63243. export * from "babylonjs/Materials/materialFlags";
  63244. export * from "babylonjs/Materials/Node/index";
  63245. export * from "babylonjs/Materials/effectRenderer";
  63246. }
  63247. declare module "babylonjs/Maths/index" {
  63248. export * from "babylonjs/Maths/math.scalar";
  63249. export * from "babylonjs/Maths/math";
  63250. export * from "babylonjs/Maths/sphericalPolynomial";
  63251. }
  63252. declare module "babylonjs/Misc/workerPool" {
  63253. import { IDisposable } from "babylonjs/scene";
  63254. /**
  63255. * Helper class to push actions to a pool of workers.
  63256. */
  63257. export class WorkerPool implements IDisposable {
  63258. private _workerInfos;
  63259. private _pendingActions;
  63260. /**
  63261. * Constructor
  63262. * @param workers Array of workers to use for actions
  63263. */
  63264. constructor(workers: Array<Worker>);
  63265. /**
  63266. * Terminates all workers and clears any pending actions.
  63267. */
  63268. dispose(): void;
  63269. /**
  63270. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63271. * pended until a worker has completed its action.
  63272. * @param action The action to perform. Call onComplete when the action is complete.
  63273. */
  63274. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63275. private _execute;
  63276. }
  63277. }
  63278. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63279. import { IDisposable } from "babylonjs/scene";
  63280. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63281. /**
  63282. * Configuration for Draco compression
  63283. */
  63284. export interface IDracoCompressionConfiguration {
  63285. /**
  63286. * Configuration for the decoder.
  63287. */
  63288. decoder: {
  63289. /**
  63290. * The url to the WebAssembly module.
  63291. */
  63292. wasmUrl?: string;
  63293. /**
  63294. * The url to the WebAssembly binary.
  63295. */
  63296. wasmBinaryUrl?: string;
  63297. /**
  63298. * The url to the fallback JavaScript module.
  63299. */
  63300. fallbackUrl?: string;
  63301. };
  63302. }
  63303. /**
  63304. * Draco compression (https://google.github.io/draco/)
  63305. *
  63306. * This class wraps the Draco module.
  63307. *
  63308. * **Encoder**
  63309. *
  63310. * The encoder is not currently implemented.
  63311. *
  63312. * **Decoder**
  63313. *
  63314. * 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.
  63315. *
  63316. * To update the configuration, use the following code:
  63317. * ```javascript
  63318. * DracoCompression.Configuration = {
  63319. * decoder: {
  63320. * wasmUrl: "<url to the WebAssembly library>",
  63321. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63322. * fallbackUrl: "<url to the fallback JavaScript library>",
  63323. * }
  63324. * };
  63325. * ```
  63326. *
  63327. * 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.
  63328. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63329. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63330. *
  63331. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63332. * ```javascript
  63333. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63334. * ```
  63335. *
  63336. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63337. */
  63338. export class DracoCompression implements IDisposable {
  63339. private _workerPoolPromise?;
  63340. private _decoderModulePromise?;
  63341. /**
  63342. * The configuration. Defaults to the following urls:
  63343. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63344. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63345. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63346. */
  63347. static Configuration: IDracoCompressionConfiguration;
  63348. /**
  63349. * Returns true if the decoder configuration is available.
  63350. */
  63351. static get DecoderAvailable(): boolean;
  63352. /**
  63353. * Default number of workers to create when creating the draco compression object.
  63354. */
  63355. static DefaultNumWorkers: number;
  63356. private static GetDefaultNumWorkers;
  63357. private static _Default;
  63358. /**
  63359. * Default instance for the draco compression object.
  63360. */
  63361. static get Default(): DracoCompression;
  63362. /**
  63363. * Constructor
  63364. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63365. */
  63366. constructor(numWorkers?: number);
  63367. /**
  63368. * Stop all async operations and release resources.
  63369. */
  63370. dispose(): void;
  63371. /**
  63372. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63373. * @returns a promise that resolves when ready
  63374. */
  63375. whenReadyAsync(): Promise<void>;
  63376. /**
  63377. * Decode Draco compressed mesh data to vertex data.
  63378. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63379. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63380. * @returns A promise that resolves with the decoded vertex data
  63381. */
  63382. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63383. [kind: string]: number;
  63384. }): Promise<VertexData>;
  63385. }
  63386. }
  63387. declare module "babylonjs/Meshes/Compression/index" {
  63388. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63389. }
  63390. declare module "babylonjs/Meshes/csg" {
  63391. import { Nullable } from "babylonjs/types";
  63392. import { Scene } from "babylonjs/scene";
  63393. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63394. import { Mesh } from "babylonjs/Meshes/mesh";
  63395. import { Material } from "babylonjs/Materials/material";
  63396. /**
  63397. * Class for building Constructive Solid Geometry
  63398. */
  63399. export class CSG {
  63400. private polygons;
  63401. /**
  63402. * The world matrix
  63403. */
  63404. matrix: Matrix;
  63405. /**
  63406. * Stores the position
  63407. */
  63408. position: Vector3;
  63409. /**
  63410. * Stores the rotation
  63411. */
  63412. rotation: Vector3;
  63413. /**
  63414. * Stores the rotation quaternion
  63415. */
  63416. rotationQuaternion: Nullable<Quaternion>;
  63417. /**
  63418. * Stores the scaling vector
  63419. */
  63420. scaling: Vector3;
  63421. /**
  63422. * Convert the Mesh to CSG
  63423. * @param mesh The Mesh to convert to CSG
  63424. * @returns A new CSG from the Mesh
  63425. */
  63426. static FromMesh(mesh: Mesh): CSG;
  63427. /**
  63428. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63429. * @param polygons Polygons used to construct a CSG solid
  63430. */
  63431. private static FromPolygons;
  63432. /**
  63433. * Clones, or makes a deep copy, of the CSG
  63434. * @returns A new CSG
  63435. */
  63436. clone(): CSG;
  63437. /**
  63438. * Unions this CSG with another CSG
  63439. * @param csg The CSG to union against this CSG
  63440. * @returns The unioned CSG
  63441. */
  63442. union(csg: CSG): CSG;
  63443. /**
  63444. * Unions this CSG with another CSG in place
  63445. * @param csg The CSG to union against this CSG
  63446. */
  63447. unionInPlace(csg: CSG): void;
  63448. /**
  63449. * Subtracts this CSG with another CSG
  63450. * @param csg The CSG to subtract against this CSG
  63451. * @returns A new CSG
  63452. */
  63453. subtract(csg: CSG): CSG;
  63454. /**
  63455. * Subtracts this CSG with another CSG in place
  63456. * @param csg The CSG to subtact against this CSG
  63457. */
  63458. subtractInPlace(csg: CSG): void;
  63459. /**
  63460. * Intersect this CSG with another CSG
  63461. * @param csg The CSG to intersect against this CSG
  63462. * @returns A new CSG
  63463. */
  63464. intersect(csg: CSG): CSG;
  63465. /**
  63466. * Intersects this CSG with another CSG in place
  63467. * @param csg The CSG to intersect against this CSG
  63468. */
  63469. intersectInPlace(csg: CSG): void;
  63470. /**
  63471. * Return a new CSG solid with solid and empty space switched. This solid is
  63472. * not modified.
  63473. * @returns A new CSG solid with solid and empty space switched
  63474. */
  63475. inverse(): CSG;
  63476. /**
  63477. * Inverses the CSG in place
  63478. */
  63479. inverseInPlace(): void;
  63480. /**
  63481. * This is used to keep meshes transformations so they can be restored
  63482. * when we build back a Babylon Mesh
  63483. * NB : All CSG operations are performed in world coordinates
  63484. * @param csg The CSG to copy the transform attributes from
  63485. * @returns This CSG
  63486. */
  63487. copyTransformAttributes(csg: CSG): CSG;
  63488. /**
  63489. * Build Raw mesh from CSG
  63490. * Coordinates here are in world space
  63491. * @param name The name of the mesh geometry
  63492. * @param scene The Scene
  63493. * @param keepSubMeshes Specifies if the submeshes should be kept
  63494. * @returns A new Mesh
  63495. */
  63496. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63497. /**
  63498. * Build Mesh from CSG taking material and transforms into account
  63499. * @param name The name of the Mesh
  63500. * @param material The material of the Mesh
  63501. * @param scene The Scene
  63502. * @param keepSubMeshes Specifies if submeshes should be kept
  63503. * @returns The new Mesh
  63504. */
  63505. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63506. }
  63507. }
  63508. declare module "babylonjs/Meshes/trailMesh" {
  63509. import { Mesh } from "babylonjs/Meshes/mesh";
  63510. import { Scene } from "babylonjs/scene";
  63511. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63512. /**
  63513. * Class used to create a trail following a mesh
  63514. */
  63515. export class TrailMesh extends Mesh {
  63516. private _generator;
  63517. private _autoStart;
  63518. private _running;
  63519. private _diameter;
  63520. private _length;
  63521. private _sectionPolygonPointsCount;
  63522. private _sectionVectors;
  63523. private _sectionNormalVectors;
  63524. private _beforeRenderObserver;
  63525. /**
  63526. * @constructor
  63527. * @param name The value used by scene.getMeshByName() to do a lookup.
  63528. * @param generator The mesh or transform node to generate a trail.
  63529. * @param scene The scene to add this mesh to.
  63530. * @param diameter Diameter of trailing mesh. Default is 1.
  63531. * @param length Length of trailing mesh. Default is 60.
  63532. * @param autoStart Automatically start trailing mesh. Default true.
  63533. */
  63534. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63535. /**
  63536. * "TrailMesh"
  63537. * @returns "TrailMesh"
  63538. */
  63539. getClassName(): string;
  63540. private _createMesh;
  63541. /**
  63542. * Start trailing mesh.
  63543. */
  63544. start(): void;
  63545. /**
  63546. * Stop trailing mesh.
  63547. */
  63548. stop(): void;
  63549. /**
  63550. * Update trailing mesh geometry.
  63551. */
  63552. update(): void;
  63553. /**
  63554. * Returns a new TrailMesh object.
  63555. * @param name is a string, the name given to the new mesh
  63556. * @param newGenerator use new generator object for cloned trail mesh
  63557. * @returns a new mesh
  63558. */
  63559. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63560. /**
  63561. * Serializes this trail mesh
  63562. * @param serializationObject object to write serialization to
  63563. */
  63564. serialize(serializationObject: any): void;
  63565. /**
  63566. * Parses a serialized trail mesh
  63567. * @param parsedMesh the serialized mesh
  63568. * @param scene the scene to create the trail mesh in
  63569. * @returns the created trail mesh
  63570. */
  63571. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63572. }
  63573. }
  63574. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63575. import { Nullable } from "babylonjs/types";
  63576. import { Scene } from "babylonjs/scene";
  63577. import { Vector4 } from "babylonjs/Maths/math.vector";
  63578. import { Color4 } from "babylonjs/Maths/math.color";
  63579. import { Mesh } from "babylonjs/Meshes/mesh";
  63580. /**
  63581. * Class containing static functions to help procedurally build meshes
  63582. */
  63583. export class TiledBoxBuilder {
  63584. /**
  63585. * Creates a box mesh
  63586. * 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)
  63587. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63591. * @param name defines the name of the mesh
  63592. * @param options defines the options used to create the mesh
  63593. * @param scene defines the hosting scene
  63594. * @returns the box mesh
  63595. */
  63596. static CreateTiledBox(name: string, options: {
  63597. pattern?: number;
  63598. width?: number;
  63599. height?: number;
  63600. depth?: number;
  63601. tileSize?: number;
  63602. tileWidth?: number;
  63603. tileHeight?: number;
  63604. alignHorizontal?: number;
  63605. alignVertical?: number;
  63606. faceUV?: Vector4[];
  63607. faceColors?: Color4[];
  63608. sideOrientation?: number;
  63609. updatable?: boolean;
  63610. }, scene?: Nullable<Scene>): Mesh;
  63611. }
  63612. }
  63613. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63614. import { Vector4 } from "babylonjs/Maths/math.vector";
  63615. import { Mesh } from "babylonjs/Meshes/mesh";
  63616. /**
  63617. * Class containing static functions to help procedurally build meshes
  63618. */
  63619. export class TorusKnotBuilder {
  63620. /**
  63621. * Creates a torus knot mesh
  63622. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63623. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63624. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63625. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63629. * @param name defines the name of the mesh
  63630. * @param options defines the options used to create the mesh
  63631. * @param scene defines the hosting scene
  63632. * @returns the torus knot mesh
  63633. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63634. */
  63635. static CreateTorusKnot(name: string, options: {
  63636. radius?: number;
  63637. tube?: number;
  63638. radialSegments?: number;
  63639. tubularSegments?: number;
  63640. p?: number;
  63641. q?: number;
  63642. updatable?: boolean;
  63643. sideOrientation?: number;
  63644. frontUVs?: Vector4;
  63645. backUVs?: Vector4;
  63646. }, scene: any): Mesh;
  63647. }
  63648. }
  63649. declare module "babylonjs/Meshes/polygonMesh" {
  63650. import { Scene } from "babylonjs/scene";
  63651. import { Vector2 } from "babylonjs/Maths/math.vector";
  63652. import { Mesh } from "babylonjs/Meshes/mesh";
  63653. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63654. import { Path2 } from "babylonjs/Maths/math.path";
  63655. /**
  63656. * Polygon
  63657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63658. */
  63659. export class Polygon {
  63660. /**
  63661. * Creates a rectangle
  63662. * @param xmin bottom X coord
  63663. * @param ymin bottom Y coord
  63664. * @param xmax top X coord
  63665. * @param ymax top Y coord
  63666. * @returns points that make the resulting rectation
  63667. */
  63668. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63669. /**
  63670. * Creates a circle
  63671. * @param radius radius of circle
  63672. * @param cx scale in x
  63673. * @param cy scale in y
  63674. * @param numberOfSides number of sides that make up the circle
  63675. * @returns points that make the resulting circle
  63676. */
  63677. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63678. /**
  63679. * Creates a polygon from input string
  63680. * @param input Input polygon data
  63681. * @returns the parsed points
  63682. */
  63683. static Parse(input: string): Vector2[];
  63684. /**
  63685. * Starts building a polygon from x and y coordinates
  63686. * @param x x coordinate
  63687. * @param y y coordinate
  63688. * @returns the started path2
  63689. */
  63690. static StartingAt(x: number, y: number): Path2;
  63691. }
  63692. /**
  63693. * Builds a polygon
  63694. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63695. */
  63696. export class PolygonMeshBuilder {
  63697. private _points;
  63698. private _outlinepoints;
  63699. private _holes;
  63700. private _name;
  63701. private _scene;
  63702. private _epoints;
  63703. private _eholes;
  63704. private _addToepoint;
  63705. /**
  63706. * Babylon reference to the earcut plugin.
  63707. */
  63708. bjsEarcut: any;
  63709. /**
  63710. * Creates a PolygonMeshBuilder
  63711. * @param name name of the builder
  63712. * @param contours Path of the polygon
  63713. * @param scene scene to add to when creating the mesh
  63714. * @param earcutInjection can be used to inject your own earcut reference
  63715. */
  63716. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63717. /**
  63718. * Adds a whole within the polygon
  63719. * @param hole Array of points defining the hole
  63720. * @returns this
  63721. */
  63722. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63723. /**
  63724. * Creates the polygon
  63725. * @param updatable If the mesh should be updatable
  63726. * @param depth The depth of the mesh created
  63727. * @returns the created mesh
  63728. */
  63729. build(updatable?: boolean, depth?: number): Mesh;
  63730. /**
  63731. * Creates the polygon
  63732. * @param depth The depth of the mesh created
  63733. * @returns the created VertexData
  63734. */
  63735. buildVertexData(depth?: number): VertexData;
  63736. /**
  63737. * Adds a side to the polygon
  63738. * @param positions points that make the polygon
  63739. * @param normals normals of the polygon
  63740. * @param uvs uvs of the polygon
  63741. * @param indices indices of the polygon
  63742. * @param bounds bounds of the polygon
  63743. * @param points points of the polygon
  63744. * @param depth depth of the polygon
  63745. * @param flip flip of the polygon
  63746. */
  63747. private addSide;
  63748. }
  63749. }
  63750. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63751. import { Scene } from "babylonjs/scene";
  63752. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63753. import { Color4 } from "babylonjs/Maths/math.color";
  63754. import { Mesh } from "babylonjs/Meshes/mesh";
  63755. import { Nullable } from "babylonjs/types";
  63756. /**
  63757. * Class containing static functions to help procedurally build meshes
  63758. */
  63759. export class PolygonBuilder {
  63760. /**
  63761. * Creates a polygon mesh
  63762. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63763. * * 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
  63764. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63767. * * Remember you can only change the shape positions, not their number when updating a polygon
  63768. * @param name defines the name of the mesh
  63769. * @param options defines the options used to create the mesh
  63770. * @param scene defines the hosting scene
  63771. * @param earcutInjection can be used to inject your own earcut reference
  63772. * @returns the polygon mesh
  63773. */
  63774. static CreatePolygon(name: string, options: {
  63775. shape: Vector3[];
  63776. holes?: Vector3[][];
  63777. depth?: number;
  63778. faceUV?: Vector4[];
  63779. faceColors?: Color4[];
  63780. updatable?: boolean;
  63781. sideOrientation?: number;
  63782. frontUVs?: Vector4;
  63783. backUVs?: Vector4;
  63784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63785. /**
  63786. * Creates an extruded polygon mesh, with depth in the Y direction.
  63787. * * 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)
  63788. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63789. * @param name defines the name of the mesh
  63790. * @param options defines the options used to create the mesh
  63791. * @param scene defines the hosting scene
  63792. * @param earcutInjection can be used to inject your own earcut reference
  63793. * @returns the polygon mesh
  63794. */
  63795. static ExtrudePolygon(name: string, options: {
  63796. shape: Vector3[];
  63797. holes?: Vector3[][];
  63798. depth?: number;
  63799. faceUV?: Vector4[];
  63800. faceColors?: Color4[];
  63801. updatable?: boolean;
  63802. sideOrientation?: number;
  63803. frontUVs?: Vector4;
  63804. backUVs?: Vector4;
  63805. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63806. }
  63807. }
  63808. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63809. import { Scene } from "babylonjs/scene";
  63810. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63811. import { Mesh } from "babylonjs/Meshes/mesh";
  63812. import { Nullable } from "babylonjs/types";
  63813. /**
  63814. * Class containing static functions to help procedurally build meshes
  63815. */
  63816. export class LatheBuilder {
  63817. /**
  63818. * Creates lathe mesh.
  63819. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63820. * * 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
  63821. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63822. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63823. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63824. * * 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
  63825. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63826. * * 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
  63827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63831. * @param name defines the name of the mesh
  63832. * @param options defines the options used to create the mesh
  63833. * @param scene defines the hosting scene
  63834. * @returns the lathe mesh
  63835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63836. */
  63837. static CreateLathe(name: string, options: {
  63838. shape: Vector3[];
  63839. radius?: number;
  63840. tessellation?: number;
  63841. clip?: number;
  63842. arc?: number;
  63843. closed?: boolean;
  63844. updatable?: boolean;
  63845. sideOrientation?: number;
  63846. frontUVs?: Vector4;
  63847. backUVs?: Vector4;
  63848. cap?: number;
  63849. invertUV?: boolean;
  63850. }, scene?: Nullable<Scene>): Mesh;
  63851. }
  63852. }
  63853. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63854. import { Nullable } from "babylonjs/types";
  63855. import { Scene } from "babylonjs/scene";
  63856. import { Vector4 } from "babylonjs/Maths/math.vector";
  63857. import { Mesh } from "babylonjs/Meshes/mesh";
  63858. /**
  63859. * Class containing static functions to help procedurally build meshes
  63860. */
  63861. export class TiledPlaneBuilder {
  63862. /**
  63863. * Creates a tiled plane mesh
  63864. * * The parameter `pattern` will, depending on value, do nothing or
  63865. * * * flip (reflect about central vertical) alternate tiles across and up
  63866. * * * flip every tile on alternate rows
  63867. * * * rotate (180 degs) alternate tiles across and up
  63868. * * * rotate every tile on alternate rows
  63869. * * * flip and rotate alternate tiles across and up
  63870. * * * flip and rotate every tile on alternate rows
  63871. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63872. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63875. * * 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)
  63876. * * 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)
  63877. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  63882. */
  63883. static CreateTiledPlane(name: string, options: {
  63884. pattern?: number;
  63885. tileSize?: number;
  63886. tileWidth?: number;
  63887. tileHeight?: number;
  63888. size?: number;
  63889. width?: number;
  63890. height?: number;
  63891. alignHorizontal?: number;
  63892. alignVertical?: number;
  63893. sideOrientation?: number;
  63894. frontUVs?: Vector4;
  63895. backUVs?: Vector4;
  63896. updatable?: boolean;
  63897. }, scene?: Nullable<Scene>): Mesh;
  63898. }
  63899. }
  63900. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63901. import { Nullable } from "babylonjs/types";
  63902. import { Scene } from "babylonjs/scene";
  63903. import { Vector3, 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 TubeBuilder {
  63909. /**
  63910. * Creates a tube mesh.
  63911. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63912. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63913. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63914. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63915. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63916. * * 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)
  63917. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63918. * * 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
  63919. * * 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
  63920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63924. * @param name defines the name of the mesh
  63925. * @param options defines the options used to create the mesh
  63926. * @param scene defines the hosting scene
  63927. * @returns the tube mesh
  63928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63929. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63930. */
  63931. static CreateTube(name: string, options: {
  63932. path: Vector3[];
  63933. radius?: number;
  63934. tessellation?: number;
  63935. radiusFunction?: {
  63936. (i: number, distance: number): number;
  63937. };
  63938. cap?: number;
  63939. arc?: number;
  63940. updatable?: boolean;
  63941. sideOrientation?: number;
  63942. frontUVs?: Vector4;
  63943. backUVs?: Vector4;
  63944. instance?: Mesh;
  63945. invertUV?: boolean;
  63946. }, scene?: Nullable<Scene>): Mesh;
  63947. }
  63948. }
  63949. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63950. import { Scene } from "babylonjs/scene";
  63951. import { Vector4 } from "babylonjs/Maths/math.vector";
  63952. import { Mesh } from "babylonjs/Meshes/mesh";
  63953. import { Nullable } from "babylonjs/types";
  63954. /**
  63955. * Class containing static functions to help procedurally build meshes
  63956. */
  63957. export class IcoSphereBuilder {
  63958. /**
  63959. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63960. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63961. * * 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`)
  63962. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63963. * * 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
  63964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63967. * @param name defines the name of the mesh
  63968. * @param options defines the options used to create the mesh
  63969. * @param scene defines the hosting scene
  63970. * @returns the icosahedron mesh
  63971. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63972. */
  63973. static CreateIcoSphere(name: string, options: {
  63974. radius?: number;
  63975. radiusX?: number;
  63976. radiusY?: number;
  63977. radiusZ?: number;
  63978. flat?: boolean;
  63979. subdivisions?: number;
  63980. sideOrientation?: number;
  63981. frontUVs?: Vector4;
  63982. backUVs?: Vector4;
  63983. updatable?: boolean;
  63984. }, scene?: Nullable<Scene>): Mesh;
  63985. }
  63986. }
  63987. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63988. import { Vector3 } from "babylonjs/Maths/math.vector";
  63989. import { Mesh } from "babylonjs/Meshes/mesh";
  63990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63991. /**
  63992. * Class containing static functions to help procedurally build meshes
  63993. */
  63994. export class DecalBuilder {
  63995. /**
  63996. * Creates a decal mesh.
  63997. * 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
  63998. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63999. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64000. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64001. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64002. * @param name defines the name of the mesh
  64003. * @param sourceMesh defines the mesh where the decal must be applied
  64004. * @param options defines the options used to create the mesh
  64005. * @param scene defines the hosting scene
  64006. * @returns the decal mesh
  64007. * @see https://doc.babylonjs.com/how_to/decals
  64008. */
  64009. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64010. position?: Vector3;
  64011. normal?: Vector3;
  64012. size?: Vector3;
  64013. angle?: number;
  64014. }): Mesh;
  64015. }
  64016. }
  64017. declare module "babylonjs/Meshes/meshBuilder" {
  64018. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64019. import { Nullable } from "babylonjs/types";
  64020. import { Scene } from "babylonjs/scene";
  64021. import { Mesh } from "babylonjs/Meshes/mesh";
  64022. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64023. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64025. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64026. import { Plane } from "babylonjs/Maths/math.plane";
  64027. /**
  64028. * Class containing static functions to help procedurally build meshes
  64029. */
  64030. export class MeshBuilder {
  64031. /**
  64032. * Creates a box mesh
  64033. * * The parameter `size` sets the size (float) of each box side (default 1)
  64034. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64035. * * 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)
  64036. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64040. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64041. * @param name defines the name of the mesh
  64042. * @param options defines the options used to create the mesh
  64043. * @param scene defines the hosting scene
  64044. * @returns the box mesh
  64045. */
  64046. static CreateBox(name: string, options: {
  64047. size?: number;
  64048. width?: number;
  64049. height?: number;
  64050. depth?: number;
  64051. faceUV?: Vector4[];
  64052. faceColors?: Color4[];
  64053. sideOrientation?: number;
  64054. frontUVs?: Vector4;
  64055. backUVs?: Vector4;
  64056. updatable?: boolean;
  64057. }, scene?: Nullable<Scene>): Mesh;
  64058. /**
  64059. * Creates a tiled box mesh
  64060. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64062. * @param name defines the name of the mesh
  64063. * @param options defines the options used to create the mesh
  64064. * @param scene defines the hosting scene
  64065. * @returns the tiled box mesh
  64066. */
  64067. static CreateTiledBox(name: string, options: {
  64068. pattern?: number;
  64069. size?: number;
  64070. width?: number;
  64071. height?: number;
  64072. depth: number;
  64073. tileSize?: number;
  64074. tileWidth?: number;
  64075. tileHeight?: number;
  64076. faceUV?: Vector4[];
  64077. faceColors?: Color4[];
  64078. alignHorizontal?: number;
  64079. alignVertical?: number;
  64080. sideOrientation?: number;
  64081. updatable?: boolean;
  64082. }, scene?: Nullable<Scene>): Mesh;
  64083. /**
  64084. * Creates a sphere mesh
  64085. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64086. * * 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`)
  64087. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64088. * * 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
  64089. * * 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)
  64090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64093. * @param name defines the name of the mesh
  64094. * @param options defines the options used to create the mesh
  64095. * @param scene defines the hosting scene
  64096. * @returns the sphere mesh
  64097. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64098. */
  64099. static CreateSphere(name: string, options: {
  64100. segments?: number;
  64101. diameter?: number;
  64102. diameterX?: number;
  64103. diameterY?: number;
  64104. diameterZ?: number;
  64105. arc?: number;
  64106. slice?: number;
  64107. sideOrientation?: number;
  64108. frontUVs?: Vector4;
  64109. backUVs?: Vector4;
  64110. updatable?: boolean;
  64111. }, scene?: Nullable<Scene>): Mesh;
  64112. /**
  64113. * Creates a plane polygonal mesh. By default, this is a disc
  64114. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64115. * * 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
  64116. * * 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
  64117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64120. * @param name defines the name of the mesh
  64121. * @param options defines the options used to create the mesh
  64122. * @param scene defines the hosting scene
  64123. * @returns the plane polygonal mesh
  64124. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64125. */
  64126. static CreateDisc(name: string, options: {
  64127. radius?: number;
  64128. tessellation?: number;
  64129. arc?: number;
  64130. updatable?: boolean;
  64131. sideOrientation?: number;
  64132. frontUVs?: Vector4;
  64133. backUVs?: Vector4;
  64134. }, scene?: Nullable<Scene>): Mesh;
  64135. /**
  64136. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64137. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64138. * * 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`)
  64139. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64140. * * 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
  64141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64144. * @param name defines the name of the mesh
  64145. * @param options defines the options used to create the mesh
  64146. * @param scene defines the hosting scene
  64147. * @returns the icosahedron mesh
  64148. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64149. */
  64150. static CreateIcoSphere(name: string, options: {
  64151. radius?: number;
  64152. radiusX?: number;
  64153. radiusY?: number;
  64154. radiusZ?: number;
  64155. flat?: boolean;
  64156. subdivisions?: number;
  64157. sideOrientation?: number;
  64158. frontUVs?: Vector4;
  64159. backUVs?: Vector4;
  64160. updatable?: boolean;
  64161. }, scene?: Nullable<Scene>): Mesh;
  64162. /**
  64163. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64164. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64165. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64166. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64167. * * 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
  64168. * * 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
  64169. * * 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
  64170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64173. * * 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
  64174. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64175. * * 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
  64176. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64178. * @param name defines the name of the mesh
  64179. * @param options defines the options used to create the mesh
  64180. * @param scene defines the hosting scene
  64181. * @returns the ribbon mesh
  64182. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64184. */
  64185. static CreateRibbon(name: string, options: {
  64186. pathArray: Vector3[][];
  64187. closeArray?: boolean;
  64188. closePath?: boolean;
  64189. offset?: number;
  64190. updatable?: boolean;
  64191. sideOrientation?: number;
  64192. frontUVs?: Vector4;
  64193. backUVs?: Vector4;
  64194. instance?: Mesh;
  64195. invertUV?: boolean;
  64196. uvs?: Vector2[];
  64197. colors?: Color4[];
  64198. }, scene?: Nullable<Scene>): Mesh;
  64199. /**
  64200. * Creates a cylinder or a cone mesh
  64201. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64202. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64203. * * 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.
  64204. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64205. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64206. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64207. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64208. * * 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).
  64209. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64210. * * 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).
  64211. * * 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
  64212. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64213. * * 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
  64214. * * 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.
  64215. * * If `enclose` is false, a ring surface is one element.
  64216. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64217. * * 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
  64218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64221. * @param name defines the name of the mesh
  64222. * @param options defines the options used to create the mesh
  64223. * @param scene defines the hosting scene
  64224. * @returns the cylinder mesh
  64225. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64226. */
  64227. static CreateCylinder(name: string, options: {
  64228. height?: number;
  64229. diameterTop?: number;
  64230. diameterBottom?: number;
  64231. diameter?: number;
  64232. tessellation?: number;
  64233. subdivisions?: number;
  64234. arc?: number;
  64235. faceColors?: Color4[];
  64236. faceUV?: Vector4[];
  64237. updatable?: boolean;
  64238. hasRings?: boolean;
  64239. enclose?: boolean;
  64240. cap?: number;
  64241. sideOrientation?: number;
  64242. frontUVs?: Vector4;
  64243. backUVs?: Vector4;
  64244. }, scene?: Nullable<Scene>): Mesh;
  64245. /**
  64246. * Creates a torus mesh
  64247. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64248. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64249. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64253. * @param name defines the name of the mesh
  64254. * @param options defines the options used to create the mesh
  64255. * @param scene defines the hosting scene
  64256. * @returns the torus mesh
  64257. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64258. */
  64259. static CreateTorus(name: string, options: {
  64260. diameter?: number;
  64261. thickness?: number;
  64262. tessellation?: number;
  64263. updatable?: boolean;
  64264. sideOrientation?: number;
  64265. frontUVs?: Vector4;
  64266. backUVs?: Vector4;
  64267. }, scene?: Nullable<Scene>): Mesh;
  64268. /**
  64269. * Creates a torus knot mesh
  64270. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64271. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64272. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64273. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64277. * @param name defines the name of the mesh
  64278. * @param options defines the options used to create the mesh
  64279. * @param scene defines the hosting scene
  64280. * @returns the torus knot mesh
  64281. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64282. */
  64283. static CreateTorusKnot(name: string, options: {
  64284. radius?: number;
  64285. tube?: number;
  64286. radialSegments?: number;
  64287. tubularSegments?: number;
  64288. p?: number;
  64289. q?: number;
  64290. updatable?: boolean;
  64291. sideOrientation?: number;
  64292. frontUVs?: Vector4;
  64293. backUVs?: Vector4;
  64294. }, scene?: Nullable<Scene>): Mesh;
  64295. /**
  64296. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64297. * * 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
  64298. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64299. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64300. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64301. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64302. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64303. * * 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
  64304. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64307. * @param name defines the name of the new line system
  64308. * @param options defines the options used to create the line system
  64309. * @param scene defines the hosting scene
  64310. * @returns a new line system mesh
  64311. */
  64312. static CreateLineSystem(name: string, options: {
  64313. lines: Vector3[][];
  64314. updatable?: boolean;
  64315. instance?: Nullable<LinesMesh>;
  64316. colors?: Nullable<Color4[][]>;
  64317. useVertexAlpha?: boolean;
  64318. }, scene: Nullable<Scene>): LinesMesh;
  64319. /**
  64320. * Creates a line mesh
  64321. * 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
  64322. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64323. * * The parameter `points` is an array successive Vector3
  64324. * * 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
  64325. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64326. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64327. * * When updating an instance, remember that only point positions can change, not the number of points
  64328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64330. * @param name defines the name of the new line system
  64331. * @param options defines the options used to create the line system
  64332. * @param scene defines the hosting scene
  64333. * @returns a new line mesh
  64334. */
  64335. static CreateLines(name: string, options: {
  64336. points: Vector3[];
  64337. updatable?: boolean;
  64338. instance?: Nullable<LinesMesh>;
  64339. colors?: Color4[];
  64340. useVertexAlpha?: boolean;
  64341. }, scene?: Nullable<Scene>): LinesMesh;
  64342. /**
  64343. * Creates a dashed line mesh
  64344. * * 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
  64345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64346. * * The parameter `points` is an array successive Vector3
  64347. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64348. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64349. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64350. * * 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
  64351. * * When updating an instance, remember that only point positions can change, not the number of points
  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. * @param name defines the name of the mesh
  64354. * @param options defines the options used to create the mesh
  64355. * @param scene defines the hosting scene
  64356. * @returns the dashed line mesh
  64357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64358. */
  64359. static CreateDashedLines(name: string, options: {
  64360. points: Vector3[];
  64361. dashSize?: number;
  64362. gapSize?: number;
  64363. dashNb?: number;
  64364. updatable?: boolean;
  64365. instance?: LinesMesh;
  64366. }, scene?: Nullable<Scene>): LinesMesh;
  64367. /**
  64368. * 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.
  64369. * * 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.
  64370. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64371. * * 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.
  64372. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64373. * * 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
  64374. * * 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
  64375. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64380. * @param name defines the name of the mesh
  64381. * @param options defines the options used to create the mesh
  64382. * @param scene defines the hosting scene
  64383. * @returns the extruded shape mesh
  64384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64386. */
  64387. static ExtrudeShape(name: string, options: {
  64388. shape: Vector3[];
  64389. path: Vector3[];
  64390. scale?: number;
  64391. rotation?: number;
  64392. cap?: number;
  64393. updatable?: boolean;
  64394. sideOrientation?: number;
  64395. frontUVs?: Vector4;
  64396. backUVs?: Vector4;
  64397. instance?: Mesh;
  64398. invertUV?: boolean;
  64399. }, scene?: Nullable<Scene>): Mesh;
  64400. /**
  64401. * Creates an custom extruded shape mesh.
  64402. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64403. * * 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.
  64404. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64405. * * 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
  64406. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64407. * * 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
  64408. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64409. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64410. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64411. * * 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
  64412. * * 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
  64413. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64418. * @param name defines the name of the mesh
  64419. * @param options defines the options used to create the mesh
  64420. * @param scene defines the hosting scene
  64421. * @returns the custom extruded shape mesh
  64422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64425. */
  64426. static ExtrudeShapeCustom(name: string, options: {
  64427. shape: Vector3[];
  64428. path: Vector3[];
  64429. scaleFunction?: any;
  64430. rotationFunction?: any;
  64431. ribbonCloseArray?: boolean;
  64432. ribbonClosePath?: boolean;
  64433. cap?: number;
  64434. updatable?: boolean;
  64435. sideOrientation?: number;
  64436. frontUVs?: Vector4;
  64437. backUVs?: Vector4;
  64438. instance?: Mesh;
  64439. invertUV?: boolean;
  64440. }, scene?: Nullable<Scene>): Mesh;
  64441. /**
  64442. * Creates lathe mesh.
  64443. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64444. * * 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
  64445. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64446. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64447. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64448. * * 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
  64449. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64450. * * 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
  64451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64455. * @param name defines the name of the mesh
  64456. * @param options defines the options used to create the mesh
  64457. * @param scene defines the hosting scene
  64458. * @returns the lathe mesh
  64459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64460. */
  64461. static CreateLathe(name: string, options: {
  64462. shape: Vector3[];
  64463. radius?: number;
  64464. tessellation?: number;
  64465. clip?: number;
  64466. arc?: number;
  64467. closed?: boolean;
  64468. updatable?: boolean;
  64469. sideOrientation?: number;
  64470. frontUVs?: Vector4;
  64471. backUVs?: Vector4;
  64472. cap?: number;
  64473. invertUV?: boolean;
  64474. }, scene?: Nullable<Scene>): Mesh;
  64475. /**
  64476. * Creates a tiled plane mesh
  64477. * * You can set a limited pattern arrangement with the tiles
  64478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64481. * @param name defines the name of the mesh
  64482. * @param options defines the options used to create the mesh
  64483. * @param scene defines the hosting scene
  64484. * @returns the plane mesh
  64485. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64486. */
  64487. static CreateTiledPlane(name: string, options: {
  64488. pattern?: number;
  64489. tileSize?: number;
  64490. tileWidth?: number;
  64491. tileHeight?: number;
  64492. size?: number;
  64493. width?: number;
  64494. height?: number;
  64495. alignHorizontal?: number;
  64496. alignVertical?: number;
  64497. sideOrientation?: number;
  64498. frontUVs?: Vector4;
  64499. backUVs?: Vector4;
  64500. updatable?: boolean;
  64501. }, scene?: Nullable<Scene>): Mesh;
  64502. /**
  64503. * Creates a plane mesh
  64504. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64505. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64506. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64510. * @param name defines the name of the mesh
  64511. * @param options defines the options used to create the mesh
  64512. * @param scene defines the hosting scene
  64513. * @returns the plane mesh
  64514. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64515. */
  64516. static CreatePlane(name: string, options: {
  64517. size?: number;
  64518. width?: number;
  64519. height?: number;
  64520. sideOrientation?: number;
  64521. frontUVs?: Vector4;
  64522. backUVs?: Vector4;
  64523. updatable?: boolean;
  64524. sourcePlane?: Plane;
  64525. }, scene?: Nullable<Scene>): Mesh;
  64526. /**
  64527. * Creates a ground mesh
  64528. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64529. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64531. * @param name defines the name of the mesh
  64532. * @param options defines the options used to create the mesh
  64533. * @param scene defines the hosting scene
  64534. * @returns the ground mesh
  64535. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64536. */
  64537. static CreateGround(name: string, options: {
  64538. width?: number;
  64539. height?: number;
  64540. subdivisions?: number;
  64541. subdivisionsX?: number;
  64542. subdivisionsY?: number;
  64543. updatable?: boolean;
  64544. }, scene?: Nullable<Scene>): Mesh;
  64545. /**
  64546. * Creates a tiled ground mesh
  64547. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64548. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64549. * * 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
  64550. * * 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
  64551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64552. * @param name defines the name of the mesh
  64553. * @param options defines the options used to create the mesh
  64554. * @param scene defines the hosting scene
  64555. * @returns the tiled ground mesh
  64556. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64557. */
  64558. static CreateTiledGround(name: string, options: {
  64559. xmin: number;
  64560. zmin: number;
  64561. xmax: number;
  64562. zmax: number;
  64563. subdivisions?: {
  64564. w: number;
  64565. h: number;
  64566. };
  64567. precision?: {
  64568. w: number;
  64569. h: number;
  64570. };
  64571. updatable?: boolean;
  64572. }, scene?: Nullable<Scene>): Mesh;
  64573. /**
  64574. * Creates a ground mesh from a height map
  64575. * * The parameter `url` sets the URL of the height map image resource.
  64576. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64577. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64578. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64579. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64580. * * 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.
  64581. * * 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).
  64582. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64584. * @param name defines the name of the mesh
  64585. * @param url defines the url to the height map
  64586. * @param options defines the options used to create the mesh
  64587. * @param scene defines the hosting scene
  64588. * @returns the ground mesh
  64589. * @see https://doc.babylonjs.com/babylon101/height_map
  64590. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64591. */
  64592. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64593. width?: number;
  64594. height?: number;
  64595. subdivisions?: number;
  64596. minHeight?: number;
  64597. maxHeight?: number;
  64598. colorFilter?: Color3;
  64599. alphaFilter?: number;
  64600. updatable?: boolean;
  64601. onReady?: (mesh: GroundMesh) => void;
  64602. }, scene?: Nullable<Scene>): GroundMesh;
  64603. /**
  64604. * Creates a polygon mesh
  64605. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64606. * * 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
  64607. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64610. * * Remember you can only change the shape positions, not their number when updating a polygon
  64611. * @param name defines the name of the mesh
  64612. * @param options defines the options used to create the mesh
  64613. * @param scene defines the hosting scene
  64614. * @param earcutInjection can be used to inject your own earcut reference
  64615. * @returns the polygon mesh
  64616. */
  64617. static CreatePolygon(name: string, options: {
  64618. shape: Vector3[];
  64619. holes?: Vector3[][];
  64620. depth?: number;
  64621. faceUV?: Vector4[];
  64622. faceColors?: Color4[];
  64623. updatable?: boolean;
  64624. sideOrientation?: number;
  64625. frontUVs?: Vector4;
  64626. backUVs?: Vector4;
  64627. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64628. /**
  64629. * Creates an extruded polygon mesh, with depth in the Y direction.
  64630. * * 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)
  64631. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64632. * @param name defines the name of the mesh
  64633. * @param options defines the options used to create the mesh
  64634. * @param scene defines the hosting scene
  64635. * @param earcutInjection can be used to inject your own earcut reference
  64636. * @returns the polygon mesh
  64637. */
  64638. static ExtrudePolygon(name: string, options: {
  64639. shape: Vector3[];
  64640. holes?: Vector3[][];
  64641. depth?: number;
  64642. faceUV?: Vector4[];
  64643. faceColors?: Color4[];
  64644. updatable?: boolean;
  64645. sideOrientation?: number;
  64646. frontUVs?: Vector4;
  64647. backUVs?: Vector4;
  64648. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64649. /**
  64650. * Creates a tube mesh.
  64651. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64652. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64653. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64654. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64655. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64656. * * 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)
  64657. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64658. * * 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
  64659. * * 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
  64660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64664. * @param name defines the name of the mesh
  64665. * @param options defines the options used to create the mesh
  64666. * @param scene defines the hosting scene
  64667. * @returns the tube mesh
  64668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64669. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64670. */
  64671. static CreateTube(name: string, options: {
  64672. path: Vector3[];
  64673. radius?: number;
  64674. tessellation?: number;
  64675. radiusFunction?: {
  64676. (i: number, distance: number): number;
  64677. };
  64678. cap?: number;
  64679. arc?: number;
  64680. updatable?: boolean;
  64681. sideOrientation?: number;
  64682. frontUVs?: Vector4;
  64683. backUVs?: Vector4;
  64684. instance?: Mesh;
  64685. invertUV?: boolean;
  64686. }, scene?: Nullable<Scene>): Mesh;
  64687. /**
  64688. * Creates a polyhedron mesh
  64689. * * 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
  64690. * * The parameter `size` (positive float, default 1) sets the polygon size
  64691. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64692. * * 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`
  64693. * * 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
  64694. * * 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)`)
  64695. * * 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
  64696. * * 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
  64697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64700. * @param name defines the name of the mesh
  64701. * @param options defines the options used to create the mesh
  64702. * @param scene defines the hosting scene
  64703. * @returns the polyhedron mesh
  64704. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64705. */
  64706. static CreatePolyhedron(name: string, options: {
  64707. type?: number;
  64708. size?: number;
  64709. sizeX?: number;
  64710. sizeY?: number;
  64711. sizeZ?: number;
  64712. custom?: any;
  64713. faceUV?: Vector4[];
  64714. faceColors?: Color4[];
  64715. flat?: boolean;
  64716. updatable?: boolean;
  64717. sideOrientation?: number;
  64718. frontUVs?: Vector4;
  64719. backUVs?: Vector4;
  64720. }, scene?: Nullable<Scene>): Mesh;
  64721. /**
  64722. * Creates a decal mesh.
  64723. * 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
  64724. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64725. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64726. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64727. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64728. * @param name defines the name of the mesh
  64729. * @param sourceMesh defines the mesh where the decal must be applied
  64730. * @param options defines the options used to create the mesh
  64731. * @param scene defines the hosting scene
  64732. * @returns the decal mesh
  64733. * @see https://doc.babylonjs.com/how_to/decals
  64734. */
  64735. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64736. position?: Vector3;
  64737. normal?: Vector3;
  64738. size?: Vector3;
  64739. angle?: number;
  64740. }): Mesh;
  64741. }
  64742. }
  64743. declare module "babylonjs/Meshes/meshSimplification" {
  64744. import { Mesh } from "babylonjs/Meshes/mesh";
  64745. /**
  64746. * A simplifier interface for future simplification implementations
  64747. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64748. */
  64749. export interface ISimplifier {
  64750. /**
  64751. * Simplification of a given mesh according to the given settings.
  64752. * Since this requires computation, it is assumed that the function runs async.
  64753. * @param settings The settings of the simplification, including quality and distance
  64754. * @param successCallback A callback that will be called after the mesh was simplified.
  64755. * @param errorCallback in case of an error, this callback will be called. optional.
  64756. */
  64757. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64758. }
  64759. /**
  64760. * Expected simplification settings.
  64761. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64762. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64763. */
  64764. export interface ISimplificationSettings {
  64765. /**
  64766. * Gets or sets the expected quality
  64767. */
  64768. quality: number;
  64769. /**
  64770. * Gets or sets the distance when this optimized version should be used
  64771. */
  64772. distance: number;
  64773. /**
  64774. * Gets an already optimized mesh
  64775. */
  64776. optimizeMesh?: boolean;
  64777. }
  64778. /**
  64779. * Class used to specify simplification options
  64780. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64781. */
  64782. export class SimplificationSettings implements ISimplificationSettings {
  64783. /** expected quality */
  64784. quality: number;
  64785. /** distance when this optimized version should be used */
  64786. distance: number;
  64787. /** already optimized mesh */
  64788. optimizeMesh?: boolean | undefined;
  64789. /**
  64790. * Creates a SimplificationSettings
  64791. * @param quality expected quality
  64792. * @param distance distance when this optimized version should be used
  64793. * @param optimizeMesh already optimized mesh
  64794. */
  64795. constructor(
  64796. /** expected quality */
  64797. quality: number,
  64798. /** distance when this optimized version should be used */
  64799. distance: number,
  64800. /** already optimized mesh */
  64801. optimizeMesh?: boolean | undefined);
  64802. }
  64803. /**
  64804. * Interface used to define a simplification task
  64805. */
  64806. export interface ISimplificationTask {
  64807. /**
  64808. * Array of settings
  64809. */
  64810. settings: Array<ISimplificationSettings>;
  64811. /**
  64812. * Simplification type
  64813. */
  64814. simplificationType: SimplificationType;
  64815. /**
  64816. * Mesh to simplify
  64817. */
  64818. mesh: Mesh;
  64819. /**
  64820. * Callback called on success
  64821. */
  64822. successCallback?: () => void;
  64823. /**
  64824. * Defines if parallel processing can be used
  64825. */
  64826. parallelProcessing: boolean;
  64827. }
  64828. /**
  64829. * Queue used to order the simplification tasks
  64830. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64831. */
  64832. export class SimplificationQueue {
  64833. private _simplificationArray;
  64834. /**
  64835. * Gets a boolean indicating that the process is still running
  64836. */
  64837. running: boolean;
  64838. /**
  64839. * Creates a new queue
  64840. */
  64841. constructor();
  64842. /**
  64843. * Adds a new simplification task
  64844. * @param task defines a task to add
  64845. */
  64846. addTask(task: ISimplificationTask): void;
  64847. /**
  64848. * Execute next task
  64849. */
  64850. executeNext(): void;
  64851. /**
  64852. * Execute a simplification task
  64853. * @param task defines the task to run
  64854. */
  64855. runSimplification(task: ISimplificationTask): void;
  64856. private getSimplifier;
  64857. }
  64858. /**
  64859. * The implemented types of simplification
  64860. * At the moment only Quadratic Error Decimation is implemented
  64861. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64862. */
  64863. export enum SimplificationType {
  64864. /** Quadratic error decimation */
  64865. QUADRATIC = 0
  64866. }
  64867. }
  64868. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64869. import { Scene } from "babylonjs/scene";
  64870. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64871. import { ISceneComponent } from "babylonjs/sceneComponent";
  64872. module "babylonjs/scene" {
  64873. interface Scene {
  64874. /** @hidden (Backing field) */
  64875. _simplificationQueue: SimplificationQueue;
  64876. /**
  64877. * Gets or sets the simplification queue attached to the scene
  64878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64879. */
  64880. simplificationQueue: SimplificationQueue;
  64881. }
  64882. }
  64883. module "babylonjs/Meshes/mesh" {
  64884. interface Mesh {
  64885. /**
  64886. * Simplify the mesh according to the given array of settings.
  64887. * Function will return immediately and will simplify async
  64888. * @param settings a collection of simplification settings
  64889. * @param parallelProcessing should all levels calculate parallel or one after the other
  64890. * @param simplificationType the type of simplification to run
  64891. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64892. * @returns the current mesh
  64893. */
  64894. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64895. }
  64896. }
  64897. /**
  64898. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64899. * created in a scene
  64900. */
  64901. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64902. /**
  64903. * The component name helpfull to identify the component in the list of scene components.
  64904. */
  64905. readonly name: string;
  64906. /**
  64907. * The scene the component belongs to.
  64908. */
  64909. scene: Scene;
  64910. /**
  64911. * Creates a new instance of the component for the given scene
  64912. * @param scene Defines the scene to register the component in
  64913. */
  64914. constructor(scene: Scene);
  64915. /**
  64916. * Registers the component in a given scene
  64917. */
  64918. register(): void;
  64919. /**
  64920. * Rebuilds the elements related to this component in case of
  64921. * context lost for instance.
  64922. */
  64923. rebuild(): void;
  64924. /**
  64925. * Disposes the component and the associated ressources
  64926. */
  64927. dispose(): void;
  64928. private _beforeCameraUpdate;
  64929. }
  64930. }
  64931. declare module "babylonjs/Meshes/Builders/index" {
  64932. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64933. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64934. export * from "babylonjs/Meshes/Builders/discBuilder";
  64935. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64936. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64937. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64938. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64939. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64940. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64941. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64942. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64943. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64944. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64945. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64946. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64947. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64948. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64949. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64950. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64951. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64952. }
  64953. declare module "babylonjs/Meshes/index" {
  64954. export * from "babylonjs/Meshes/abstractMesh";
  64955. export * from "babylonjs/Meshes/buffer";
  64956. export * from "babylonjs/Meshes/Compression/index";
  64957. export * from "babylonjs/Meshes/csg";
  64958. export * from "babylonjs/Meshes/geometry";
  64959. export * from "babylonjs/Meshes/groundMesh";
  64960. export * from "babylonjs/Meshes/trailMesh";
  64961. export * from "babylonjs/Meshes/instancedMesh";
  64962. export * from "babylonjs/Meshes/linesMesh";
  64963. export * from "babylonjs/Meshes/mesh";
  64964. export * from "babylonjs/Meshes/mesh.vertexData";
  64965. export * from "babylonjs/Meshes/meshBuilder";
  64966. export * from "babylonjs/Meshes/meshSimplification";
  64967. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64968. export * from "babylonjs/Meshes/polygonMesh";
  64969. export * from "babylonjs/Meshes/subMesh";
  64970. export * from "babylonjs/Meshes/meshLODLevel";
  64971. export * from "babylonjs/Meshes/transformNode";
  64972. export * from "babylonjs/Meshes/Builders/index";
  64973. export * from "babylonjs/Meshes/dataBuffer";
  64974. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64975. }
  64976. declare module "babylonjs/Morph/index" {
  64977. export * from "babylonjs/Morph/morphTarget";
  64978. export * from "babylonjs/Morph/morphTargetManager";
  64979. }
  64980. declare module "babylonjs/Navigation/INavigationEngine" {
  64981. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64982. import { Vector3 } from "babylonjs/Maths/math";
  64983. import { Mesh } from "babylonjs/Meshes/mesh";
  64984. import { Scene } from "babylonjs/scene";
  64985. /**
  64986. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64987. */
  64988. export interface INavigationEnginePlugin {
  64989. /**
  64990. * plugin name
  64991. */
  64992. name: string;
  64993. /**
  64994. * Creates a navigation mesh
  64995. * @param meshes array of all the geometry used to compute the navigatio mesh
  64996. * @param parameters bunch of parameters used to filter geometry
  64997. */
  64998. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64999. /**
  65000. * Create a navigation mesh debug mesh
  65001. * @param scene is where the mesh will be added
  65002. * @returns debug display mesh
  65003. */
  65004. createDebugNavMesh(scene: Scene): Mesh;
  65005. /**
  65006. * Get a navigation mesh constrained position, closest to the parameter position
  65007. * @param position world position
  65008. * @returns the closest point to position constrained by the navigation mesh
  65009. */
  65010. getClosestPoint(position: Vector3): Vector3;
  65011. /**
  65012. * Get a navigation mesh constrained position, within a particular radius
  65013. * @param position world position
  65014. * @param maxRadius the maximum distance to the constrained world position
  65015. * @returns the closest point to position constrained by the navigation mesh
  65016. */
  65017. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65018. /**
  65019. * Compute the final position from a segment made of destination-position
  65020. * @param position world position
  65021. * @param destination world position
  65022. * @returns the resulting point along the navmesh
  65023. */
  65024. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65025. /**
  65026. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65027. * @param start world position
  65028. * @param end world position
  65029. * @returns array containing world position composing the path
  65030. */
  65031. computePath(start: Vector3, end: Vector3): Vector3[];
  65032. /**
  65033. * If this plugin is supported
  65034. * @returns true if plugin is supported
  65035. */
  65036. isSupported(): boolean;
  65037. /**
  65038. * Create a new Crowd so you can add agents
  65039. * @param maxAgents the maximum agent count in the crowd
  65040. * @param maxAgentRadius the maximum radius an agent can have
  65041. * @param scene to attach the crowd to
  65042. * @returns the crowd you can add agents to
  65043. */
  65044. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65045. /**
  65046. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65047. * The queries will try to find a solution within those bounds
  65048. * default is (1,1,1)
  65049. * @param extent x,y,z value that define the extent around the queries point of reference
  65050. */
  65051. setDefaultQueryExtent(extent: Vector3): void;
  65052. /**
  65053. * Get the Bounding box extent specified by setDefaultQueryExtent
  65054. * @returns the box extent values
  65055. */
  65056. getDefaultQueryExtent(): Vector3;
  65057. /**
  65058. * Release all resources
  65059. */
  65060. dispose(): void;
  65061. }
  65062. /**
  65063. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65064. */
  65065. export interface ICrowd {
  65066. /**
  65067. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65068. * You can attach anything to that node. The node position is updated in the scene update tick.
  65069. * @param pos world position that will be constrained by the navigation mesh
  65070. * @param parameters agent parameters
  65071. * @param transform hooked to the agent that will be update by the scene
  65072. * @returns agent index
  65073. */
  65074. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65075. /**
  65076. * Returns the agent position in world space
  65077. * @param index agent index returned by addAgent
  65078. * @returns world space position
  65079. */
  65080. getAgentPosition(index: number): Vector3;
  65081. /**
  65082. * Gets the agent velocity in world space
  65083. * @param index agent index returned by addAgent
  65084. * @returns world space velocity
  65085. */
  65086. getAgentVelocity(index: number): Vector3;
  65087. /**
  65088. * remove a particular agent previously created
  65089. * @param index agent index returned by addAgent
  65090. */
  65091. removeAgent(index: number): void;
  65092. /**
  65093. * get the list of all agents attached to this crowd
  65094. * @returns list of agent indices
  65095. */
  65096. getAgents(): number[];
  65097. /**
  65098. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65099. * @param deltaTime in seconds
  65100. */
  65101. update(deltaTime: number): void;
  65102. /**
  65103. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65104. * @param index agent index returned by addAgent
  65105. * @param destination targeted world position
  65106. */
  65107. agentGoto(index: number, destination: Vector3): void;
  65108. /**
  65109. * Teleport the agent to a new position
  65110. * @param index agent index returned by addAgent
  65111. * @param destination targeted world position
  65112. */
  65113. agentTeleport(index: number, destination: Vector3): void;
  65114. /**
  65115. * Update agent parameters
  65116. * @param index agent index returned by addAgent
  65117. * @param parameters agent parameters
  65118. */
  65119. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65120. /**
  65121. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65122. * The queries will try to find a solution within those bounds
  65123. * default is (1,1,1)
  65124. * @param extent x,y,z value that define the extent around the queries point of reference
  65125. */
  65126. setDefaultQueryExtent(extent: Vector3): void;
  65127. /**
  65128. * Get the Bounding box extent specified by setDefaultQueryExtent
  65129. * @returns the box extent values
  65130. */
  65131. getDefaultQueryExtent(): Vector3;
  65132. /**
  65133. * Release all resources
  65134. */
  65135. dispose(): void;
  65136. }
  65137. /**
  65138. * Configures an agent
  65139. */
  65140. export interface IAgentParameters {
  65141. /**
  65142. * Agent radius. [Limit: >= 0]
  65143. */
  65144. radius: number;
  65145. /**
  65146. * Agent height. [Limit: > 0]
  65147. */
  65148. height: number;
  65149. /**
  65150. * Maximum allowed acceleration. [Limit: >= 0]
  65151. */
  65152. maxAcceleration: number;
  65153. /**
  65154. * Maximum allowed speed. [Limit: >= 0]
  65155. */
  65156. maxSpeed: number;
  65157. /**
  65158. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65159. */
  65160. collisionQueryRange: number;
  65161. /**
  65162. * The path visibility optimization range. [Limit: > 0]
  65163. */
  65164. pathOptimizationRange: number;
  65165. /**
  65166. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65167. */
  65168. separationWeight: number;
  65169. }
  65170. /**
  65171. * Configures the navigation mesh creation
  65172. */
  65173. export interface INavMeshParameters {
  65174. /**
  65175. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65176. */
  65177. cs: number;
  65178. /**
  65179. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65180. */
  65181. ch: number;
  65182. /**
  65183. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65184. */
  65185. walkableSlopeAngle: number;
  65186. /**
  65187. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65188. * be considered walkable. [Limit: >= 3] [Units: vx]
  65189. */
  65190. walkableHeight: number;
  65191. /**
  65192. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65193. */
  65194. walkableClimb: number;
  65195. /**
  65196. * The distance to erode/shrink the walkable area of the heightfield away from
  65197. * obstructions. [Limit: >=0] [Units: vx]
  65198. */
  65199. walkableRadius: number;
  65200. /**
  65201. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65202. */
  65203. maxEdgeLen: number;
  65204. /**
  65205. * The maximum distance a simplfied contour's border edges should deviate
  65206. * the original raw contour. [Limit: >=0] [Units: vx]
  65207. */
  65208. maxSimplificationError: number;
  65209. /**
  65210. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65211. */
  65212. minRegionArea: number;
  65213. /**
  65214. * Any regions with a span count smaller than this value will, if possible,
  65215. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65216. */
  65217. mergeRegionArea: number;
  65218. /**
  65219. * The maximum number of vertices allowed for polygons generated during the
  65220. * contour to polygon conversion process. [Limit: >= 3]
  65221. */
  65222. maxVertsPerPoly: number;
  65223. /**
  65224. * Sets the sampling distance to use when generating the detail mesh.
  65225. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65226. */
  65227. detailSampleDist: number;
  65228. /**
  65229. * The maximum distance the detail mesh surface should deviate from heightfield
  65230. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65231. */
  65232. detailSampleMaxError: number;
  65233. }
  65234. }
  65235. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65236. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65237. import { Mesh } from "babylonjs/Meshes/mesh";
  65238. import { Scene } from "babylonjs/scene";
  65239. import { Vector3 } from "babylonjs/Maths/math";
  65240. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65241. /**
  65242. * RecastJS navigation plugin
  65243. */
  65244. export class RecastJSPlugin implements INavigationEnginePlugin {
  65245. /**
  65246. * Reference to the Recast library
  65247. */
  65248. bjsRECAST: any;
  65249. /**
  65250. * plugin name
  65251. */
  65252. name: string;
  65253. /**
  65254. * the first navmesh created. We might extend this to support multiple navmeshes
  65255. */
  65256. navMesh: any;
  65257. /**
  65258. * Initializes the recastJS plugin
  65259. * @param recastInjection can be used to inject your own recast reference
  65260. */
  65261. constructor(recastInjection?: any);
  65262. /**
  65263. * Creates a navigation mesh
  65264. * @param meshes array of all the geometry used to compute the navigatio mesh
  65265. * @param parameters bunch of parameters used to filter geometry
  65266. */
  65267. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65268. /**
  65269. * Create a navigation mesh debug mesh
  65270. * @param scene is where the mesh will be added
  65271. * @returns debug display mesh
  65272. */
  65273. createDebugNavMesh(scene: Scene): Mesh;
  65274. /**
  65275. * Get a navigation mesh constrained position, closest to the parameter position
  65276. * @param position world position
  65277. * @returns the closest point to position constrained by the navigation mesh
  65278. */
  65279. getClosestPoint(position: Vector3): Vector3;
  65280. /**
  65281. * Get a navigation mesh constrained position, within a particular radius
  65282. * @param position world position
  65283. * @param maxRadius the maximum distance to the constrained world position
  65284. * @returns the closest point to position constrained by the navigation mesh
  65285. */
  65286. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65287. /**
  65288. * Compute the final position from a segment made of destination-position
  65289. * @param position world position
  65290. * @param destination world position
  65291. * @returns the resulting point along the navmesh
  65292. */
  65293. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65294. /**
  65295. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65296. * @param start world position
  65297. * @param end world position
  65298. * @returns array containing world position composing the path
  65299. */
  65300. computePath(start: Vector3, end: Vector3): Vector3[];
  65301. /**
  65302. * Create a new Crowd so you can add agents
  65303. * @param maxAgents the maximum agent count in the crowd
  65304. * @param maxAgentRadius the maximum radius an agent can have
  65305. * @param scene to attach the crowd to
  65306. * @returns the crowd you can add agents to
  65307. */
  65308. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65309. /**
  65310. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65311. * The queries will try to find a solution within those bounds
  65312. * default is (1,1,1)
  65313. * @param extent x,y,z value that define the extent around the queries point of reference
  65314. */
  65315. setDefaultQueryExtent(extent: Vector3): void;
  65316. /**
  65317. * Get the Bounding box extent specified by setDefaultQueryExtent
  65318. * @returns the box extent values
  65319. */
  65320. getDefaultQueryExtent(): Vector3;
  65321. /**
  65322. * Disposes
  65323. */
  65324. dispose(): void;
  65325. /**
  65326. * If this plugin is supported
  65327. * @returns true if plugin is supported
  65328. */
  65329. isSupported(): boolean;
  65330. }
  65331. /**
  65332. * Recast detour crowd implementation
  65333. */
  65334. export class RecastJSCrowd implements ICrowd {
  65335. /**
  65336. * Recast/detour plugin
  65337. */
  65338. bjsRECASTPlugin: RecastJSPlugin;
  65339. /**
  65340. * Link to the detour crowd
  65341. */
  65342. recastCrowd: any;
  65343. /**
  65344. * One transform per agent
  65345. */
  65346. transforms: TransformNode[];
  65347. /**
  65348. * All agents created
  65349. */
  65350. agents: number[];
  65351. /**
  65352. * Link to the scene is kept to unregister the crowd from the scene
  65353. */
  65354. private _scene;
  65355. /**
  65356. * Observer for crowd updates
  65357. */
  65358. private _onBeforeAnimationsObserver;
  65359. /**
  65360. * Constructor
  65361. * @param plugin recastJS plugin
  65362. * @param maxAgents the maximum agent count in the crowd
  65363. * @param maxAgentRadius the maximum radius an agent can have
  65364. * @param scene to attach the crowd to
  65365. * @returns the crowd you can add agents to
  65366. */
  65367. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65368. /**
  65369. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65370. * You can attach anything to that node. The node position is updated in the scene update tick.
  65371. * @param pos world position that will be constrained by the navigation mesh
  65372. * @param parameters agent parameters
  65373. * @param transform hooked to the agent that will be update by the scene
  65374. * @returns agent index
  65375. */
  65376. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65377. /**
  65378. * Returns the agent position in world space
  65379. * @param index agent index returned by addAgent
  65380. * @returns world space position
  65381. */
  65382. getAgentPosition(index: number): Vector3;
  65383. /**
  65384. * Returns the agent velocity in world space
  65385. * @param index agent index returned by addAgent
  65386. * @returns world space velocity
  65387. */
  65388. getAgentVelocity(index: number): Vector3;
  65389. /**
  65390. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65391. * @param index agent index returned by addAgent
  65392. * @param destination targeted world position
  65393. */
  65394. agentGoto(index: number, destination: Vector3): void;
  65395. /**
  65396. * Teleport the agent to a new position
  65397. * @param index agent index returned by addAgent
  65398. * @param destination targeted world position
  65399. */
  65400. agentTeleport(index: number, destination: Vector3): void;
  65401. /**
  65402. * Update agent parameters
  65403. * @param index agent index returned by addAgent
  65404. * @param parameters agent parameters
  65405. */
  65406. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65407. /**
  65408. * remove a particular agent previously created
  65409. * @param index agent index returned by addAgent
  65410. */
  65411. removeAgent(index: number): void;
  65412. /**
  65413. * get the list of all agents attached to this crowd
  65414. * @returns list of agent indices
  65415. */
  65416. getAgents(): number[];
  65417. /**
  65418. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65419. * @param deltaTime in seconds
  65420. */
  65421. update(deltaTime: number): void;
  65422. /**
  65423. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65424. * The queries will try to find a solution within those bounds
  65425. * default is (1,1,1)
  65426. * @param extent x,y,z value that define the extent around the queries point of reference
  65427. */
  65428. setDefaultQueryExtent(extent: Vector3): void;
  65429. /**
  65430. * Get the Bounding box extent specified by setDefaultQueryExtent
  65431. * @returns the box extent values
  65432. */
  65433. getDefaultQueryExtent(): Vector3;
  65434. /**
  65435. * Release all resources
  65436. */
  65437. dispose(): void;
  65438. }
  65439. }
  65440. declare module "babylonjs/Navigation/Plugins/index" {
  65441. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65442. }
  65443. declare module "babylonjs/Navigation/index" {
  65444. export * from "babylonjs/Navigation/INavigationEngine";
  65445. export * from "babylonjs/Navigation/Plugins/index";
  65446. }
  65447. declare module "babylonjs/Offline/database" {
  65448. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65449. /**
  65450. * Class used to enable access to IndexedDB
  65451. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65452. */
  65453. export class Database implements IOfflineProvider {
  65454. private _callbackManifestChecked;
  65455. private _currentSceneUrl;
  65456. private _db;
  65457. private _enableSceneOffline;
  65458. private _enableTexturesOffline;
  65459. private _manifestVersionFound;
  65460. private _mustUpdateRessources;
  65461. private _hasReachedQuota;
  65462. private _isSupported;
  65463. private _idbFactory;
  65464. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65465. private static IsUASupportingBlobStorage;
  65466. /**
  65467. * Gets a boolean indicating if Database storate is enabled (off by default)
  65468. */
  65469. static IDBStorageEnabled: boolean;
  65470. /**
  65471. * Gets a boolean indicating if scene must be saved in the database
  65472. */
  65473. get enableSceneOffline(): boolean;
  65474. /**
  65475. * Gets a boolean indicating if textures must be saved in the database
  65476. */
  65477. get enableTexturesOffline(): boolean;
  65478. /**
  65479. * Creates a new Database
  65480. * @param urlToScene defines the url to load the scene
  65481. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65482. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65483. */
  65484. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65485. private static _ParseURL;
  65486. private static _ReturnFullUrlLocation;
  65487. private _checkManifestFile;
  65488. /**
  65489. * Open the database and make it available
  65490. * @param successCallback defines the callback to call on success
  65491. * @param errorCallback defines the callback to call on error
  65492. */
  65493. open(successCallback: () => void, errorCallback: () => void): void;
  65494. /**
  65495. * Loads an image from the database
  65496. * @param url defines the url to load from
  65497. * @param image defines the target DOM image
  65498. */
  65499. loadImage(url: string, image: HTMLImageElement): void;
  65500. private _loadImageFromDBAsync;
  65501. private _saveImageIntoDBAsync;
  65502. private _checkVersionFromDB;
  65503. private _loadVersionFromDBAsync;
  65504. private _saveVersionIntoDBAsync;
  65505. /**
  65506. * Loads a file from database
  65507. * @param url defines the URL to load from
  65508. * @param sceneLoaded defines a callback to call on success
  65509. * @param progressCallBack defines a callback to call when progress changed
  65510. * @param errorCallback defines a callback to call on error
  65511. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65512. */
  65513. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65514. private _loadFileAsync;
  65515. private _saveFileAsync;
  65516. /**
  65517. * Validates if xhr data is correct
  65518. * @param xhr defines the request to validate
  65519. * @param dataType defines the expected data type
  65520. * @returns true if data is correct
  65521. */
  65522. private static _ValidateXHRData;
  65523. }
  65524. }
  65525. declare module "babylonjs/Offline/index" {
  65526. export * from "babylonjs/Offline/database";
  65527. export * from "babylonjs/Offline/IOfflineProvider";
  65528. }
  65529. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65530. /** @hidden */
  65531. export var gpuUpdateParticlesPixelShader: {
  65532. name: string;
  65533. shader: string;
  65534. };
  65535. }
  65536. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65537. /** @hidden */
  65538. export var gpuUpdateParticlesVertexShader: {
  65539. name: string;
  65540. shader: string;
  65541. };
  65542. }
  65543. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65544. /** @hidden */
  65545. export var clipPlaneFragmentDeclaration2: {
  65546. name: string;
  65547. shader: string;
  65548. };
  65549. }
  65550. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65551. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65553. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65554. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65555. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65556. /** @hidden */
  65557. export var gpuRenderParticlesPixelShader: {
  65558. name: string;
  65559. shader: string;
  65560. };
  65561. }
  65562. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65563. /** @hidden */
  65564. export var clipPlaneVertexDeclaration2: {
  65565. name: string;
  65566. shader: string;
  65567. };
  65568. }
  65569. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65572. /** @hidden */
  65573. export var gpuRenderParticlesVertexShader: {
  65574. name: string;
  65575. shader: string;
  65576. };
  65577. }
  65578. declare module "babylonjs/Particles/gpuParticleSystem" {
  65579. import { Nullable } from "babylonjs/types";
  65580. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65581. import { Observable } from "babylonjs/Misc/observable";
  65582. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65583. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65584. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65585. import { Scene, IDisposable } from "babylonjs/scene";
  65586. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65588. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65589. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65590. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65591. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65592. /**
  65593. * This represents a GPU particle system in Babylon
  65594. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65595. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65596. */
  65597. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65598. /**
  65599. * The layer mask we are rendering the particles through.
  65600. */
  65601. layerMask: number;
  65602. private _capacity;
  65603. private _activeCount;
  65604. private _currentActiveCount;
  65605. private _accumulatedCount;
  65606. private _renderEffect;
  65607. private _updateEffect;
  65608. private _buffer0;
  65609. private _buffer1;
  65610. private _spriteBuffer;
  65611. private _updateVAO;
  65612. private _renderVAO;
  65613. private _targetIndex;
  65614. private _sourceBuffer;
  65615. private _targetBuffer;
  65616. private _engine;
  65617. private _currentRenderId;
  65618. private _started;
  65619. private _stopped;
  65620. private _timeDelta;
  65621. private _randomTexture;
  65622. private _randomTexture2;
  65623. private _attributesStrideSize;
  65624. private _updateEffectOptions;
  65625. private _randomTextureSize;
  65626. private _actualFrame;
  65627. private readonly _rawTextureWidth;
  65628. /**
  65629. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65630. */
  65631. static get IsSupported(): boolean;
  65632. /**
  65633. * An event triggered when the system is disposed.
  65634. */
  65635. onDisposeObservable: Observable<GPUParticleSystem>;
  65636. /**
  65637. * Gets the maximum number of particles active at the same time.
  65638. * @returns The max number of active particles.
  65639. */
  65640. getCapacity(): number;
  65641. /**
  65642. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65643. * to override the particles.
  65644. */
  65645. forceDepthWrite: boolean;
  65646. /**
  65647. * Gets or set the number of active particles
  65648. */
  65649. get activeParticleCount(): number;
  65650. set activeParticleCount(value: number);
  65651. private _preWarmDone;
  65652. /**
  65653. * Specifies if the particles are updated in emitter local space or world space.
  65654. * This is always false for GPU particles
  65655. */
  65656. get isLocal(): boolean;
  65657. set isLocal(value: boolean);
  65658. /**
  65659. * Is this system ready to be used/rendered
  65660. * @return true if the system is ready
  65661. */
  65662. isReady(): boolean;
  65663. /**
  65664. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65665. * @returns True if it has been started, otherwise false.
  65666. */
  65667. isStarted(): boolean;
  65668. /**
  65669. * Starts the particle system and begins to emit
  65670. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65671. */
  65672. start(delay?: number): void;
  65673. /**
  65674. * Stops the particle system.
  65675. */
  65676. stop(): void;
  65677. /**
  65678. * Remove all active particles
  65679. */
  65680. reset(): void;
  65681. /**
  65682. * Returns the string "GPUParticleSystem"
  65683. * @returns a string containing the class name
  65684. */
  65685. getClassName(): string;
  65686. private _colorGradientsTexture;
  65687. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65688. /**
  65689. * Adds a new color gradient
  65690. * @param gradient defines the gradient to use (between 0 and 1)
  65691. * @param color1 defines the color to affect to the specified gradient
  65692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65693. * @returns the current particle system
  65694. */
  65695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65696. /**
  65697. * Remove a specific color gradient
  65698. * @param gradient defines the gradient to remove
  65699. * @returns the current particle system
  65700. */
  65701. removeColorGradient(gradient: number): GPUParticleSystem;
  65702. private _angularSpeedGradientsTexture;
  65703. private _sizeGradientsTexture;
  65704. private _velocityGradientsTexture;
  65705. private _limitVelocityGradientsTexture;
  65706. private _dragGradientsTexture;
  65707. private _addFactorGradient;
  65708. /**
  65709. * Adds a new size gradient
  65710. * @param gradient defines the gradient to use (between 0 and 1)
  65711. * @param factor defines the size factor to affect to the specified gradient
  65712. * @returns the current particle system
  65713. */
  65714. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65715. /**
  65716. * Remove a specific size gradient
  65717. * @param gradient defines the gradient to remove
  65718. * @returns the current particle system
  65719. */
  65720. removeSizeGradient(gradient: number): GPUParticleSystem;
  65721. /**
  65722. * Adds a new angular speed gradient
  65723. * @param gradient defines the gradient to use (between 0 and 1)
  65724. * @param factor defines the angular speed to affect to the specified gradient
  65725. * @returns the current particle system
  65726. */
  65727. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65728. /**
  65729. * Remove a specific angular speed gradient
  65730. * @param gradient defines the gradient to remove
  65731. * @returns the current particle system
  65732. */
  65733. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65734. /**
  65735. * Adds a new velocity gradient
  65736. * @param gradient defines the gradient to use (between 0 and 1)
  65737. * @param factor defines the velocity to affect to the specified gradient
  65738. * @returns the current particle system
  65739. */
  65740. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65741. /**
  65742. * Remove a specific velocity gradient
  65743. * @param gradient defines the gradient to remove
  65744. * @returns the current particle system
  65745. */
  65746. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65747. /**
  65748. * Adds a new limit velocity gradient
  65749. * @param gradient defines the gradient to use (between 0 and 1)
  65750. * @param factor defines the limit velocity value to affect to the specified gradient
  65751. * @returns the current particle system
  65752. */
  65753. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65754. /**
  65755. * Remove a specific limit velocity gradient
  65756. * @param gradient defines the gradient to remove
  65757. * @returns the current particle system
  65758. */
  65759. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65760. /**
  65761. * Adds a new drag gradient
  65762. * @param gradient defines the gradient to use (between 0 and 1)
  65763. * @param factor defines the drag value to affect to the specified gradient
  65764. * @returns the current particle system
  65765. */
  65766. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65767. /**
  65768. * Remove a specific drag gradient
  65769. * @param gradient defines the gradient to remove
  65770. * @returns the current particle system
  65771. */
  65772. removeDragGradient(gradient: number): GPUParticleSystem;
  65773. /**
  65774. * Not supported by GPUParticleSystem
  65775. * @param gradient defines the gradient to use (between 0 and 1)
  65776. * @param factor defines the emit rate value to affect to the specified gradient
  65777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65778. * @returns the current particle system
  65779. */
  65780. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65781. /**
  65782. * Not supported by GPUParticleSystem
  65783. * @param gradient defines the gradient to remove
  65784. * @returns the current particle system
  65785. */
  65786. removeEmitRateGradient(gradient: number): IParticleSystem;
  65787. /**
  65788. * Not supported by GPUParticleSystem
  65789. * @param gradient defines the gradient to use (between 0 and 1)
  65790. * @param factor defines the start size value to affect to the specified gradient
  65791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65792. * @returns the current particle system
  65793. */
  65794. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65795. /**
  65796. * Not supported by GPUParticleSystem
  65797. * @param gradient defines the gradient to remove
  65798. * @returns the current particle system
  65799. */
  65800. removeStartSizeGradient(gradient: number): IParticleSystem;
  65801. /**
  65802. * Not supported by GPUParticleSystem
  65803. * @param gradient defines the gradient to use (between 0 and 1)
  65804. * @param min defines the color remap minimal range
  65805. * @param max defines the color remap maximal range
  65806. * @returns the current particle system
  65807. */
  65808. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65809. /**
  65810. * Not supported by GPUParticleSystem
  65811. * @param gradient defines the gradient to remove
  65812. * @returns the current particle system
  65813. */
  65814. removeColorRemapGradient(): IParticleSystem;
  65815. /**
  65816. * Not supported by GPUParticleSystem
  65817. * @param gradient defines the gradient to use (between 0 and 1)
  65818. * @param min defines the alpha remap minimal range
  65819. * @param max defines the alpha remap maximal range
  65820. * @returns the current particle system
  65821. */
  65822. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65823. /**
  65824. * Not supported by GPUParticleSystem
  65825. * @param gradient defines the gradient to remove
  65826. * @returns the current particle system
  65827. */
  65828. removeAlphaRemapGradient(): IParticleSystem;
  65829. /**
  65830. * Not supported by GPUParticleSystem
  65831. * @param gradient defines the gradient to use (between 0 and 1)
  65832. * @param color defines the color to affect to the specified gradient
  65833. * @returns the current particle system
  65834. */
  65835. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65836. /**
  65837. * Not supported by GPUParticleSystem
  65838. * @param gradient defines the gradient to remove
  65839. * @returns the current particle system
  65840. */
  65841. removeRampGradient(): IParticleSystem;
  65842. /**
  65843. * Not supported by GPUParticleSystem
  65844. * @returns the list of ramp gradients
  65845. */
  65846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65847. /**
  65848. * Not supported by GPUParticleSystem
  65849. * Gets or sets a boolean indicating that ramp gradients must be used
  65850. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65851. */
  65852. get useRampGradients(): boolean;
  65853. set useRampGradients(value: boolean);
  65854. /**
  65855. * Not supported by GPUParticleSystem
  65856. * @param gradient defines the gradient to use (between 0 and 1)
  65857. * @param factor defines the life time factor to affect to the specified gradient
  65858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65859. * @returns the current particle system
  65860. */
  65861. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65862. /**
  65863. * Not supported by GPUParticleSystem
  65864. * @param gradient defines the gradient to remove
  65865. * @returns the current particle system
  65866. */
  65867. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65868. /**
  65869. * Instantiates a GPU particle system.
  65870. * 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.
  65871. * @param name The name of the particle system
  65872. * @param options The options used to create the system
  65873. * @param scene The scene the particle system belongs to
  65874. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65875. */
  65876. constructor(name: string, options: Partial<{
  65877. capacity: number;
  65878. randomTextureSize: number;
  65879. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65880. protected _reset(): void;
  65881. private _createUpdateVAO;
  65882. private _createRenderVAO;
  65883. private _initialize;
  65884. /** @hidden */
  65885. _recreateUpdateEffect(): void;
  65886. /** @hidden */
  65887. _recreateRenderEffect(): void;
  65888. /**
  65889. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65890. * @param preWarm defines if we are in the pre-warmimg phase
  65891. */
  65892. animate(preWarm?: boolean): void;
  65893. private _createFactorGradientTexture;
  65894. private _createSizeGradientTexture;
  65895. private _createAngularSpeedGradientTexture;
  65896. private _createVelocityGradientTexture;
  65897. private _createLimitVelocityGradientTexture;
  65898. private _createDragGradientTexture;
  65899. private _createColorGradientTexture;
  65900. /**
  65901. * Renders the particle system in its current state
  65902. * @param preWarm defines if the system should only update the particles but not render them
  65903. * @returns the current number of particles
  65904. */
  65905. render(preWarm?: boolean): number;
  65906. /**
  65907. * Rebuilds the particle system
  65908. */
  65909. rebuild(): void;
  65910. private _releaseBuffers;
  65911. private _releaseVAOs;
  65912. /**
  65913. * Disposes the particle system and free the associated resources
  65914. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65915. */
  65916. dispose(disposeTexture?: boolean): void;
  65917. /**
  65918. * Clones the particle system.
  65919. * @param name The name of the cloned object
  65920. * @param newEmitter The new emitter to use
  65921. * @returns the cloned particle system
  65922. */
  65923. clone(name: string, newEmitter: any): GPUParticleSystem;
  65924. /**
  65925. * Serializes the particle system to a JSON object.
  65926. * @returns the JSON object
  65927. */
  65928. serialize(): any;
  65929. /**
  65930. * Parses a JSON object to create a GPU particle system.
  65931. * @param parsedParticleSystem The JSON object to parse
  65932. * @param scene The scene to create the particle system in
  65933. * @param rootUrl The root url to use to load external dependencies like texture
  65934. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65935. * @returns the parsed GPU particle system
  65936. */
  65937. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65938. }
  65939. }
  65940. declare module "babylonjs/Particles/particleSystemSet" {
  65941. import { Nullable } from "babylonjs/types";
  65942. import { Color3 } from "babylonjs/Maths/math.color";
  65943. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65945. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65946. import { Scene, IDisposable } from "babylonjs/scene";
  65947. /**
  65948. * Represents a set of particle systems working together to create a specific effect
  65949. */
  65950. export class ParticleSystemSet implements IDisposable {
  65951. /**
  65952. * Gets or sets base Assets URL
  65953. */
  65954. static BaseAssetsUrl: string;
  65955. private _emitterCreationOptions;
  65956. private _emitterNode;
  65957. /**
  65958. * Gets the particle system list
  65959. */
  65960. systems: IParticleSystem[];
  65961. /**
  65962. * Gets the emitter node used with this set
  65963. */
  65964. get emitterNode(): Nullable<TransformNode>;
  65965. /**
  65966. * Creates a new emitter mesh as a sphere
  65967. * @param options defines the options used to create the sphere
  65968. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65969. * @param scene defines the hosting scene
  65970. */
  65971. setEmitterAsSphere(options: {
  65972. diameter: number;
  65973. segments: number;
  65974. color: Color3;
  65975. }, renderingGroupId: number, scene: Scene): void;
  65976. /**
  65977. * Starts all particle systems of the set
  65978. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65979. */
  65980. start(emitter?: AbstractMesh): void;
  65981. /**
  65982. * Release all associated resources
  65983. */
  65984. dispose(): void;
  65985. /**
  65986. * Serialize the set into a JSON compatible object
  65987. * @returns a JSON compatible representation of the set
  65988. */
  65989. serialize(): any;
  65990. /**
  65991. * Parse a new ParticleSystemSet from a serialized source
  65992. * @param data defines a JSON compatible representation of the set
  65993. * @param scene defines the hosting scene
  65994. * @param gpu defines if we want GPU particles or CPU particles
  65995. * @returns a new ParticleSystemSet
  65996. */
  65997. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65998. }
  65999. }
  66000. declare module "babylonjs/Particles/particleHelper" {
  66001. import { Nullable } from "babylonjs/types";
  66002. import { Scene } from "babylonjs/scene";
  66003. import { Vector3 } from "babylonjs/Maths/math.vector";
  66004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66005. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66006. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66007. /**
  66008. * This class is made for on one-liner static method to help creating particle system set.
  66009. */
  66010. export class ParticleHelper {
  66011. /**
  66012. * Gets or sets base Assets URL
  66013. */
  66014. static BaseAssetsUrl: string;
  66015. /**
  66016. * Create a default particle system that you can tweak
  66017. * @param emitter defines the emitter to use
  66018. * @param capacity defines the system capacity (default is 500 particles)
  66019. * @param scene defines the hosting scene
  66020. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66021. * @returns the new Particle system
  66022. */
  66023. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66024. /**
  66025. * This is the main static method (one-liner) of this helper to create different particle systems
  66026. * @param type This string represents the type to the particle system to create
  66027. * @param scene The scene where the particle system should live
  66028. * @param gpu If the system will use gpu
  66029. * @returns the ParticleSystemSet created
  66030. */
  66031. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66032. /**
  66033. * Static function used to export a particle system to a ParticleSystemSet variable.
  66034. * Please note that the emitter shape is not exported
  66035. * @param systems defines the particle systems to export
  66036. * @returns the created particle system set
  66037. */
  66038. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66039. }
  66040. }
  66041. declare module "babylonjs/Particles/particleSystemComponent" {
  66042. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66043. import { Effect } from "babylonjs/Materials/effect";
  66044. import "babylonjs/Shaders/particles.vertex";
  66045. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66046. module "babylonjs/Engines/engine" {
  66047. interface Engine {
  66048. /**
  66049. * Create an effect to use with particle systems.
  66050. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66051. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66052. * @param uniformsNames defines a list of attribute names
  66053. * @param samplers defines an array of string used to represent textures
  66054. * @param defines defines the string containing the defines to use to compile the shaders
  66055. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66056. * @param onCompiled defines a function to call when the effect creation is successful
  66057. * @param onError defines a function to call when the effect creation has failed
  66058. * @returns the new Effect
  66059. */
  66060. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66061. }
  66062. }
  66063. module "babylonjs/Meshes/mesh" {
  66064. interface Mesh {
  66065. /**
  66066. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66067. * @returns an array of IParticleSystem
  66068. */
  66069. getEmittedParticleSystems(): IParticleSystem[];
  66070. /**
  66071. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66072. * @returns an array of IParticleSystem
  66073. */
  66074. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66075. }
  66076. }
  66077. /**
  66078. * @hidden
  66079. */
  66080. export var _IDoNeedToBeInTheBuild: number;
  66081. }
  66082. declare module "babylonjs/Particles/pointsCloudSystem" {
  66083. import { Color4 } from "babylonjs/Maths/math";
  66084. import { Mesh } from "babylonjs/Meshes/mesh";
  66085. import { Scene, IDisposable } from "babylonjs/scene";
  66086. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66087. /** Defines the 4 color options */
  66088. export enum PointColor {
  66089. /** color value */
  66090. Color = 2,
  66091. /** uv value */
  66092. UV = 1,
  66093. /** random value */
  66094. Random = 0,
  66095. /** stated value */
  66096. Stated = 3
  66097. }
  66098. /**
  66099. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66100. * 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.
  66101. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66102. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66103. *
  66104. * Full documentation here : TO BE ENTERED
  66105. */
  66106. export class PointsCloudSystem implements IDisposable {
  66107. /**
  66108. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66109. * Example : var p = SPS.particles[i];
  66110. */
  66111. particles: CloudPoint[];
  66112. /**
  66113. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66114. */
  66115. nbParticles: number;
  66116. /**
  66117. * This a counter for your own usage. It's not set by any SPS functions.
  66118. */
  66119. counter: number;
  66120. /**
  66121. * The PCS name. This name is also given to the underlying mesh.
  66122. */
  66123. name: string;
  66124. /**
  66125. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66126. */
  66127. mesh: Mesh;
  66128. /**
  66129. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66130. * Please read :
  66131. */
  66132. vars: any;
  66133. /**
  66134. * @hidden
  66135. */
  66136. _size: number;
  66137. private _scene;
  66138. private _promises;
  66139. private _positions;
  66140. private _indices;
  66141. private _normals;
  66142. private _colors;
  66143. private _uvs;
  66144. private _indices32;
  66145. private _positions32;
  66146. private _colors32;
  66147. private _uvs32;
  66148. private _updatable;
  66149. private _isVisibilityBoxLocked;
  66150. private _alwaysVisible;
  66151. private _groups;
  66152. private _groupCounter;
  66153. private _computeParticleColor;
  66154. private _computeParticleTexture;
  66155. private _computeParticleRotation;
  66156. private _computeBoundingBox;
  66157. private _isReady;
  66158. /**
  66159. * Creates a PCS (Points Cloud System) object
  66160. * @param name (String) is the PCS name, this will be the underlying mesh name
  66161. * @param pointSize (number) is the size for each point
  66162. * @param scene (Scene) is the scene in which the PCS is added
  66163. * @param options defines the options of the PCS e.g.
  66164. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66165. */
  66166. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66167. updatable?: boolean;
  66168. });
  66169. /**
  66170. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66171. * If no points were added to the PCS, the returned mesh is just a single point.
  66172. * @returns a promise for the created mesh
  66173. */
  66174. buildMeshAsync(): Promise<Mesh>;
  66175. /**
  66176. * @hidden
  66177. */
  66178. private _buildMesh;
  66179. private _addParticle;
  66180. private _randomUnitVector;
  66181. private _getColorIndicesForCoord;
  66182. private _setPointsColorOrUV;
  66183. private _colorFromTexture;
  66184. private _calculateDensity;
  66185. /**
  66186. * Adds points to the PCS in random positions within a unit sphere
  66187. * @param nb (positive integer) the number of particles to be created from this model
  66188. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66189. * @returns the number of groups in the system
  66190. */
  66191. addPoints(nb: number, pointFunction?: any): number;
  66192. /**
  66193. * Adds points to the PCS from the surface of the model shape
  66194. * @param mesh is any Mesh object that will be used as a surface model for the points
  66195. * @param nb (positive integer) the number of particles to be created from this model
  66196. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66197. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66198. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66199. * @returns the number of groups in the system
  66200. */
  66201. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66202. /**
  66203. * Adds points to the PCS inside the model shape
  66204. * @param mesh is any Mesh object that will be used as a surface model for the points
  66205. * @param nb (positive integer) the number of particles to be created from this model
  66206. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66207. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66208. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66209. * @returns the number of groups in the system
  66210. */
  66211. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66212. /**
  66213. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66214. * This method calls `updateParticle()` for each particle of the SPS.
  66215. * For an animated SPS, it is usually called within the render loop.
  66216. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66217. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66218. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66219. * @returns the PCS.
  66220. */
  66221. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66222. /**
  66223. * Disposes the PCS.
  66224. */
  66225. dispose(): void;
  66226. /**
  66227. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66228. * doc :
  66229. * @returns the PCS.
  66230. */
  66231. refreshVisibleSize(): PointsCloudSystem;
  66232. /**
  66233. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66234. * @param size the size (float) of the visibility box
  66235. * note : this doesn't lock the PCS mesh bounding box.
  66236. * doc :
  66237. */
  66238. setVisibilityBox(size: number): void;
  66239. /**
  66240. * Gets whether the PCS is always visible or not
  66241. * doc :
  66242. */
  66243. get isAlwaysVisible(): boolean;
  66244. /**
  66245. * Sets the PCS as always visible or not
  66246. * doc :
  66247. */
  66248. set isAlwaysVisible(val: boolean);
  66249. /**
  66250. * Tells to `setParticles()` to compute the particle rotations or not
  66251. * Default value : false. The PCS is faster when it's set to false
  66252. * Note : particle rotations are only applied to parent particles
  66253. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66254. */
  66255. set computeParticleRotation(val: boolean);
  66256. /**
  66257. * Tells to `setParticles()` to compute the particle colors or not.
  66258. * Default value : true. The PCS is faster when it's set to false.
  66259. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66260. */
  66261. set computeParticleColor(val: boolean);
  66262. set computeParticleTexture(val: boolean);
  66263. /**
  66264. * Gets if `setParticles()` computes the particle colors or not.
  66265. * Default value : false. The PCS is faster when it's set to false.
  66266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66267. */
  66268. get computeParticleColor(): boolean;
  66269. /**
  66270. * Gets if `setParticles()` computes the particle textures or not.
  66271. * Default value : false. The PCS is faster when it's set to false.
  66272. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66273. */
  66274. get computeParticleTexture(): boolean;
  66275. /**
  66276. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66277. */
  66278. set computeBoundingBox(val: boolean);
  66279. /**
  66280. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66281. */
  66282. get computeBoundingBox(): boolean;
  66283. /**
  66284. * This function does nothing. It may be overwritten to set all the particle first values.
  66285. * The PCS doesn't call this function, you may have to call it by your own.
  66286. * doc :
  66287. */
  66288. initParticles(): void;
  66289. /**
  66290. * This function does nothing. It may be overwritten to recycle a particle
  66291. * The PCS doesn't call this function, you can to call it
  66292. * doc :
  66293. * @param particle The particle to recycle
  66294. * @returns the recycled particle
  66295. */
  66296. recycleParticle(particle: CloudPoint): CloudPoint;
  66297. /**
  66298. * Updates a particle : this function should be overwritten by the user.
  66299. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66300. * doc :
  66301. * @example : just set a particle position or velocity and recycle conditions
  66302. * @param particle The particle to update
  66303. * @returns the updated particle
  66304. */
  66305. updateParticle(particle: CloudPoint): CloudPoint;
  66306. /**
  66307. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66308. * This does nothing and may be overwritten by the user.
  66309. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66310. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66311. * @param update the boolean update value actually passed to setParticles()
  66312. */
  66313. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66314. /**
  66315. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66316. * This will be passed three parameters.
  66317. * This does nothing and may be overwritten by the user.
  66318. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66319. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66320. * @param update the boolean update value actually passed to setParticles()
  66321. */
  66322. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66323. }
  66324. }
  66325. declare module "babylonjs/Particles/cloudPoint" {
  66326. import { Nullable } from "babylonjs/types";
  66327. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66328. import { Mesh } from "babylonjs/Meshes/mesh";
  66329. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66330. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66331. /**
  66332. * Represents one particle of a points cloud system.
  66333. */
  66334. export class CloudPoint {
  66335. /**
  66336. * particle global index
  66337. */
  66338. idx: number;
  66339. /**
  66340. * The color of the particle
  66341. */
  66342. color: Nullable<Color4>;
  66343. /**
  66344. * The world space position of the particle.
  66345. */
  66346. position: Vector3;
  66347. /**
  66348. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66349. */
  66350. rotation: Vector3;
  66351. /**
  66352. * The world space rotation quaternion of the particle.
  66353. */
  66354. rotationQuaternion: Nullable<Quaternion>;
  66355. /**
  66356. * The uv of the particle.
  66357. */
  66358. uv: Nullable<Vector2>;
  66359. /**
  66360. * The current speed of the particle.
  66361. */
  66362. velocity: Vector3;
  66363. /**
  66364. * The pivot point in the particle local space.
  66365. */
  66366. pivot: Vector3;
  66367. /**
  66368. * Must the particle be translated from its pivot point in its local space ?
  66369. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66370. * Default : false
  66371. */
  66372. translateFromPivot: boolean;
  66373. /**
  66374. * Index of this particle in the global "positions" array (Internal use)
  66375. * @hidden
  66376. */
  66377. _pos: number;
  66378. /**
  66379. * @hidden Index of this particle in the global "indices" array (Internal use)
  66380. */
  66381. _ind: number;
  66382. /**
  66383. * Group this particle belongs to
  66384. */
  66385. _group: PointsGroup;
  66386. /**
  66387. * Group id of this particle
  66388. */
  66389. groupId: number;
  66390. /**
  66391. * Index of the particle in its group id (Internal use)
  66392. */
  66393. idxInGroup: number;
  66394. /**
  66395. * @hidden Particle BoundingInfo object (Internal use)
  66396. */
  66397. _boundingInfo: BoundingInfo;
  66398. /**
  66399. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66400. */
  66401. _pcs: PointsCloudSystem;
  66402. /**
  66403. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66404. */
  66405. _stillInvisible: boolean;
  66406. /**
  66407. * @hidden Last computed particle rotation matrix
  66408. */
  66409. _rotationMatrix: number[];
  66410. /**
  66411. * Parent particle Id, if any.
  66412. * Default null.
  66413. */
  66414. parentId: Nullable<number>;
  66415. /**
  66416. * @hidden Internal global position in the PCS.
  66417. */
  66418. _globalPosition: Vector3;
  66419. /**
  66420. * Creates a Point Cloud object.
  66421. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66422. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66423. * @param group (PointsGroup) is the group the particle belongs to
  66424. * @param groupId (integer) is the group identifier in the PCS.
  66425. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66426. * @param pcs defines the PCS it is associated to
  66427. */
  66428. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66429. /**
  66430. * get point size
  66431. */
  66432. get size(): Vector3;
  66433. /**
  66434. * Set point size
  66435. */
  66436. set size(scale: Vector3);
  66437. /**
  66438. * Legacy support, changed quaternion to rotationQuaternion
  66439. */
  66440. get quaternion(): Nullable<Quaternion>;
  66441. /**
  66442. * Legacy support, changed quaternion to rotationQuaternion
  66443. */
  66444. set quaternion(q: Nullable<Quaternion>);
  66445. /**
  66446. * Returns a boolean. True if the particle intersects a mesh, else false
  66447. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66448. * @param target is the object (point or mesh) what the intersection is computed against
  66449. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66450. * @returns true if it intersects
  66451. */
  66452. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66453. /**
  66454. * get the rotation matrix of the particle
  66455. * @hidden
  66456. */
  66457. getRotationMatrix(m: Matrix): void;
  66458. }
  66459. /**
  66460. * Represents a group of points in a points cloud system
  66461. * * PCS internal tool, don't use it manually.
  66462. */
  66463. export class PointsGroup {
  66464. /**
  66465. * The group id
  66466. * @hidden
  66467. */
  66468. groupID: number;
  66469. /**
  66470. * image data for group (internal use)
  66471. * @hidden
  66472. */
  66473. _groupImageData: Nullable<ArrayBufferView>;
  66474. /**
  66475. * Image Width (internal use)
  66476. * @hidden
  66477. */
  66478. _groupImgWidth: number;
  66479. /**
  66480. * Image Height (internal use)
  66481. * @hidden
  66482. */
  66483. _groupImgHeight: number;
  66484. /**
  66485. * Custom position function (internal use)
  66486. * @hidden
  66487. */
  66488. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66489. /**
  66490. * density per facet for surface points
  66491. * @hidden
  66492. */
  66493. _groupDensity: number[];
  66494. /**
  66495. * Only when points are colored by texture carries pointer to texture list array
  66496. * @hidden
  66497. */
  66498. _textureNb: number;
  66499. /**
  66500. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66501. * PCS internal tool, don't use it manually.
  66502. * @hidden
  66503. */
  66504. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66505. }
  66506. }
  66507. declare module "babylonjs/Particles/index" {
  66508. export * from "babylonjs/Particles/baseParticleSystem";
  66509. export * from "babylonjs/Particles/EmitterTypes/index";
  66510. export * from "babylonjs/Particles/gpuParticleSystem";
  66511. export * from "babylonjs/Particles/IParticleSystem";
  66512. export * from "babylonjs/Particles/particle";
  66513. export * from "babylonjs/Particles/particleHelper";
  66514. export * from "babylonjs/Particles/particleSystem";
  66515. export * from "babylonjs/Particles/particleSystemComponent";
  66516. export * from "babylonjs/Particles/particleSystemSet";
  66517. export * from "babylonjs/Particles/solidParticle";
  66518. export * from "babylonjs/Particles/solidParticleSystem";
  66519. export * from "babylonjs/Particles/cloudPoint";
  66520. export * from "babylonjs/Particles/pointsCloudSystem";
  66521. export * from "babylonjs/Particles/subEmitter";
  66522. }
  66523. declare module "babylonjs/Physics/physicsEngineComponent" {
  66524. import { Nullable } from "babylonjs/types";
  66525. import { Observable, Observer } from "babylonjs/Misc/observable";
  66526. import { Vector3 } from "babylonjs/Maths/math.vector";
  66527. import { Mesh } from "babylonjs/Meshes/mesh";
  66528. import { ISceneComponent } from "babylonjs/sceneComponent";
  66529. import { Scene } from "babylonjs/scene";
  66530. import { Node } from "babylonjs/node";
  66531. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66532. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66533. module "babylonjs/scene" {
  66534. interface Scene {
  66535. /** @hidden (Backing field) */
  66536. _physicsEngine: Nullable<IPhysicsEngine>;
  66537. /** @hidden */
  66538. _physicsTimeAccumulator: number;
  66539. /**
  66540. * Gets the current physics engine
  66541. * @returns a IPhysicsEngine or null if none attached
  66542. */
  66543. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66544. /**
  66545. * Enables physics to the current scene
  66546. * @param gravity defines the scene's gravity for the physics engine
  66547. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66548. * @return a boolean indicating if the physics engine was initialized
  66549. */
  66550. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66551. /**
  66552. * Disables and disposes the physics engine associated with the scene
  66553. */
  66554. disablePhysicsEngine(): void;
  66555. /**
  66556. * Gets a boolean indicating if there is an active physics engine
  66557. * @returns a boolean indicating if there is an active physics engine
  66558. */
  66559. isPhysicsEnabled(): boolean;
  66560. /**
  66561. * Deletes a physics compound impostor
  66562. * @param compound defines the compound to delete
  66563. */
  66564. deleteCompoundImpostor(compound: any): void;
  66565. /**
  66566. * An event triggered when physic simulation is about to be run
  66567. */
  66568. onBeforePhysicsObservable: Observable<Scene>;
  66569. /**
  66570. * An event triggered when physic simulation has been done
  66571. */
  66572. onAfterPhysicsObservable: Observable<Scene>;
  66573. }
  66574. }
  66575. module "babylonjs/Meshes/abstractMesh" {
  66576. interface AbstractMesh {
  66577. /** @hidden */
  66578. _physicsImpostor: Nullable<PhysicsImpostor>;
  66579. /**
  66580. * Gets or sets impostor used for physic simulation
  66581. * @see http://doc.babylonjs.com/features/physics_engine
  66582. */
  66583. physicsImpostor: Nullable<PhysicsImpostor>;
  66584. /**
  66585. * Gets the current physics impostor
  66586. * @see http://doc.babylonjs.com/features/physics_engine
  66587. * @returns a physics impostor or null
  66588. */
  66589. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66590. /** Apply a physic impulse to the mesh
  66591. * @param force defines the force to apply
  66592. * @param contactPoint defines where to apply the force
  66593. * @returns the current mesh
  66594. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66595. */
  66596. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66597. /**
  66598. * Creates a physic joint between two meshes
  66599. * @param otherMesh defines the other mesh to use
  66600. * @param pivot1 defines the pivot to use on this mesh
  66601. * @param pivot2 defines the pivot to use on the other mesh
  66602. * @param options defines additional options (can be plugin dependent)
  66603. * @returns the current mesh
  66604. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66605. */
  66606. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66607. /** @hidden */
  66608. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66609. }
  66610. }
  66611. /**
  66612. * Defines the physics engine scene component responsible to manage a physics engine
  66613. */
  66614. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66615. /**
  66616. * The component name helpful to identify the component in the list of scene components.
  66617. */
  66618. readonly name: string;
  66619. /**
  66620. * The scene the component belongs to.
  66621. */
  66622. scene: Scene;
  66623. /**
  66624. * Creates a new instance of the component for the given scene
  66625. * @param scene Defines the scene to register the component in
  66626. */
  66627. constructor(scene: Scene);
  66628. /**
  66629. * Registers the component in a given scene
  66630. */
  66631. register(): void;
  66632. /**
  66633. * Rebuilds the elements related to this component in case of
  66634. * context lost for instance.
  66635. */
  66636. rebuild(): void;
  66637. /**
  66638. * Disposes the component and the associated ressources
  66639. */
  66640. dispose(): void;
  66641. }
  66642. }
  66643. declare module "babylonjs/Physics/physicsHelper" {
  66644. import { Nullable } from "babylonjs/types";
  66645. import { Vector3 } from "babylonjs/Maths/math.vector";
  66646. import { Mesh } from "babylonjs/Meshes/mesh";
  66647. import { Scene } from "babylonjs/scene";
  66648. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66649. /**
  66650. * A helper for physics simulations
  66651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66652. */
  66653. export class PhysicsHelper {
  66654. private _scene;
  66655. private _physicsEngine;
  66656. /**
  66657. * Initializes the Physics helper
  66658. * @param scene Babylon.js scene
  66659. */
  66660. constructor(scene: Scene);
  66661. /**
  66662. * Applies a radial explosion impulse
  66663. * @param origin the origin of the explosion
  66664. * @param radiusOrEventOptions the radius or the options of radial explosion
  66665. * @param strength the explosion strength
  66666. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66667. * @returns A physics radial explosion event, or null
  66668. */
  66669. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66670. /**
  66671. * Applies a radial explosion force
  66672. * @param origin the origin of the explosion
  66673. * @param radiusOrEventOptions the radius or the options of radial explosion
  66674. * @param strength the explosion strength
  66675. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66676. * @returns A physics radial explosion event, or null
  66677. */
  66678. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66679. /**
  66680. * Creates a gravitational field
  66681. * @param origin the origin of the explosion
  66682. * @param radiusOrEventOptions the radius or the options of radial explosion
  66683. * @param strength the explosion strength
  66684. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66685. * @returns A physics gravitational field event, or null
  66686. */
  66687. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66688. /**
  66689. * Creates a physics updraft event
  66690. * @param origin the origin of the updraft
  66691. * @param radiusOrEventOptions the radius or the options of the updraft
  66692. * @param strength the strength of the updraft
  66693. * @param height the height of the updraft
  66694. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66695. * @returns A physics updraft event, or null
  66696. */
  66697. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66698. /**
  66699. * Creates a physics vortex event
  66700. * @param origin the of the vortex
  66701. * @param radiusOrEventOptions the radius or the options of the vortex
  66702. * @param strength the strength of the vortex
  66703. * @param height the height of the vortex
  66704. * @returns a Physics vortex event, or null
  66705. * A physics vortex event or null
  66706. */
  66707. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66708. }
  66709. /**
  66710. * Represents a physics radial explosion event
  66711. */
  66712. class PhysicsRadialExplosionEvent {
  66713. private _scene;
  66714. private _options;
  66715. private _sphere;
  66716. private _dataFetched;
  66717. /**
  66718. * Initializes a radial explosioin event
  66719. * @param _scene BabylonJS scene
  66720. * @param _options The options for the vortex event
  66721. */
  66722. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66723. /**
  66724. * Returns the data related to the radial explosion event (sphere).
  66725. * @returns The radial explosion event data
  66726. */
  66727. getData(): PhysicsRadialExplosionEventData;
  66728. /**
  66729. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66730. * @param impostor A physics imposter
  66731. * @param origin the origin of the explosion
  66732. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66733. */
  66734. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66735. /**
  66736. * Triggers affecterd impostors callbacks
  66737. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66738. */
  66739. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66740. /**
  66741. * Disposes the sphere.
  66742. * @param force Specifies if the sphere should be disposed by force
  66743. */
  66744. dispose(force?: boolean): void;
  66745. /*** Helpers ***/
  66746. private _prepareSphere;
  66747. private _intersectsWithSphere;
  66748. }
  66749. /**
  66750. * Represents a gravitational field event
  66751. */
  66752. class PhysicsGravitationalFieldEvent {
  66753. private _physicsHelper;
  66754. private _scene;
  66755. private _origin;
  66756. private _options;
  66757. private _tickCallback;
  66758. private _sphere;
  66759. private _dataFetched;
  66760. /**
  66761. * Initializes the physics gravitational field event
  66762. * @param _physicsHelper A physics helper
  66763. * @param _scene BabylonJS scene
  66764. * @param _origin The origin position of the gravitational field event
  66765. * @param _options The options for the vortex event
  66766. */
  66767. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66768. /**
  66769. * Returns the data related to the gravitational field event (sphere).
  66770. * @returns A gravitational field event
  66771. */
  66772. getData(): PhysicsGravitationalFieldEventData;
  66773. /**
  66774. * Enables the gravitational field.
  66775. */
  66776. enable(): void;
  66777. /**
  66778. * Disables the gravitational field.
  66779. */
  66780. disable(): void;
  66781. /**
  66782. * Disposes the sphere.
  66783. * @param force The force to dispose from the gravitational field event
  66784. */
  66785. dispose(force?: boolean): void;
  66786. private _tick;
  66787. }
  66788. /**
  66789. * Represents a physics updraft event
  66790. */
  66791. class PhysicsUpdraftEvent {
  66792. private _scene;
  66793. private _origin;
  66794. private _options;
  66795. private _physicsEngine;
  66796. private _originTop;
  66797. private _originDirection;
  66798. private _tickCallback;
  66799. private _cylinder;
  66800. private _cylinderPosition;
  66801. private _dataFetched;
  66802. /**
  66803. * Initializes the physics updraft event
  66804. * @param _scene BabylonJS scene
  66805. * @param _origin The origin position of the updraft
  66806. * @param _options The options for the updraft event
  66807. */
  66808. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66809. /**
  66810. * Returns the data related to the updraft event (cylinder).
  66811. * @returns A physics updraft event
  66812. */
  66813. getData(): PhysicsUpdraftEventData;
  66814. /**
  66815. * Enables the updraft.
  66816. */
  66817. enable(): void;
  66818. /**
  66819. * Disables the updraft.
  66820. */
  66821. disable(): void;
  66822. /**
  66823. * Disposes the cylinder.
  66824. * @param force Specifies if the updraft should be disposed by force
  66825. */
  66826. dispose(force?: boolean): void;
  66827. private getImpostorHitData;
  66828. private _tick;
  66829. /*** Helpers ***/
  66830. private _prepareCylinder;
  66831. private _intersectsWithCylinder;
  66832. }
  66833. /**
  66834. * Represents a physics vortex event
  66835. */
  66836. class PhysicsVortexEvent {
  66837. private _scene;
  66838. private _origin;
  66839. private _options;
  66840. private _physicsEngine;
  66841. private _originTop;
  66842. private _tickCallback;
  66843. private _cylinder;
  66844. private _cylinderPosition;
  66845. private _dataFetched;
  66846. /**
  66847. * Initializes the physics vortex event
  66848. * @param _scene The BabylonJS scene
  66849. * @param _origin The origin position of the vortex
  66850. * @param _options The options for the vortex event
  66851. */
  66852. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66853. /**
  66854. * Returns the data related to the vortex event (cylinder).
  66855. * @returns The physics vortex event data
  66856. */
  66857. getData(): PhysicsVortexEventData;
  66858. /**
  66859. * Enables the vortex.
  66860. */
  66861. enable(): void;
  66862. /**
  66863. * Disables the cortex.
  66864. */
  66865. disable(): void;
  66866. /**
  66867. * Disposes the sphere.
  66868. * @param force
  66869. */
  66870. dispose(force?: boolean): void;
  66871. private getImpostorHitData;
  66872. private _tick;
  66873. /*** Helpers ***/
  66874. private _prepareCylinder;
  66875. private _intersectsWithCylinder;
  66876. }
  66877. /**
  66878. * Options fot the radial explosion event
  66879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66880. */
  66881. export class PhysicsRadialExplosionEventOptions {
  66882. /**
  66883. * The radius of the sphere for the radial explosion.
  66884. */
  66885. radius: number;
  66886. /**
  66887. * The strenth of the explosion.
  66888. */
  66889. strength: number;
  66890. /**
  66891. * The strenght of the force in correspondence to the distance of the affected object
  66892. */
  66893. falloff: PhysicsRadialImpulseFalloff;
  66894. /**
  66895. * Sphere options for the radial explosion.
  66896. */
  66897. sphere: {
  66898. segments: number;
  66899. diameter: number;
  66900. };
  66901. /**
  66902. * Sphere options for the radial explosion.
  66903. */
  66904. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66905. }
  66906. /**
  66907. * Options fot the updraft event
  66908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66909. */
  66910. export class PhysicsUpdraftEventOptions {
  66911. /**
  66912. * The radius of the cylinder for the vortex
  66913. */
  66914. radius: number;
  66915. /**
  66916. * The strenth of the updraft.
  66917. */
  66918. strength: number;
  66919. /**
  66920. * The height of the cylinder for the updraft.
  66921. */
  66922. height: number;
  66923. /**
  66924. * The mode for the the updraft.
  66925. */
  66926. updraftMode: PhysicsUpdraftMode;
  66927. }
  66928. /**
  66929. * Options fot the vortex event
  66930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66931. */
  66932. export class PhysicsVortexEventOptions {
  66933. /**
  66934. * The radius of the cylinder for the vortex
  66935. */
  66936. radius: number;
  66937. /**
  66938. * The strenth of the vortex.
  66939. */
  66940. strength: number;
  66941. /**
  66942. * The height of the cylinder for the vortex.
  66943. */
  66944. height: number;
  66945. /**
  66946. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66947. */
  66948. centripetalForceThreshold: number;
  66949. /**
  66950. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66951. */
  66952. centripetalForceMultiplier: number;
  66953. /**
  66954. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66955. */
  66956. centrifugalForceMultiplier: number;
  66957. /**
  66958. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66959. */
  66960. updraftForceMultiplier: number;
  66961. }
  66962. /**
  66963. * The strenght of the force in correspondence to the distance of the affected object
  66964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66965. */
  66966. export enum PhysicsRadialImpulseFalloff {
  66967. /** Defines that impulse is constant in strength across it's whole radius */
  66968. Constant = 0,
  66969. /** Defines that impulse gets weaker if it's further from the origin */
  66970. Linear = 1
  66971. }
  66972. /**
  66973. * The strength of the force in correspondence to the distance of the affected object
  66974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66975. */
  66976. export enum PhysicsUpdraftMode {
  66977. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66978. Center = 0,
  66979. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66980. Perpendicular = 1
  66981. }
  66982. /**
  66983. * Interface for a physics hit data
  66984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66985. */
  66986. export interface PhysicsHitData {
  66987. /**
  66988. * The force applied at the contact point
  66989. */
  66990. force: Vector3;
  66991. /**
  66992. * The contact point
  66993. */
  66994. contactPoint: Vector3;
  66995. /**
  66996. * The distance from the origin to the contact point
  66997. */
  66998. distanceFromOrigin: number;
  66999. }
  67000. /**
  67001. * Interface for radial explosion event data
  67002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67003. */
  67004. export interface PhysicsRadialExplosionEventData {
  67005. /**
  67006. * A sphere used for the radial explosion event
  67007. */
  67008. sphere: Mesh;
  67009. }
  67010. /**
  67011. * Interface for gravitational field event data
  67012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67013. */
  67014. export interface PhysicsGravitationalFieldEventData {
  67015. /**
  67016. * A sphere mesh used for the gravitational field event
  67017. */
  67018. sphere: Mesh;
  67019. }
  67020. /**
  67021. * Interface for updraft event data
  67022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67023. */
  67024. export interface PhysicsUpdraftEventData {
  67025. /**
  67026. * A cylinder used for the updraft event
  67027. */
  67028. cylinder: Mesh;
  67029. }
  67030. /**
  67031. * Interface for vortex event data
  67032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67033. */
  67034. export interface PhysicsVortexEventData {
  67035. /**
  67036. * A cylinder used for the vortex event
  67037. */
  67038. cylinder: Mesh;
  67039. }
  67040. /**
  67041. * Interface for an affected physics impostor
  67042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67043. */
  67044. export interface PhysicsAffectedImpostorWithData {
  67045. /**
  67046. * The impostor affected by the effect
  67047. */
  67048. impostor: PhysicsImpostor;
  67049. /**
  67050. * The data about the hit/horce from the explosion
  67051. */
  67052. hitData: PhysicsHitData;
  67053. }
  67054. }
  67055. declare module "babylonjs/Physics/Plugins/index" {
  67056. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67057. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67058. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67059. }
  67060. declare module "babylonjs/Physics/index" {
  67061. export * from "babylonjs/Physics/IPhysicsEngine";
  67062. export * from "babylonjs/Physics/physicsEngine";
  67063. export * from "babylonjs/Physics/physicsEngineComponent";
  67064. export * from "babylonjs/Physics/physicsHelper";
  67065. export * from "babylonjs/Physics/physicsImpostor";
  67066. export * from "babylonjs/Physics/physicsJoint";
  67067. export * from "babylonjs/Physics/Plugins/index";
  67068. }
  67069. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67070. /** @hidden */
  67071. export var blackAndWhitePixelShader: {
  67072. name: string;
  67073. shader: string;
  67074. };
  67075. }
  67076. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67078. import { Camera } from "babylonjs/Cameras/camera";
  67079. import { Engine } from "babylonjs/Engines/engine";
  67080. import "babylonjs/Shaders/blackAndWhite.fragment";
  67081. /**
  67082. * Post process used to render in black and white
  67083. */
  67084. export class BlackAndWhitePostProcess extends PostProcess {
  67085. /**
  67086. * Linear about to convert he result to black and white (default: 1)
  67087. */
  67088. degree: number;
  67089. /**
  67090. * Creates a black and white post process
  67091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67092. * @param name The name of the effect.
  67093. * @param options The required width/height ratio to downsize to before computing the render pass.
  67094. * @param camera The camera to apply the render pass to.
  67095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67096. * @param engine The engine which the post process will be applied. (default: current engine)
  67097. * @param reusable If the post process can be reused on the same frame. (default: false)
  67098. */
  67099. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67100. }
  67101. }
  67102. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67103. import { Nullable } from "babylonjs/types";
  67104. import { Camera } from "babylonjs/Cameras/camera";
  67105. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67106. import { Engine } from "babylonjs/Engines/engine";
  67107. /**
  67108. * This represents a set of one or more post processes in Babylon.
  67109. * A post process can be used to apply a shader to a texture after it is rendered.
  67110. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67111. */
  67112. export class PostProcessRenderEffect {
  67113. private _postProcesses;
  67114. private _getPostProcesses;
  67115. private _singleInstance;
  67116. private _cameras;
  67117. private _indicesForCamera;
  67118. /**
  67119. * Name of the effect
  67120. * @hidden
  67121. */
  67122. _name: string;
  67123. /**
  67124. * Instantiates a post process render effect.
  67125. * A post process can be used to apply a shader to a texture after it is rendered.
  67126. * @param engine The engine the effect is tied to
  67127. * @param name The name of the effect
  67128. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67129. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67130. */
  67131. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67132. /**
  67133. * Checks if all the post processes in the effect are supported.
  67134. */
  67135. get isSupported(): boolean;
  67136. /**
  67137. * Updates the current state of the effect
  67138. * @hidden
  67139. */
  67140. _update(): void;
  67141. /**
  67142. * Attaches the effect on cameras
  67143. * @param cameras The camera to attach to.
  67144. * @hidden
  67145. */
  67146. _attachCameras(cameras: Camera): void;
  67147. /**
  67148. * Attaches the effect on cameras
  67149. * @param cameras The camera to attach to.
  67150. * @hidden
  67151. */
  67152. _attachCameras(cameras: Camera[]): void;
  67153. /**
  67154. * Detaches the effect on cameras
  67155. * @param cameras The camera to detatch from.
  67156. * @hidden
  67157. */
  67158. _detachCameras(cameras: Camera): void;
  67159. /**
  67160. * Detatches the effect on cameras
  67161. * @param cameras The camera to detatch from.
  67162. * @hidden
  67163. */
  67164. _detachCameras(cameras: Camera[]): void;
  67165. /**
  67166. * Enables the effect on given cameras
  67167. * @param cameras The camera to enable.
  67168. * @hidden
  67169. */
  67170. _enable(cameras: Camera): void;
  67171. /**
  67172. * Enables the effect on given cameras
  67173. * @param cameras The camera to enable.
  67174. * @hidden
  67175. */
  67176. _enable(cameras: Nullable<Camera[]>): void;
  67177. /**
  67178. * Disables the effect on the given cameras
  67179. * @param cameras The camera to disable.
  67180. * @hidden
  67181. */
  67182. _disable(cameras: Camera): void;
  67183. /**
  67184. * Disables the effect on the given cameras
  67185. * @param cameras The camera to disable.
  67186. * @hidden
  67187. */
  67188. _disable(cameras: Nullable<Camera[]>): void;
  67189. /**
  67190. * Gets a list of the post processes contained in the effect.
  67191. * @param camera The camera to get the post processes on.
  67192. * @returns The list of the post processes in the effect.
  67193. */
  67194. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67195. }
  67196. }
  67197. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67198. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67199. /** @hidden */
  67200. export var extractHighlightsPixelShader: {
  67201. name: string;
  67202. shader: string;
  67203. };
  67204. }
  67205. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67206. import { Nullable } from "babylonjs/types";
  67207. import { Camera } from "babylonjs/Cameras/camera";
  67208. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67209. import { Engine } from "babylonjs/Engines/engine";
  67210. import "babylonjs/Shaders/extractHighlights.fragment";
  67211. /**
  67212. * 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.
  67213. */
  67214. export class ExtractHighlightsPostProcess extends PostProcess {
  67215. /**
  67216. * The luminance threshold, pixels below this value will be set to black.
  67217. */
  67218. threshold: number;
  67219. /** @hidden */
  67220. _exposure: number;
  67221. /**
  67222. * Post process which has the input texture to be used when performing highlight extraction
  67223. * @hidden
  67224. */
  67225. _inputPostProcess: Nullable<PostProcess>;
  67226. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67227. }
  67228. }
  67229. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67230. /** @hidden */
  67231. export var bloomMergePixelShader: {
  67232. name: string;
  67233. shader: string;
  67234. };
  67235. }
  67236. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67237. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67238. import { Nullable } from "babylonjs/types";
  67239. import { Engine } from "babylonjs/Engines/engine";
  67240. import { Camera } from "babylonjs/Cameras/camera";
  67241. import "babylonjs/Shaders/bloomMerge.fragment";
  67242. /**
  67243. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67244. */
  67245. export class BloomMergePostProcess extends PostProcess {
  67246. /** Weight of the bloom to be added to the original input. */
  67247. weight: number;
  67248. /**
  67249. * Creates a new instance of @see BloomMergePostProcess
  67250. * @param name The name of the effect.
  67251. * @param originalFromInput Post process which's input will be used for the merge.
  67252. * @param blurred Blurred highlights post process which's output will be used.
  67253. * @param weight Weight of the bloom to be added to the original input.
  67254. * @param options The required width/height ratio to downsize to before computing the render pass.
  67255. * @param camera The camera to apply the render pass to.
  67256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67257. * @param engine The engine which the post process will be applied. (default: current engine)
  67258. * @param reusable If the post process can be reused on the same frame. (default: false)
  67259. * @param textureType Type of textures used when performing the post process. (default: 0)
  67260. * @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)
  67261. */
  67262. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67263. /** Weight of the bloom to be added to the original input. */
  67264. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67265. }
  67266. }
  67267. declare module "babylonjs/PostProcesses/bloomEffect" {
  67268. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67269. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67270. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67271. import { Camera } from "babylonjs/Cameras/camera";
  67272. import { Scene } from "babylonjs/scene";
  67273. /**
  67274. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67275. */
  67276. export class BloomEffect extends PostProcessRenderEffect {
  67277. private bloomScale;
  67278. /**
  67279. * @hidden Internal
  67280. */
  67281. _effects: Array<PostProcess>;
  67282. /**
  67283. * @hidden Internal
  67284. */
  67285. _downscale: ExtractHighlightsPostProcess;
  67286. private _blurX;
  67287. private _blurY;
  67288. private _merge;
  67289. /**
  67290. * The luminance threshold to find bright areas of the image to bloom.
  67291. */
  67292. get threshold(): number;
  67293. set threshold(value: number);
  67294. /**
  67295. * The strength of the bloom.
  67296. */
  67297. get weight(): number;
  67298. set weight(value: number);
  67299. /**
  67300. * Specifies the size of the bloom blur kernel, relative to the final output size
  67301. */
  67302. get kernel(): number;
  67303. set kernel(value: number);
  67304. /**
  67305. * Creates a new instance of @see BloomEffect
  67306. * @param scene The scene the effect belongs to.
  67307. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67308. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67309. * @param bloomWeight The the strength of bloom.
  67310. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67311. * @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)
  67312. */
  67313. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67314. /**
  67315. * Disposes each of the internal effects for a given camera.
  67316. * @param camera The camera to dispose the effect on.
  67317. */
  67318. disposeEffects(camera: Camera): void;
  67319. /**
  67320. * @hidden Internal
  67321. */
  67322. _updateEffects(): void;
  67323. /**
  67324. * Internal
  67325. * @returns if all the contained post processes are ready.
  67326. * @hidden
  67327. */
  67328. _isReady(): boolean;
  67329. }
  67330. }
  67331. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67332. /** @hidden */
  67333. export var chromaticAberrationPixelShader: {
  67334. name: string;
  67335. shader: string;
  67336. };
  67337. }
  67338. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67339. import { Vector2 } from "babylonjs/Maths/math.vector";
  67340. import { Nullable } from "babylonjs/types";
  67341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67342. import { Camera } from "babylonjs/Cameras/camera";
  67343. import { Engine } from "babylonjs/Engines/engine";
  67344. import "babylonjs/Shaders/chromaticAberration.fragment";
  67345. /**
  67346. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67347. */
  67348. export class ChromaticAberrationPostProcess extends PostProcess {
  67349. /**
  67350. * The amount of seperation of rgb channels (default: 30)
  67351. */
  67352. aberrationAmount: number;
  67353. /**
  67354. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67355. */
  67356. radialIntensity: number;
  67357. /**
  67358. * 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))
  67359. */
  67360. direction: Vector2;
  67361. /**
  67362. * 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))
  67363. */
  67364. centerPosition: Vector2;
  67365. /**
  67366. * Creates a new instance ChromaticAberrationPostProcess
  67367. * @param name The name of the effect.
  67368. * @param screenWidth The width of the screen to apply the effect on.
  67369. * @param screenHeight The height of the screen to apply the effect on.
  67370. * @param options The required width/height ratio to downsize to before computing the render pass.
  67371. * @param camera The camera to apply the render pass to.
  67372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67373. * @param engine The engine which the post process will be applied. (default: current engine)
  67374. * @param reusable If the post process can be reused on the same frame. (default: false)
  67375. * @param textureType Type of textures used when performing the post process. (default: 0)
  67376. * @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)
  67377. */
  67378. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67379. }
  67380. }
  67381. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67382. /** @hidden */
  67383. export var circleOfConfusionPixelShader: {
  67384. name: string;
  67385. shader: string;
  67386. };
  67387. }
  67388. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67389. import { Nullable } from "babylonjs/types";
  67390. import { Engine } from "babylonjs/Engines/engine";
  67391. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67393. import { Camera } from "babylonjs/Cameras/camera";
  67394. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67395. /**
  67396. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67397. */
  67398. export class CircleOfConfusionPostProcess extends PostProcess {
  67399. /**
  67400. * 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.
  67401. */
  67402. lensSize: number;
  67403. /**
  67404. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67405. */
  67406. fStop: number;
  67407. /**
  67408. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67409. */
  67410. focusDistance: number;
  67411. /**
  67412. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67413. */
  67414. focalLength: number;
  67415. private _depthTexture;
  67416. /**
  67417. * Creates a new instance CircleOfConfusionPostProcess
  67418. * @param name The name of the effect.
  67419. * @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.
  67420. * @param options The required width/height ratio to downsize to before computing the render pass.
  67421. * @param camera The camera to apply the render pass to.
  67422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67423. * @param engine The engine which the post process will be applied. (default: current engine)
  67424. * @param reusable If the post process can be reused on the same frame. (default: false)
  67425. * @param textureType Type of textures used when performing the post process. (default: 0)
  67426. * @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)
  67427. */
  67428. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67429. /**
  67430. * 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.
  67431. */
  67432. set depthTexture(value: RenderTargetTexture);
  67433. }
  67434. }
  67435. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67436. /** @hidden */
  67437. export var colorCorrectionPixelShader: {
  67438. name: string;
  67439. shader: string;
  67440. };
  67441. }
  67442. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67443. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67444. import { Engine } from "babylonjs/Engines/engine";
  67445. import { Camera } from "babylonjs/Cameras/camera";
  67446. import "babylonjs/Shaders/colorCorrection.fragment";
  67447. /**
  67448. *
  67449. * This post-process allows the modification of rendered colors by using
  67450. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67451. *
  67452. * The object needs to be provided an url to a texture containing the color
  67453. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67454. * Use an image editing software to tweak the LUT to match your needs.
  67455. *
  67456. * For an example of a color LUT, see here:
  67457. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67458. * For explanations on color grading, see here:
  67459. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67460. *
  67461. */
  67462. export class ColorCorrectionPostProcess extends PostProcess {
  67463. private _colorTableTexture;
  67464. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67465. }
  67466. }
  67467. declare module "babylonjs/Shaders/convolution.fragment" {
  67468. /** @hidden */
  67469. export var convolutionPixelShader: {
  67470. name: string;
  67471. shader: string;
  67472. };
  67473. }
  67474. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67475. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67476. import { Nullable } from "babylonjs/types";
  67477. import { Camera } from "babylonjs/Cameras/camera";
  67478. import { Engine } from "babylonjs/Engines/engine";
  67479. import "babylonjs/Shaders/convolution.fragment";
  67480. /**
  67481. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67482. * input texture to perform effects such as edge detection or sharpening
  67483. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67484. */
  67485. export class ConvolutionPostProcess extends PostProcess {
  67486. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67487. kernel: number[];
  67488. /**
  67489. * Creates a new instance ConvolutionPostProcess
  67490. * @param name The name of the effect.
  67491. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67492. * @param options The required width/height ratio to downsize to before computing the render pass.
  67493. * @param camera The camera to apply the render pass to.
  67494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67495. * @param engine The engine which the post process will be applied. (default: current engine)
  67496. * @param reusable If the post process can be reused on the same frame. (default: false)
  67497. * @param textureType Type of textures used when performing the post process. (default: 0)
  67498. */
  67499. constructor(name: string,
  67500. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67501. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67502. /**
  67503. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67504. */
  67505. static EdgeDetect0Kernel: number[];
  67506. /**
  67507. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67508. */
  67509. static EdgeDetect1Kernel: number[];
  67510. /**
  67511. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67512. */
  67513. static EdgeDetect2Kernel: number[];
  67514. /**
  67515. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67516. */
  67517. static SharpenKernel: number[];
  67518. /**
  67519. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67520. */
  67521. static EmbossKernel: number[];
  67522. /**
  67523. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67524. */
  67525. static GaussianKernel: number[];
  67526. }
  67527. }
  67528. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67529. import { Nullable } from "babylonjs/types";
  67530. import { Vector2 } from "babylonjs/Maths/math.vector";
  67531. import { Camera } from "babylonjs/Cameras/camera";
  67532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67533. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67534. import { Engine } from "babylonjs/Engines/engine";
  67535. import { Scene } from "babylonjs/scene";
  67536. /**
  67537. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67538. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67539. * based on samples that have a large difference in distance than the center pixel.
  67540. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67541. */
  67542. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67543. direction: Vector2;
  67544. /**
  67545. * Creates a new instance CircleOfConfusionPostProcess
  67546. * @param name The name of the effect.
  67547. * @param scene The scene the effect belongs to.
  67548. * @param direction The direction the blur should be applied.
  67549. * @param kernel The size of the kernel used to blur.
  67550. * @param options The required width/height ratio to downsize to before computing the render pass.
  67551. * @param camera The camera to apply the render pass to.
  67552. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67553. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67555. * @param engine The engine which the post process will be applied. (default: current engine)
  67556. * @param reusable If the post process can be reused on the same frame. (default: false)
  67557. * @param textureType Type of textures used when performing the post process. (default: 0)
  67558. * @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)
  67559. */
  67560. 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);
  67561. }
  67562. }
  67563. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67564. /** @hidden */
  67565. export var depthOfFieldMergePixelShader: {
  67566. name: string;
  67567. shader: string;
  67568. };
  67569. }
  67570. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67571. import { Nullable } from "babylonjs/types";
  67572. import { Camera } from "babylonjs/Cameras/camera";
  67573. import { Effect } from "babylonjs/Materials/effect";
  67574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67575. import { Engine } from "babylonjs/Engines/engine";
  67576. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67577. /**
  67578. * Options to be set when merging outputs from the default pipeline.
  67579. */
  67580. export class DepthOfFieldMergePostProcessOptions {
  67581. /**
  67582. * The original image to merge on top of
  67583. */
  67584. originalFromInput: PostProcess;
  67585. /**
  67586. * Parameters to perform the merge of the depth of field effect
  67587. */
  67588. depthOfField?: {
  67589. circleOfConfusion: PostProcess;
  67590. blurSteps: Array<PostProcess>;
  67591. };
  67592. /**
  67593. * Parameters to perform the merge of bloom effect
  67594. */
  67595. bloom?: {
  67596. blurred: PostProcess;
  67597. weight: number;
  67598. };
  67599. }
  67600. /**
  67601. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67602. */
  67603. export class DepthOfFieldMergePostProcess extends PostProcess {
  67604. private blurSteps;
  67605. /**
  67606. * Creates a new instance of DepthOfFieldMergePostProcess
  67607. * @param name The name of the effect.
  67608. * @param originalFromInput Post process which's input will be used for the merge.
  67609. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67610. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67611. * @param options The required width/height ratio to downsize to before computing the render pass.
  67612. * @param camera The camera to apply the render pass to.
  67613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67614. * @param engine The engine which the post process will be applied. (default: current engine)
  67615. * @param reusable If the post process can be reused on the same frame. (default: false)
  67616. * @param textureType Type of textures used when performing the post process. (default: 0)
  67617. * @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)
  67618. */
  67619. 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);
  67620. /**
  67621. * Updates the effect with the current post process compile time values and recompiles the shader.
  67622. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67623. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67624. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67625. * @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
  67626. * @param onCompiled Called when the shader has been compiled.
  67627. * @param onError Called if there is an error when compiling a shader.
  67628. */
  67629. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67630. }
  67631. }
  67632. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67633. import { Nullable } from "babylonjs/types";
  67634. import { Camera } from "babylonjs/Cameras/camera";
  67635. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67636. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67637. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67638. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67639. import { Scene } from "babylonjs/scene";
  67640. /**
  67641. * Specifies the level of max blur that should be applied when using the depth of field effect
  67642. */
  67643. export enum DepthOfFieldEffectBlurLevel {
  67644. /**
  67645. * Subtle blur
  67646. */
  67647. Low = 0,
  67648. /**
  67649. * Medium blur
  67650. */
  67651. Medium = 1,
  67652. /**
  67653. * Large blur
  67654. */
  67655. High = 2
  67656. }
  67657. /**
  67658. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67659. */
  67660. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67661. private _circleOfConfusion;
  67662. /**
  67663. * @hidden Internal, blurs from high to low
  67664. */
  67665. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67666. private _depthOfFieldBlurY;
  67667. private _dofMerge;
  67668. /**
  67669. * @hidden Internal post processes in depth of field effect
  67670. */
  67671. _effects: Array<PostProcess>;
  67672. /**
  67673. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67674. */
  67675. set focalLength(value: number);
  67676. get focalLength(): number;
  67677. /**
  67678. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67679. */
  67680. set fStop(value: number);
  67681. get fStop(): number;
  67682. /**
  67683. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67684. */
  67685. set focusDistance(value: number);
  67686. get focusDistance(): number;
  67687. /**
  67688. * 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.
  67689. */
  67690. set lensSize(value: number);
  67691. get lensSize(): number;
  67692. /**
  67693. * Creates a new instance DepthOfFieldEffect
  67694. * @param scene The scene the effect belongs to.
  67695. * @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.
  67696. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67697. * @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)
  67698. */
  67699. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67700. /**
  67701. * Get the current class name of the current effet
  67702. * @returns "DepthOfFieldEffect"
  67703. */
  67704. getClassName(): string;
  67705. /**
  67706. * 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.
  67707. */
  67708. set depthTexture(value: RenderTargetTexture);
  67709. /**
  67710. * Disposes each of the internal effects for a given camera.
  67711. * @param camera The camera to dispose the effect on.
  67712. */
  67713. disposeEffects(camera: Camera): void;
  67714. /**
  67715. * @hidden Internal
  67716. */
  67717. _updateEffects(): void;
  67718. /**
  67719. * Internal
  67720. * @returns if all the contained post processes are ready.
  67721. * @hidden
  67722. */
  67723. _isReady(): boolean;
  67724. }
  67725. }
  67726. declare module "babylonjs/Shaders/displayPass.fragment" {
  67727. /** @hidden */
  67728. export var displayPassPixelShader: {
  67729. name: string;
  67730. shader: string;
  67731. };
  67732. }
  67733. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67734. import { Nullable } from "babylonjs/types";
  67735. import { Camera } from "babylonjs/Cameras/camera";
  67736. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67737. import { Engine } from "babylonjs/Engines/engine";
  67738. import "babylonjs/Shaders/displayPass.fragment";
  67739. /**
  67740. * DisplayPassPostProcess which produces an output the same as it's input
  67741. */
  67742. export class DisplayPassPostProcess extends PostProcess {
  67743. /**
  67744. * Creates the DisplayPassPostProcess
  67745. * @param name The name of the effect.
  67746. * @param options The required width/height ratio to downsize to before computing the render pass.
  67747. * @param camera The camera to apply the render pass to.
  67748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67749. * @param engine The engine which the post process will be applied. (default: current engine)
  67750. * @param reusable If the post process can be reused on the same frame. (default: false)
  67751. */
  67752. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67753. }
  67754. }
  67755. declare module "babylonjs/Shaders/filter.fragment" {
  67756. /** @hidden */
  67757. export var filterPixelShader: {
  67758. name: string;
  67759. shader: string;
  67760. };
  67761. }
  67762. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67763. import { Nullable } from "babylonjs/types";
  67764. import { Matrix } from "babylonjs/Maths/math.vector";
  67765. import { Camera } from "babylonjs/Cameras/camera";
  67766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67767. import { Engine } from "babylonjs/Engines/engine";
  67768. import "babylonjs/Shaders/filter.fragment";
  67769. /**
  67770. * Applies a kernel filter to the image
  67771. */
  67772. export class FilterPostProcess extends PostProcess {
  67773. /** The matrix to be applied to the image */
  67774. kernelMatrix: Matrix;
  67775. /**
  67776. *
  67777. * @param name The name of the effect.
  67778. * @param kernelMatrix The matrix to be applied to the image
  67779. * @param options The required width/height ratio to downsize to before computing the render pass.
  67780. * @param camera The camera to apply the render pass to.
  67781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67782. * @param engine The engine which the post process will be applied. (default: current engine)
  67783. * @param reusable If the post process can be reused on the same frame. (default: false)
  67784. */
  67785. constructor(name: string,
  67786. /** The matrix to be applied to the image */
  67787. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67788. }
  67789. }
  67790. declare module "babylonjs/Shaders/fxaa.fragment" {
  67791. /** @hidden */
  67792. export var fxaaPixelShader: {
  67793. name: string;
  67794. shader: string;
  67795. };
  67796. }
  67797. declare module "babylonjs/Shaders/fxaa.vertex" {
  67798. /** @hidden */
  67799. export var fxaaVertexShader: {
  67800. name: string;
  67801. shader: string;
  67802. };
  67803. }
  67804. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67805. import { Nullable } from "babylonjs/types";
  67806. import { Camera } from "babylonjs/Cameras/camera";
  67807. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67808. import { Engine } from "babylonjs/Engines/engine";
  67809. import "babylonjs/Shaders/fxaa.fragment";
  67810. import "babylonjs/Shaders/fxaa.vertex";
  67811. /**
  67812. * Fxaa post process
  67813. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67814. */
  67815. export class FxaaPostProcess extends PostProcess {
  67816. /** @hidden */
  67817. texelWidth: number;
  67818. /** @hidden */
  67819. texelHeight: number;
  67820. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67821. private _getDefines;
  67822. }
  67823. }
  67824. declare module "babylonjs/Shaders/grain.fragment" {
  67825. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67826. /** @hidden */
  67827. export var grainPixelShader: {
  67828. name: string;
  67829. shader: string;
  67830. };
  67831. }
  67832. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67833. import { Nullable } from "babylonjs/types";
  67834. import { Camera } from "babylonjs/Cameras/camera";
  67835. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67836. import { Engine } from "babylonjs/Engines/engine";
  67837. import "babylonjs/Shaders/grain.fragment";
  67838. /**
  67839. * The GrainPostProcess adds noise to the image at mid luminance levels
  67840. */
  67841. export class GrainPostProcess extends PostProcess {
  67842. /**
  67843. * The intensity of the grain added (default: 30)
  67844. */
  67845. intensity: number;
  67846. /**
  67847. * If the grain should be randomized on every frame
  67848. */
  67849. animated: boolean;
  67850. /**
  67851. * Creates a new instance of @see GrainPostProcess
  67852. * @param name The name of the effect.
  67853. * @param options The required width/height ratio to downsize to before computing the render pass.
  67854. * @param camera The camera to apply the render pass to.
  67855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67856. * @param engine The engine which the post process will be applied. (default: current engine)
  67857. * @param reusable If the post process can be reused on the same frame. (default: false)
  67858. * @param textureType Type of textures used when performing the post process. (default: 0)
  67859. * @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)
  67860. */
  67861. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67862. }
  67863. }
  67864. declare module "babylonjs/Shaders/highlights.fragment" {
  67865. /** @hidden */
  67866. export var highlightsPixelShader: {
  67867. name: string;
  67868. shader: string;
  67869. };
  67870. }
  67871. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67872. import { Nullable } from "babylonjs/types";
  67873. import { Camera } from "babylonjs/Cameras/camera";
  67874. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67875. import { Engine } from "babylonjs/Engines/engine";
  67876. import "babylonjs/Shaders/highlights.fragment";
  67877. /**
  67878. * Extracts highlights from the image
  67879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67880. */
  67881. export class HighlightsPostProcess extends PostProcess {
  67882. /**
  67883. * Extracts highlights from the image
  67884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67885. * @param name The name of the effect.
  67886. * @param options The required width/height ratio to downsize to before computing the render pass.
  67887. * @param camera The camera to apply the render pass to.
  67888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67889. * @param engine The engine which the post process will be applied. (default: current engine)
  67890. * @param reusable If the post process can be reused on the same frame. (default: false)
  67891. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67892. */
  67893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67894. }
  67895. }
  67896. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67897. /** @hidden */
  67898. export var mrtFragmentDeclaration: {
  67899. name: string;
  67900. shader: string;
  67901. };
  67902. }
  67903. declare module "babylonjs/Shaders/geometry.fragment" {
  67904. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67905. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67906. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67907. /** @hidden */
  67908. export var geometryPixelShader: {
  67909. name: string;
  67910. shader: string;
  67911. };
  67912. }
  67913. declare module "babylonjs/Shaders/geometry.vertex" {
  67914. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67917. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67919. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67920. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67921. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67922. /** @hidden */
  67923. export var geometryVertexShader: {
  67924. name: string;
  67925. shader: string;
  67926. };
  67927. }
  67928. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67929. import { Matrix } from "babylonjs/Maths/math.vector";
  67930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67931. import { Mesh } from "babylonjs/Meshes/mesh";
  67932. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67933. import { Effect } from "babylonjs/Materials/effect";
  67934. import { Scene } from "babylonjs/scene";
  67935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67936. import "babylonjs/Shaders/geometry.fragment";
  67937. import "babylonjs/Shaders/geometry.vertex";
  67938. /** @hidden */
  67939. interface ISavedTransformationMatrix {
  67940. world: Matrix;
  67941. viewProjection: Matrix;
  67942. }
  67943. /**
  67944. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67945. */
  67946. export class GeometryBufferRenderer {
  67947. /**
  67948. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67949. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67950. */
  67951. static readonly POSITION_TEXTURE_TYPE: number;
  67952. /**
  67953. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67954. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67955. */
  67956. static readonly VELOCITY_TEXTURE_TYPE: number;
  67957. /**
  67958. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67959. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67960. */
  67961. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67962. /**
  67963. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67964. * in order to compute objects velocities when enableVelocity is set to "true"
  67965. * @hidden
  67966. */
  67967. _previousTransformationMatrices: {
  67968. [index: number]: ISavedTransformationMatrix;
  67969. };
  67970. /**
  67971. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67972. * in order to compute objects velocities when enableVelocity is set to "true"
  67973. * @hidden
  67974. */
  67975. _previousBonesTransformationMatrices: {
  67976. [index: number]: Float32Array;
  67977. };
  67978. /**
  67979. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67980. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67981. */
  67982. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67983. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67984. renderTransparentMeshes: boolean;
  67985. private _scene;
  67986. private _multiRenderTarget;
  67987. private _ratio;
  67988. private _enablePosition;
  67989. private _enableVelocity;
  67990. private _enableReflectivity;
  67991. private _positionIndex;
  67992. private _velocityIndex;
  67993. private _reflectivityIndex;
  67994. protected _effect: Effect;
  67995. protected _cachedDefines: string;
  67996. /**
  67997. * Set the render list (meshes to be rendered) used in the G buffer.
  67998. */
  67999. set renderList(meshes: Mesh[]);
  68000. /**
  68001. * Gets wether or not G buffer are supported by the running hardware.
  68002. * This requires draw buffer supports
  68003. */
  68004. get isSupported(): boolean;
  68005. /**
  68006. * Returns the index of the given texture type in the G-Buffer textures array
  68007. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68008. * @returns the index of the given texture type in the G-Buffer textures array
  68009. */
  68010. getTextureIndex(textureType: number): number;
  68011. /**
  68012. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68013. */
  68014. get enablePosition(): boolean;
  68015. /**
  68016. * Sets whether or not objects positions are enabled for the G buffer.
  68017. */
  68018. set enablePosition(enable: boolean);
  68019. /**
  68020. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68021. */
  68022. get enableVelocity(): boolean;
  68023. /**
  68024. * Sets wether or not objects velocities are enabled for the G buffer.
  68025. */
  68026. set enableVelocity(enable: boolean);
  68027. /**
  68028. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68029. */
  68030. get enableReflectivity(): boolean;
  68031. /**
  68032. * Sets wether or not objects roughness are enabled for the G buffer.
  68033. */
  68034. set enableReflectivity(enable: boolean);
  68035. /**
  68036. * Gets the scene associated with the buffer.
  68037. */
  68038. get scene(): Scene;
  68039. /**
  68040. * Gets the ratio used by the buffer during its creation.
  68041. * How big is the buffer related to the main canvas.
  68042. */
  68043. get ratio(): number;
  68044. /** @hidden */
  68045. static _SceneComponentInitialization: (scene: Scene) => void;
  68046. /**
  68047. * Creates a new G Buffer for the scene
  68048. * @param scene The scene the buffer belongs to
  68049. * @param ratio How big is the buffer related to the main canvas.
  68050. */
  68051. constructor(scene: Scene, ratio?: number);
  68052. /**
  68053. * Checks wether everything is ready to render a submesh to the G buffer.
  68054. * @param subMesh the submesh to check readiness for
  68055. * @param useInstances is the mesh drawn using instance or not
  68056. * @returns true if ready otherwise false
  68057. */
  68058. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68059. /**
  68060. * Gets the current underlying G Buffer.
  68061. * @returns the buffer
  68062. */
  68063. getGBuffer(): MultiRenderTarget;
  68064. /**
  68065. * Gets the number of samples used to render the buffer (anti aliasing).
  68066. */
  68067. get samples(): number;
  68068. /**
  68069. * Sets the number of samples used to render the buffer (anti aliasing).
  68070. */
  68071. set samples(value: number);
  68072. /**
  68073. * Disposes the renderer and frees up associated resources.
  68074. */
  68075. dispose(): void;
  68076. protected _createRenderTargets(): void;
  68077. private _copyBonesTransformationMatrices;
  68078. }
  68079. }
  68080. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68081. import { Nullable } from "babylonjs/types";
  68082. import { Scene } from "babylonjs/scene";
  68083. import { ISceneComponent } from "babylonjs/sceneComponent";
  68084. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68085. module "babylonjs/scene" {
  68086. interface Scene {
  68087. /** @hidden (Backing field) */
  68088. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68089. /**
  68090. * Gets or Sets the current geometry buffer associated to the scene.
  68091. */
  68092. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68093. /**
  68094. * Enables a GeometryBufferRender and associates it with the scene
  68095. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68096. * @returns the GeometryBufferRenderer
  68097. */
  68098. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68099. /**
  68100. * Disables the GeometryBufferRender associated with the scene
  68101. */
  68102. disableGeometryBufferRenderer(): void;
  68103. }
  68104. }
  68105. /**
  68106. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68107. * in several rendering techniques.
  68108. */
  68109. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68110. /**
  68111. * The component name helpful to identify the component in the list of scene components.
  68112. */
  68113. readonly name: string;
  68114. /**
  68115. * The scene the component belongs to.
  68116. */
  68117. scene: Scene;
  68118. /**
  68119. * Creates a new instance of the component for the given scene
  68120. * @param scene Defines the scene to register the component in
  68121. */
  68122. constructor(scene: Scene);
  68123. /**
  68124. * Registers the component in a given scene
  68125. */
  68126. register(): void;
  68127. /**
  68128. * Rebuilds the elements related to this component in case of
  68129. * context lost for instance.
  68130. */
  68131. rebuild(): void;
  68132. /**
  68133. * Disposes the component and the associated ressources
  68134. */
  68135. dispose(): void;
  68136. private _gatherRenderTargets;
  68137. }
  68138. }
  68139. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68140. /** @hidden */
  68141. export var motionBlurPixelShader: {
  68142. name: string;
  68143. shader: string;
  68144. };
  68145. }
  68146. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68147. import { Nullable } from "babylonjs/types";
  68148. import { Camera } from "babylonjs/Cameras/camera";
  68149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68150. import { Scene } from "babylonjs/scene";
  68151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68152. import "babylonjs/Animations/animatable";
  68153. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68154. import "babylonjs/Shaders/motionBlur.fragment";
  68155. import { Engine } from "babylonjs/Engines/engine";
  68156. /**
  68157. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68158. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68159. * As an example, all you have to do is to create the post-process:
  68160. * var mb = new BABYLON.MotionBlurPostProcess(
  68161. * 'mb', // The name of the effect.
  68162. * scene, // The scene containing the objects to blur according to their velocity.
  68163. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68164. * camera // The camera to apply the render pass to.
  68165. * );
  68166. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68167. */
  68168. export class MotionBlurPostProcess extends PostProcess {
  68169. /**
  68170. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68171. */
  68172. motionStrength: number;
  68173. /**
  68174. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68175. */
  68176. get motionBlurSamples(): number;
  68177. /**
  68178. * Sets the number of iterations to be used for motion blur quality
  68179. */
  68180. set motionBlurSamples(samples: number);
  68181. private _motionBlurSamples;
  68182. private _geometryBufferRenderer;
  68183. /**
  68184. * Creates a new instance MotionBlurPostProcess
  68185. * @param name The name of the effect.
  68186. * @param scene The scene containing the objects to blur according to their velocity.
  68187. * @param options The required width/height ratio to downsize to before computing the render pass.
  68188. * @param camera The camera to apply the render pass to.
  68189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68190. * @param engine The engine which the post process will be applied. (default: current engine)
  68191. * @param reusable If the post process can be reused on the same frame. (default: false)
  68192. * @param textureType Type of textures used when performing the post process. (default: 0)
  68193. * @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)
  68194. */
  68195. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68196. /**
  68197. * Excludes the given skinned mesh from computing bones velocities.
  68198. * 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.
  68199. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68200. */
  68201. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68202. /**
  68203. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68204. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68205. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68206. */
  68207. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68208. /**
  68209. * Disposes the post process.
  68210. * @param camera The camera to dispose the post process on.
  68211. */
  68212. dispose(camera?: Camera): void;
  68213. }
  68214. }
  68215. declare module "babylonjs/Shaders/refraction.fragment" {
  68216. /** @hidden */
  68217. export var refractionPixelShader: {
  68218. name: string;
  68219. shader: string;
  68220. };
  68221. }
  68222. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68223. import { Color3 } from "babylonjs/Maths/math.color";
  68224. import { Camera } from "babylonjs/Cameras/camera";
  68225. import { Texture } from "babylonjs/Materials/Textures/texture";
  68226. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68227. import { Engine } from "babylonjs/Engines/engine";
  68228. import "babylonjs/Shaders/refraction.fragment";
  68229. /**
  68230. * Post process which applies a refractin texture
  68231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68232. */
  68233. export class RefractionPostProcess extends PostProcess {
  68234. /** the base color of the refraction (used to taint the rendering) */
  68235. color: Color3;
  68236. /** simulated refraction depth */
  68237. depth: number;
  68238. /** the coefficient of the base color (0 to remove base color tainting) */
  68239. colorLevel: number;
  68240. private _refTexture;
  68241. private _ownRefractionTexture;
  68242. /**
  68243. * Gets or sets the refraction texture
  68244. * Please note that you are responsible for disposing the texture if you set it manually
  68245. */
  68246. get refractionTexture(): Texture;
  68247. set refractionTexture(value: Texture);
  68248. /**
  68249. * Initializes the RefractionPostProcess
  68250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68251. * @param name The name of the effect.
  68252. * @param refractionTextureUrl Url of the refraction texture to use
  68253. * @param color the base color of the refraction (used to taint the rendering)
  68254. * @param depth simulated refraction depth
  68255. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68256. * @param camera The camera to apply the render pass to.
  68257. * @param options The required width/height ratio to downsize to before computing the render pass.
  68258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68259. * @param engine The engine which the post process will be applied. (default: current engine)
  68260. * @param reusable If the post process can be reused on the same frame. (default: false)
  68261. */
  68262. constructor(name: string, refractionTextureUrl: string,
  68263. /** the base color of the refraction (used to taint the rendering) */
  68264. color: Color3,
  68265. /** simulated refraction depth */
  68266. depth: number,
  68267. /** the coefficient of the base color (0 to remove base color tainting) */
  68268. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68269. /**
  68270. * Disposes of the post process
  68271. * @param camera Camera to dispose post process on
  68272. */
  68273. dispose(camera: Camera): void;
  68274. }
  68275. }
  68276. declare module "babylonjs/Shaders/sharpen.fragment" {
  68277. /** @hidden */
  68278. export var sharpenPixelShader: {
  68279. name: string;
  68280. shader: string;
  68281. };
  68282. }
  68283. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68284. import { Nullable } from "babylonjs/types";
  68285. import { Camera } from "babylonjs/Cameras/camera";
  68286. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68287. import "babylonjs/Shaders/sharpen.fragment";
  68288. import { Engine } from "babylonjs/Engines/engine";
  68289. /**
  68290. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68291. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68292. */
  68293. export class SharpenPostProcess extends PostProcess {
  68294. /**
  68295. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68296. */
  68297. colorAmount: number;
  68298. /**
  68299. * How much sharpness should be applied (default: 0.3)
  68300. */
  68301. edgeAmount: number;
  68302. /**
  68303. * Creates a new instance ConvolutionPostProcess
  68304. * @param name The name of the effect.
  68305. * @param options The required width/height ratio to downsize to before computing the render pass.
  68306. * @param camera The camera to apply the render pass to.
  68307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68308. * @param engine The engine which the post process will be applied. (default: current engine)
  68309. * @param reusable If the post process can be reused on the same frame. (default: false)
  68310. * @param textureType Type of textures used when performing the post process. (default: 0)
  68311. * @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)
  68312. */
  68313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68314. }
  68315. }
  68316. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68317. import { Nullable } from "babylonjs/types";
  68318. import { Camera } from "babylonjs/Cameras/camera";
  68319. import { Engine } from "babylonjs/Engines/engine";
  68320. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68321. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68322. /**
  68323. * PostProcessRenderPipeline
  68324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68325. */
  68326. export class PostProcessRenderPipeline {
  68327. private engine;
  68328. private _renderEffects;
  68329. private _renderEffectsForIsolatedPass;
  68330. /**
  68331. * List of inspectable custom properties (used by the Inspector)
  68332. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68333. */
  68334. inspectableCustomProperties: IInspectable[];
  68335. /**
  68336. * @hidden
  68337. */
  68338. protected _cameras: Camera[];
  68339. /** @hidden */
  68340. _name: string;
  68341. /**
  68342. * Gets pipeline name
  68343. */
  68344. get name(): string;
  68345. /** Gets the list of attached cameras */
  68346. get cameras(): Camera[];
  68347. /**
  68348. * Initializes a PostProcessRenderPipeline
  68349. * @param engine engine to add the pipeline to
  68350. * @param name name of the pipeline
  68351. */
  68352. constructor(engine: Engine, name: string);
  68353. /**
  68354. * Gets the class name
  68355. * @returns "PostProcessRenderPipeline"
  68356. */
  68357. getClassName(): string;
  68358. /**
  68359. * If all the render effects in the pipeline are supported
  68360. */
  68361. get isSupported(): boolean;
  68362. /**
  68363. * Adds an effect to the pipeline
  68364. * @param renderEffect the effect to add
  68365. */
  68366. addEffect(renderEffect: PostProcessRenderEffect): void;
  68367. /** @hidden */
  68368. _rebuild(): void;
  68369. /** @hidden */
  68370. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68371. /** @hidden */
  68372. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68373. /** @hidden */
  68374. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68375. /** @hidden */
  68376. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68377. /** @hidden */
  68378. _attachCameras(cameras: Camera, unique: boolean): void;
  68379. /** @hidden */
  68380. _attachCameras(cameras: Camera[], unique: boolean): void;
  68381. /** @hidden */
  68382. _detachCameras(cameras: Camera): void;
  68383. /** @hidden */
  68384. _detachCameras(cameras: Nullable<Camera[]>): void;
  68385. /** @hidden */
  68386. _update(): void;
  68387. /** @hidden */
  68388. _reset(): void;
  68389. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68390. /**
  68391. * Disposes of the pipeline
  68392. */
  68393. dispose(): void;
  68394. }
  68395. }
  68396. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68397. import { Camera } from "babylonjs/Cameras/camera";
  68398. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68399. /**
  68400. * PostProcessRenderPipelineManager class
  68401. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68402. */
  68403. export class PostProcessRenderPipelineManager {
  68404. private _renderPipelines;
  68405. /**
  68406. * Initializes a PostProcessRenderPipelineManager
  68407. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68408. */
  68409. constructor();
  68410. /**
  68411. * Gets the list of supported render pipelines
  68412. */
  68413. get supportedPipelines(): PostProcessRenderPipeline[];
  68414. /**
  68415. * Adds a pipeline to the manager
  68416. * @param renderPipeline The pipeline to add
  68417. */
  68418. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68419. /**
  68420. * Attaches a camera to the pipeline
  68421. * @param renderPipelineName The name of the pipeline to attach to
  68422. * @param cameras the camera to attach
  68423. * @param unique if the camera can be attached multiple times to the pipeline
  68424. */
  68425. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68426. /**
  68427. * Detaches a camera from the pipeline
  68428. * @param renderPipelineName The name of the pipeline to detach from
  68429. * @param cameras the camera to detach
  68430. */
  68431. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68432. /**
  68433. * Enables an effect by name on a pipeline
  68434. * @param renderPipelineName the name of the pipeline to enable the effect in
  68435. * @param renderEffectName the name of the effect to enable
  68436. * @param cameras the cameras that the effect should be enabled on
  68437. */
  68438. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68439. /**
  68440. * Disables an effect by name on a pipeline
  68441. * @param renderPipelineName the name of the pipeline to disable the effect in
  68442. * @param renderEffectName the name of the effect to disable
  68443. * @param cameras the cameras that the effect should be disabled on
  68444. */
  68445. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68446. /**
  68447. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68448. */
  68449. update(): void;
  68450. /** @hidden */
  68451. _rebuild(): void;
  68452. /**
  68453. * Disposes of the manager and pipelines
  68454. */
  68455. dispose(): void;
  68456. }
  68457. }
  68458. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68459. import { ISceneComponent } from "babylonjs/sceneComponent";
  68460. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68461. import { Scene } from "babylonjs/scene";
  68462. module "babylonjs/scene" {
  68463. interface Scene {
  68464. /** @hidden (Backing field) */
  68465. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68466. /**
  68467. * Gets the postprocess render pipeline manager
  68468. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68469. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68470. */
  68471. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68472. }
  68473. }
  68474. /**
  68475. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68476. */
  68477. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68478. /**
  68479. * The component name helpfull to identify the component in the list of scene components.
  68480. */
  68481. readonly name: string;
  68482. /**
  68483. * The scene the component belongs to.
  68484. */
  68485. scene: Scene;
  68486. /**
  68487. * Creates a new instance of the component for the given scene
  68488. * @param scene Defines the scene to register the component in
  68489. */
  68490. constructor(scene: Scene);
  68491. /**
  68492. * Registers the component in a given scene
  68493. */
  68494. register(): void;
  68495. /**
  68496. * Rebuilds the elements related to this component in case of
  68497. * context lost for instance.
  68498. */
  68499. rebuild(): void;
  68500. /**
  68501. * Disposes the component and the associated ressources
  68502. */
  68503. dispose(): void;
  68504. private _gatherRenderTargets;
  68505. }
  68506. }
  68507. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68508. import { Nullable } from "babylonjs/types";
  68509. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68510. import { Camera } from "babylonjs/Cameras/camera";
  68511. import { IDisposable } from "babylonjs/scene";
  68512. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68513. import { Scene } from "babylonjs/scene";
  68514. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68515. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68516. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68517. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68518. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68519. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68520. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68521. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68522. import { Animation } from "babylonjs/Animations/animation";
  68523. /**
  68524. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68525. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68526. */
  68527. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68528. private _scene;
  68529. private _camerasToBeAttached;
  68530. /**
  68531. * ID of the sharpen post process,
  68532. */
  68533. private readonly SharpenPostProcessId;
  68534. /**
  68535. * @ignore
  68536. * ID of the image processing post process;
  68537. */
  68538. readonly ImageProcessingPostProcessId: string;
  68539. /**
  68540. * @ignore
  68541. * ID of the Fast Approximate Anti-Aliasing post process;
  68542. */
  68543. readonly FxaaPostProcessId: string;
  68544. /**
  68545. * ID of the chromatic aberration post process,
  68546. */
  68547. private readonly ChromaticAberrationPostProcessId;
  68548. /**
  68549. * ID of the grain post process
  68550. */
  68551. private readonly GrainPostProcessId;
  68552. /**
  68553. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68554. */
  68555. sharpen: SharpenPostProcess;
  68556. private _sharpenEffect;
  68557. private bloom;
  68558. /**
  68559. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68560. */
  68561. depthOfField: DepthOfFieldEffect;
  68562. /**
  68563. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68564. */
  68565. fxaa: FxaaPostProcess;
  68566. /**
  68567. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68568. */
  68569. imageProcessing: ImageProcessingPostProcess;
  68570. /**
  68571. * Chromatic aberration post process which will shift rgb colors in the image
  68572. */
  68573. chromaticAberration: ChromaticAberrationPostProcess;
  68574. private _chromaticAberrationEffect;
  68575. /**
  68576. * Grain post process which add noise to the image
  68577. */
  68578. grain: GrainPostProcess;
  68579. private _grainEffect;
  68580. /**
  68581. * Glow post process which adds a glow to emissive areas of the image
  68582. */
  68583. private _glowLayer;
  68584. /**
  68585. * Animations which can be used to tweak settings over a period of time
  68586. */
  68587. animations: Animation[];
  68588. private _imageProcessingConfigurationObserver;
  68589. private _sharpenEnabled;
  68590. private _bloomEnabled;
  68591. private _depthOfFieldEnabled;
  68592. private _depthOfFieldBlurLevel;
  68593. private _fxaaEnabled;
  68594. private _imageProcessingEnabled;
  68595. private _defaultPipelineTextureType;
  68596. private _bloomScale;
  68597. private _chromaticAberrationEnabled;
  68598. private _grainEnabled;
  68599. private _buildAllowed;
  68600. /**
  68601. * Gets active scene
  68602. */
  68603. get scene(): Scene;
  68604. /**
  68605. * Enable or disable the sharpen process from the pipeline
  68606. */
  68607. set sharpenEnabled(enabled: boolean);
  68608. get sharpenEnabled(): boolean;
  68609. private _resizeObserver;
  68610. private _hardwareScaleLevel;
  68611. private _bloomKernel;
  68612. /**
  68613. * Specifies the size of the bloom blur kernel, relative to the final output size
  68614. */
  68615. get bloomKernel(): number;
  68616. set bloomKernel(value: number);
  68617. /**
  68618. * Specifies the weight of the bloom in the final rendering
  68619. */
  68620. private _bloomWeight;
  68621. /**
  68622. * Specifies the luma threshold for the area that will be blurred by the bloom
  68623. */
  68624. private _bloomThreshold;
  68625. private _hdr;
  68626. /**
  68627. * The strength of the bloom.
  68628. */
  68629. set bloomWeight(value: number);
  68630. get bloomWeight(): number;
  68631. /**
  68632. * The strength of the bloom.
  68633. */
  68634. set bloomThreshold(value: number);
  68635. get bloomThreshold(): number;
  68636. /**
  68637. * The scale of the bloom, lower value will provide better performance.
  68638. */
  68639. set bloomScale(value: number);
  68640. get bloomScale(): number;
  68641. /**
  68642. * Enable or disable the bloom from the pipeline
  68643. */
  68644. set bloomEnabled(enabled: boolean);
  68645. get bloomEnabled(): boolean;
  68646. private _rebuildBloom;
  68647. /**
  68648. * If the depth of field is enabled.
  68649. */
  68650. get depthOfFieldEnabled(): boolean;
  68651. set depthOfFieldEnabled(enabled: boolean);
  68652. /**
  68653. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68654. */
  68655. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68656. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68657. /**
  68658. * If the anti aliasing is enabled.
  68659. */
  68660. set fxaaEnabled(enabled: boolean);
  68661. get fxaaEnabled(): boolean;
  68662. private _samples;
  68663. /**
  68664. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68665. */
  68666. set samples(sampleCount: number);
  68667. get samples(): number;
  68668. /**
  68669. * If image processing is enabled.
  68670. */
  68671. set imageProcessingEnabled(enabled: boolean);
  68672. get imageProcessingEnabled(): boolean;
  68673. /**
  68674. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68675. */
  68676. set glowLayerEnabled(enabled: boolean);
  68677. get glowLayerEnabled(): boolean;
  68678. /**
  68679. * Gets the glow layer (or null if not defined)
  68680. */
  68681. get glowLayer(): Nullable<GlowLayer>;
  68682. /**
  68683. * Enable or disable the chromaticAberration process from the pipeline
  68684. */
  68685. set chromaticAberrationEnabled(enabled: boolean);
  68686. get chromaticAberrationEnabled(): boolean;
  68687. /**
  68688. * Enable or disable the grain process from the pipeline
  68689. */
  68690. set grainEnabled(enabled: boolean);
  68691. get grainEnabled(): boolean;
  68692. /**
  68693. * @constructor
  68694. * @param name - The rendering pipeline name (default: "")
  68695. * @param hdr - If high dynamic range textures should be used (default: true)
  68696. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68697. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68698. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68699. */
  68700. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68701. /**
  68702. * Get the class name
  68703. * @returns "DefaultRenderingPipeline"
  68704. */
  68705. getClassName(): string;
  68706. /**
  68707. * Force the compilation of the entire pipeline.
  68708. */
  68709. prepare(): void;
  68710. private _hasCleared;
  68711. private _prevPostProcess;
  68712. private _prevPrevPostProcess;
  68713. private _setAutoClearAndTextureSharing;
  68714. private _depthOfFieldSceneObserver;
  68715. private _buildPipeline;
  68716. private _disposePostProcesses;
  68717. /**
  68718. * Adds a camera to the pipeline
  68719. * @param camera the camera to be added
  68720. */
  68721. addCamera(camera: Camera): void;
  68722. /**
  68723. * Removes a camera from the pipeline
  68724. * @param camera the camera to remove
  68725. */
  68726. removeCamera(camera: Camera): void;
  68727. /**
  68728. * Dispose of the pipeline and stop all post processes
  68729. */
  68730. dispose(): void;
  68731. /**
  68732. * Serialize the rendering pipeline (Used when exporting)
  68733. * @returns the serialized object
  68734. */
  68735. serialize(): any;
  68736. /**
  68737. * Parse the serialized pipeline
  68738. * @param source Source pipeline.
  68739. * @param scene The scene to load the pipeline to.
  68740. * @param rootUrl The URL of the serialized pipeline.
  68741. * @returns An instantiated pipeline from the serialized object.
  68742. */
  68743. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68744. }
  68745. }
  68746. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68747. /** @hidden */
  68748. export var lensHighlightsPixelShader: {
  68749. name: string;
  68750. shader: string;
  68751. };
  68752. }
  68753. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68754. /** @hidden */
  68755. export var depthOfFieldPixelShader: {
  68756. name: string;
  68757. shader: string;
  68758. };
  68759. }
  68760. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68761. import { Camera } from "babylonjs/Cameras/camera";
  68762. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68763. import { Scene } from "babylonjs/scene";
  68764. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68765. import "babylonjs/Shaders/chromaticAberration.fragment";
  68766. import "babylonjs/Shaders/lensHighlights.fragment";
  68767. import "babylonjs/Shaders/depthOfField.fragment";
  68768. /**
  68769. * BABYLON.JS Chromatic Aberration GLSL Shader
  68770. * Author: Olivier Guyot
  68771. * Separates very slightly R, G and B colors on the edges of the screen
  68772. * Inspired by Francois Tarlier & Martins Upitis
  68773. */
  68774. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68775. /**
  68776. * @ignore
  68777. * The chromatic aberration PostProcess id in the pipeline
  68778. */
  68779. LensChromaticAberrationEffect: string;
  68780. /**
  68781. * @ignore
  68782. * The highlights enhancing PostProcess id in the pipeline
  68783. */
  68784. HighlightsEnhancingEffect: string;
  68785. /**
  68786. * @ignore
  68787. * The depth-of-field PostProcess id in the pipeline
  68788. */
  68789. LensDepthOfFieldEffect: string;
  68790. private _scene;
  68791. private _depthTexture;
  68792. private _grainTexture;
  68793. private _chromaticAberrationPostProcess;
  68794. private _highlightsPostProcess;
  68795. private _depthOfFieldPostProcess;
  68796. private _edgeBlur;
  68797. private _grainAmount;
  68798. private _chromaticAberration;
  68799. private _distortion;
  68800. private _highlightsGain;
  68801. private _highlightsThreshold;
  68802. private _dofDistance;
  68803. private _dofAperture;
  68804. private _dofDarken;
  68805. private _dofPentagon;
  68806. private _blurNoise;
  68807. /**
  68808. * @constructor
  68809. *
  68810. * Effect parameters are as follow:
  68811. * {
  68812. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68813. * edge_blur: number; // from 0 to x (1 for realism)
  68814. * distortion: number; // from 0 to x (1 for realism)
  68815. * grain_amount: number; // from 0 to 1
  68816. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68817. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68818. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68819. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68820. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68821. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68822. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68823. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68824. * }
  68825. * Note: if an effect parameter is unset, effect is disabled
  68826. *
  68827. * @param name The rendering pipeline name
  68828. * @param parameters - An object containing all parameters (see above)
  68829. * @param scene The scene linked to this pipeline
  68830. * @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)
  68831. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68832. */
  68833. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68834. /**
  68835. * Get the class name
  68836. * @returns "LensRenderingPipeline"
  68837. */
  68838. getClassName(): string;
  68839. /**
  68840. * Gets associated scene
  68841. */
  68842. get scene(): Scene;
  68843. /**
  68844. * Gets or sets the edge blur
  68845. */
  68846. get edgeBlur(): number;
  68847. set edgeBlur(value: number);
  68848. /**
  68849. * Gets or sets the grain amount
  68850. */
  68851. get grainAmount(): number;
  68852. set grainAmount(value: number);
  68853. /**
  68854. * Gets or sets the chromatic aberration amount
  68855. */
  68856. get chromaticAberration(): number;
  68857. set chromaticAberration(value: number);
  68858. /**
  68859. * Gets or sets the depth of field aperture
  68860. */
  68861. get dofAperture(): number;
  68862. set dofAperture(value: number);
  68863. /**
  68864. * Gets or sets the edge distortion
  68865. */
  68866. get edgeDistortion(): number;
  68867. set edgeDistortion(value: number);
  68868. /**
  68869. * Gets or sets the depth of field distortion
  68870. */
  68871. get dofDistortion(): number;
  68872. set dofDistortion(value: number);
  68873. /**
  68874. * Gets or sets the darken out of focus amount
  68875. */
  68876. get darkenOutOfFocus(): number;
  68877. set darkenOutOfFocus(value: number);
  68878. /**
  68879. * Gets or sets a boolean indicating if blur noise is enabled
  68880. */
  68881. get blurNoise(): boolean;
  68882. set blurNoise(value: boolean);
  68883. /**
  68884. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68885. */
  68886. get pentagonBokeh(): boolean;
  68887. set pentagonBokeh(value: boolean);
  68888. /**
  68889. * Gets or sets the highlight grain amount
  68890. */
  68891. get highlightsGain(): number;
  68892. set highlightsGain(value: number);
  68893. /**
  68894. * Gets or sets the highlight threshold
  68895. */
  68896. get highlightsThreshold(): number;
  68897. set highlightsThreshold(value: number);
  68898. /**
  68899. * Sets the amount of blur at the edges
  68900. * @param amount blur amount
  68901. */
  68902. setEdgeBlur(amount: number): void;
  68903. /**
  68904. * Sets edge blur to 0
  68905. */
  68906. disableEdgeBlur(): void;
  68907. /**
  68908. * Sets the amout of grain
  68909. * @param amount Amount of grain
  68910. */
  68911. setGrainAmount(amount: number): void;
  68912. /**
  68913. * Set grain amount to 0
  68914. */
  68915. disableGrain(): void;
  68916. /**
  68917. * Sets the chromatic aberration amount
  68918. * @param amount amount of chromatic aberration
  68919. */
  68920. setChromaticAberration(amount: number): void;
  68921. /**
  68922. * Sets chromatic aberration amount to 0
  68923. */
  68924. disableChromaticAberration(): void;
  68925. /**
  68926. * Sets the EdgeDistortion amount
  68927. * @param amount amount of EdgeDistortion
  68928. */
  68929. setEdgeDistortion(amount: number): void;
  68930. /**
  68931. * Sets edge distortion to 0
  68932. */
  68933. disableEdgeDistortion(): void;
  68934. /**
  68935. * Sets the FocusDistance amount
  68936. * @param amount amount of FocusDistance
  68937. */
  68938. setFocusDistance(amount: number): void;
  68939. /**
  68940. * Disables depth of field
  68941. */
  68942. disableDepthOfField(): void;
  68943. /**
  68944. * Sets the Aperture amount
  68945. * @param amount amount of Aperture
  68946. */
  68947. setAperture(amount: number): void;
  68948. /**
  68949. * Sets the DarkenOutOfFocus amount
  68950. * @param amount amount of DarkenOutOfFocus
  68951. */
  68952. setDarkenOutOfFocus(amount: number): void;
  68953. private _pentagonBokehIsEnabled;
  68954. /**
  68955. * Creates a pentagon bokeh effect
  68956. */
  68957. enablePentagonBokeh(): void;
  68958. /**
  68959. * Disables the pentagon bokeh effect
  68960. */
  68961. disablePentagonBokeh(): void;
  68962. /**
  68963. * Enables noise blur
  68964. */
  68965. enableNoiseBlur(): void;
  68966. /**
  68967. * Disables noise blur
  68968. */
  68969. disableNoiseBlur(): void;
  68970. /**
  68971. * Sets the HighlightsGain amount
  68972. * @param amount amount of HighlightsGain
  68973. */
  68974. setHighlightsGain(amount: number): void;
  68975. /**
  68976. * Sets the HighlightsThreshold amount
  68977. * @param amount amount of HighlightsThreshold
  68978. */
  68979. setHighlightsThreshold(amount: number): void;
  68980. /**
  68981. * Disables highlights
  68982. */
  68983. disableHighlights(): void;
  68984. /**
  68985. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68986. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68987. */
  68988. dispose(disableDepthRender?: boolean): void;
  68989. private _createChromaticAberrationPostProcess;
  68990. private _createHighlightsPostProcess;
  68991. private _createDepthOfFieldPostProcess;
  68992. private _createGrainTexture;
  68993. }
  68994. }
  68995. declare module "babylonjs/Shaders/ssao2.fragment" {
  68996. /** @hidden */
  68997. export var ssao2PixelShader: {
  68998. name: string;
  68999. shader: string;
  69000. };
  69001. }
  69002. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69003. /** @hidden */
  69004. export var ssaoCombinePixelShader: {
  69005. name: string;
  69006. shader: string;
  69007. };
  69008. }
  69009. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69010. import { Camera } from "babylonjs/Cameras/camera";
  69011. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69012. import { Scene } from "babylonjs/scene";
  69013. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69014. import "babylonjs/Shaders/ssao2.fragment";
  69015. import "babylonjs/Shaders/ssaoCombine.fragment";
  69016. /**
  69017. * Render pipeline to produce ssao effect
  69018. */
  69019. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69020. /**
  69021. * @ignore
  69022. * The PassPostProcess id in the pipeline that contains the original scene color
  69023. */
  69024. SSAOOriginalSceneColorEffect: string;
  69025. /**
  69026. * @ignore
  69027. * The SSAO PostProcess id in the pipeline
  69028. */
  69029. SSAORenderEffect: string;
  69030. /**
  69031. * @ignore
  69032. * The horizontal blur PostProcess id in the pipeline
  69033. */
  69034. SSAOBlurHRenderEffect: string;
  69035. /**
  69036. * @ignore
  69037. * The vertical blur PostProcess id in the pipeline
  69038. */
  69039. SSAOBlurVRenderEffect: string;
  69040. /**
  69041. * @ignore
  69042. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69043. */
  69044. SSAOCombineRenderEffect: string;
  69045. /**
  69046. * The output strength of the SSAO post-process. Default value is 1.0.
  69047. */
  69048. totalStrength: number;
  69049. /**
  69050. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69051. */
  69052. maxZ: number;
  69053. /**
  69054. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69055. */
  69056. minZAspect: number;
  69057. private _samples;
  69058. /**
  69059. * Number of samples used for the SSAO calculations. Default value is 8
  69060. */
  69061. set samples(n: number);
  69062. get samples(): number;
  69063. private _textureSamples;
  69064. /**
  69065. * Number of samples to use for antialiasing
  69066. */
  69067. set textureSamples(n: number);
  69068. get textureSamples(): number;
  69069. /**
  69070. * Ratio object used for SSAO ratio and blur ratio
  69071. */
  69072. private _ratio;
  69073. /**
  69074. * Dynamically generated sphere sampler.
  69075. */
  69076. private _sampleSphere;
  69077. /**
  69078. * Blur filter offsets
  69079. */
  69080. private _samplerOffsets;
  69081. private _expensiveBlur;
  69082. /**
  69083. * If bilateral blur should be used
  69084. */
  69085. set expensiveBlur(b: boolean);
  69086. get expensiveBlur(): boolean;
  69087. /**
  69088. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69089. */
  69090. radius: number;
  69091. /**
  69092. * The base color of the SSAO post-process
  69093. * The final result is "base + ssao" between [0, 1]
  69094. */
  69095. base: number;
  69096. /**
  69097. * Support test.
  69098. */
  69099. static get IsSupported(): boolean;
  69100. private _scene;
  69101. private _depthTexture;
  69102. private _normalTexture;
  69103. private _randomTexture;
  69104. private _originalColorPostProcess;
  69105. private _ssaoPostProcess;
  69106. private _blurHPostProcess;
  69107. private _blurVPostProcess;
  69108. private _ssaoCombinePostProcess;
  69109. /**
  69110. * Gets active scene
  69111. */
  69112. get scene(): Scene;
  69113. /**
  69114. * @constructor
  69115. * @param name The rendering pipeline name
  69116. * @param scene The scene linked to this pipeline
  69117. * @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 }
  69118. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69119. */
  69120. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69121. /**
  69122. * Get the class name
  69123. * @returns "SSAO2RenderingPipeline"
  69124. */
  69125. getClassName(): string;
  69126. /**
  69127. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69128. */
  69129. dispose(disableGeometryBufferRenderer?: boolean): void;
  69130. private _createBlurPostProcess;
  69131. /** @hidden */
  69132. _rebuild(): void;
  69133. private _bits;
  69134. private _radicalInverse_VdC;
  69135. private _hammersley;
  69136. private _hemisphereSample_uniform;
  69137. private _generateHemisphere;
  69138. private _createSSAOPostProcess;
  69139. private _createSSAOCombinePostProcess;
  69140. private _createRandomTexture;
  69141. /**
  69142. * Serialize the rendering pipeline (Used when exporting)
  69143. * @returns the serialized object
  69144. */
  69145. serialize(): any;
  69146. /**
  69147. * Parse the serialized pipeline
  69148. * @param source Source pipeline.
  69149. * @param scene The scene to load the pipeline to.
  69150. * @param rootUrl The URL of the serialized pipeline.
  69151. * @returns An instantiated pipeline from the serialized object.
  69152. */
  69153. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69154. }
  69155. }
  69156. declare module "babylonjs/Shaders/ssao.fragment" {
  69157. /** @hidden */
  69158. export var ssaoPixelShader: {
  69159. name: string;
  69160. shader: string;
  69161. };
  69162. }
  69163. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69164. import { Camera } from "babylonjs/Cameras/camera";
  69165. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69166. import { Scene } from "babylonjs/scene";
  69167. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69168. import "babylonjs/Shaders/ssao.fragment";
  69169. import "babylonjs/Shaders/ssaoCombine.fragment";
  69170. /**
  69171. * Render pipeline to produce ssao effect
  69172. */
  69173. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69174. /**
  69175. * @ignore
  69176. * The PassPostProcess id in the pipeline that contains the original scene color
  69177. */
  69178. SSAOOriginalSceneColorEffect: string;
  69179. /**
  69180. * @ignore
  69181. * The SSAO PostProcess id in the pipeline
  69182. */
  69183. SSAORenderEffect: string;
  69184. /**
  69185. * @ignore
  69186. * The horizontal blur PostProcess id in the pipeline
  69187. */
  69188. SSAOBlurHRenderEffect: string;
  69189. /**
  69190. * @ignore
  69191. * The vertical blur PostProcess id in the pipeline
  69192. */
  69193. SSAOBlurVRenderEffect: string;
  69194. /**
  69195. * @ignore
  69196. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69197. */
  69198. SSAOCombineRenderEffect: string;
  69199. /**
  69200. * The output strength of the SSAO post-process. Default value is 1.0.
  69201. */
  69202. totalStrength: number;
  69203. /**
  69204. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69205. */
  69206. radius: number;
  69207. /**
  69208. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69209. * Must not be equal to fallOff and superior to fallOff.
  69210. * Default value is 0.0075
  69211. */
  69212. area: number;
  69213. /**
  69214. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69215. * Must not be equal to area and inferior to area.
  69216. * Default value is 0.000001
  69217. */
  69218. fallOff: number;
  69219. /**
  69220. * The base color of the SSAO post-process
  69221. * The final result is "base + ssao" between [0, 1]
  69222. */
  69223. base: number;
  69224. private _scene;
  69225. private _depthTexture;
  69226. private _randomTexture;
  69227. private _originalColorPostProcess;
  69228. private _ssaoPostProcess;
  69229. private _blurHPostProcess;
  69230. private _blurVPostProcess;
  69231. private _ssaoCombinePostProcess;
  69232. private _firstUpdate;
  69233. /**
  69234. * Gets active scene
  69235. */
  69236. get scene(): Scene;
  69237. /**
  69238. * @constructor
  69239. * @param name - The rendering pipeline name
  69240. * @param scene - The scene linked to this pipeline
  69241. * @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 }
  69242. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69243. */
  69244. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69245. /**
  69246. * Get the class name
  69247. * @returns "SSAORenderingPipeline"
  69248. */
  69249. getClassName(): string;
  69250. /**
  69251. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69252. */
  69253. dispose(disableDepthRender?: boolean): void;
  69254. private _createBlurPostProcess;
  69255. /** @hidden */
  69256. _rebuild(): void;
  69257. private _createSSAOPostProcess;
  69258. private _createSSAOCombinePostProcess;
  69259. private _createRandomTexture;
  69260. }
  69261. }
  69262. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69263. /** @hidden */
  69264. export var screenSpaceReflectionPixelShader: {
  69265. name: string;
  69266. shader: string;
  69267. };
  69268. }
  69269. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69270. import { Nullable } from "babylonjs/types";
  69271. import { Camera } from "babylonjs/Cameras/camera";
  69272. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69273. import { Scene } from "babylonjs/scene";
  69274. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69275. import { Engine } from "babylonjs/Engines/engine";
  69276. /**
  69277. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69278. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69279. */
  69280. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69281. /**
  69282. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69283. */
  69284. threshold: number;
  69285. /**
  69286. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69287. */
  69288. strength: number;
  69289. /**
  69290. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69291. */
  69292. reflectionSpecularFalloffExponent: number;
  69293. /**
  69294. * 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]
  69295. */
  69296. step: number;
  69297. /**
  69298. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69299. */
  69300. roughnessFactor: number;
  69301. private _geometryBufferRenderer;
  69302. private _enableSmoothReflections;
  69303. private _reflectionSamples;
  69304. private _smoothSteps;
  69305. /**
  69306. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69307. * @param name The name of the effect.
  69308. * @param scene The scene containing the objects to calculate reflections.
  69309. * @param options The required width/height ratio to downsize to before computing the render pass.
  69310. * @param camera The camera to apply the render pass to.
  69311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69312. * @param engine The engine which the post process will be applied. (default: current engine)
  69313. * @param reusable If the post process can be reused on the same frame. (default: false)
  69314. * @param textureType Type of textures used when performing the post process. (default: 0)
  69315. * @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)
  69316. */
  69317. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69318. /**
  69319. * Gets wether or not smoothing reflections is enabled.
  69320. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69321. */
  69322. get enableSmoothReflections(): boolean;
  69323. /**
  69324. * Sets wether or not smoothing reflections is enabled.
  69325. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69326. */
  69327. set enableSmoothReflections(enabled: boolean);
  69328. /**
  69329. * Gets the number of samples taken while computing reflections. More samples count is high,
  69330. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69331. */
  69332. get reflectionSamples(): number;
  69333. /**
  69334. * Sets the number of samples taken while computing reflections. More samples count is high,
  69335. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69336. */
  69337. set reflectionSamples(samples: number);
  69338. /**
  69339. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69340. * more the post-process will require GPU power and can generate a drop in FPS.
  69341. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69342. */
  69343. get smoothSteps(): number;
  69344. set smoothSteps(steps: number);
  69345. private _updateEffectDefines;
  69346. }
  69347. }
  69348. declare module "babylonjs/Shaders/standard.fragment" {
  69349. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69350. /** @hidden */
  69351. export var standardPixelShader: {
  69352. name: string;
  69353. shader: string;
  69354. };
  69355. }
  69356. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69357. import { Nullable } from "babylonjs/types";
  69358. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69359. import { Camera } from "babylonjs/Cameras/camera";
  69360. import { Texture } from "babylonjs/Materials/Textures/texture";
  69361. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69362. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69363. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69364. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69365. import { IDisposable } from "babylonjs/scene";
  69366. import { SpotLight } from "babylonjs/Lights/spotLight";
  69367. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69368. import { Scene } from "babylonjs/scene";
  69369. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69370. import { Animation } from "babylonjs/Animations/animation";
  69371. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69372. import "babylonjs/Shaders/standard.fragment";
  69373. /**
  69374. * Standard rendering pipeline
  69375. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69376. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69377. */
  69378. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69379. /**
  69380. * Public members
  69381. */
  69382. /**
  69383. * Post-process which contains the original scene color before the pipeline applies all the effects
  69384. */
  69385. originalPostProcess: Nullable<PostProcess>;
  69386. /**
  69387. * Post-process used to down scale an image x4
  69388. */
  69389. downSampleX4PostProcess: Nullable<PostProcess>;
  69390. /**
  69391. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69392. */
  69393. brightPassPostProcess: Nullable<PostProcess>;
  69394. /**
  69395. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69396. */
  69397. blurHPostProcesses: PostProcess[];
  69398. /**
  69399. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69400. */
  69401. blurVPostProcesses: PostProcess[];
  69402. /**
  69403. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69404. */
  69405. textureAdderPostProcess: Nullable<PostProcess>;
  69406. /**
  69407. * Post-process used to create volumetric lighting effect
  69408. */
  69409. volumetricLightPostProcess: Nullable<PostProcess>;
  69410. /**
  69411. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69412. */
  69413. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69414. /**
  69415. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69416. */
  69417. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69418. /**
  69419. * Post-process used to merge the volumetric light effect and the real scene color
  69420. */
  69421. volumetricLightMergePostProces: Nullable<PostProcess>;
  69422. /**
  69423. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69424. */
  69425. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69426. /**
  69427. * Base post-process used to calculate the average luminance of the final image for HDR
  69428. */
  69429. luminancePostProcess: Nullable<PostProcess>;
  69430. /**
  69431. * Post-processes used to create down sample post-processes in order to get
  69432. * the average luminance of the final image for HDR
  69433. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69434. */
  69435. luminanceDownSamplePostProcesses: PostProcess[];
  69436. /**
  69437. * Post-process used to create a HDR effect (light adaptation)
  69438. */
  69439. hdrPostProcess: Nullable<PostProcess>;
  69440. /**
  69441. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69442. */
  69443. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69444. /**
  69445. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69446. */
  69447. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69448. /**
  69449. * Post-process used to merge the final HDR post-process and the real scene color
  69450. */
  69451. hdrFinalPostProcess: Nullable<PostProcess>;
  69452. /**
  69453. * Post-process used to create a lens flare effect
  69454. */
  69455. lensFlarePostProcess: Nullable<PostProcess>;
  69456. /**
  69457. * Post-process that merges the result of the lens flare post-process and the real scene color
  69458. */
  69459. lensFlareComposePostProcess: Nullable<PostProcess>;
  69460. /**
  69461. * Post-process used to create a motion blur effect
  69462. */
  69463. motionBlurPostProcess: Nullable<PostProcess>;
  69464. /**
  69465. * Post-process used to create a depth of field effect
  69466. */
  69467. depthOfFieldPostProcess: Nullable<PostProcess>;
  69468. /**
  69469. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69470. */
  69471. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69472. /**
  69473. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69474. */
  69475. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69476. /**
  69477. * Represents the brightness threshold in order to configure the illuminated surfaces
  69478. */
  69479. brightThreshold: number;
  69480. /**
  69481. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69482. */
  69483. blurWidth: number;
  69484. /**
  69485. * Sets if the blur for highlighted surfaces must be only horizontal
  69486. */
  69487. horizontalBlur: boolean;
  69488. /**
  69489. * Gets the overall exposure used by the pipeline
  69490. */
  69491. get exposure(): number;
  69492. /**
  69493. * Sets the overall exposure used by the pipeline
  69494. */
  69495. set exposure(value: number);
  69496. /**
  69497. * Texture used typically to simulate "dirty" on camera lens
  69498. */
  69499. lensTexture: Nullable<Texture>;
  69500. /**
  69501. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69502. */
  69503. volumetricLightCoefficient: number;
  69504. /**
  69505. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69506. */
  69507. volumetricLightPower: number;
  69508. /**
  69509. * Used the set the blur intensity to smooth the volumetric lights
  69510. */
  69511. volumetricLightBlurScale: number;
  69512. /**
  69513. * Light (spot or directional) used to generate the volumetric lights rays
  69514. * The source light must have a shadow generate so the pipeline can get its
  69515. * depth map
  69516. */
  69517. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69518. /**
  69519. * For eye adaptation, represents the minimum luminance the eye can see
  69520. */
  69521. hdrMinimumLuminance: number;
  69522. /**
  69523. * For eye adaptation, represents the decrease luminance speed
  69524. */
  69525. hdrDecreaseRate: number;
  69526. /**
  69527. * For eye adaptation, represents the increase luminance speed
  69528. */
  69529. hdrIncreaseRate: number;
  69530. /**
  69531. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69532. */
  69533. get hdrAutoExposure(): boolean;
  69534. /**
  69535. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69536. */
  69537. set hdrAutoExposure(value: boolean);
  69538. /**
  69539. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69540. */
  69541. lensColorTexture: Nullable<Texture>;
  69542. /**
  69543. * The overall strengh for the lens flare effect
  69544. */
  69545. lensFlareStrength: number;
  69546. /**
  69547. * Dispersion coefficient for lens flare ghosts
  69548. */
  69549. lensFlareGhostDispersal: number;
  69550. /**
  69551. * Main lens flare halo width
  69552. */
  69553. lensFlareHaloWidth: number;
  69554. /**
  69555. * Based on the lens distortion effect, defines how much the lens flare result
  69556. * is distorted
  69557. */
  69558. lensFlareDistortionStrength: number;
  69559. /**
  69560. * Configures the blur intensity used for for lens flare (halo)
  69561. */
  69562. lensFlareBlurWidth: number;
  69563. /**
  69564. * Lens star texture must be used to simulate rays on the flares and is available
  69565. * in the documentation
  69566. */
  69567. lensStarTexture: Nullable<Texture>;
  69568. /**
  69569. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69570. * flare effect by taking account of the dirt texture
  69571. */
  69572. lensFlareDirtTexture: Nullable<Texture>;
  69573. /**
  69574. * Represents the focal length for the depth of field effect
  69575. */
  69576. depthOfFieldDistance: number;
  69577. /**
  69578. * Represents the blur intensity for the blurred part of the depth of field effect
  69579. */
  69580. depthOfFieldBlurWidth: number;
  69581. /**
  69582. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69583. */
  69584. get motionStrength(): number;
  69585. /**
  69586. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69587. */
  69588. set motionStrength(strength: number);
  69589. /**
  69590. * Gets wether or not the motion blur post-process is object based or screen based.
  69591. */
  69592. get objectBasedMotionBlur(): boolean;
  69593. /**
  69594. * Sets wether or not the motion blur post-process should be object based or screen based
  69595. */
  69596. set objectBasedMotionBlur(value: boolean);
  69597. /**
  69598. * List of animations for the pipeline (IAnimatable implementation)
  69599. */
  69600. animations: Animation[];
  69601. /**
  69602. * Private members
  69603. */
  69604. private _scene;
  69605. private _currentDepthOfFieldSource;
  69606. private _basePostProcess;
  69607. private _fixedExposure;
  69608. private _currentExposure;
  69609. private _hdrAutoExposure;
  69610. private _hdrCurrentLuminance;
  69611. private _motionStrength;
  69612. private _isObjectBasedMotionBlur;
  69613. private _floatTextureType;
  69614. private _camerasToBeAttached;
  69615. private _ratio;
  69616. private _bloomEnabled;
  69617. private _depthOfFieldEnabled;
  69618. private _vlsEnabled;
  69619. private _lensFlareEnabled;
  69620. private _hdrEnabled;
  69621. private _motionBlurEnabled;
  69622. private _fxaaEnabled;
  69623. private _screenSpaceReflectionsEnabled;
  69624. private _motionBlurSamples;
  69625. private _volumetricLightStepsCount;
  69626. private _samples;
  69627. /**
  69628. * @ignore
  69629. * Specifies if the bloom pipeline is enabled
  69630. */
  69631. get BloomEnabled(): boolean;
  69632. set BloomEnabled(enabled: boolean);
  69633. /**
  69634. * @ignore
  69635. * Specifies if the depth of field pipeline is enabed
  69636. */
  69637. get DepthOfFieldEnabled(): boolean;
  69638. set DepthOfFieldEnabled(enabled: boolean);
  69639. /**
  69640. * @ignore
  69641. * Specifies if the lens flare pipeline is enabed
  69642. */
  69643. get LensFlareEnabled(): boolean;
  69644. set LensFlareEnabled(enabled: boolean);
  69645. /**
  69646. * @ignore
  69647. * Specifies if the HDR pipeline is enabled
  69648. */
  69649. get HDREnabled(): boolean;
  69650. set HDREnabled(enabled: boolean);
  69651. /**
  69652. * @ignore
  69653. * Specifies if the volumetric lights scattering effect is enabled
  69654. */
  69655. get VLSEnabled(): boolean;
  69656. set VLSEnabled(enabled: boolean);
  69657. /**
  69658. * @ignore
  69659. * Specifies if the motion blur effect is enabled
  69660. */
  69661. get MotionBlurEnabled(): boolean;
  69662. set MotionBlurEnabled(enabled: boolean);
  69663. /**
  69664. * Specifies if anti-aliasing is enabled
  69665. */
  69666. get fxaaEnabled(): boolean;
  69667. set fxaaEnabled(enabled: boolean);
  69668. /**
  69669. * Specifies if screen space reflections are enabled.
  69670. */
  69671. get screenSpaceReflectionsEnabled(): boolean;
  69672. set screenSpaceReflectionsEnabled(enabled: boolean);
  69673. /**
  69674. * Specifies the number of steps used to calculate the volumetric lights
  69675. * Typically in interval [50, 200]
  69676. */
  69677. get volumetricLightStepsCount(): number;
  69678. set volumetricLightStepsCount(count: number);
  69679. /**
  69680. * Specifies the number of samples used for the motion blur effect
  69681. * Typically in interval [16, 64]
  69682. */
  69683. get motionBlurSamples(): number;
  69684. set motionBlurSamples(samples: number);
  69685. /**
  69686. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69687. */
  69688. get samples(): number;
  69689. set samples(sampleCount: number);
  69690. /**
  69691. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69692. * @constructor
  69693. * @param name The rendering pipeline name
  69694. * @param scene The scene linked to this pipeline
  69695. * @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)
  69696. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69697. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69698. */
  69699. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69700. private _buildPipeline;
  69701. private _createDownSampleX4PostProcess;
  69702. private _createBrightPassPostProcess;
  69703. private _createBlurPostProcesses;
  69704. private _createTextureAdderPostProcess;
  69705. private _createVolumetricLightPostProcess;
  69706. private _createLuminancePostProcesses;
  69707. private _createHdrPostProcess;
  69708. private _createLensFlarePostProcess;
  69709. private _createDepthOfFieldPostProcess;
  69710. private _createMotionBlurPostProcess;
  69711. private _getDepthTexture;
  69712. private _disposePostProcesses;
  69713. /**
  69714. * Dispose of the pipeline and stop all post processes
  69715. */
  69716. dispose(): void;
  69717. /**
  69718. * Serialize the rendering pipeline (Used when exporting)
  69719. * @returns the serialized object
  69720. */
  69721. serialize(): any;
  69722. /**
  69723. * Parse the serialized pipeline
  69724. * @param source Source pipeline.
  69725. * @param scene The scene to load the pipeline to.
  69726. * @param rootUrl The URL of the serialized pipeline.
  69727. * @returns An instantiated pipeline from the serialized object.
  69728. */
  69729. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69730. /**
  69731. * Luminance steps
  69732. */
  69733. static LuminanceSteps: number;
  69734. }
  69735. }
  69736. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69737. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69738. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69739. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69740. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69741. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69742. }
  69743. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69744. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69745. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69746. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69749. }
  69750. declare module "babylonjs/Shaders/tonemap.fragment" {
  69751. /** @hidden */
  69752. export var tonemapPixelShader: {
  69753. name: string;
  69754. shader: string;
  69755. };
  69756. }
  69757. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69758. import { Camera } from "babylonjs/Cameras/camera";
  69759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69760. import "babylonjs/Shaders/tonemap.fragment";
  69761. import { Engine } from "babylonjs/Engines/engine";
  69762. /** Defines operator used for tonemapping */
  69763. export enum TonemappingOperator {
  69764. /** Hable */
  69765. Hable = 0,
  69766. /** Reinhard */
  69767. Reinhard = 1,
  69768. /** HejiDawson */
  69769. HejiDawson = 2,
  69770. /** Photographic */
  69771. Photographic = 3
  69772. }
  69773. /**
  69774. * Defines a post process to apply tone mapping
  69775. */
  69776. export class TonemapPostProcess extends PostProcess {
  69777. private _operator;
  69778. /** Defines the required exposure adjustement */
  69779. exposureAdjustment: number;
  69780. /**
  69781. * Creates a new TonemapPostProcess
  69782. * @param name defines the name of the postprocess
  69783. * @param _operator defines the operator to use
  69784. * @param exposureAdjustment defines the required exposure adjustement
  69785. * @param camera defines the camera to use (can be null)
  69786. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69787. * @param engine defines the hosting engine (can be ignore if camera is set)
  69788. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69789. */
  69790. constructor(name: string, _operator: TonemappingOperator,
  69791. /** Defines the required exposure adjustement */
  69792. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69793. }
  69794. }
  69795. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69796. /** @hidden */
  69797. export var volumetricLightScatteringPixelShader: {
  69798. name: string;
  69799. shader: string;
  69800. };
  69801. }
  69802. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69803. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69804. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69805. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69806. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69807. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69808. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69809. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69810. /** @hidden */
  69811. export var volumetricLightScatteringPassVertexShader: {
  69812. name: string;
  69813. shader: string;
  69814. };
  69815. }
  69816. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69817. /** @hidden */
  69818. export var volumetricLightScatteringPassPixelShader: {
  69819. name: string;
  69820. shader: string;
  69821. };
  69822. }
  69823. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69824. import { Vector3 } from "babylonjs/Maths/math.vector";
  69825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69826. import { Mesh } from "babylonjs/Meshes/mesh";
  69827. import { Camera } from "babylonjs/Cameras/camera";
  69828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69829. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69830. import { Scene } from "babylonjs/scene";
  69831. import "babylonjs/Meshes/Builders/planeBuilder";
  69832. import "babylonjs/Shaders/depth.vertex";
  69833. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69834. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69835. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69836. import { Engine } from "babylonjs/Engines/engine";
  69837. /**
  69838. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69839. */
  69840. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69841. private _volumetricLightScatteringPass;
  69842. private _volumetricLightScatteringRTT;
  69843. private _viewPort;
  69844. private _screenCoordinates;
  69845. private _cachedDefines;
  69846. /**
  69847. * If not undefined, the mesh position is computed from the attached node position
  69848. */
  69849. attachedNode: {
  69850. position: Vector3;
  69851. };
  69852. /**
  69853. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69854. */
  69855. customMeshPosition: Vector3;
  69856. /**
  69857. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69858. */
  69859. useCustomMeshPosition: boolean;
  69860. /**
  69861. * If the post-process should inverse the light scattering direction
  69862. */
  69863. invert: boolean;
  69864. /**
  69865. * The internal mesh used by the post-process
  69866. */
  69867. mesh: Mesh;
  69868. /**
  69869. * @hidden
  69870. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69871. */
  69872. get useDiffuseColor(): boolean;
  69873. set useDiffuseColor(useDiffuseColor: boolean);
  69874. /**
  69875. * Array containing the excluded meshes not rendered in the internal pass
  69876. */
  69877. excludedMeshes: AbstractMesh[];
  69878. /**
  69879. * Controls the overall intensity of the post-process
  69880. */
  69881. exposure: number;
  69882. /**
  69883. * Dissipates each sample's contribution in range [0, 1]
  69884. */
  69885. decay: number;
  69886. /**
  69887. * Controls the overall intensity of each sample
  69888. */
  69889. weight: number;
  69890. /**
  69891. * Controls the density of each sample
  69892. */
  69893. density: number;
  69894. /**
  69895. * @constructor
  69896. * @param name The post-process name
  69897. * @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)
  69898. * @param camera The camera that the post-process will be attached to
  69899. * @param mesh The mesh used to create the light scattering
  69900. * @param samples The post-process quality, default 100
  69901. * @param samplingModeThe post-process filtering mode
  69902. * @param engine The babylon engine
  69903. * @param reusable If the post-process is reusable
  69904. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69905. */
  69906. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69907. /**
  69908. * Returns the string "VolumetricLightScatteringPostProcess"
  69909. * @returns "VolumetricLightScatteringPostProcess"
  69910. */
  69911. getClassName(): string;
  69912. private _isReady;
  69913. /**
  69914. * Sets the new light position for light scattering effect
  69915. * @param position The new custom light position
  69916. */
  69917. setCustomMeshPosition(position: Vector3): void;
  69918. /**
  69919. * Returns the light position for light scattering effect
  69920. * @return Vector3 The custom light position
  69921. */
  69922. getCustomMeshPosition(): Vector3;
  69923. /**
  69924. * Disposes the internal assets and detaches the post-process from the camera
  69925. */
  69926. dispose(camera: Camera): void;
  69927. /**
  69928. * Returns the render target texture used by the post-process
  69929. * @return the render target texture used by the post-process
  69930. */
  69931. getPass(): RenderTargetTexture;
  69932. private _meshExcluded;
  69933. private _createPass;
  69934. private _updateMeshScreenCoordinates;
  69935. /**
  69936. * Creates a default mesh for the Volumeric Light Scattering post-process
  69937. * @param name The mesh name
  69938. * @param scene The scene where to create the mesh
  69939. * @return the default mesh
  69940. */
  69941. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69942. }
  69943. }
  69944. declare module "babylonjs/PostProcesses/index" {
  69945. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69946. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69947. export * from "babylonjs/PostProcesses/bloomEffect";
  69948. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69949. export * from "babylonjs/PostProcesses/blurPostProcess";
  69950. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69951. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69952. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69953. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69954. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69955. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69956. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69957. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69958. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69959. export * from "babylonjs/PostProcesses/filterPostProcess";
  69960. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69961. export * from "babylonjs/PostProcesses/grainPostProcess";
  69962. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69963. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69964. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69965. export * from "babylonjs/PostProcesses/passPostProcess";
  69966. export * from "babylonjs/PostProcesses/postProcess";
  69967. export * from "babylonjs/PostProcesses/postProcessManager";
  69968. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69969. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69970. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69971. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69972. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69973. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69974. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69975. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69976. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69977. }
  69978. declare module "babylonjs/Probes/index" {
  69979. export * from "babylonjs/Probes/reflectionProbe";
  69980. }
  69981. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69982. import { Scene } from "babylonjs/scene";
  69983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69984. import { SmartArray } from "babylonjs/Misc/smartArray";
  69985. import { ISceneComponent } from "babylonjs/sceneComponent";
  69986. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69987. import "babylonjs/Meshes/Builders/boxBuilder";
  69988. import "babylonjs/Shaders/color.fragment";
  69989. import "babylonjs/Shaders/color.vertex";
  69990. import { Color3 } from "babylonjs/Maths/math.color";
  69991. module "babylonjs/scene" {
  69992. interface Scene {
  69993. /** @hidden (Backing field) */
  69994. _boundingBoxRenderer: BoundingBoxRenderer;
  69995. /** @hidden (Backing field) */
  69996. _forceShowBoundingBoxes: boolean;
  69997. /**
  69998. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69999. */
  70000. forceShowBoundingBoxes: boolean;
  70001. /**
  70002. * Gets the bounding box renderer associated with the scene
  70003. * @returns a BoundingBoxRenderer
  70004. */
  70005. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70006. }
  70007. }
  70008. module "babylonjs/Meshes/abstractMesh" {
  70009. interface AbstractMesh {
  70010. /** @hidden (Backing field) */
  70011. _showBoundingBox: boolean;
  70012. /**
  70013. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70014. */
  70015. showBoundingBox: boolean;
  70016. }
  70017. }
  70018. /**
  70019. * Component responsible of rendering the bounding box of the meshes in a scene.
  70020. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70021. */
  70022. export class BoundingBoxRenderer implements ISceneComponent {
  70023. /**
  70024. * The component name helpfull to identify the component in the list of scene components.
  70025. */
  70026. readonly name: string;
  70027. /**
  70028. * The scene the component belongs to.
  70029. */
  70030. scene: Scene;
  70031. /**
  70032. * Color of the bounding box lines placed in front of an object
  70033. */
  70034. frontColor: Color3;
  70035. /**
  70036. * Color of the bounding box lines placed behind an object
  70037. */
  70038. backColor: Color3;
  70039. /**
  70040. * Defines if the renderer should show the back lines or not
  70041. */
  70042. showBackLines: boolean;
  70043. /**
  70044. * @hidden
  70045. */
  70046. renderList: SmartArray<BoundingBox>;
  70047. private _colorShader;
  70048. private _vertexBuffers;
  70049. private _indexBuffer;
  70050. private _fillIndexBuffer;
  70051. private _fillIndexData;
  70052. /**
  70053. * Instantiates a new bounding box renderer in a scene.
  70054. * @param scene the scene the renderer renders in
  70055. */
  70056. constructor(scene: Scene);
  70057. /**
  70058. * Registers the component in a given scene
  70059. */
  70060. register(): void;
  70061. private _evaluateSubMesh;
  70062. private _activeMesh;
  70063. private _prepareRessources;
  70064. private _createIndexBuffer;
  70065. /**
  70066. * Rebuilds the elements related to this component in case of
  70067. * context lost for instance.
  70068. */
  70069. rebuild(): void;
  70070. /**
  70071. * @hidden
  70072. */
  70073. reset(): void;
  70074. /**
  70075. * Render the bounding boxes of a specific rendering group
  70076. * @param renderingGroupId defines the rendering group to render
  70077. */
  70078. render(renderingGroupId: number): void;
  70079. /**
  70080. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70081. * @param mesh Define the mesh to render the occlusion bounding box for
  70082. */
  70083. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70084. /**
  70085. * Dispose and release the resources attached to this renderer.
  70086. */
  70087. dispose(): void;
  70088. }
  70089. }
  70090. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70091. import { Nullable } from "babylonjs/types";
  70092. import { Scene } from "babylonjs/scene";
  70093. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70094. import { Camera } from "babylonjs/Cameras/camera";
  70095. import { ISceneComponent } from "babylonjs/sceneComponent";
  70096. module "babylonjs/scene" {
  70097. interface Scene {
  70098. /** @hidden (Backing field) */
  70099. _depthRenderer: {
  70100. [id: string]: DepthRenderer;
  70101. };
  70102. /**
  70103. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70104. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70105. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70106. * @returns the created depth renderer
  70107. */
  70108. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70109. /**
  70110. * Disables a depth renderer for a given camera
  70111. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70112. */
  70113. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70114. }
  70115. }
  70116. /**
  70117. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70118. * in several rendering techniques.
  70119. */
  70120. export class DepthRendererSceneComponent implements ISceneComponent {
  70121. /**
  70122. * The component name helpfull to identify the component in the list of scene components.
  70123. */
  70124. readonly name: string;
  70125. /**
  70126. * The scene the component belongs to.
  70127. */
  70128. scene: Scene;
  70129. /**
  70130. * Creates a new instance of the component for the given scene
  70131. * @param scene Defines the scene to register the component in
  70132. */
  70133. constructor(scene: Scene);
  70134. /**
  70135. * Registers the component in a given scene
  70136. */
  70137. register(): void;
  70138. /**
  70139. * Rebuilds the elements related to this component in case of
  70140. * context lost for instance.
  70141. */
  70142. rebuild(): void;
  70143. /**
  70144. * Disposes the component and the associated ressources
  70145. */
  70146. dispose(): void;
  70147. private _gatherRenderTargets;
  70148. private _gatherActiveCameraRenderTargets;
  70149. }
  70150. }
  70151. declare module "babylonjs/Shaders/outline.fragment" {
  70152. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70153. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70154. /** @hidden */
  70155. export var outlinePixelShader: {
  70156. name: string;
  70157. shader: string;
  70158. };
  70159. }
  70160. declare module "babylonjs/Shaders/outline.vertex" {
  70161. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70162. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70164. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70165. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70166. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70167. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70168. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70169. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70170. /** @hidden */
  70171. export var outlineVertexShader: {
  70172. name: string;
  70173. shader: string;
  70174. };
  70175. }
  70176. declare module "babylonjs/Rendering/outlineRenderer" {
  70177. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70178. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70179. import { Scene } from "babylonjs/scene";
  70180. import { ISceneComponent } from "babylonjs/sceneComponent";
  70181. import "babylonjs/Shaders/outline.fragment";
  70182. import "babylonjs/Shaders/outline.vertex";
  70183. module "babylonjs/scene" {
  70184. interface Scene {
  70185. /** @hidden */
  70186. _outlineRenderer: OutlineRenderer;
  70187. /**
  70188. * Gets the outline renderer associated with the scene
  70189. * @returns a OutlineRenderer
  70190. */
  70191. getOutlineRenderer(): OutlineRenderer;
  70192. }
  70193. }
  70194. module "babylonjs/Meshes/abstractMesh" {
  70195. interface AbstractMesh {
  70196. /** @hidden (Backing field) */
  70197. _renderOutline: boolean;
  70198. /**
  70199. * Gets or sets a boolean indicating if the outline must be rendered as well
  70200. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70201. */
  70202. renderOutline: boolean;
  70203. /** @hidden (Backing field) */
  70204. _renderOverlay: boolean;
  70205. /**
  70206. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70207. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70208. */
  70209. renderOverlay: boolean;
  70210. }
  70211. }
  70212. /**
  70213. * This class is responsible to draw bothe outline/overlay of meshes.
  70214. * It should not be used directly but through the available method on mesh.
  70215. */
  70216. export class OutlineRenderer implements ISceneComponent {
  70217. /**
  70218. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70219. */
  70220. private static _StencilReference;
  70221. /**
  70222. * The name of the component. Each component must have a unique name.
  70223. */
  70224. name: string;
  70225. /**
  70226. * The scene the component belongs to.
  70227. */
  70228. scene: Scene;
  70229. /**
  70230. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70231. */
  70232. zOffset: number;
  70233. private _engine;
  70234. private _effect;
  70235. private _cachedDefines;
  70236. private _savedDepthWrite;
  70237. /**
  70238. * Instantiates a new outline renderer. (There could be only one per scene).
  70239. * @param scene Defines the scene it belongs to
  70240. */
  70241. constructor(scene: Scene);
  70242. /**
  70243. * Register the component to one instance of a scene.
  70244. */
  70245. register(): void;
  70246. /**
  70247. * Rebuilds the elements related to this component in case of
  70248. * context lost for instance.
  70249. */
  70250. rebuild(): void;
  70251. /**
  70252. * Disposes the component and the associated ressources.
  70253. */
  70254. dispose(): void;
  70255. /**
  70256. * Renders the outline in the canvas.
  70257. * @param subMesh Defines the sumesh to render
  70258. * @param batch Defines the batch of meshes in case of instances
  70259. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70260. */
  70261. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70262. /**
  70263. * Returns whether or not the outline renderer is ready for a given submesh.
  70264. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70265. * @param subMesh Defines the submesh to check readyness for
  70266. * @param useInstances Defines wheter wee are trying to render instances or not
  70267. * @returns true if ready otherwise false
  70268. */
  70269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70270. private _beforeRenderingMesh;
  70271. private _afterRenderingMesh;
  70272. }
  70273. }
  70274. declare module "babylonjs/Rendering/index" {
  70275. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70276. export * from "babylonjs/Rendering/depthRenderer";
  70277. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70278. export * from "babylonjs/Rendering/edgesRenderer";
  70279. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70280. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70281. export * from "babylonjs/Rendering/outlineRenderer";
  70282. export * from "babylonjs/Rendering/renderingGroup";
  70283. export * from "babylonjs/Rendering/renderingManager";
  70284. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70285. }
  70286. declare module "babylonjs/Sprites/ISprites" {
  70287. /**
  70288. * Defines the basic options interface of a Sprite Frame Source Size.
  70289. */
  70290. export interface ISpriteJSONSpriteSourceSize {
  70291. /**
  70292. * number of the original width of the Frame
  70293. */
  70294. w: number;
  70295. /**
  70296. * number of the original height of the Frame
  70297. */
  70298. h: number;
  70299. }
  70300. /**
  70301. * Defines the basic options interface of a Sprite Frame Data.
  70302. */
  70303. export interface ISpriteJSONSpriteFrameData {
  70304. /**
  70305. * number of the x offset of the Frame
  70306. */
  70307. x: number;
  70308. /**
  70309. * number of the y offset of the Frame
  70310. */
  70311. y: number;
  70312. /**
  70313. * number of the width of the Frame
  70314. */
  70315. w: number;
  70316. /**
  70317. * number of the height of the Frame
  70318. */
  70319. h: number;
  70320. }
  70321. /**
  70322. * Defines the basic options interface of a JSON Sprite.
  70323. */
  70324. export interface ISpriteJSONSprite {
  70325. /**
  70326. * string name of the Frame
  70327. */
  70328. filename: string;
  70329. /**
  70330. * ISpriteJSONSpriteFrame basic object of the frame data
  70331. */
  70332. frame: ISpriteJSONSpriteFrameData;
  70333. /**
  70334. * boolean to flag is the frame was rotated.
  70335. */
  70336. rotated: boolean;
  70337. /**
  70338. * boolean to flag is the frame was trimmed.
  70339. */
  70340. trimmed: boolean;
  70341. /**
  70342. * ISpriteJSONSpriteFrame basic object of the source data
  70343. */
  70344. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70345. /**
  70346. * ISpriteJSONSpriteFrame basic object of the source data
  70347. */
  70348. sourceSize: ISpriteJSONSpriteSourceSize;
  70349. }
  70350. /**
  70351. * Defines the basic options interface of a JSON atlas.
  70352. */
  70353. export interface ISpriteJSONAtlas {
  70354. /**
  70355. * Array of objects that contain the frame data.
  70356. */
  70357. frames: Array<ISpriteJSONSprite>;
  70358. /**
  70359. * object basic object containing the sprite meta data.
  70360. */
  70361. meta?: object;
  70362. }
  70363. }
  70364. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70365. /** @hidden */
  70366. export var spriteMapPixelShader: {
  70367. name: string;
  70368. shader: string;
  70369. };
  70370. }
  70371. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70372. /** @hidden */
  70373. export var spriteMapVertexShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module "babylonjs/Sprites/spriteMap" {
  70379. import { IDisposable, Scene } from "babylonjs/scene";
  70380. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70381. import { Texture } from "babylonjs/Materials/Textures/texture";
  70382. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70383. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70384. import "babylonjs/Meshes/Builders/planeBuilder";
  70385. import "babylonjs/Shaders/spriteMap.fragment";
  70386. import "babylonjs/Shaders/spriteMap.vertex";
  70387. /**
  70388. * Defines the basic options interface of a SpriteMap
  70389. */
  70390. export interface ISpriteMapOptions {
  70391. /**
  70392. * Vector2 of the number of cells in the grid.
  70393. */
  70394. stageSize?: Vector2;
  70395. /**
  70396. * Vector2 of the size of the output plane in World Units.
  70397. */
  70398. outputSize?: Vector2;
  70399. /**
  70400. * Vector3 of the position of the output plane in World Units.
  70401. */
  70402. outputPosition?: Vector3;
  70403. /**
  70404. * Vector3 of the rotation of the output plane.
  70405. */
  70406. outputRotation?: Vector3;
  70407. /**
  70408. * number of layers that the system will reserve in resources.
  70409. */
  70410. layerCount?: number;
  70411. /**
  70412. * number of max animation frames a single cell will reserve in resources.
  70413. */
  70414. maxAnimationFrames?: number;
  70415. /**
  70416. * number cell index of the base tile when the system compiles.
  70417. */
  70418. baseTile?: number;
  70419. /**
  70420. * boolean flip the sprite after its been repositioned by the framing data.
  70421. */
  70422. flipU?: boolean;
  70423. /**
  70424. * Vector3 scalar of the global RGB values of the SpriteMap.
  70425. */
  70426. colorMultiply?: Vector3;
  70427. }
  70428. /**
  70429. * Defines the IDisposable interface in order to be cleanable from resources.
  70430. */
  70431. export interface ISpriteMap extends IDisposable {
  70432. /**
  70433. * String name of the SpriteMap.
  70434. */
  70435. name: string;
  70436. /**
  70437. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70438. */
  70439. atlasJSON: ISpriteJSONAtlas;
  70440. /**
  70441. * Texture of the SpriteMap.
  70442. */
  70443. spriteSheet: Texture;
  70444. /**
  70445. * The parameters to initialize the SpriteMap with.
  70446. */
  70447. options: ISpriteMapOptions;
  70448. }
  70449. /**
  70450. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70451. */
  70452. export class SpriteMap implements ISpriteMap {
  70453. /** The Name of the spriteMap */
  70454. name: string;
  70455. /** The JSON file with the frame and meta data */
  70456. atlasJSON: ISpriteJSONAtlas;
  70457. /** The systems Sprite Sheet Texture */
  70458. spriteSheet: Texture;
  70459. /** Arguments passed with the Constructor */
  70460. options: ISpriteMapOptions;
  70461. /** Public Sprite Storage array, parsed from atlasJSON */
  70462. sprites: Array<ISpriteJSONSprite>;
  70463. /** Returns the Number of Sprites in the System */
  70464. get spriteCount(): number;
  70465. /** Returns the Position of Output Plane*/
  70466. get position(): Vector3;
  70467. /** Returns the Position of Output Plane*/
  70468. set position(v: Vector3);
  70469. /** Returns the Rotation of Output Plane*/
  70470. get rotation(): Vector3;
  70471. /** Returns the Rotation of Output Plane*/
  70472. set rotation(v: Vector3);
  70473. /** Sets the AnimationMap*/
  70474. get animationMap(): RawTexture;
  70475. /** Sets the AnimationMap*/
  70476. set animationMap(v: RawTexture);
  70477. /** Scene that the SpriteMap was created in */
  70478. private _scene;
  70479. /** Texture Buffer of Float32 that holds tile frame data*/
  70480. private _frameMap;
  70481. /** Texture Buffers of Float32 that holds tileMap data*/
  70482. private _tileMaps;
  70483. /** Texture Buffer of Float32 that holds Animation Data*/
  70484. private _animationMap;
  70485. /** Custom ShaderMaterial Central to the System*/
  70486. private _material;
  70487. /** Custom ShaderMaterial Central to the System*/
  70488. private _output;
  70489. /** Systems Time Ticker*/
  70490. private _time;
  70491. /**
  70492. * Creates a new SpriteMap
  70493. * @param name defines the SpriteMaps Name
  70494. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70495. * @param spriteSheet is the Texture that the Sprites are on.
  70496. * @param options a basic deployment configuration
  70497. * @param scene The Scene that the map is deployed on
  70498. */
  70499. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70500. /**
  70501. * Returns tileID location
  70502. * @returns Vector2 the cell position ID
  70503. */
  70504. getTileID(): Vector2;
  70505. /**
  70506. * Gets the UV location of the mouse over the SpriteMap.
  70507. * @returns Vector2 the UV position of the mouse interaction
  70508. */
  70509. getMousePosition(): Vector2;
  70510. /**
  70511. * Creates the "frame" texture Buffer
  70512. * -------------------------------------
  70513. * Structure of frames
  70514. * "filename": "Falling-Water-2.png",
  70515. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70516. * "rotated": true,
  70517. * "trimmed": true,
  70518. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70519. * "sourceSize": {"w":32,"h":32}
  70520. * @returns RawTexture of the frameMap
  70521. */
  70522. private _createFrameBuffer;
  70523. /**
  70524. * Creates the tileMap texture Buffer
  70525. * @param buffer normally and array of numbers, or a false to generate from scratch
  70526. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70527. * @returns RawTexture of the tileMap
  70528. */
  70529. private _createTileBuffer;
  70530. /**
  70531. * Modifies the data of the tileMaps
  70532. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70533. * @param pos is the iVector2 Coordinates of the Tile
  70534. * @param tile The SpriteIndex of the new Tile
  70535. */
  70536. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70537. /**
  70538. * Creates the animationMap texture Buffer
  70539. * @param buffer normally and array of numbers, or a false to generate from scratch
  70540. * @returns RawTexture of the animationMap
  70541. */
  70542. private _createTileAnimationBuffer;
  70543. /**
  70544. * Modifies the data of the animationMap
  70545. * @param cellID is the Index of the Sprite
  70546. * @param _frame is the target Animation frame
  70547. * @param toCell is the Target Index of the next frame of the animation
  70548. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70549. * @param speed is a global scalar of the time variable on the map.
  70550. */
  70551. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70552. /**
  70553. * Exports the .tilemaps file
  70554. */
  70555. saveTileMaps(): void;
  70556. /**
  70557. * Imports the .tilemaps file
  70558. * @param url of the .tilemaps file
  70559. */
  70560. loadTileMaps(url: string): void;
  70561. /**
  70562. * Release associated resources
  70563. */
  70564. dispose(): void;
  70565. }
  70566. }
  70567. declare module "babylonjs/Sprites/spritePackedManager" {
  70568. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70569. import { Scene } from "babylonjs/scene";
  70570. /**
  70571. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70572. * @see http://doc.babylonjs.com/babylon101/sprites
  70573. */
  70574. export class SpritePackedManager extends SpriteManager {
  70575. /** defines the packed manager's name */
  70576. name: string;
  70577. /**
  70578. * Creates a new sprite manager from a packed sprite sheet
  70579. * @param name defines the manager's name
  70580. * @param imgUrl defines the sprite sheet url
  70581. * @param capacity defines the maximum allowed number of sprites
  70582. * @param scene defines the hosting scene
  70583. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70584. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70585. * @param samplingMode defines the smapling mode to use with spritesheet
  70586. * @param fromPacked set to true; do not alter
  70587. */
  70588. constructor(
  70589. /** defines the packed manager's name */
  70590. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70591. }
  70592. }
  70593. declare module "babylonjs/Sprites/index" {
  70594. export * from "babylonjs/Sprites/sprite";
  70595. export * from "babylonjs/Sprites/ISprites";
  70596. export * from "babylonjs/Sprites/spriteManager";
  70597. export * from "babylonjs/Sprites/spriteMap";
  70598. export * from "babylonjs/Sprites/spritePackedManager";
  70599. export * from "babylonjs/Sprites/spriteSceneComponent";
  70600. }
  70601. declare module "babylonjs/States/index" {
  70602. export * from "babylonjs/States/alphaCullingState";
  70603. export * from "babylonjs/States/depthCullingState";
  70604. export * from "babylonjs/States/stencilState";
  70605. }
  70606. declare module "babylonjs/Misc/assetsManager" {
  70607. import { Scene } from "babylonjs/scene";
  70608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70609. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70610. import { Skeleton } from "babylonjs/Bones/skeleton";
  70611. import { Observable } from "babylonjs/Misc/observable";
  70612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70613. import { Texture } from "babylonjs/Materials/Textures/texture";
  70614. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70615. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70616. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70617. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70618. /**
  70619. * Defines the list of states available for a task inside a AssetsManager
  70620. */
  70621. export enum AssetTaskState {
  70622. /**
  70623. * Initialization
  70624. */
  70625. INIT = 0,
  70626. /**
  70627. * Running
  70628. */
  70629. RUNNING = 1,
  70630. /**
  70631. * Done
  70632. */
  70633. DONE = 2,
  70634. /**
  70635. * Error
  70636. */
  70637. ERROR = 3
  70638. }
  70639. /**
  70640. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70641. */
  70642. export abstract class AbstractAssetTask {
  70643. /**
  70644. * Task name
  70645. */ name: string;
  70646. /**
  70647. * Callback called when the task is successful
  70648. */
  70649. onSuccess: (task: any) => void;
  70650. /**
  70651. * Callback called when the task is not successful
  70652. */
  70653. onError: (task: any, message?: string, exception?: any) => void;
  70654. /**
  70655. * Creates a new AssetsManager
  70656. * @param name defines the name of the task
  70657. */
  70658. constructor(
  70659. /**
  70660. * Task name
  70661. */ name: string);
  70662. private _isCompleted;
  70663. private _taskState;
  70664. private _errorObject;
  70665. /**
  70666. * Get if the task is completed
  70667. */
  70668. get isCompleted(): boolean;
  70669. /**
  70670. * Gets the current state of the task
  70671. */
  70672. get taskState(): AssetTaskState;
  70673. /**
  70674. * Gets the current error object (if task is in error)
  70675. */
  70676. get errorObject(): {
  70677. message?: string;
  70678. exception?: any;
  70679. };
  70680. /**
  70681. * Internal only
  70682. * @hidden
  70683. */
  70684. _setErrorObject(message?: string, exception?: any): void;
  70685. /**
  70686. * Execute the current task
  70687. * @param scene defines the scene where you want your assets to be loaded
  70688. * @param onSuccess is a callback called when the task is successfully executed
  70689. * @param onError is a callback called if an error occurs
  70690. */
  70691. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70692. /**
  70693. * Execute the current task
  70694. * @param scene defines the scene where you want your assets to be loaded
  70695. * @param onSuccess is a callback called when the task is successfully executed
  70696. * @param onError is a callback called if an error occurs
  70697. */
  70698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70699. /**
  70700. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70701. * This can be used with failed tasks that have the reason for failure fixed.
  70702. */
  70703. reset(): void;
  70704. private onErrorCallback;
  70705. private onDoneCallback;
  70706. }
  70707. /**
  70708. * Define the interface used by progress events raised during assets loading
  70709. */
  70710. export interface IAssetsProgressEvent {
  70711. /**
  70712. * Defines the number of remaining tasks to process
  70713. */
  70714. remainingCount: number;
  70715. /**
  70716. * Defines the total number of tasks
  70717. */
  70718. totalCount: number;
  70719. /**
  70720. * Defines the task that was just processed
  70721. */
  70722. task: AbstractAssetTask;
  70723. }
  70724. /**
  70725. * Class used to share progress information about assets loading
  70726. */
  70727. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70728. /**
  70729. * Defines the number of remaining tasks to process
  70730. */
  70731. remainingCount: number;
  70732. /**
  70733. * Defines the total number of tasks
  70734. */
  70735. totalCount: number;
  70736. /**
  70737. * Defines the task that was just processed
  70738. */
  70739. task: AbstractAssetTask;
  70740. /**
  70741. * Creates a AssetsProgressEvent
  70742. * @param remainingCount defines the number of remaining tasks to process
  70743. * @param totalCount defines the total number of tasks
  70744. * @param task defines the task that was just processed
  70745. */
  70746. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70747. }
  70748. /**
  70749. * Define a task used by AssetsManager to load meshes
  70750. */
  70751. export class MeshAssetTask extends AbstractAssetTask {
  70752. /**
  70753. * Defines the name of the task
  70754. */
  70755. name: string;
  70756. /**
  70757. * Defines the list of mesh's names you want to load
  70758. */
  70759. meshesNames: any;
  70760. /**
  70761. * Defines the root url to use as a base to load your meshes and associated resources
  70762. */
  70763. rootUrl: string;
  70764. /**
  70765. * Defines the filename of the scene to load from
  70766. */
  70767. sceneFilename: string;
  70768. /**
  70769. * Gets the list of loaded meshes
  70770. */
  70771. loadedMeshes: Array<AbstractMesh>;
  70772. /**
  70773. * Gets the list of loaded particle systems
  70774. */
  70775. loadedParticleSystems: Array<IParticleSystem>;
  70776. /**
  70777. * Gets the list of loaded skeletons
  70778. */
  70779. loadedSkeletons: Array<Skeleton>;
  70780. /**
  70781. * Gets the list of loaded animation groups
  70782. */
  70783. loadedAnimationGroups: Array<AnimationGroup>;
  70784. /**
  70785. * Callback called when the task is successful
  70786. */
  70787. onSuccess: (task: MeshAssetTask) => void;
  70788. /**
  70789. * Callback called when the task is successful
  70790. */
  70791. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70792. /**
  70793. * Creates a new MeshAssetTask
  70794. * @param name defines the name of the task
  70795. * @param meshesNames defines the list of mesh's names you want to load
  70796. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70797. * @param sceneFilename defines the filename of the scene to load from
  70798. */
  70799. constructor(
  70800. /**
  70801. * Defines the name of the task
  70802. */
  70803. name: string,
  70804. /**
  70805. * Defines the list of mesh's names you want to load
  70806. */
  70807. meshesNames: any,
  70808. /**
  70809. * Defines the root url to use as a base to load your meshes and associated resources
  70810. */
  70811. rootUrl: string,
  70812. /**
  70813. * Defines the filename of the scene to load from
  70814. */
  70815. sceneFilename: string);
  70816. /**
  70817. * Execute the current task
  70818. * @param scene defines the scene where you want your assets to be loaded
  70819. * @param onSuccess is a callback called when the task is successfully executed
  70820. * @param onError is a callback called if an error occurs
  70821. */
  70822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70823. }
  70824. /**
  70825. * Define a task used by AssetsManager to load text content
  70826. */
  70827. export class TextFileAssetTask extends AbstractAssetTask {
  70828. /**
  70829. * Defines the name of the task
  70830. */
  70831. name: string;
  70832. /**
  70833. * Defines the location of the file to load
  70834. */
  70835. url: string;
  70836. /**
  70837. * Gets the loaded text string
  70838. */
  70839. text: string;
  70840. /**
  70841. * Callback called when the task is successful
  70842. */
  70843. onSuccess: (task: TextFileAssetTask) => void;
  70844. /**
  70845. * Callback called when the task is successful
  70846. */
  70847. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70848. /**
  70849. * Creates a new TextFileAssetTask object
  70850. * @param name defines the name of the task
  70851. * @param url defines the location of the file to load
  70852. */
  70853. constructor(
  70854. /**
  70855. * Defines the name of the task
  70856. */
  70857. name: string,
  70858. /**
  70859. * Defines the location of the file to load
  70860. */
  70861. url: string);
  70862. /**
  70863. * Execute the current task
  70864. * @param scene defines the scene where you want your assets to be loaded
  70865. * @param onSuccess is a callback called when the task is successfully executed
  70866. * @param onError is a callback called if an error occurs
  70867. */
  70868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70869. }
  70870. /**
  70871. * Define a task used by AssetsManager to load binary data
  70872. */
  70873. export class BinaryFileAssetTask extends AbstractAssetTask {
  70874. /**
  70875. * Defines the name of the task
  70876. */
  70877. name: string;
  70878. /**
  70879. * Defines the location of the file to load
  70880. */
  70881. url: string;
  70882. /**
  70883. * Gets the lodaded data (as an array buffer)
  70884. */
  70885. data: ArrayBuffer;
  70886. /**
  70887. * Callback called when the task is successful
  70888. */
  70889. onSuccess: (task: BinaryFileAssetTask) => void;
  70890. /**
  70891. * Callback called when the task is successful
  70892. */
  70893. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70894. /**
  70895. * Creates a new BinaryFileAssetTask object
  70896. * @param name defines the name of the new task
  70897. * @param url defines the location of the file to load
  70898. */
  70899. constructor(
  70900. /**
  70901. * Defines the name of the task
  70902. */
  70903. name: string,
  70904. /**
  70905. * Defines the location of the file to load
  70906. */
  70907. url: 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 images
  70918. */
  70919. export class ImageAssetTask extends AbstractAssetTask {
  70920. /**
  70921. * Defines the name of the task
  70922. */
  70923. name: string;
  70924. /**
  70925. * Defines the location of the image to load
  70926. */
  70927. url: string;
  70928. /**
  70929. * Gets the loaded images
  70930. */
  70931. image: HTMLImageElement;
  70932. /**
  70933. * Callback called when the task is successful
  70934. */
  70935. onSuccess: (task: ImageAssetTask) => void;
  70936. /**
  70937. * Callback called when the task is successful
  70938. */
  70939. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70940. /**
  70941. * Creates a new ImageAssetTask
  70942. * @param name defines the name of the task
  70943. * @param url defines the location of the image to load
  70944. */
  70945. constructor(
  70946. /**
  70947. * Defines the name of the task
  70948. */
  70949. name: string,
  70950. /**
  70951. * Defines the location of the image 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. * Defines the interface used by texture loading tasks
  70964. */
  70965. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70966. /**
  70967. * Gets the loaded texture
  70968. */
  70969. texture: TEX;
  70970. }
  70971. /**
  70972. * Define a task used by AssetsManager to load 2D textures
  70973. */
  70974. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70975. /**
  70976. * Defines the name of the task
  70977. */
  70978. name: string;
  70979. /**
  70980. * Defines the location of the file to load
  70981. */
  70982. url: string;
  70983. /**
  70984. * Defines if mipmap should not be generated (default is false)
  70985. */
  70986. noMipmap?: boolean | undefined;
  70987. /**
  70988. * Defines if texture must be inverted on Y axis (default is false)
  70989. */
  70990. invertY?: boolean | undefined;
  70991. /**
  70992. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70993. */
  70994. samplingMode: number;
  70995. /**
  70996. * Gets the loaded texture
  70997. */
  70998. texture: Texture;
  70999. /**
  71000. * Callback called when the task is successful
  71001. */
  71002. onSuccess: (task: TextureAssetTask) => void;
  71003. /**
  71004. * Callback called when the task is successful
  71005. */
  71006. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71007. /**
  71008. * Creates a new TextureAssetTask object
  71009. * @param name defines the name of the task
  71010. * @param url defines the location of the file to load
  71011. * @param noMipmap defines if mipmap should not be generated (default is false)
  71012. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71013. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71014. */
  71015. constructor(
  71016. /**
  71017. * Defines the name of the task
  71018. */
  71019. name: string,
  71020. /**
  71021. * Defines the location of the file to load
  71022. */
  71023. url: string,
  71024. /**
  71025. * Defines if mipmap should not be generated (default is false)
  71026. */
  71027. noMipmap?: boolean | undefined,
  71028. /**
  71029. * Defines if texture must be inverted on Y axis (default is false)
  71030. */
  71031. invertY?: boolean | undefined,
  71032. /**
  71033. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71034. */
  71035. samplingMode?: number);
  71036. /**
  71037. * Execute the current task
  71038. * @param scene defines the scene where you want your assets to be loaded
  71039. * @param onSuccess is a callback called when the task is successfully executed
  71040. * @param onError is a callback called if an error occurs
  71041. */
  71042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71043. }
  71044. /**
  71045. * Define a task used by AssetsManager to load cube textures
  71046. */
  71047. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71048. /**
  71049. * Defines the name of the task
  71050. */
  71051. name: string;
  71052. /**
  71053. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71054. */
  71055. url: string;
  71056. /**
  71057. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71058. */
  71059. extensions?: string[] | undefined;
  71060. /**
  71061. * Defines if mipmaps should not be generated (default is false)
  71062. */
  71063. noMipmap?: boolean | undefined;
  71064. /**
  71065. * Defines the explicit list of files (undefined by default)
  71066. */
  71067. files?: string[] | undefined;
  71068. /**
  71069. * Gets the loaded texture
  71070. */
  71071. texture: CubeTexture;
  71072. /**
  71073. * Callback called when the task is successful
  71074. */
  71075. onSuccess: (task: CubeTextureAssetTask) => void;
  71076. /**
  71077. * Callback called when the task is successful
  71078. */
  71079. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71080. /**
  71081. * Creates a new CubeTextureAssetTask
  71082. * @param name defines the name of the task
  71083. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71084. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71085. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71086. * @param files defines the explicit list of files (undefined by default)
  71087. */
  71088. constructor(
  71089. /**
  71090. * Defines the name of the task
  71091. */
  71092. name: string,
  71093. /**
  71094. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71095. */
  71096. url: string,
  71097. /**
  71098. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71099. */
  71100. extensions?: string[] | undefined,
  71101. /**
  71102. * Defines if mipmaps should not be generated (default is false)
  71103. */
  71104. noMipmap?: boolean | undefined,
  71105. /**
  71106. * Defines the explicit list of files (undefined by default)
  71107. */
  71108. files?: string[] | undefined);
  71109. /**
  71110. * Execute the current task
  71111. * @param scene defines the scene where you want your assets to be loaded
  71112. * @param onSuccess is a callback called when the task is successfully executed
  71113. * @param onError is a callback called if an error occurs
  71114. */
  71115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71116. }
  71117. /**
  71118. * Define a task used by AssetsManager to load HDR cube textures
  71119. */
  71120. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71121. /**
  71122. * Defines the name of the task
  71123. */
  71124. name: string;
  71125. /**
  71126. * Defines the location of the file to load
  71127. */
  71128. url: string;
  71129. /**
  71130. * Defines the desired size (the more it increases the longer the generation will be)
  71131. */
  71132. size: number;
  71133. /**
  71134. * Defines if mipmaps should not be generated (default is false)
  71135. */
  71136. noMipmap: boolean;
  71137. /**
  71138. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71139. */
  71140. generateHarmonics: boolean;
  71141. /**
  71142. * 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)
  71143. */
  71144. gammaSpace: boolean;
  71145. /**
  71146. * Internal Use Only
  71147. */
  71148. reserved: boolean;
  71149. /**
  71150. * Gets the loaded texture
  71151. */
  71152. texture: HDRCubeTexture;
  71153. /**
  71154. * Callback called when the task is successful
  71155. */
  71156. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71157. /**
  71158. * Callback called when the task is successful
  71159. */
  71160. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71161. /**
  71162. * Creates a new HDRCubeTextureAssetTask object
  71163. * @param name defines the name of the task
  71164. * @param url defines the location of the file to load
  71165. * @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.
  71166. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71167. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71168. * @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)
  71169. * @param reserved Internal use only
  71170. */
  71171. constructor(
  71172. /**
  71173. * Defines the name of the task
  71174. */
  71175. name: string,
  71176. /**
  71177. * Defines the location of the file to load
  71178. */
  71179. url: string,
  71180. /**
  71181. * Defines the desired size (the more it increases the longer the generation will be)
  71182. */
  71183. size: number,
  71184. /**
  71185. * Defines if mipmaps should not be generated (default is false)
  71186. */
  71187. noMipmap?: boolean,
  71188. /**
  71189. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71190. */
  71191. generateHarmonics?: boolean,
  71192. /**
  71193. * 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)
  71194. */
  71195. gammaSpace?: boolean,
  71196. /**
  71197. * Internal Use Only
  71198. */
  71199. reserved?: boolean);
  71200. /**
  71201. * Execute the current task
  71202. * @param scene defines the scene where you want your assets to be loaded
  71203. * @param onSuccess is a callback called when the task is successfully executed
  71204. * @param onError is a callback called if an error occurs
  71205. */
  71206. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71207. }
  71208. /**
  71209. * Define a task used by AssetsManager to load Equirectangular cube textures
  71210. */
  71211. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71212. /**
  71213. * Defines the name of the task
  71214. */
  71215. name: string;
  71216. /**
  71217. * Defines the location of the file to load
  71218. */
  71219. url: string;
  71220. /**
  71221. * Defines the desired size (the more it increases the longer the generation will be)
  71222. */
  71223. size: number;
  71224. /**
  71225. * Defines if mipmaps should not be generated (default is false)
  71226. */
  71227. noMipmap: boolean;
  71228. /**
  71229. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71230. * but the standard material would require them in Gamma space) (default is true)
  71231. */
  71232. gammaSpace: boolean;
  71233. /**
  71234. * Gets the loaded texture
  71235. */
  71236. texture: EquiRectangularCubeTexture;
  71237. /**
  71238. * Callback called when the task is successful
  71239. */
  71240. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71241. /**
  71242. * Callback called when the task is successful
  71243. */
  71244. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71245. /**
  71246. * Creates a new EquiRectangularCubeTextureAssetTask object
  71247. * @param name defines the name of the task
  71248. * @param url defines the location of the file to load
  71249. * @param size defines the desired size (the more it increases the longer the generation will be)
  71250. * If the size is omitted this implies you are using a preprocessed cubemap.
  71251. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71252. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71253. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71254. * (default is true)
  71255. */
  71256. constructor(
  71257. /**
  71258. * Defines the name of the task
  71259. */
  71260. name: string,
  71261. /**
  71262. * Defines the location of the file to load
  71263. */
  71264. url: string,
  71265. /**
  71266. * Defines the desired size (the more it increases the longer the generation will be)
  71267. */
  71268. size: number,
  71269. /**
  71270. * Defines if mipmaps should not be generated (default is false)
  71271. */
  71272. noMipmap?: boolean,
  71273. /**
  71274. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71275. * but the standard material would require them in Gamma space) (default is true)
  71276. */
  71277. gammaSpace?: boolean);
  71278. /**
  71279. * Execute the current task
  71280. * @param scene defines the scene where you want your assets to be loaded
  71281. * @param onSuccess is a callback called when the task is successfully executed
  71282. * @param onError is a callback called if an error occurs
  71283. */
  71284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71285. }
  71286. /**
  71287. * This class can be used to easily import assets into a scene
  71288. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71289. */
  71290. export class AssetsManager {
  71291. private _scene;
  71292. private _isLoading;
  71293. protected _tasks: AbstractAssetTask[];
  71294. protected _waitingTasksCount: number;
  71295. protected _totalTasksCount: number;
  71296. /**
  71297. * Callback called when all tasks are processed
  71298. */
  71299. onFinish: (tasks: AbstractAssetTask[]) => void;
  71300. /**
  71301. * Callback called when a task is successful
  71302. */
  71303. onTaskSuccess: (task: AbstractAssetTask) => void;
  71304. /**
  71305. * Callback called when a task had an error
  71306. */
  71307. onTaskError: (task: AbstractAssetTask) => void;
  71308. /**
  71309. * Callback called when a task is done (whatever the result is)
  71310. */
  71311. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71312. /**
  71313. * Observable called when all tasks are processed
  71314. */
  71315. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71316. /**
  71317. * Observable called when a task had an error
  71318. */
  71319. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71320. /**
  71321. * Observable called when all tasks were executed
  71322. */
  71323. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71324. /**
  71325. * Observable called when a task is done (whatever the result is)
  71326. */
  71327. onProgressObservable: Observable<IAssetsProgressEvent>;
  71328. /**
  71329. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71330. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71331. */
  71332. useDefaultLoadingScreen: boolean;
  71333. /**
  71334. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71335. * when all assets have been downloaded.
  71336. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71337. */
  71338. autoHideLoadingUI: boolean;
  71339. /**
  71340. * Creates a new AssetsManager
  71341. * @param scene defines the scene to work on
  71342. */
  71343. constructor(scene: Scene);
  71344. /**
  71345. * Add a MeshAssetTask to the list of active tasks
  71346. * @param taskName defines the name of the new task
  71347. * @param meshesNames defines the name of meshes to load
  71348. * @param rootUrl defines the root url to use to locate files
  71349. * @param sceneFilename defines the filename of the scene file
  71350. * @returns a new MeshAssetTask object
  71351. */
  71352. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71353. /**
  71354. * Add a TextFileAssetTask to the list of active tasks
  71355. * @param taskName defines the name of the new task
  71356. * @param url defines the url of the file to load
  71357. * @returns a new TextFileAssetTask object
  71358. */
  71359. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71360. /**
  71361. * Add a BinaryFileAssetTask to the list of active tasks
  71362. * @param taskName defines the name of the new task
  71363. * @param url defines the url of the file to load
  71364. * @returns a new BinaryFileAssetTask object
  71365. */
  71366. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71367. /**
  71368. * Add a ImageAssetTask to the list of active tasks
  71369. * @param taskName defines the name of the new task
  71370. * @param url defines the url of the file to load
  71371. * @returns a new ImageAssetTask object
  71372. */
  71373. addImageTask(taskName: string, url: string): ImageAssetTask;
  71374. /**
  71375. * Add a TextureAssetTask to the list of active tasks
  71376. * @param taskName defines the name of the new task
  71377. * @param url defines the url of the file to load
  71378. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71379. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71380. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71381. * @returns a new TextureAssetTask object
  71382. */
  71383. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71384. /**
  71385. * Add a CubeTextureAssetTask to the list of active tasks
  71386. * @param taskName defines the name of the new task
  71387. * @param url defines the url of the file to load
  71388. * @param extensions defines the extension to use to load the cube map (can be null)
  71389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71390. * @param files defines the list of files to load (can be null)
  71391. * @returns a new CubeTextureAssetTask object
  71392. */
  71393. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71394. /**
  71395. *
  71396. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71397. * @param taskName defines the name of the new task
  71398. * @param url defines the url of the file to load
  71399. * @param size defines the size you want for the cubemap (can be null)
  71400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71401. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71402. * @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)
  71403. * @param reserved Internal use only
  71404. * @returns a new HDRCubeTextureAssetTask object
  71405. */
  71406. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71407. /**
  71408. *
  71409. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71410. * @param taskName defines the name of the new task
  71411. * @param url defines the url of the file to load
  71412. * @param size defines the size you want for the cubemap (can be null)
  71413. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71414. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71415. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71416. * @returns a new EquiRectangularCubeTextureAssetTask object
  71417. */
  71418. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71419. /**
  71420. * Remove a task from the assets manager.
  71421. * @param task the task to remove
  71422. */
  71423. removeTask(task: AbstractAssetTask): void;
  71424. private _decreaseWaitingTasksCount;
  71425. private _runTask;
  71426. /**
  71427. * Reset the AssetsManager and remove all tasks
  71428. * @return the current instance of the AssetsManager
  71429. */
  71430. reset(): AssetsManager;
  71431. /**
  71432. * Start the loading process
  71433. * @return the current instance of the AssetsManager
  71434. */
  71435. load(): AssetsManager;
  71436. /**
  71437. * Start the loading process as an async operation
  71438. * @return a promise returning the list of failed tasks
  71439. */
  71440. loadAsync(): Promise<void>;
  71441. }
  71442. }
  71443. declare module "babylonjs/Misc/deferred" {
  71444. /**
  71445. * Wrapper class for promise with external resolve and reject.
  71446. */
  71447. export class Deferred<T> {
  71448. /**
  71449. * The promise associated with this deferred object.
  71450. */
  71451. readonly promise: Promise<T>;
  71452. private _resolve;
  71453. private _reject;
  71454. /**
  71455. * The resolve method of the promise associated with this deferred object.
  71456. */
  71457. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71458. /**
  71459. * The reject method of the promise associated with this deferred object.
  71460. */
  71461. get reject(): (reason?: any) => void;
  71462. /**
  71463. * Constructor for this deferred object.
  71464. */
  71465. constructor();
  71466. }
  71467. }
  71468. declare module "babylonjs/Misc/meshExploder" {
  71469. import { Mesh } from "babylonjs/Meshes/mesh";
  71470. /**
  71471. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71472. */
  71473. export class MeshExploder {
  71474. private _centerMesh;
  71475. private _meshes;
  71476. private _meshesOrigins;
  71477. private _toCenterVectors;
  71478. private _scaledDirection;
  71479. private _newPosition;
  71480. private _centerPosition;
  71481. /**
  71482. * Explodes meshes from a center mesh.
  71483. * @param meshes The meshes to explode.
  71484. * @param centerMesh The mesh to be center of explosion.
  71485. */
  71486. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71487. private _setCenterMesh;
  71488. /**
  71489. * Get class name
  71490. * @returns "MeshExploder"
  71491. */
  71492. getClassName(): string;
  71493. /**
  71494. * "Exploded meshes"
  71495. * @returns Array of meshes with the centerMesh at index 0.
  71496. */
  71497. getMeshes(): Array<Mesh>;
  71498. /**
  71499. * Explodes meshes giving a specific direction
  71500. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71501. */
  71502. explode(direction?: number): void;
  71503. }
  71504. }
  71505. declare module "babylonjs/Misc/filesInput" {
  71506. import { Engine } from "babylonjs/Engines/engine";
  71507. import { Scene } from "babylonjs/scene";
  71508. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71509. /**
  71510. * Class used to help managing file picking and drag'n'drop
  71511. */
  71512. export class FilesInput {
  71513. /**
  71514. * List of files ready to be loaded
  71515. */
  71516. static get FilesToLoad(): {
  71517. [key: string]: File;
  71518. };
  71519. /**
  71520. * Callback called when a file is processed
  71521. */
  71522. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71523. private _engine;
  71524. private _currentScene;
  71525. private _sceneLoadedCallback;
  71526. private _progressCallback;
  71527. private _additionalRenderLoopLogicCallback;
  71528. private _textureLoadingCallback;
  71529. private _startingProcessingFilesCallback;
  71530. private _onReloadCallback;
  71531. private _errorCallback;
  71532. private _elementToMonitor;
  71533. private _sceneFileToLoad;
  71534. private _filesToLoad;
  71535. /**
  71536. * Creates a new FilesInput
  71537. * @param engine defines the rendering engine
  71538. * @param scene defines the hosting scene
  71539. * @param sceneLoadedCallback callback called when scene is loaded
  71540. * @param progressCallback callback called to track progress
  71541. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71542. * @param textureLoadingCallback callback called when a texture is loading
  71543. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71544. * @param onReloadCallback callback called when a reload is requested
  71545. * @param errorCallback callback call if an error occurs
  71546. */
  71547. 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);
  71548. private _dragEnterHandler;
  71549. private _dragOverHandler;
  71550. private _dropHandler;
  71551. /**
  71552. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71553. * @param elementToMonitor defines the DOM element to track
  71554. */
  71555. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71556. /**
  71557. * Release all associated resources
  71558. */
  71559. dispose(): void;
  71560. private renderFunction;
  71561. private drag;
  71562. private drop;
  71563. private _traverseFolder;
  71564. private _processFiles;
  71565. /**
  71566. * Load files from a drop event
  71567. * @param event defines the drop event to use as source
  71568. */
  71569. loadFiles(event: any): void;
  71570. private _processReload;
  71571. /**
  71572. * Reload the current scene from the loaded files
  71573. */
  71574. reload(): void;
  71575. }
  71576. }
  71577. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71578. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71579. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71580. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71581. }
  71582. declare module "babylonjs/Misc/sceneOptimizer" {
  71583. import { Scene, IDisposable } from "babylonjs/scene";
  71584. import { Observable } from "babylonjs/Misc/observable";
  71585. /**
  71586. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71587. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71588. */
  71589. export class SceneOptimization {
  71590. /**
  71591. * Defines the priority of this optimization (0 by default which means first in the list)
  71592. */
  71593. priority: number;
  71594. /**
  71595. * Gets a string describing the action executed by the current optimization
  71596. * @returns description string
  71597. */
  71598. getDescription(): string;
  71599. /**
  71600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71601. * @param scene defines the current scene where to apply this optimization
  71602. * @param optimizer defines the current optimizer
  71603. * @returns true if everything that can be done was applied
  71604. */
  71605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71606. /**
  71607. * Creates the SceneOptimization object
  71608. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71609. * @param desc defines the description associated with the optimization
  71610. */
  71611. constructor(
  71612. /**
  71613. * Defines the priority of this optimization (0 by default which means first in the list)
  71614. */
  71615. priority?: number);
  71616. }
  71617. /**
  71618. * Defines an optimization used to reduce the size of render target textures
  71619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71620. */
  71621. export class TextureOptimization extends SceneOptimization {
  71622. /**
  71623. * Defines the priority of this optimization (0 by default which means first in the list)
  71624. */
  71625. priority: number;
  71626. /**
  71627. * 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
  71628. */
  71629. maximumSize: number;
  71630. /**
  71631. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71632. */
  71633. step: number;
  71634. /**
  71635. * Gets a string describing the action executed by the current optimization
  71636. * @returns description string
  71637. */
  71638. getDescription(): string;
  71639. /**
  71640. * Creates the TextureOptimization object
  71641. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71642. * @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
  71643. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71644. */
  71645. constructor(
  71646. /**
  71647. * Defines the priority of this optimization (0 by default which means first in the list)
  71648. */
  71649. priority?: number,
  71650. /**
  71651. * 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
  71652. */
  71653. maximumSize?: number,
  71654. /**
  71655. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71656. */
  71657. step?: number);
  71658. /**
  71659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71660. * @param scene defines the current scene where to apply this optimization
  71661. * @param optimizer defines the current optimizer
  71662. * @returns true if everything that can be done was applied
  71663. */
  71664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71665. }
  71666. /**
  71667. * Defines an optimization used to increase or decrease the rendering resolution
  71668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71669. */
  71670. export class HardwareScalingOptimization extends SceneOptimization {
  71671. /**
  71672. * Defines the priority of this optimization (0 by default which means first in the list)
  71673. */
  71674. priority: number;
  71675. /**
  71676. * Defines the maximum scale to use (2 by default)
  71677. */
  71678. maximumScale: number;
  71679. /**
  71680. * Defines the step to use between two passes (0.5 by default)
  71681. */
  71682. step: number;
  71683. private _currentScale;
  71684. private _directionOffset;
  71685. /**
  71686. * Gets a string describing the action executed by the current optimization
  71687. * @return description string
  71688. */
  71689. getDescription(): string;
  71690. /**
  71691. * Creates the HardwareScalingOptimization object
  71692. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71693. * @param maximumScale defines the maximum scale to use (2 by default)
  71694. * @param step defines the step to use between two passes (0.5 by default)
  71695. */
  71696. constructor(
  71697. /**
  71698. * Defines the priority of this optimization (0 by default which means first in the list)
  71699. */
  71700. priority?: number,
  71701. /**
  71702. * Defines the maximum scale to use (2 by default)
  71703. */
  71704. maximumScale?: number,
  71705. /**
  71706. * Defines the step to use between two passes (0.5 by default)
  71707. */
  71708. step?: number);
  71709. /**
  71710. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71711. * @param scene defines the current scene where to apply this optimization
  71712. * @param optimizer defines the current optimizer
  71713. * @returns true if everything that can be done was applied
  71714. */
  71715. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71716. }
  71717. /**
  71718. * Defines an optimization used to remove shadows
  71719. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71720. */
  71721. export class ShadowsOptimization extends SceneOptimization {
  71722. /**
  71723. * Gets a string describing the action executed by the current optimization
  71724. * @return description string
  71725. */
  71726. getDescription(): string;
  71727. /**
  71728. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71729. * @param scene defines the current scene where to apply this optimization
  71730. * @param optimizer defines the current optimizer
  71731. * @returns true if everything that can be done was applied
  71732. */
  71733. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71734. }
  71735. /**
  71736. * Defines an optimization used to turn post-processes off
  71737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71738. */
  71739. export class PostProcessesOptimization extends SceneOptimization {
  71740. /**
  71741. * Gets a string describing the action executed by the current optimization
  71742. * @return description string
  71743. */
  71744. getDescription(): string;
  71745. /**
  71746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71747. * @param scene defines the current scene where to apply this optimization
  71748. * @param optimizer defines the current optimizer
  71749. * @returns true if everything that can be done was applied
  71750. */
  71751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71752. }
  71753. /**
  71754. * Defines an optimization used to turn lens flares off
  71755. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71756. */
  71757. export class LensFlaresOptimization extends SceneOptimization {
  71758. /**
  71759. * Gets a string describing the action executed by the current optimization
  71760. * @return description string
  71761. */
  71762. getDescription(): string;
  71763. /**
  71764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71765. * @param scene defines the current scene where to apply this optimization
  71766. * @param optimizer defines the current optimizer
  71767. * @returns true if everything that can be done was applied
  71768. */
  71769. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71770. }
  71771. /**
  71772. * Defines an optimization based on user defined callback.
  71773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71774. */
  71775. export class CustomOptimization extends SceneOptimization {
  71776. /**
  71777. * Callback called to apply the custom optimization.
  71778. */
  71779. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71780. /**
  71781. * Callback called to get custom description
  71782. */
  71783. onGetDescription: () => string;
  71784. /**
  71785. * Gets a string describing the action executed by the current optimization
  71786. * @returns description string
  71787. */
  71788. getDescription(): string;
  71789. /**
  71790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71791. * @param scene defines the current scene where to apply this optimization
  71792. * @param optimizer defines the current optimizer
  71793. * @returns true if everything that can be done was applied
  71794. */
  71795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71796. }
  71797. /**
  71798. * Defines an optimization used to turn particles off
  71799. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71800. */
  71801. export class ParticlesOptimization extends SceneOptimization {
  71802. /**
  71803. * Gets a string describing the action executed by the current optimization
  71804. * @return description string
  71805. */
  71806. getDescription(): string;
  71807. /**
  71808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71809. * @param scene defines the current scene where to apply this optimization
  71810. * @param optimizer defines the current optimizer
  71811. * @returns true if everything that can be done was applied
  71812. */
  71813. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71814. }
  71815. /**
  71816. * Defines an optimization used to turn render targets off
  71817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71818. */
  71819. export class RenderTargetsOptimization extends SceneOptimization {
  71820. /**
  71821. * Gets a string describing the action executed by the current optimization
  71822. * @return description string
  71823. */
  71824. getDescription(): string;
  71825. /**
  71826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71827. * @param scene defines the current scene where to apply this optimization
  71828. * @param optimizer defines the current optimizer
  71829. * @returns true if everything that can be done was applied
  71830. */
  71831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71832. }
  71833. /**
  71834. * Defines an optimization used to merge meshes with compatible materials
  71835. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71836. */
  71837. export class MergeMeshesOptimization extends SceneOptimization {
  71838. private static _UpdateSelectionTree;
  71839. /**
  71840. * Gets or sets a boolean which defines if optimization octree has to be updated
  71841. */
  71842. static get UpdateSelectionTree(): boolean;
  71843. /**
  71844. * Gets or sets a boolean which defines if optimization octree has to be updated
  71845. */
  71846. static set UpdateSelectionTree(value: boolean);
  71847. /**
  71848. * Gets a string describing the action executed by the current optimization
  71849. * @return description string
  71850. */
  71851. getDescription(): string;
  71852. private _canBeMerged;
  71853. /**
  71854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71855. * @param scene defines the current scene where to apply this optimization
  71856. * @param optimizer defines the current optimizer
  71857. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71858. * @returns true if everything that can be done was applied
  71859. */
  71860. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71861. }
  71862. /**
  71863. * Defines a list of options used by SceneOptimizer
  71864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71865. */
  71866. export class SceneOptimizerOptions {
  71867. /**
  71868. * Defines the target frame rate to reach (60 by default)
  71869. */
  71870. targetFrameRate: number;
  71871. /**
  71872. * Defines the interval between two checkes (2000ms by default)
  71873. */
  71874. trackerDuration: number;
  71875. /**
  71876. * Gets the list of optimizations to apply
  71877. */
  71878. optimizations: SceneOptimization[];
  71879. /**
  71880. * Creates a new list of options used by SceneOptimizer
  71881. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71882. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71883. */
  71884. constructor(
  71885. /**
  71886. * Defines the target frame rate to reach (60 by default)
  71887. */
  71888. targetFrameRate?: number,
  71889. /**
  71890. * Defines the interval between two checkes (2000ms by default)
  71891. */
  71892. trackerDuration?: number);
  71893. /**
  71894. * Add a new optimization
  71895. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71896. * @returns the current SceneOptimizerOptions
  71897. */
  71898. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71899. /**
  71900. * Add a new custom optimization
  71901. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71902. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71903. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71904. * @returns the current SceneOptimizerOptions
  71905. */
  71906. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71907. /**
  71908. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71909. * @param targetFrameRate defines the target frame rate (60 by default)
  71910. * @returns a SceneOptimizerOptions object
  71911. */
  71912. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71913. /**
  71914. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71915. * @param targetFrameRate defines the target frame rate (60 by default)
  71916. * @returns a SceneOptimizerOptions object
  71917. */
  71918. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71919. /**
  71920. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71921. * @param targetFrameRate defines the target frame rate (60 by default)
  71922. * @returns a SceneOptimizerOptions object
  71923. */
  71924. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71925. }
  71926. /**
  71927. * Class used to run optimizations in order to reach a target frame rate
  71928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71929. */
  71930. export class SceneOptimizer implements IDisposable {
  71931. private _isRunning;
  71932. private _options;
  71933. private _scene;
  71934. private _currentPriorityLevel;
  71935. private _targetFrameRate;
  71936. private _trackerDuration;
  71937. private _currentFrameRate;
  71938. private _sceneDisposeObserver;
  71939. private _improvementMode;
  71940. /**
  71941. * Defines an observable called when the optimizer reaches the target frame rate
  71942. */
  71943. onSuccessObservable: Observable<SceneOptimizer>;
  71944. /**
  71945. * Defines an observable called when the optimizer enables an optimization
  71946. */
  71947. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71948. /**
  71949. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71950. */
  71951. onFailureObservable: Observable<SceneOptimizer>;
  71952. /**
  71953. * Gets a boolean indicating if the optimizer is in improvement mode
  71954. */
  71955. get isInImprovementMode(): boolean;
  71956. /**
  71957. * Gets the current priority level (0 at start)
  71958. */
  71959. get currentPriorityLevel(): number;
  71960. /**
  71961. * Gets the current frame rate checked by the SceneOptimizer
  71962. */
  71963. get currentFrameRate(): number;
  71964. /**
  71965. * Gets or sets the current target frame rate (60 by default)
  71966. */
  71967. get targetFrameRate(): number;
  71968. /**
  71969. * Gets or sets the current target frame rate (60 by default)
  71970. */
  71971. set targetFrameRate(value: number);
  71972. /**
  71973. * Gets or sets the current interval between two checks (every 2000ms by default)
  71974. */
  71975. get trackerDuration(): number;
  71976. /**
  71977. * Gets or sets the current interval between two checks (every 2000ms by default)
  71978. */
  71979. set trackerDuration(value: number);
  71980. /**
  71981. * Gets the list of active optimizations
  71982. */
  71983. get optimizations(): SceneOptimization[];
  71984. /**
  71985. * Creates a new SceneOptimizer
  71986. * @param scene defines the scene to work on
  71987. * @param options defines the options to use with the SceneOptimizer
  71988. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71989. * @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)
  71990. */
  71991. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71992. /**
  71993. * Stops the current optimizer
  71994. */
  71995. stop(): void;
  71996. /**
  71997. * Reset the optimizer to initial step (current priority level = 0)
  71998. */
  71999. reset(): void;
  72000. /**
  72001. * Start the optimizer. By default it will try to reach a specific framerate
  72002. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72003. */
  72004. start(): void;
  72005. private _checkCurrentState;
  72006. /**
  72007. * Release all resources
  72008. */
  72009. dispose(): void;
  72010. /**
  72011. * Helper function to create a SceneOptimizer with one single line of code
  72012. * @param scene defines the scene to work on
  72013. * @param options defines the options to use with the SceneOptimizer
  72014. * @param onSuccess defines a callback to call on success
  72015. * @param onFailure defines a callback to call on failure
  72016. * @returns the new SceneOptimizer object
  72017. */
  72018. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72019. }
  72020. }
  72021. declare module "babylonjs/Misc/sceneSerializer" {
  72022. import { Scene } from "babylonjs/scene";
  72023. /**
  72024. * Class used to serialize a scene into a string
  72025. */
  72026. export class SceneSerializer {
  72027. /**
  72028. * Clear cache used by a previous serialization
  72029. */
  72030. static ClearCache(): void;
  72031. /**
  72032. * Serialize a scene into a JSON compatible object
  72033. * @param scene defines the scene to serialize
  72034. * @returns a JSON compatible object
  72035. */
  72036. static Serialize(scene: Scene): any;
  72037. /**
  72038. * Serialize a mesh into a JSON compatible object
  72039. * @param toSerialize defines the mesh to serialize
  72040. * @param withParents defines if parents must be serialized as well
  72041. * @param withChildren defines if children must be serialized as well
  72042. * @returns a JSON compatible object
  72043. */
  72044. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72045. }
  72046. }
  72047. declare module "babylonjs/Misc/textureTools" {
  72048. import { Texture } from "babylonjs/Materials/Textures/texture";
  72049. /**
  72050. * Class used to host texture specific utilities
  72051. */
  72052. export class TextureTools {
  72053. /**
  72054. * Uses the GPU to create a copy texture rescaled at a given size
  72055. * @param texture Texture to copy from
  72056. * @param width defines the desired width
  72057. * @param height defines the desired height
  72058. * @param useBilinearMode defines if bilinear mode has to be used
  72059. * @return the generated texture
  72060. */
  72061. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72062. }
  72063. }
  72064. declare module "babylonjs/Misc/videoRecorder" {
  72065. import { Nullable } from "babylonjs/types";
  72066. import { Engine } from "babylonjs/Engines/engine";
  72067. /**
  72068. * This represents the different options available for the video capture.
  72069. */
  72070. export interface VideoRecorderOptions {
  72071. /** Defines the mime type of the video. */
  72072. mimeType: string;
  72073. /** Defines the FPS the video should be recorded at. */
  72074. fps: number;
  72075. /** Defines the chunk size for the recording data. */
  72076. recordChunckSize: number;
  72077. /** The audio tracks to attach to the recording. */
  72078. audioTracks?: MediaStreamTrack[];
  72079. }
  72080. /**
  72081. * This can help with recording videos from BabylonJS.
  72082. * This is based on the available WebRTC functionalities of the browser.
  72083. *
  72084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72085. */
  72086. export class VideoRecorder {
  72087. private static readonly _defaultOptions;
  72088. /**
  72089. * Returns whether or not the VideoRecorder is available in your browser.
  72090. * @param engine Defines the Babylon Engine.
  72091. * @returns true if supported otherwise false.
  72092. */
  72093. static IsSupported(engine: Engine): boolean;
  72094. private readonly _options;
  72095. private _canvas;
  72096. private _mediaRecorder;
  72097. private _recordedChunks;
  72098. private _fileName;
  72099. private _resolve;
  72100. private _reject;
  72101. /**
  72102. * True when a recording is already in progress.
  72103. */
  72104. get isRecording(): boolean;
  72105. /**
  72106. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72107. * @param engine Defines the BabylonJS Engine you wish to record.
  72108. * @param options Defines options that can be used to customize the capture.
  72109. */
  72110. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72111. /**
  72112. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72113. */
  72114. stopRecording(): void;
  72115. /**
  72116. * Starts recording the canvas for a max duration specified in parameters.
  72117. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72118. * If null no automatic download will start and you can rely on the promise to get the data back.
  72119. * @param maxDuration Defines the maximum recording time in seconds.
  72120. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72121. * @return A promise callback at the end of the recording with the video data in Blob.
  72122. */
  72123. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72124. /**
  72125. * Releases internal resources used during the recording.
  72126. */
  72127. dispose(): void;
  72128. private _handleDataAvailable;
  72129. private _handleError;
  72130. private _handleStop;
  72131. }
  72132. }
  72133. declare module "babylonjs/Misc/screenshotTools" {
  72134. import { Camera } from "babylonjs/Cameras/camera";
  72135. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72136. import { Engine } from "babylonjs/Engines/engine";
  72137. /**
  72138. * Class containing a set of static utilities functions for screenshots
  72139. */
  72140. export class ScreenshotTools {
  72141. /**
  72142. * Captures a screenshot of the current rendering
  72143. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72144. * @param engine defines the rendering engine
  72145. * @param camera defines the source camera
  72146. * @param size This parameter can be set to a single number or to an object with the
  72147. * following (optional) properties: precision, width, height. If a single number is passed,
  72148. * it will be used for both width and height. If an object is passed, the screenshot size
  72149. * will be derived from the parameters. The precision property is a multiplier allowing
  72150. * rendering at a higher or lower resolution
  72151. * @param successCallback defines the callback receives a single parameter which contains the
  72152. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72153. * src parameter of an <img> to display it
  72154. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72155. * Check your browser for supported MIME types
  72156. */
  72157. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72158. /**
  72159. * Captures a screenshot of the current rendering
  72160. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72161. * @param engine defines the rendering engine
  72162. * @param camera defines the source camera
  72163. * @param size This parameter can be set to a single number or to an object with the
  72164. * following (optional) properties: precision, width, height. If a single number is passed,
  72165. * it will be used for both width and height. If an object is passed, the screenshot size
  72166. * will be derived from the parameters. The precision property is a multiplier allowing
  72167. * rendering at a higher or lower resolution
  72168. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72169. * Check your browser for supported MIME types
  72170. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72171. * to the src parameter of an <img> to display it
  72172. */
  72173. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72174. /**
  72175. * Generates an image screenshot from the specified camera.
  72176. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72177. * @param engine The engine to use for rendering
  72178. * @param camera The camera to use for rendering
  72179. * @param size This parameter can be set to a single number or to an object with the
  72180. * following (optional) properties: precision, width, height. If a single number is passed,
  72181. * it will be used for both width and height. If an object is passed, the screenshot size
  72182. * will be derived from the parameters. The precision property is a multiplier allowing
  72183. * rendering at a higher or lower resolution
  72184. * @param successCallback The callback receives a single parameter which contains the
  72185. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72186. * src parameter of an <img> to display it
  72187. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72188. * Check your browser for supported MIME types
  72189. * @param samples Texture samples (default: 1)
  72190. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72191. * @param fileName A name for for the downloaded file.
  72192. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72193. */
  72194. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72195. /**
  72196. * Generates an image screenshot from the specified camera.
  72197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72198. * @param engine The engine to use for rendering
  72199. * @param camera The camera to use for rendering
  72200. * @param size This parameter can be set to a single number or to an object with the
  72201. * following (optional) properties: precision, width, height. If a single number is passed,
  72202. * it will be used for both width and height. If an object is passed, the screenshot size
  72203. * will be derived from the parameters. The precision property is a multiplier allowing
  72204. * rendering at a higher or lower resolution
  72205. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72206. * Check your browser for supported MIME types
  72207. * @param samples Texture samples (default: 1)
  72208. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72209. * @param fileName A name for for the downloaded file.
  72210. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72211. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72212. * to the src parameter of an <img> to display it
  72213. */
  72214. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72215. /**
  72216. * Gets height and width for screenshot size
  72217. * @private
  72218. */
  72219. private static _getScreenshotSize;
  72220. }
  72221. }
  72222. declare module "babylonjs/Misc/dataReader" {
  72223. /**
  72224. * Interface for a data buffer
  72225. */
  72226. export interface IDataBuffer {
  72227. /**
  72228. * Reads bytes from the data buffer.
  72229. * @param byteOffset The byte offset to read
  72230. * @param byteLength The byte length to read
  72231. * @returns A promise that resolves when the bytes are read
  72232. */
  72233. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72234. /**
  72235. * The byte length of the buffer.
  72236. */
  72237. readonly byteLength: number;
  72238. }
  72239. /**
  72240. * Utility class for reading from a data buffer
  72241. */
  72242. export class DataReader {
  72243. /**
  72244. * The data buffer associated with this data reader.
  72245. */
  72246. readonly buffer: IDataBuffer;
  72247. /**
  72248. * The current byte offset from the beginning of the data buffer.
  72249. */
  72250. byteOffset: number;
  72251. private _dataView;
  72252. private _dataByteOffset;
  72253. /**
  72254. * Constructor
  72255. * @param buffer The buffer to read
  72256. */
  72257. constructor(buffer: IDataBuffer);
  72258. /**
  72259. * Loads the given byte length.
  72260. * @param byteLength The byte length to load
  72261. * @returns A promise that resolves when the load is complete
  72262. */
  72263. loadAsync(byteLength: number): Promise<void>;
  72264. /**
  72265. * Read a unsigned 32-bit integer from the currently loaded data range.
  72266. * @returns The 32-bit integer read
  72267. */
  72268. readUint32(): number;
  72269. /**
  72270. * Read a byte array from the currently loaded data range.
  72271. * @param byteLength The byte length to read
  72272. * @returns The byte array read
  72273. */
  72274. readUint8Array(byteLength: number): Uint8Array;
  72275. /**
  72276. * Read a string from the currently loaded data range.
  72277. * @param byteLength The byte length to read
  72278. * @returns The string read
  72279. */
  72280. readString(byteLength: number): string;
  72281. /**
  72282. * Skips the given byte length the currently loaded data range.
  72283. * @param byteLength The byte length to skip
  72284. */
  72285. skipBytes(byteLength: number): void;
  72286. }
  72287. }
  72288. declare module "babylonjs/Misc/index" {
  72289. export * from "babylonjs/Misc/andOrNotEvaluator";
  72290. export * from "babylonjs/Misc/assetsManager";
  72291. export * from "babylonjs/Misc/basis";
  72292. export * from "babylonjs/Misc/dds";
  72293. export * from "babylonjs/Misc/decorators";
  72294. export * from "babylonjs/Misc/deferred";
  72295. export * from "babylonjs/Misc/environmentTextureTools";
  72296. export * from "babylonjs/Misc/meshExploder";
  72297. export * from "babylonjs/Misc/filesInput";
  72298. export * from "babylonjs/Misc/HighDynamicRange/index";
  72299. export * from "babylonjs/Misc/khronosTextureContainer";
  72300. export * from "babylonjs/Misc/observable";
  72301. export * from "babylonjs/Misc/performanceMonitor";
  72302. export * from "babylonjs/Misc/promise";
  72303. export * from "babylonjs/Misc/sceneOptimizer";
  72304. export * from "babylonjs/Misc/sceneSerializer";
  72305. export * from "babylonjs/Misc/smartArray";
  72306. export * from "babylonjs/Misc/stringDictionary";
  72307. export * from "babylonjs/Misc/tags";
  72308. export * from "babylonjs/Misc/textureTools";
  72309. export * from "babylonjs/Misc/tga";
  72310. export * from "babylonjs/Misc/tools";
  72311. export * from "babylonjs/Misc/videoRecorder";
  72312. export * from "babylonjs/Misc/virtualJoystick";
  72313. export * from "babylonjs/Misc/workerPool";
  72314. export * from "babylonjs/Misc/logger";
  72315. export * from "babylonjs/Misc/typeStore";
  72316. export * from "babylonjs/Misc/filesInputStore";
  72317. export * from "babylonjs/Misc/deepCopier";
  72318. export * from "babylonjs/Misc/pivotTools";
  72319. export * from "babylonjs/Misc/precisionDate";
  72320. export * from "babylonjs/Misc/screenshotTools";
  72321. export * from "babylonjs/Misc/typeStore";
  72322. export * from "babylonjs/Misc/webRequest";
  72323. export * from "babylonjs/Misc/iInspectable";
  72324. export * from "babylonjs/Misc/brdfTextureTools";
  72325. export * from "babylonjs/Misc/rgbdTextureTools";
  72326. export * from "babylonjs/Misc/gradients";
  72327. export * from "babylonjs/Misc/perfCounter";
  72328. export * from "babylonjs/Misc/fileRequest";
  72329. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72330. export * from "babylonjs/Misc/retryStrategy";
  72331. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72332. export * from "babylonjs/Misc/canvasGenerator";
  72333. export * from "babylonjs/Misc/fileTools";
  72334. export * from "babylonjs/Misc/stringTools";
  72335. export * from "babylonjs/Misc/dataReader";
  72336. export * from "babylonjs/Misc/minMaxReducer";
  72337. export * from "babylonjs/Misc/depthReducer";
  72338. }
  72339. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72340. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72341. import { Observable } from "babylonjs/Misc/observable";
  72342. import { Matrix } from "babylonjs/Maths/math.vector";
  72343. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72344. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72345. /**
  72346. * Options used for hit testing
  72347. */
  72348. export interface IWebXRHitTestOptions {
  72349. /**
  72350. * Only test when user interacted with the scene. Default - hit test every frame
  72351. */
  72352. testOnPointerDownOnly?: boolean;
  72353. /**
  72354. * The node to use to transform the local results to world coordinates
  72355. */
  72356. worldParentNode?: TransformNode;
  72357. }
  72358. /**
  72359. * Interface defining the babylon result of raycasting/hit-test
  72360. */
  72361. export interface IWebXRHitResult {
  72362. /**
  72363. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72364. */
  72365. transformationMatrix: Matrix;
  72366. /**
  72367. * The native hit test result
  72368. */
  72369. xrHitResult: XRHitResult;
  72370. }
  72371. /**
  72372. * The currently-working hit-test module.
  72373. * Hit test (or Ray-casting) is used to interact with the real world.
  72374. * For further information read here - https://github.com/immersive-web/hit-test
  72375. */
  72376. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72377. /**
  72378. * options to use when constructing this feature
  72379. */
  72380. readonly options: IWebXRHitTestOptions;
  72381. private _direction;
  72382. private _mat;
  72383. private _onSelectEnabled;
  72384. private _origin;
  72385. /**
  72386. * The module's name
  72387. */
  72388. static readonly Name: string;
  72389. /**
  72390. * The (Babylon) version of this module.
  72391. * This is an integer representing the implementation version.
  72392. * This number does not correspond to the WebXR specs version
  72393. */
  72394. static readonly Version: number;
  72395. /**
  72396. * Populated with the last native XR Hit Results
  72397. */
  72398. lastNativeXRHitResults: XRHitResult[];
  72399. /**
  72400. * Triggered when new babylon (transformed) hit test results are available
  72401. */
  72402. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72403. /**
  72404. * Creates a new instance of the (legacy version) hit test feature
  72405. * @param _xrSessionManager an instance of WebXRSessionManager
  72406. * @param options options to use when constructing this feature
  72407. */
  72408. constructor(_xrSessionManager: WebXRSessionManager,
  72409. /**
  72410. * options to use when constructing this feature
  72411. */
  72412. options?: IWebXRHitTestOptions);
  72413. /**
  72414. * execute a hit test with an XR Ray
  72415. *
  72416. * @param xrSession a native xrSession that will execute this hit test
  72417. * @param xrRay the ray (position and direction) to use for ray-casting
  72418. * @param referenceSpace native XR reference space to use for the hit-test
  72419. * @param filter filter function that will filter the results
  72420. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72421. */
  72422. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72423. /**
  72424. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72425. * @param event the (select) event to use to select with
  72426. * @param referenceSpace the reference space to use for this hit test
  72427. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72428. */
  72429. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72430. /**
  72431. * attach this feature
  72432. * Will usually be called by the features manager
  72433. *
  72434. * @returns true if successful.
  72435. */
  72436. attach(): boolean;
  72437. /**
  72438. * detach this feature.
  72439. * Will usually be called by the features manager
  72440. *
  72441. * @returns true if successful.
  72442. */
  72443. detach(): boolean;
  72444. /**
  72445. * Dispose this feature and all of the resources attached
  72446. */
  72447. dispose(): void;
  72448. protected _onXRFrame(frame: XRFrame): void;
  72449. private _onHitTestResults;
  72450. private _onSelect;
  72451. }
  72452. }
  72453. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72455. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72456. import { Observable } from "babylonjs/Misc/observable";
  72457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72458. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72459. /**
  72460. * Options used in the plane detector module
  72461. */
  72462. export interface IWebXRPlaneDetectorOptions {
  72463. /**
  72464. * The node to use to transform the local results to world coordinates
  72465. */
  72466. worldParentNode?: TransformNode;
  72467. }
  72468. /**
  72469. * A babylon interface for a WebXR plane.
  72470. * A Plane is actually a polygon, built from N points in space
  72471. *
  72472. * Supported in chrome 79, not supported in canary 81 ATM
  72473. */
  72474. export interface IWebXRPlane {
  72475. /**
  72476. * a babylon-assigned ID for this polygon
  72477. */
  72478. id: number;
  72479. /**
  72480. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72481. */
  72482. polygonDefinition: Array<Vector3>;
  72483. /**
  72484. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72485. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72486. */
  72487. transformationMatrix: Matrix;
  72488. /**
  72489. * the native xr-plane object
  72490. */
  72491. xrPlane: XRPlane;
  72492. }
  72493. /**
  72494. * The plane detector is used to detect planes in the real world when in AR
  72495. * For more information see https://github.com/immersive-web/real-world-geometry/
  72496. */
  72497. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72498. private _options;
  72499. private _detectedPlanes;
  72500. private _enabled;
  72501. private _lastFrameDetected;
  72502. /**
  72503. * The module's name
  72504. */
  72505. static readonly Name: string;
  72506. /**
  72507. * The (Babylon) version of this module.
  72508. * This is an integer representing the implementation version.
  72509. * This number does not correspond to the WebXR specs version
  72510. */
  72511. static readonly Version: number;
  72512. /**
  72513. * Observers registered here will be executed when a new plane was added to the session
  72514. */
  72515. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72516. /**
  72517. * Observers registered here will be executed when a plane is no longer detected in the session
  72518. */
  72519. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72520. /**
  72521. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72522. * This can execute N times every frame
  72523. */
  72524. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72525. /**
  72526. * construct a new Plane Detector
  72527. * @param _xrSessionManager an instance of xr Session manager
  72528. * @param _options configuration to use when constructing this feature
  72529. */
  72530. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72531. /**
  72532. * Dispose this feature and all of the resources attached
  72533. */
  72534. dispose(): void;
  72535. protected _onXRFrame(frame: XRFrame): void;
  72536. private _init;
  72537. private _updatePlaneWithXRPlane;
  72538. /**
  72539. * avoiding using Array.find for global support.
  72540. * @param xrPlane the plane to find in the array
  72541. */
  72542. private findIndexInPlaneArray;
  72543. }
  72544. }
  72545. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72546. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72547. import { Observable } from "babylonjs/Misc/observable";
  72548. import { Matrix } from "babylonjs/Maths/math.vector";
  72549. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72550. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72551. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72552. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72553. /**
  72554. * Configuration options of the anchor system
  72555. */
  72556. export interface IWebXRAnchorSystemOptions {
  72557. /**
  72558. * Should a new anchor be added every time a select event is triggered
  72559. */
  72560. addAnchorOnSelect?: boolean;
  72561. /**
  72562. * should the anchor system use plane detection.
  72563. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72564. */
  72565. usePlaneDetection?: boolean;
  72566. /**
  72567. * a node that will be used to convert local to world coordinates
  72568. */
  72569. worldParentNode?: TransformNode;
  72570. }
  72571. /**
  72572. * A babylon container for an XR Anchor
  72573. */
  72574. export interface IWebXRAnchor {
  72575. /**
  72576. * A babylon-assigned ID for this anchor
  72577. */
  72578. id: number;
  72579. /**
  72580. * Transformation matrix to apply to an object attached to this anchor
  72581. */
  72582. transformationMatrix: Matrix;
  72583. /**
  72584. * The native anchor object
  72585. */
  72586. xrAnchor: XRAnchor;
  72587. }
  72588. /**
  72589. * An implementation of the anchor system of WebXR.
  72590. * Note that the current documented implementation is not available in any browser. Future implementations
  72591. * will use the frame to create an anchor and not the session or a detected plane
  72592. * For further information see https://github.com/immersive-web/anchors/
  72593. */
  72594. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72595. private _options;
  72596. private _enabled;
  72597. private _hitTestModule;
  72598. private _lastFrameDetected;
  72599. private _onSelect;
  72600. private _planeDetector;
  72601. private _trackedAnchors;
  72602. /**
  72603. * The module's name
  72604. */
  72605. static readonly Name: string;
  72606. /**
  72607. * The (Babylon) version of this module.
  72608. * This is an integer representing the implementation version.
  72609. * This number does not correspond to the WebXR specs version
  72610. */
  72611. static readonly Version: number;
  72612. /**
  72613. * Observers registered here will be executed when a new anchor was added to the session
  72614. */
  72615. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72616. /**
  72617. * Observers registered here will be executed when an anchor was removed from the session
  72618. */
  72619. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72620. /**
  72621. * Observers registered here will be executed when an existing anchor updates
  72622. * This can execute N times every frame
  72623. */
  72624. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72625. /**
  72626. * constructs a new anchor system
  72627. * @param _xrSessionManager an instance of WebXRSessionManager
  72628. * @param _options configuration object for this feature
  72629. */
  72630. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72631. /**
  72632. * Add anchor at a specific XR point.
  72633. *
  72634. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72635. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72636. * @returns a promise the fulfills when the anchor was created
  72637. */
  72638. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72639. /**
  72640. * attach this feature
  72641. * Will usually be called by the features manager
  72642. *
  72643. * @returns true if successful.
  72644. */
  72645. attach(): boolean;
  72646. /**
  72647. * detach this feature.
  72648. * Will usually be called by the features manager
  72649. *
  72650. * @returns true if successful.
  72651. */
  72652. detach(): boolean;
  72653. /**
  72654. * Dispose this feature and all of the resources attached
  72655. */
  72656. dispose(): void;
  72657. /**
  72658. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72659. * @param hitTestModule the hit-test module to use.
  72660. */
  72661. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72662. /**
  72663. * set the plane detector to use in order to create anchors from frames
  72664. * @param planeDetector the plane-detector module to use
  72665. * @param enable enable plane-anchors. default is true
  72666. */
  72667. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72668. protected _onXRFrame(frame: XRFrame): void;
  72669. /**
  72670. * avoiding using Array.find for global support.
  72671. * @param xrAnchor the plane to find in the array
  72672. */
  72673. private _findIndexInAnchorArray;
  72674. private _updateAnchorWithXRFrame;
  72675. }
  72676. }
  72677. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72678. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72680. import { Observable } from "babylonjs/Misc/observable";
  72681. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72682. /**
  72683. * Options interface for the background remover plugin
  72684. */
  72685. export interface IWebXRBackgroundRemoverOptions {
  72686. /**
  72687. * Further background meshes to disable when entering AR
  72688. */
  72689. backgroundMeshes?: AbstractMesh[];
  72690. /**
  72691. * flags to configure the removal of the environment helper.
  72692. * If not set, the entire background will be removed. If set, flags should be set as well.
  72693. */
  72694. environmentHelperRemovalFlags?: {
  72695. /**
  72696. * Should the skybox be removed (default false)
  72697. */
  72698. skyBox?: boolean;
  72699. /**
  72700. * Should the ground be removed (default false)
  72701. */
  72702. ground?: boolean;
  72703. };
  72704. /**
  72705. * don't disable the environment helper
  72706. */
  72707. ignoreEnvironmentHelper?: boolean;
  72708. }
  72709. /**
  72710. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72711. */
  72712. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72713. /**
  72714. * read-only options to be used in this module
  72715. */
  72716. readonly options: IWebXRBackgroundRemoverOptions;
  72717. /**
  72718. * The module's name
  72719. */
  72720. static readonly Name: string;
  72721. /**
  72722. * The (Babylon) version of this module.
  72723. * This is an integer representing the implementation version.
  72724. * This number does not correspond to the WebXR specs version
  72725. */
  72726. static readonly Version: number;
  72727. /**
  72728. * registered observers will be triggered when the background state changes
  72729. */
  72730. onBackgroundStateChangedObservable: Observable<boolean>;
  72731. /**
  72732. * constructs a new background remover module
  72733. * @param _xrSessionManager the session manager for this module
  72734. * @param options read-only options to be used in this module
  72735. */
  72736. constructor(_xrSessionManager: WebXRSessionManager,
  72737. /**
  72738. * read-only options to be used in this module
  72739. */
  72740. options?: IWebXRBackgroundRemoverOptions);
  72741. /**
  72742. * attach this feature
  72743. * Will usually be called by the features manager
  72744. *
  72745. * @returns true if successful.
  72746. */
  72747. attach(): boolean;
  72748. /**
  72749. * detach this feature.
  72750. * Will usually be called by the features manager
  72751. *
  72752. * @returns true if successful.
  72753. */
  72754. detach(): boolean;
  72755. /**
  72756. * Dispose this feature and all of the resources attached
  72757. */
  72758. dispose(): void;
  72759. protected _onXRFrame(_xrFrame: XRFrame): void;
  72760. private _setBackgroundState;
  72761. }
  72762. }
  72763. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72764. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72765. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72766. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72767. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72768. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72769. import { Nullable } from "babylonjs/types";
  72770. /**
  72771. * Options for the controller physics feature
  72772. */
  72773. export class IWebXRControllerPhysicsOptions {
  72774. /**
  72775. * Should the headset get its own impostor
  72776. */
  72777. enableHeadsetImpostor?: boolean;
  72778. /**
  72779. * Optional parameters for the headset impostor
  72780. */
  72781. headsetImpostorParams?: {
  72782. /**
  72783. * The type of impostor to create. Default is sphere
  72784. */
  72785. impostorType: number;
  72786. /**
  72787. * the size of the impostor. Defaults to 10cm
  72788. */
  72789. impostorSize?: number | {
  72790. width: number;
  72791. height: number;
  72792. depth: number;
  72793. };
  72794. /**
  72795. * Friction definitions
  72796. */
  72797. friction?: number;
  72798. /**
  72799. * Restitution
  72800. */
  72801. restitution?: number;
  72802. };
  72803. /**
  72804. * The physics properties of the future impostors
  72805. */
  72806. physicsProperties?: {
  72807. /**
  72808. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72809. * Note that this requires a physics engine that supports mesh impostors!
  72810. */
  72811. useControllerMesh?: boolean;
  72812. /**
  72813. * The type of impostor to create. Default is sphere
  72814. */
  72815. impostorType?: number;
  72816. /**
  72817. * the size of the impostor. Defaults to 10cm
  72818. */
  72819. impostorSize?: number | {
  72820. width: number;
  72821. height: number;
  72822. depth: number;
  72823. };
  72824. /**
  72825. * Friction definitions
  72826. */
  72827. friction?: number;
  72828. /**
  72829. * Restitution
  72830. */
  72831. restitution?: number;
  72832. };
  72833. /**
  72834. * the xr input to use with this pointer selection
  72835. */
  72836. xrInput: WebXRInput;
  72837. }
  72838. /**
  72839. * Add physics impostor to your webxr controllers,
  72840. * including naive calculation of their linear and angular velocity
  72841. */
  72842. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72843. private readonly _options;
  72844. private _attachController;
  72845. private _controllers;
  72846. private _debugMode;
  72847. private _delta;
  72848. private _headsetImpostor?;
  72849. private _headsetMesh?;
  72850. private _lastTimestamp;
  72851. private _tmpQuaternion;
  72852. private _tmpVector;
  72853. /**
  72854. * The module's name
  72855. */
  72856. static readonly Name: string;
  72857. /**
  72858. * The (Babylon) version of this module.
  72859. * This is an integer representing the implementation version.
  72860. * This number does not correspond to the webxr specs version
  72861. */
  72862. static readonly Version: number;
  72863. /**
  72864. * Construct a new Controller Physics Feature
  72865. * @param _xrSessionManager the corresponding xr session manager
  72866. * @param _options options to create this feature with
  72867. */
  72868. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72869. /**
  72870. * @hidden
  72871. * enable debugging - will show console outputs and the impostor mesh
  72872. */
  72873. _enablePhysicsDebug(): void;
  72874. /**
  72875. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72876. * @param xrController the controller to add
  72877. */
  72878. addController(xrController: WebXRInputSource): void;
  72879. /**
  72880. * attach this feature
  72881. * Will usually be called by the features manager
  72882. *
  72883. * @returns true if successful.
  72884. */
  72885. attach(): boolean;
  72886. /**
  72887. * detach this feature.
  72888. * Will usually be called by the features manager
  72889. *
  72890. * @returns true if successful.
  72891. */
  72892. detach(): boolean;
  72893. /**
  72894. * Get the headset impostor, if enabled
  72895. * @returns the impostor
  72896. */
  72897. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72898. /**
  72899. * Get the physics impostor of a specific controller.
  72900. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72901. * @param controller the controller or the controller id of which to get the impostor
  72902. * @returns the impostor or null
  72903. */
  72904. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72905. /**
  72906. * Update the physics properties provided in the constructor
  72907. * @param newProperties the new properties object
  72908. */
  72909. setPhysicsProperties(newProperties: {
  72910. impostorType?: number;
  72911. impostorSize?: number | {
  72912. width: number;
  72913. height: number;
  72914. depth: number;
  72915. };
  72916. friction?: number;
  72917. restitution?: number;
  72918. }): void;
  72919. protected _onXRFrame(_xrFrame: any): void;
  72920. private _detachController;
  72921. }
  72922. }
  72923. declare module "babylonjs/XR/features/index" {
  72924. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72925. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72926. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72927. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72928. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72929. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72930. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72931. }
  72932. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72933. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72935. import { Scene } from "babylonjs/scene";
  72936. /**
  72937. * The motion controller class for all microsoft mixed reality controllers
  72938. */
  72939. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72940. protected readonly _mapping: {
  72941. defaultButton: {
  72942. "valueNodeName": string;
  72943. "unpressedNodeName": string;
  72944. "pressedNodeName": string;
  72945. };
  72946. defaultAxis: {
  72947. "valueNodeName": string;
  72948. "minNodeName": string;
  72949. "maxNodeName": string;
  72950. };
  72951. buttons: {
  72952. "xr-standard-trigger": {
  72953. "rootNodeName": string;
  72954. "componentProperty": string;
  72955. "states": string[];
  72956. };
  72957. "xr-standard-squeeze": {
  72958. "rootNodeName": string;
  72959. "componentProperty": string;
  72960. "states": string[];
  72961. };
  72962. "xr-standard-touchpad": {
  72963. "rootNodeName": string;
  72964. "labelAnchorNodeName": string;
  72965. "touchPointNodeName": string;
  72966. };
  72967. "xr-standard-thumbstick": {
  72968. "rootNodeName": string;
  72969. "componentProperty": string;
  72970. "states": string[];
  72971. };
  72972. };
  72973. axes: {
  72974. "xr-standard-touchpad": {
  72975. "x-axis": {
  72976. "rootNodeName": string;
  72977. };
  72978. "y-axis": {
  72979. "rootNodeName": string;
  72980. };
  72981. };
  72982. "xr-standard-thumbstick": {
  72983. "x-axis": {
  72984. "rootNodeName": string;
  72985. };
  72986. "y-axis": {
  72987. "rootNodeName": string;
  72988. };
  72989. };
  72990. };
  72991. };
  72992. /**
  72993. * The base url used to load the left and right controller models
  72994. */
  72995. static MODEL_BASE_URL: string;
  72996. /**
  72997. * The name of the left controller model file
  72998. */
  72999. static MODEL_LEFT_FILENAME: string;
  73000. /**
  73001. * The name of the right controller model file
  73002. */
  73003. static MODEL_RIGHT_FILENAME: string;
  73004. profileId: string;
  73005. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73006. protected _getFilenameAndPath(): {
  73007. filename: string;
  73008. path: string;
  73009. };
  73010. protected _getModelLoadingConstraints(): boolean;
  73011. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73012. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73013. protected _updateModel(): void;
  73014. }
  73015. }
  73016. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73017. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73019. import { Scene } from "babylonjs/scene";
  73020. /**
  73021. * The motion controller class for oculus touch (quest, rift).
  73022. * This class supports legacy mapping as well the standard xr mapping
  73023. */
  73024. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73025. private _forceLegacyControllers;
  73026. private _modelRootNode;
  73027. /**
  73028. * The base url used to load the left and right controller models
  73029. */
  73030. static MODEL_BASE_URL: string;
  73031. /**
  73032. * The name of the left controller model file
  73033. */
  73034. static MODEL_LEFT_FILENAME: string;
  73035. /**
  73036. * The name of the right controller model file
  73037. */
  73038. static MODEL_RIGHT_FILENAME: string;
  73039. /**
  73040. * Base Url for the Quest controller model.
  73041. */
  73042. static QUEST_MODEL_BASE_URL: string;
  73043. profileId: string;
  73044. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73045. protected _getFilenameAndPath(): {
  73046. filename: string;
  73047. path: string;
  73048. };
  73049. protected _getModelLoadingConstraints(): boolean;
  73050. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73051. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73052. protected _updateModel(): void;
  73053. /**
  73054. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73055. * between the touch and touch 2.
  73056. */
  73057. private _isQuest;
  73058. }
  73059. }
  73060. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73061. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73062. import { Scene } from "babylonjs/scene";
  73063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73064. /**
  73065. * The motion controller class for the standard HTC-Vive controllers
  73066. */
  73067. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73068. private _modelRootNode;
  73069. /**
  73070. * The base url used to load the left and right controller models
  73071. */
  73072. static MODEL_BASE_URL: string;
  73073. /**
  73074. * File name for the controller model.
  73075. */
  73076. static MODEL_FILENAME: string;
  73077. profileId: string;
  73078. /**
  73079. * Create a new Vive motion controller object
  73080. * @param scene the scene to use to create this controller
  73081. * @param gamepadObject the corresponding gamepad object
  73082. * @param handness the handness of the controller
  73083. */
  73084. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73085. protected _getFilenameAndPath(): {
  73086. filename: string;
  73087. path: string;
  73088. };
  73089. protected _getModelLoadingConstraints(): boolean;
  73090. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73091. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73092. protected _updateModel(): void;
  73093. }
  73094. }
  73095. declare module "babylonjs/XR/motionController/index" {
  73096. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73097. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73098. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73099. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73100. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73101. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73102. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73103. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73104. }
  73105. declare module "babylonjs/XR/index" {
  73106. export * from "babylonjs/XR/webXRCamera";
  73107. export * from "babylonjs/XR/webXREnterExitUI";
  73108. export * from "babylonjs/XR/webXRExperienceHelper";
  73109. export * from "babylonjs/XR/webXRInput";
  73110. export * from "babylonjs/XR/webXRInputSource";
  73111. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73112. export * from "babylonjs/XR/webXRTypes";
  73113. export * from "babylonjs/XR/webXRSessionManager";
  73114. export * from "babylonjs/XR/webXRDefaultExperience";
  73115. export * from "babylonjs/XR/webXRFeaturesManager";
  73116. export * from "babylonjs/XR/features/index";
  73117. export * from "babylonjs/XR/motionController/index";
  73118. }
  73119. declare module "babylonjs/index" {
  73120. export * from "babylonjs/abstractScene";
  73121. export * from "babylonjs/Actions/index";
  73122. export * from "babylonjs/Animations/index";
  73123. export * from "babylonjs/assetContainer";
  73124. export * from "babylonjs/Audio/index";
  73125. export * from "babylonjs/Behaviors/index";
  73126. export * from "babylonjs/Bones/index";
  73127. export * from "babylonjs/Cameras/index";
  73128. export * from "babylonjs/Collisions/index";
  73129. export * from "babylonjs/Culling/index";
  73130. export * from "babylonjs/Debug/index";
  73131. export * from "babylonjs/Engines/index";
  73132. export * from "babylonjs/Events/index";
  73133. export * from "babylonjs/Gamepads/index";
  73134. export * from "babylonjs/Gizmos/index";
  73135. export * from "babylonjs/Helpers/index";
  73136. export * from "babylonjs/Instrumentation/index";
  73137. export * from "babylonjs/Layers/index";
  73138. export * from "babylonjs/LensFlares/index";
  73139. export * from "babylonjs/Lights/index";
  73140. export * from "babylonjs/Loading/index";
  73141. export * from "babylonjs/Materials/index";
  73142. export * from "babylonjs/Maths/index";
  73143. export * from "babylonjs/Meshes/index";
  73144. export * from "babylonjs/Morph/index";
  73145. export * from "babylonjs/Navigation/index";
  73146. export * from "babylonjs/node";
  73147. export * from "babylonjs/Offline/index";
  73148. export * from "babylonjs/Particles/index";
  73149. export * from "babylonjs/Physics/index";
  73150. export * from "babylonjs/PostProcesses/index";
  73151. export * from "babylonjs/Probes/index";
  73152. export * from "babylonjs/Rendering/index";
  73153. export * from "babylonjs/scene";
  73154. export * from "babylonjs/sceneComponent";
  73155. export * from "babylonjs/Sprites/index";
  73156. export * from "babylonjs/States/index";
  73157. export * from "babylonjs/Misc/index";
  73158. export * from "babylonjs/XR/index";
  73159. export * from "babylonjs/types";
  73160. }
  73161. declare module "babylonjs/Animations/pathCursor" {
  73162. import { Vector3 } from "babylonjs/Maths/math.vector";
  73163. import { Path2 } from "babylonjs/Maths/math.path";
  73164. /**
  73165. * A cursor which tracks a point on a path
  73166. */
  73167. export class PathCursor {
  73168. private path;
  73169. /**
  73170. * Stores path cursor callbacks for when an onchange event is triggered
  73171. */
  73172. private _onchange;
  73173. /**
  73174. * The value of the path cursor
  73175. */
  73176. value: number;
  73177. /**
  73178. * The animation array of the path cursor
  73179. */
  73180. animations: Animation[];
  73181. /**
  73182. * Initializes the path cursor
  73183. * @param path The path to track
  73184. */
  73185. constructor(path: Path2);
  73186. /**
  73187. * Gets the cursor point on the path
  73188. * @returns A point on the path cursor at the cursor location
  73189. */
  73190. getPoint(): Vector3;
  73191. /**
  73192. * Moves the cursor ahead by the step amount
  73193. * @param step The amount to move the cursor forward
  73194. * @returns This path cursor
  73195. */
  73196. moveAhead(step?: number): PathCursor;
  73197. /**
  73198. * Moves the cursor behind by the step amount
  73199. * @param step The amount to move the cursor back
  73200. * @returns This path cursor
  73201. */
  73202. moveBack(step?: number): PathCursor;
  73203. /**
  73204. * Moves the cursor by the step amount
  73205. * If the step amount is greater than one, an exception is thrown
  73206. * @param step The amount to move the cursor
  73207. * @returns This path cursor
  73208. */
  73209. move(step: number): PathCursor;
  73210. /**
  73211. * Ensures that the value is limited between zero and one
  73212. * @returns This path cursor
  73213. */
  73214. private ensureLimits;
  73215. /**
  73216. * Runs onchange callbacks on change (used by the animation engine)
  73217. * @returns This path cursor
  73218. */
  73219. private raiseOnChange;
  73220. /**
  73221. * Executes a function on change
  73222. * @param f A path cursor onchange callback
  73223. * @returns This path cursor
  73224. */
  73225. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73226. }
  73227. }
  73228. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73229. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73230. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73231. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73232. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73233. }
  73234. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73235. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73236. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73237. }
  73238. declare module "babylonjs/Engines/Processors/index" {
  73239. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73240. export * from "babylonjs/Engines/Processors/Expressions/index";
  73241. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73242. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73243. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73244. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73245. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73246. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73247. }
  73248. declare module "babylonjs/Legacy/legacy" {
  73249. import * as Babylon from "babylonjs/index";
  73250. export * from "babylonjs/index";
  73251. }
  73252. declare module "babylonjs/Shaders/blur.fragment" {
  73253. /** @hidden */
  73254. export var blurPixelShader: {
  73255. name: string;
  73256. shader: string;
  73257. };
  73258. }
  73259. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73260. /** @hidden */
  73261. export var pointCloudVertexDeclaration: {
  73262. name: string;
  73263. shader: string;
  73264. };
  73265. }
  73266. declare module "babylonjs" {
  73267. export * from "babylonjs/Legacy/legacy";
  73268. }
  73269. declare module BABYLON {
  73270. /** Alias type for value that can be null */
  73271. export type Nullable<T> = T | null;
  73272. /**
  73273. * Alias type for number that are floats
  73274. * @ignorenaming
  73275. */
  73276. export type float = number;
  73277. /**
  73278. * Alias type for number that are doubles.
  73279. * @ignorenaming
  73280. */
  73281. export type double = number;
  73282. /**
  73283. * Alias type for number that are integer
  73284. * @ignorenaming
  73285. */
  73286. export type int = number;
  73287. /** Alias type for number array or Float32Array */
  73288. export type FloatArray = number[] | Float32Array;
  73289. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73290. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73291. /**
  73292. * Alias for types that can be used by a Buffer or VertexBuffer.
  73293. */
  73294. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73295. /**
  73296. * Alias type for primitive types
  73297. * @ignorenaming
  73298. */
  73299. type Primitive = undefined | null | boolean | string | number | Function;
  73300. /**
  73301. * Type modifier to make all the properties of an object Readonly
  73302. */
  73303. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73304. /**
  73305. * Type modifier to make all the properties of an object Readonly recursively
  73306. */
  73307. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73308. /**
  73309. * Type modifier to make object properties readonly.
  73310. */
  73311. export type DeepImmutableObject<T> = {
  73312. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73313. };
  73314. /** @hidden */
  73315. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73316. }
  73317. }
  73318. declare module BABYLON {
  73319. /**
  73320. * A class serves as a medium between the observable and its observers
  73321. */
  73322. export class EventState {
  73323. /**
  73324. * Create a new EventState
  73325. * @param mask defines the mask associated with this state
  73326. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73327. * @param target defines the original target of the state
  73328. * @param currentTarget defines the current target of the state
  73329. */
  73330. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73331. /**
  73332. * Initialize the current event state
  73333. * @param mask defines the mask associated with this state
  73334. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73335. * @param target defines the original target of the state
  73336. * @param currentTarget defines the current target of the state
  73337. * @returns the current event state
  73338. */
  73339. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73340. /**
  73341. * An Observer can set this property to true to prevent subsequent observers of being notified
  73342. */
  73343. skipNextObservers: boolean;
  73344. /**
  73345. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73346. */
  73347. mask: number;
  73348. /**
  73349. * The object that originally notified the event
  73350. */
  73351. target?: any;
  73352. /**
  73353. * The current object in the bubbling phase
  73354. */
  73355. currentTarget?: any;
  73356. /**
  73357. * This will be populated with the return value of the last function that was executed.
  73358. * If it is the first function in the callback chain it will be the event data.
  73359. */
  73360. lastReturnValue?: any;
  73361. }
  73362. /**
  73363. * Represent an Observer registered to a given Observable object.
  73364. */
  73365. export class Observer<T> {
  73366. /**
  73367. * Defines the callback to call when the observer is notified
  73368. */
  73369. callback: (eventData: T, eventState: EventState) => void;
  73370. /**
  73371. * Defines the mask of the observer (used to filter notifications)
  73372. */
  73373. mask: number;
  73374. /**
  73375. * Defines the current scope used to restore the JS context
  73376. */
  73377. scope: any;
  73378. /** @hidden */
  73379. _willBeUnregistered: boolean;
  73380. /**
  73381. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73382. */
  73383. unregisterOnNextCall: boolean;
  73384. /**
  73385. * Creates a new observer
  73386. * @param callback defines the callback to call when the observer is notified
  73387. * @param mask defines the mask of the observer (used to filter notifications)
  73388. * @param scope defines the current scope used to restore the JS context
  73389. */
  73390. constructor(
  73391. /**
  73392. * Defines the callback to call when the observer is notified
  73393. */
  73394. callback: (eventData: T, eventState: EventState) => void,
  73395. /**
  73396. * Defines the mask of the observer (used to filter notifications)
  73397. */
  73398. mask: number,
  73399. /**
  73400. * Defines the current scope used to restore the JS context
  73401. */
  73402. scope?: any);
  73403. }
  73404. /**
  73405. * Represent a list of observers registered to multiple Observables object.
  73406. */
  73407. export class MultiObserver<T> {
  73408. private _observers;
  73409. private _observables;
  73410. /**
  73411. * Release associated resources
  73412. */
  73413. dispose(): void;
  73414. /**
  73415. * Raise a callback when one of the observable will notify
  73416. * @param observables defines a list of observables to watch
  73417. * @param callback defines the callback to call on notification
  73418. * @param mask defines the mask used to filter notifications
  73419. * @param scope defines the current scope used to restore the JS context
  73420. * @returns the new MultiObserver
  73421. */
  73422. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73423. }
  73424. /**
  73425. * The Observable class is a simple implementation of the Observable pattern.
  73426. *
  73427. * 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.
  73428. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73429. * 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).
  73430. * 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.
  73431. */
  73432. export class Observable<T> {
  73433. private _observers;
  73434. private _eventState;
  73435. private _onObserverAdded;
  73436. /**
  73437. * Gets the list of observers
  73438. */
  73439. get observers(): Array<Observer<T>>;
  73440. /**
  73441. * Creates a new observable
  73442. * @param onObserverAdded defines a callback to call when a new observer is added
  73443. */
  73444. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73445. /**
  73446. * Create a new Observer with the specified callback
  73447. * @param callback the callback that will be executed for that Observer
  73448. * @param mask the mask used to filter observers
  73449. * @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.
  73450. * @param scope optional scope for the callback to be called from
  73451. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73452. * @returns the new observer created for the callback
  73453. */
  73454. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73455. /**
  73456. * Create a new Observer with the specified callback and unregisters after the next notification
  73457. * @param callback the callback that will be executed for that Observer
  73458. * @returns the new observer created for the callback
  73459. */
  73460. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73461. /**
  73462. * Remove an Observer from the Observable object
  73463. * @param observer the instance of the Observer to remove
  73464. * @returns false if it doesn't belong to this Observable
  73465. */
  73466. remove(observer: Nullable<Observer<T>>): boolean;
  73467. /**
  73468. * Remove a callback from the Observable object
  73469. * @param callback the callback to remove
  73470. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73471. * @returns false if it doesn't belong to this Observable
  73472. */
  73473. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73474. private _deferUnregister;
  73475. private _remove;
  73476. /**
  73477. * Moves the observable to the top of the observer list making it get called first when notified
  73478. * @param observer the observer to move
  73479. */
  73480. makeObserverTopPriority(observer: Observer<T>): void;
  73481. /**
  73482. * Moves the observable to the bottom of the observer list making it get called last when notified
  73483. * @param observer the observer to move
  73484. */
  73485. makeObserverBottomPriority(observer: Observer<T>): void;
  73486. /**
  73487. * Notify all Observers by calling their respective callback with the given data
  73488. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73489. * @param eventData defines the data to send to all observers
  73490. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73491. * @param target defines the original target of the state
  73492. * @param currentTarget defines the current target of the state
  73493. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73494. */
  73495. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73496. /**
  73497. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73498. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73499. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73500. * and it is crucial that all callbacks will be executed.
  73501. * The order of the callbacks is kept, callbacks are not executed parallel.
  73502. *
  73503. * @param eventData The data to be sent to each callback
  73504. * @param mask is used to filter observers defaults to -1
  73505. * @param target defines the callback target (see EventState)
  73506. * @param currentTarget defines he current object in the bubbling phase
  73507. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73508. */
  73509. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73510. /**
  73511. * Notify a specific observer
  73512. * @param observer defines the observer to notify
  73513. * @param eventData defines the data to be sent to each callback
  73514. * @param mask is used to filter observers defaults to -1
  73515. */
  73516. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73517. /**
  73518. * Gets a boolean indicating if the observable has at least one observer
  73519. * @returns true is the Observable has at least one Observer registered
  73520. */
  73521. hasObservers(): boolean;
  73522. /**
  73523. * Clear the list of observers
  73524. */
  73525. clear(): void;
  73526. /**
  73527. * Clone the current observable
  73528. * @returns a new observable
  73529. */
  73530. clone(): Observable<T>;
  73531. /**
  73532. * Does this observable handles observer registered with a given mask
  73533. * @param mask defines the mask to be tested
  73534. * @return whether or not one observer registered with the given mask is handeled
  73535. **/
  73536. hasSpecificMask(mask?: number): boolean;
  73537. }
  73538. }
  73539. declare module BABYLON {
  73540. /**
  73541. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73542. * Babylon.js
  73543. */
  73544. export class DomManagement {
  73545. /**
  73546. * Checks if the window object exists
  73547. * @returns true if the window object exists
  73548. */
  73549. static IsWindowObjectExist(): boolean;
  73550. /**
  73551. * Checks if the navigator object exists
  73552. * @returns true if the navigator object exists
  73553. */
  73554. static IsNavigatorAvailable(): boolean;
  73555. /**
  73556. * Extracts text content from a DOM element hierarchy
  73557. * @param element defines the root element
  73558. * @returns a string
  73559. */
  73560. static GetDOMTextContent(element: HTMLElement): string;
  73561. }
  73562. }
  73563. declare module BABYLON {
  73564. /**
  73565. * Logger used througouht the application to allow configuration of
  73566. * the log level required for the messages.
  73567. */
  73568. export class Logger {
  73569. /**
  73570. * No log
  73571. */
  73572. static readonly NoneLogLevel: number;
  73573. /**
  73574. * Only message logs
  73575. */
  73576. static readonly MessageLogLevel: number;
  73577. /**
  73578. * Only warning logs
  73579. */
  73580. static readonly WarningLogLevel: number;
  73581. /**
  73582. * Only error logs
  73583. */
  73584. static readonly ErrorLogLevel: number;
  73585. /**
  73586. * All logs
  73587. */
  73588. static readonly AllLogLevel: number;
  73589. private static _LogCache;
  73590. /**
  73591. * Gets a value indicating the number of loading errors
  73592. * @ignorenaming
  73593. */
  73594. static errorsCount: number;
  73595. /**
  73596. * Callback called when a new log is added
  73597. */
  73598. static OnNewCacheEntry: (entry: string) => void;
  73599. private static _AddLogEntry;
  73600. private static _FormatMessage;
  73601. private static _LogDisabled;
  73602. private static _LogEnabled;
  73603. private static _WarnDisabled;
  73604. private static _WarnEnabled;
  73605. private static _ErrorDisabled;
  73606. private static _ErrorEnabled;
  73607. /**
  73608. * Log a message to the console
  73609. */
  73610. static Log: (message: string) => void;
  73611. /**
  73612. * Write a warning message to the console
  73613. */
  73614. static Warn: (message: string) => void;
  73615. /**
  73616. * Write an error message to the console
  73617. */
  73618. static Error: (message: string) => void;
  73619. /**
  73620. * Gets current log cache (list of logs)
  73621. */
  73622. static get LogCache(): string;
  73623. /**
  73624. * Clears the log cache
  73625. */
  73626. static ClearLogCache(): void;
  73627. /**
  73628. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73629. */
  73630. static set LogLevels(level: number);
  73631. }
  73632. }
  73633. declare module BABYLON {
  73634. /** @hidden */
  73635. export class _TypeStore {
  73636. /** @hidden */
  73637. static RegisteredTypes: {
  73638. [key: string]: Object;
  73639. };
  73640. /** @hidden */
  73641. static GetClass(fqdn: string): any;
  73642. }
  73643. }
  73644. declare module BABYLON {
  73645. /**
  73646. * Helper to manipulate strings
  73647. */
  73648. export class StringTools {
  73649. /**
  73650. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73651. * @param str Source string
  73652. * @param suffix Suffix to search for in the source string
  73653. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73654. */
  73655. static EndsWith(str: string, suffix: string): boolean;
  73656. /**
  73657. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73658. * @param str Source string
  73659. * @param suffix Suffix to search for in the source string
  73660. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73661. */
  73662. static StartsWith(str: string, suffix: string): boolean;
  73663. /**
  73664. * Decodes a buffer into a string
  73665. * @param buffer The buffer to decode
  73666. * @returns The decoded string
  73667. */
  73668. static Decode(buffer: Uint8Array | Uint16Array): string;
  73669. /**
  73670. * Encode a buffer to a base64 string
  73671. * @param buffer defines the buffer to encode
  73672. * @returns the encoded string
  73673. */
  73674. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73675. }
  73676. }
  73677. declare module BABYLON {
  73678. /**
  73679. * Class containing a set of static utilities functions for deep copy.
  73680. */
  73681. export class DeepCopier {
  73682. /**
  73683. * Tries to copy an object by duplicating every property
  73684. * @param source defines the source object
  73685. * @param destination defines the target object
  73686. * @param doNotCopyList defines a list of properties to avoid
  73687. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73688. */
  73689. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73690. }
  73691. }
  73692. declare module BABYLON {
  73693. /**
  73694. * Class containing a set of static utilities functions for precision date
  73695. */
  73696. export class PrecisionDate {
  73697. /**
  73698. * Gets either window.performance.now() if supported or Date.now() else
  73699. */
  73700. static get Now(): number;
  73701. }
  73702. }
  73703. declare module BABYLON {
  73704. /** @hidden */
  73705. export class _DevTools {
  73706. static WarnImport(name: string): string;
  73707. }
  73708. }
  73709. declare module BABYLON {
  73710. /**
  73711. * Interface used to define the mechanism to get data from the network
  73712. */
  73713. export interface IWebRequest {
  73714. /**
  73715. * Returns client's response url
  73716. */
  73717. responseURL: string;
  73718. /**
  73719. * Returns client's status
  73720. */
  73721. status: number;
  73722. /**
  73723. * Returns client's status as a text
  73724. */
  73725. statusText: string;
  73726. }
  73727. }
  73728. declare module BABYLON {
  73729. /**
  73730. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73731. */
  73732. export class WebRequest implements IWebRequest {
  73733. private _xhr;
  73734. /**
  73735. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73736. * i.e. when loading files, where the server/service expects an Authorization header
  73737. */
  73738. static CustomRequestHeaders: {
  73739. [key: string]: string;
  73740. };
  73741. /**
  73742. * Add callback functions in this array to update all the requests before they get sent to the network
  73743. */
  73744. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73745. private _injectCustomRequestHeaders;
  73746. /**
  73747. * Gets or sets a function to be called when loading progress changes
  73748. */
  73749. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73750. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73751. /**
  73752. * Returns client's state
  73753. */
  73754. get readyState(): number;
  73755. /**
  73756. * Returns client's status
  73757. */
  73758. get status(): number;
  73759. /**
  73760. * Returns client's status as a text
  73761. */
  73762. get statusText(): string;
  73763. /**
  73764. * Returns client's response
  73765. */
  73766. get response(): any;
  73767. /**
  73768. * Returns client's response url
  73769. */
  73770. get responseURL(): string;
  73771. /**
  73772. * Returns client's response as text
  73773. */
  73774. get responseText(): string;
  73775. /**
  73776. * Gets or sets the expected response type
  73777. */
  73778. get responseType(): XMLHttpRequestResponseType;
  73779. set responseType(value: XMLHttpRequestResponseType);
  73780. /** @hidden */
  73781. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73782. /** @hidden */
  73783. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73784. /**
  73785. * Cancels any network activity
  73786. */
  73787. abort(): void;
  73788. /**
  73789. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73790. * @param body defines an optional request body
  73791. */
  73792. send(body?: Document | BodyInit | null): void;
  73793. /**
  73794. * Sets the request method, request URL
  73795. * @param method defines the method to use (GET, POST, etc..)
  73796. * @param url defines the url to connect with
  73797. */
  73798. open(method: string, url: string): void;
  73799. /**
  73800. * Sets the value of a request header.
  73801. * @param name The name of the header whose value is to be set
  73802. * @param value The value to set as the body of the header
  73803. */
  73804. setRequestHeader(name: string, value: string): void;
  73805. /**
  73806. * Get the string containing the text of a particular header's value.
  73807. * @param name The name of the header
  73808. * @returns The string containing the text of the given header name
  73809. */
  73810. getResponseHeader(name: string): Nullable<string>;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * File request interface
  73816. */
  73817. export interface IFileRequest {
  73818. /**
  73819. * Raised when the request is complete (success or error).
  73820. */
  73821. onCompleteObservable: Observable<IFileRequest>;
  73822. /**
  73823. * Aborts the request for a file.
  73824. */
  73825. abort: () => void;
  73826. }
  73827. }
  73828. declare module BABYLON {
  73829. /**
  73830. * Define options used to create a render target texture
  73831. */
  73832. export class RenderTargetCreationOptions {
  73833. /**
  73834. * Specifies is mipmaps must be generated
  73835. */
  73836. generateMipMaps?: boolean;
  73837. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73838. generateDepthBuffer?: boolean;
  73839. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73840. generateStencilBuffer?: boolean;
  73841. /** Defines texture type (int by default) */
  73842. type?: number;
  73843. /** Defines sampling mode (trilinear by default) */
  73844. samplingMode?: number;
  73845. /** Defines format (RGBA by default) */
  73846. format?: number;
  73847. }
  73848. }
  73849. declare module BABYLON {
  73850. /** Defines the cross module used constants to avoid circular dependncies */
  73851. export class Constants {
  73852. /** Defines that alpha blending is disabled */
  73853. static readonly ALPHA_DISABLE: number;
  73854. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73855. static readonly ALPHA_ADD: number;
  73856. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73857. static readonly ALPHA_COMBINE: number;
  73858. /** Defines that alpha blending is DEST - SRC * DEST */
  73859. static readonly ALPHA_SUBTRACT: number;
  73860. /** Defines that alpha blending is SRC * DEST */
  73861. static readonly ALPHA_MULTIPLY: number;
  73862. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73863. static readonly ALPHA_MAXIMIZED: number;
  73864. /** Defines that alpha blending is SRC + DEST */
  73865. static readonly ALPHA_ONEONE: number;
  73866. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73867. static readonly ALPHA_PREMULTIPLIED: number;
  73868. /**
  73869. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73870. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73871. */
  73872. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73873. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73874. static readonly ALPHA_INTERPOLATE: number;
  73875. /**
  73876. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73877. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73878. */
  73879. static readonly ALPHA_SCREENMODE: number;
  73880. /**
  73881. * Defines that alpha blending is SRC + DST
  73882. * Alpha will be set to SRC ALPHA + DST ALPHA
  73883. */
  73884. static readonly ALPHA_ONEONE_ONEONE: number;
  73885. /**
  73886. * Defines that alpha blending is SRC * DST ALPHA + DST
  73887. * Alpha will be set to 0
  73888. */
  73889. static readonly ALPHA_ALPHATOCOLOR: number;
  73890. /**
  73891. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73892. */
  73893. static readonly ALPHA_REVERSEONEMINUS: number;
  73894. /**
  73895. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73896. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73897. */
  73898. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73899. /**
  73900. * Defines that alpha blending is SRC + DST
  73901. * Alpha will be set to SRC ALPHA
  73902. */
  73903. static readonly ALPHA_ONEONE_ONEZERO: number;
  73904. /**
  73905. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73906. * Alpha will be set to DST ALPHA
  73907. */
  73908. static readonly ALPHA_EXCLUSION: number;
  73909. /** Defines that alpha blending equation a SUM */
  73910. static readonly ALPHA_EQUATION_ADD: number;
  73911. /** Defines that alpha blending equation a SUBSTRACTION */
  73912. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73913. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73914. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73915. /** Defines that alpha blending equation a MAX operation */
  73916. static readonly ALPHA_EQUATION_MAX: number;
  73917. /** Defines that alpha blending equation a MIN operation */
  73918. static readonly ALPHA_EQUATION_MIN: number;
  73919. /**
  73920. * Defines that alpha blending equation a DARKEN operation:
  73921. * It takes the min of the src and sums the alpha channels.
  73922. */
  73923. static readonly ALPHA_EQUATION_DARKEN: number;
  73924. /** Defines that the ressource is not delayed*/
  73925. static readonly DELAYLOADSTATE_NONE: number;
  73926. /** Defines that the ressource was successfully delay loaded */
  73927. static readonly DELAYLOADSTATE_LOADED: number;
  73928. /** Defines that the ressource is currently delay loading */
  73929. static readonly DELAYLOADSTATE_LOADING: number;
  73930. /** Defines that the ressource is delayed and has not started loading */
  73931. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73932. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73933. static readonly NEVER: number;
  73934. /** 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 */
  73935. static readonly ALWAYS: number;
  73936. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73937. static readonly LESS: number;
  73938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73939. static readonly EQUAL: number;
  73940. /** 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 */
  73941. static readonly LEQUAL: number;
  73942. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73943. static readonly GREATER: number;
  73944. /** 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 */
  73945. static readonly GEQUAL: number;
  73946. /** 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 */
  73947. static readonly NOTEQUAL: number;
  73948. /** Passed to stencilOperation to specify that stencil value must be kept */
  73949. static readonly KEEP: number;
  73950. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73951. static readonly REPLACE: number;
  73952. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73953. static readonly INCR: number;
  73954. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73955. static readonly DECR: number;
  73956. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73957. static readonly INVERT: number;
  73958. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73959. static readonly INCR_WRAP: number;
  73960. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73961. static readonly DECR_WRAP: number;
  73962. /** Texture is not repeating outside of 0..1 UVs */
  73963. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73964. /** Texture is repeating outside of 0..1 UVs */
  73965. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73966. /** Texture is repeating and mirrored */
  73967. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73968. /** ALPHA */
  73969. static readonly TEXTUREFORMAT_ALPHA: number;
  73970. /** LUMINANCE */
  73971. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73972. /** LUMINANCE_ALPHA */
  73973. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73974. /** RGB */
  73975. static readonly TEXTUREFORMAT_RGB: number;
  73976. /** RGBA */
  73977. static readonly TEXTUREFORMAT_RGBA: number;
  73978. /** RED */
  73979. static readonly TEXTUREFORMAT_RED: number;
  73980. /** RED (2nd reference) */
  73981. static readonly TEXTUREFORMAT_R: number;
  73982. /** RG */
  73983. static readonly TEXTUREFORMAT_RG: number;
  73984. /** RED_INTEGER */
  73985. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73986. /** RED_INTEGER (2nd reference) */
  73987. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73988. /** RG_INTEGER */
  73989. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73990. /** RGB_INTEGER */
  73991. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73992. /** RGBA_INTEGER */
  73993. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73994. /** UNSIGNED_BYTE */
  73995. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73996. /** UNSIGNED_BYTE (2nd reference) */
  73997. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73998. /** FLOAT */
  73999. static readonly TEXTURETYPE_FLOAT: number;
  74000. /** HALF_FLOAT */
  74001. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74002. /** BYTE */
  74003. static readonly TEXTURETYPE_BYTE: number;
  74004. /** SHORT */
  74005. static readonly TEXTURETYPE_SHORT: number;
  74006. /** UNSIGNED_SHORT */
  74007. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74008. /** INT */
  74009. static readonly TEXTURETYPE_INT: number;
  74010. /** UNSIGNED_INT */
  74011. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74012. /** UNSIGNED_SHORT_4_4_4_4 */
  74013. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74014. /** UNSIGNED_SHORT_5_5_5_1 */
  74015. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74016. /** UNSIGNED_SHORT_5_6_5 */
  74017. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74018. /** UNSIGNED_INT_2_10_10_10_REV */
  74019. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74020. /** UNSIGNED_INT_24_8 */
  74021. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74022. /** UNSIGNED_INT_10F_11F_11F_REV */
  74023. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74024. /** UNSIGNED_INT_5_9_9_9_REV */
  74025. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74026. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74027. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74028. /** nearest is mag = nearest and min = nearest and no mip */
  74029. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74030. /** mag = nearest and min = nearest and mip = none */
  74031. static readonly TEXTURE_NEAREST_NEAREST: number;
  74032. /** Bilinear is mag = linear and min = linear and no mip */
  74033. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74034. /** mag = linear and min = linear and mip = none */
  74035. static readonly TEXTURE_LINEAR_LINEAR: number;
  74036. /** Trilinear is mag = linear and min = linear and mip = linear */
  74037. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74038. /** Trilinear is mag = linear and min = linear and mip = linear */
  74039. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74040. /** mag = nearest and min = nearest and mip = nearest */
  74041. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74042. /** mag = nearest and min = linear and mip = nearest */
  74043. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74044. /** mag = nearest and min = linear and mip = linear */
  74045. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74046. /** mag = nearest and min = linear and mip = none */
  74047. static readonly TEXTURE_NEAREST_LINEAR: number;
  74048. /** nearest is mag = nearest and min = nearest and mip = linear */
  74049. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74050. /** mag = linear and min = nearest and mip = nearest */
  74051. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74052. /** mag = linear and min = nearest and mip = linear */
  74053. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74054. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74055. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74056. /** mag = linear and min = nearest and mip = none */
  74057. static readonly TEXTURE_LINEAR_NEAREST: number;
  74058. /** Explicit coordinates mode */
  74059. static readonly TEXTURE_EXPLICIT_MODE: number;
  74060. /** Spherical coordinates mode */
  74061. static readonly TEXTURE_SPHERICAL_MODE: number;
  74062. /** Planar coordinates mode */
  74063. static readonly TEXTURE_PLANAR_MODE: number;
  74064. /** Cubic coordinates mode */
  74065. static readonly TEXTURE_CUBIC_MODE: number;
  74066. /** Projection coordinates mode */
  74067. static readonly TEXTURE_PROJECTION_MODE: number;
  74068. /** Skybox coordinates mode */
  74069. static readonly TEXTURE_SKYBOX_MODE: number;
  74070. /** Inverse Cubic coordinates mode */
  74071. static readonly TEXTURE_INVCUBIC_MODE: number;
  74072. /** Equirectangular coordinates mode */
  74073. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74074. /** Equirectangular Fixed coordinates mode */
  74075. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74076. /** Equirectangular Fixed Mirrored coordinates mode */
  74077. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74078. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74079. static readonly SCALEMODE_FLOOR: number;
  74080. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74081. static readonly SCALEMODE_NEAREST: number;
  74082. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74083. static readonly SCALEMODE_CEILING: number;
  74084. /**
  74085. * The dirty texture flag value
  74086. */
  74087. static readonly MATERIAL_TextureDirtyFlag: number;
  74088. /**
  74089. * The dirty light flag value
  74090. */
  74091. static readonly MATERIAL_LightDirtyFlag: number;
  74092. /**
  74093. * The dirty fresnel flag value
  74094. */
  74095. static readonly MATERIAL_FresnelDirtyFlag: number;
  74096. /**
  74097. * The dirty attribute flag value
  74098. */
  74099. static readonly MATERIAL_AttributesDirtyFlag: number;
  74100. /**
  74101. * The dirty misc flag value
  74102. */
  74103. static readonly MATERIAL_MiscDirtyFlag: number;
  74104. /**
  74105. * The all dirty flag value
  74106. */
  74107. static readonly MATERIAL_AllDirtyFlag: number;
  74108. /**
  74109. * Returns the triangle fill mode
  74110. */
  74111. static readonly MATERIAL_TriangleFillMode: number;
  74112. /**
  74113. * Returns the wireframe mode
  74114. */
  74115. static readonly MATERIAL_WireFrameFillMode: number;
  74116. /**
  74117. * Returns the point fill mode
  74118. */
  74119. static readonly MATERIAL_PointFillMode: number;
  74120. /**
  74121. * Returns the point list draw mode
  74122. */
  74123. static readonly MATERIAL_PointListDrawMode: number;
  74124. /**
  74125. * Returns the line list draw mode
  74126. */
  74127. static readonly MATERIAL_LineListDrawMode: number;
  74128. /**
  74129. * Returns the line loop draw mode
  74130. */
  74131. static readonly MATERIAL_LineLoopDrawMode: number;
  74132. /**
  74133. * Returns the line strip draw mode
  74134. */
  74135. static readonly MATERIAL_LineStripDrawMode: number;
  74136. /**
  74137. * Returns the triangle strip draw mode
  74138. */
  74139. static readonly MATERIAL_TriangleStripDrawMode: number;
  74140. /**
  74141. * Returns the triangle fan draw mode
  74142. */
  74143. static readonly MATERIAL_TriangleFanDrawMode: number;
  74144. /**
  74145. * Stores the clock-wise side orientation
  74146. */
  74147. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74148. /**
  74149. * Stores the counter clock-wise side orientation
  74150. */
  74151. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74152. /**
  74153. * Nothing
  74154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74155. */
  74156. static readonly ACTION_NothingTrigger: number;
  74157. /**
  74158. * On pick
  74159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74160. */
  74161. static readonly ACTION_OnPickTrigger: number;
  74162. /**
  74163. * On left pick
  74164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74165. */
  74166. static readonly ACTION_OnLeftPickTrigger: number;
  74167. /**
  74168. * On right pick
  74169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74170. */
  74171. static readonly ACTION_OnRightPickTrigger: number;
  74172. /**
  74173. * On center pick
  74174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74175. */
  74176. static readonly ACTION_OnCenterPickTrigger: number;
  74177. /**
  74178. * On pick down
  74179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74180. */
  74181. static readonly ACTION_OnPickDownTrigger: number;
  74182. /**
  74183. * On double pick
  74184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74185. */
  74186. static readonly ACTION_OnDoublePickTrigger: number;
  74187. /**
  74188. * On pick up
  74189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74190. */
  74191. static readonly ACTION_OnPickUpTrigger: number;
  74192. /**
  74193. * On pick out.
  74194. * This trigger will only be raised if you also declared a OnPickDown
  74195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74196. */
  74197. static readonly ACTION_OnPickOutTrigger: number;
  74198. /**
  74199. * On long press
  74200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74201. */
  74202. static readonly ACTION_OnLongPressTrigger: number;
  74203. /**
  74204. * On pointer over
  74205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74206. */
  74207. static readonly ACTION_OnPointerOverTrigger: number;
  74208. /**
  74209. * On pointer out
  74210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74211. */
  74212. static readonly ACTION_OnPointerOutTrigger: number;
  74213. /**
  74214. * On every frame
  74215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74216. */
  74217. static readonly ACTION_OnEveryFrameTrigger: number;
  74218. /**
  74219. * On intersection enter
  74220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74221. */
  74222. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74223. /**
  74224. * On intersection exit
  74225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74226. */
  74227. static readonly ACTION_OnIntersectionExitTrigger: number;
  74228. /**
  74229. * On key down
  74230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74231. */
  74232. static readonly ACTION_OnKeyDownTrigger: number;
  74233. /**
  74234. * On key up
  74235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74236. */
  74237. static readonly ACTION_OnKeyUpTrigger: number;
  74238. /**
  74239. * Billboard mode will only apply to Y axis
  74240. */
  74241. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74242. /**
  74243. * Billboard mode will apply to all axes
  74244. */
  74245. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74246. /**
  74247. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74248. */
  74249. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74250. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74251. * Test order :
  74252. * Is the bounding sphere outside the frustum ?
  74253. * If not, are the bounding box vertices outside the frustum ?
  74254. * It not, then the cullable object is in the frustum.
  74255. */
  74256. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74257. /** Culling strategy : Bounding Sphere Only.
  74258. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74259. * It's also less accurate than the standard because some not visible objects can still be selected.
  74260. * Test : is the bounding sphere outside the frustum ?
  74261. * If not, then the cullable object is in the frustum.
  74262. */
  74263. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74264. /** Culling strategy : Optimistic Inclusion.
  74265. * This in an inclusion test first, then the standard exclusion test.
  74266. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74267. * 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.
  74268. * Anyway, it's as accurate as the standard strategy.
  74269. * Test :
  74270. * Is the cullable object bounding sphere center in the frustum ?
  74271. * If not, apply the default culling strategy.
  74272. */
  74273. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74274. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74275. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74276. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74277. * 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.
  74278. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74279. * Test :
  74280. * Is the cullable object bounding sphere center in the frustum ?
  74281. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74282. */
  74283. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74284. /**
  74285. * No logging while loading
  74286. */
  74287. static readonly SCENELOADER_NO_LOGGING: number;
  74288. /**
  74289. * Minimal logging while loading
  74290. */
  74291. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74292. /**
  74293. * Summary logging while loading
  74294. */
  74295. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74296. /**
  74297. * Detailled logging while loading
  74298. */
  74299. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74300. }
  74301. }
  74302. declare module BABYLON {
  74303. /**
  74304. * This represents the required contract to create a new type of texture loader.
  74305. */
  74306. export interface IInternalTextureLoader {
  74307. /**
  74308. * Defines wether the loader supports cascade loading the different faces.
  74309. */
  74310. supportCascades: boolean;
  74311. /**
  74312. * This returns if the loader support the current file information.
  74313. * @param extension defines the file extension of the file being loaded
  74314. * @returns true if the loader can load the specified file
  74315. */
  74316. canLoad(extension: string): boolean;
  74317. /**
  74318. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74319. * @param data contains the texture data
  74320. * @param texture defines the BabylonJS internal texture
  74321. * @param createPolynomials will be true if polynomials have been requested
  74322. * @param onLoad defines the callback to trigger once the texture is ready
  74323. * @param onError defines the callback to trigger in case of error
  74324. */
  74325. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74326. /**
  74327. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74328. * @param data contains the texture data
  74329. * @param texture defines the BabylonJS internal texture
  74330. * @param callback defines the method to call once ready to upload
  74331. */
  74332. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74333. }
  74334. }
  74335. declare module BABYLON {
  74336. /**
  74337. * Class used to store and describe the pipeline context associated with an effect
  74338. */
  74339. export interface IPipelineContext {
  74340. /**
  74341. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74342. */
  74343. isAsync: boolean;
  74344. /**
  74345. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74346. */
  74347. isReady: boolean;
  74348. /** @hidden */
  74349. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74350. }
  74351. }
  74352. declare module BABYLON {
  74353. /**
  74354. * Class used to store gfx data (like WebGLBuffer)
  74355. */
  74356. export class DataBuffer {
  74357. /**
  74358. * Gets or sets the number of objects referencing this buffer
  74359. */
  74360. references: number;
  74361. /** Gets or sets the size of the underlying buffer */
  74362. capacity: number;
  74363. /**
  74364. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74365. */
  74366. is32Bits: boolean;
  74367. /**
  74368. * Gets the underlying buffer
  74369. */
  74370. get underlyingResource(): any;
  74371. }
  74372. }
  74373. declare module BABYLON {
  74374. /** @hidden */
  74375. export interface IShaderProcessor {
  74376. attributeProcessor?: (attribute: string) => string;
  74377. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74378. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74379. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74380. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74381. lineProcessor?: (line: string, isFragment: boolean) => string;
  74382. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74383. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74384. }
  74385. }
  74386. declare module BABYLON {
  74387. /** @hidden */
  74388. export interface ProcessingOptions {
  74389. defines: string[];
  74390. indexParameters: any;
  74391. isFragment: boolean;
  74392. shouldUseHighPrecisionShader: boolean;
  74393. supportsUniformBuffers: boolean;
  74394. shadersRepository: string;
  74395. includesShadersStore: {
  74396. [key: string]: string;
  74397. };
  74398. processor?: IShaderProcessor;
  74399. version: string;
  74400. platformName: string;
  74401. lookForClosingBracketForUniformBuffer?: boolean;
  74402. }
  74403. }
  74404. declare module BABYLON {
  74405. /** @hidden */
  74406. export class ShaderCodeNode {
  74407. line: string;
  74408. children: ShaderCodeNode[];
  74409. additionalDefineKey?: string;
  74410. additionalDefineValue?: string;
  74411. isValid(preprocessors: {
  74412. [key: string]: string;
  74413. }): boolean;
  74414. process(preprocessors: {
  74415. [key: string]: string;
  74416. }, options: ProcessingOptions): string;
  74417. }
  74418. }
  74419. declare module BABYLON {
  74420. /** @hidden */
  74421. export class ShaderCodeCursor {
  74422. private _lines;
  74423. lineIndex: number;
  74424. get currentLine(): string;
  74425. get canRead(): boolean;
  74426. set lines(value: string[]);
  74427. }
  74428. }
  74429. declare module BABYLON {
  74430. /** @hidden */
  74431. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74432. process(preprocessors: {
  74433. [key: string]: string;
  74434. }, options: ProcessingOptions): string;
  74435. }
  74436. }
  74437. declare module BABYLON {
  74438. /** @hidden */
  74439. export class ShaderDefineExpression {
  74440. isTrue(preprocessors: {
  74441. [key: string]: string;
  74442. }): boolean;
  74443. }
  74444. }
  74445. declare module BABYLON {
  74446. /** @hidden */
  74447. export class ShaderCodeTestNode extends ShaderCodeNode {
  74448. testExpression: ShaderDefineExpression;
  74449. isValid(preprocessors: {
  74450. [key: string]: string;
  74451. }): boolean;
  74452. }
  74453. }
  74454. declare module BABYLON {
  74455. /** @hidden */
  74456. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74457. define: string;
  74458. not: boolean;
  74459. constructor(define: string, not?: boolean);
  74460. isTrue(preprocessors: {
  74461. [key: string]: string;
  74462. }): boolean;
  74463. }
  74464. }
  74465. declare module BABYLON {
  74466. /** @hidden */
  74467. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74468. leftOperand: ShaderDefineExpression;
  74469. rightOperand: ShaderDefineExpression;
  74470. isTrue(preprocessors: {
  74471. [key: string]: string;
  74472. }): boolean;
  74473. }
  74474. }
  74475. declare module BABYLON {
  74476. /** @hidden */
  74477. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74478. leftOperand: ShaderDefineExpression;
  74479. rightOperand: ShaderDefineExpression;
  74480. isTrue(preprocessors: {
  74481. [key: string]: string;
  74482. }): boolean;
  74483. }
  74484. }
  74485. declare module BABYLON {
  74486. /** @hidden */
  74487. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74488. define: string;
  74489. operand: string;
  74490. testValue: string;
  74491. constructor(define: string, operand: string, testValue: string);
  74492. isTrue(preprocessors: {
  74493. [key: string]: string;
  74494. }): boolean;
  74495. }
  74496. }
  74497. declare module BABYLON {
  74498. /**
  74499. * Class used to enable access to offline support
  74500. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74501. */
  74502. export interface IOfflineProvider {
  74503. /**
  74504. * Gets a boolean indicating if scene must be saved in the database
  74505. */
  74506. enableSceneOffline: boolean;
  74507. /**
  74508. * Gets a boolean indicating if textures must be saved in the database
  74509. */
  74510. enableTexturesOffline: boolean;
  74511. /**
  74512. * Open the offline support and make it available
  74513. * @param successCallback defines the callback to call on success
  74514. * @param errorCallback defines the callback to call on error
  74515. */
  74516. open(successCallback: () => void, errorCallback: () => void): void;
  74517. /**
  74518. * Loads an image from the offline support
  74519. * @param url defines the url to load from
  74520. * @param image defines the target DOM image
  74521. */
  74522. loadImage(url: string, image: HTMLImageElement): void;
  74523. /**
  74524. * Loads a file from offline support
  74525. * @param url defines the URL to load from
  74526. * @param sceneLoaded defines a callback to call on success
  74527. * @param progressCallBack defines a callback to call when progress changed
  74528. * @param errorCallback defines a callback to call on error
  74529. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74530. */
  74531. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74532. }
  74533. }
  74534. declare module BABYLON {
  74535. /**
  74536. * Class used to help managing file picking and drag'n'drop
  74537. * File Storage
  74538. */
  74539. export class FilesInputStore {
  74540. /**
  74541. * List of files ready to be loaded
  74542. */
  74543. static FilesToLoad: {
  74544. [key: string]: File;
  74545. };
  74546. }
  74547. }
  74548. declare module BABYLON {
  74549. /**
  74550. * Class used to define a retry strategy when error happens while loading assets
  74551. */
  74552. export class RetryStrategy {
  74553. /**
  74554. * Function used to defines an exponential back off strategy
  74555. * @param maxRetries defines the maximum number of retries (3 by default)
  74556. * @param baseInterval defines the interval between retries
  74557. * @returns the strategy function to use
  74558. */
  74559. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74560. }
  74561. }
  74562. declare module BABYLON {
  74563. /**
  74564. * @ignore
  74565. * Application error to support additional information when loading a file
  74566. */
  74567. export abstract class BaseError extends Error {
  74568. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74569. }
  74570. }
  74571. declare module BABYLON {
  74572. /** @ignore */
  74573. export class LoadFileError extends BaseError {
  74574. request?: WebRequest;
  74575. file?: File;
  74576. /**
  74577. * Creates a new LoadFileError
  74578. * @param message defines the message of the error
  74579. * @param request defines the optional web request
  74580. * @param file defines the optional file
  74581. */
  74582. constructor(message: string, object?: WebRequest | File);
  74583. }
  74584. /** @ignore */
  74585. export class RequestFileError extends BaseError {
  74586. request: WebRequest;
  74587. /**
  74588. * Creates a new LoadFileError
  74589. * @param message defines the message of the error
  74590. * @param request defines the optional web request
  74591. */
  74592. constructor(message: string, request: WebRequest);
  74593. }
  74594. /** @ignore */
  74595. export class ReadFileError extends BaseError {
  74596. file: File;
  74597. /**
  74598. * Creates a new ReadFileError
  74599. * @param message defines the message of the error
  74600. * @param file defines the optional file
  74601. */
  74602. constructor(message: string, file: File);
  74603. }
  74604. /**
  74605. * @hidden
  74606. */
  74607. export class FileTools {
  74608. /**
  74609. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74610. */
  74611. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74612. /**
  74613. * Gets or sets the base URL to use to load assets
  74614. */
  74615. static BaseUrl: string;
  74616. /**
  74617. * Default behaviour for cors in the application.
  74618. * It can be a string if the expected behavior is identical in the entire app.
  74619. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74620. */
  74621. static CorsBehavior: string | ((url: string | string[]) => string);
  74622. /**
  74623. * Gets or sets a function used to pre-process url before using them to load assets
  74624. */
  74625. static PreprocessUrl: (url: string) => string;
  74626. /**
  74627. * Removes unwanted characters from an url
  74628. * @param url defines the url to clean
  74629. * @returns the cleaned url
  74630. */
  74631. private static _CleanUrl;
  74632. /**
  74633. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74634. * @param url define the url we are trying
  74635. * @param element define the dom element where to configure the cors policy
  74636. */
  74637. static SetCorsBehavior(url: string | string[], element: {
  74638. crossOrigin: string | null;
  74639. }): void;
  74640. /**
  74641. * Loads an image as an HTMLImageElement.
  74642. * @param input url string, ArrayBuffer, or Blob to load
  74643. * @param onLoad callback called when the image successfully loads
  74644. * @param onError callback called when the image fails to load
  74645. * @param offlineProvider offline provider for caching
  74646. * @param mimeType optional mime type
  74647. * @returns the HTMLImageElement of the loaded image
  74648. */
  74649. 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>;
  74650. /**
  74651. * Reads a file from a File object
  74652. * @param file defines the file to load
  74653. * @param onSuccess defines the callback to call when data is loaded
  74654. * @param onProgress defines the callback to call during loading process
  74655. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74656. * @param onError defines the callback to call when an error occurs
  74657. * @returns a file request object
  74658. */
  74659. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74660. /**
  74661. * Loads a file from a url
  74662. * @param url url to load
  74663. * @param onSuccess callback called when the file successfully loads
  74664. * @param onProgress callback called while file is loading (if the server supports this mode)
  74665. * @param offlineProvider defines the offline provider for caching
  74666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74667. * @param onError callback called when the file fails to load
  74668. * @returns a file request object
  74669. */
  74670. 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;
  74671. /**
  74672. * Loads a file
  74673. * @param url url to load
  74674. * @param onSuccess callback called when the file successfully loads
  74675. * @param onProgress callback called while file is loading (if the server supports this mode)
  74676. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74677. * @param onError callback called when the file fails to load
  74678. * @param onOpened callback called when the web request is opened
  74679. * @returns a file request object
  74680. */
  74681. 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;
  74682. /**
  74683. * Checks if the loaded document was accessed via `file:`-Protocol.
  74684. * @returns boolean
  74685. */
  74686. static IsFileURL(): boolean;
  74687. }
  74688. }
  74689. declare module BABYLON {
  74690. /** @hidden */
  74691. export class ShaderProcessor {
  74692. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74693. private static _ProcessPrecision;
  74694. private static _ExtractOperation;
  74695. private static _BuildSubExpression;
  74696. private static _BuildExpression;
  74697. private static _MoveCursorWithinIf;
  74698. private static _MoveCursor;
  74699. private static _EvaluatePreProcessors;
  74700. private static _PreparePreProcessors;
  74701. private static _ProcessShaderConversion;
  74702. private static _ProcessIncludes;
  74703. /**
  74704. * Loads a file from a url
  74705. * @param url url to load
  74706. * @param onSuccess callback called when the file successfully loads
  74707. * @param onProgress callback called while file is loading (if the server supports this mode)
  74708. * @param offlineProvider defines the offline provider for caching
  74709. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74710. * @param onError callback called when the file fails to load
  74711. * @returns a file request object
  74712. * @hidden
  74713. */
  74714. 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;
  74715. }
  74716. }
  74717. declare module BABYLON {
  74718. /**
  74719. * @hidden
  74720. */
  74721. export interface IColor4Like {
  74722. r: float;
  74723. g: float;
  74724. b: float;
  74725. a: float;
  74726. }
  74727. /**
  74728. * @hidden
  74729. */
  74730. export interface IColor3Like {
  74731. r: float;
  74732. g: float;
  74733. b: float;
  74734. }
  74735. /**
  74736. * @hidden
  74737. */
  74738. export interface IVector4Like {
  74739. x: float;
  74740. y: float;
  74741. z: float;
  74742. w: float;
  74743. }
  74744. /**
  74745. * @hidden
  74746. */
  74747. export interface IVector3Like {
  74748. x: float;
  74749. y: float;
  74750. z: float;
  74751. }
  74752. /**
  74753. * @hidden
  74754. */
  74755. export interface IVector2Like {
  74756. x: float;
  74757. y: float;
  74758. }
  74759. /**
  74760. * @hidden
  74761. */
  74762. export interface IMatrixLike {
  74763. toArray(): DeepImmutable<Float32Array>;
  74764. updateFlag: int;
  74765. }
  74766. /**
  74767. * @hidden
  74768. */
  74769. export interface IViewportLike {
  74770. x: float;
  74771. y: float;
  74772. width: float;
  74773. height: float;
  74774. }
  74775. /**
  74776. * @hidden
  74777. */
  74778. export interface IPlaneLike {
  74779. normal: IVector3Like;
  74780. d: float;
  74781. normalize(): void;
  74782. }
  74783. }
  74784. declare module BABYLON {
  74785. /**
  74786. * Interface used to define common properties for effect fallbacks
  74787. */
  74788. export interface IEffectFallbacks {
  74789. /**
  74790. * Removes the defines that should be removed when falling back.
  74791. * @param currentDefines defines the current define statements for the shader.
  74792. * @param effect defines the current effect we try to compile
  74793. * @returns The resulting defines with defines of the current rank removed.
  74794. */
  74795. reduce(currentDefines: string, effect: Effect): string;
  74796. /**
  74797. * Removes the fallback from the bound mesh.
  74798. */
  74799. unBindMesh(): void;
  74800. /**
  74801. * Checks to see if more fallbacks are still availible.
  74802. */
  74803. hasMoreFallbacks: boolean;
  74804. }
  74805. }
  74806. declare module BABYLON {
  74807. /**
  74808. * Class used to evalaute queries containing `and` and `or` operators
  74809. */
  74810. export class AndOrNotEvaluator {
  74811. /**
  74812. * Evaluate a query
  74813. * @param query defines the query to evaluate
  74814. * @param evaluateCallback defines the callback used to filter result
  74815. * @returns true if the query matches
  74816. */
  74817. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74818. private static _HandleParenthesisContent;
  74819. private static _SimplifyNegation;
  74820. }
  74821. }
  74822. declare module BABYLON {
  74823. /**
  74824. * Class used to store custom tags
  74825. */
  74826. export class Tags {
  74827. /**
  74828. * Adds support for tags on the given object
  74829. * @param obj defines the object to use
  74830. */
  74831. static EnableFor(obj: any): void;
  74832. /**
  74833. * Removes tags support
  74834. * @param obj defines the object to use
  74835. */
  74836. static DisableFor(obj: any): void;
  74837. /**
  74838. * Gets a boolean indicating if the given object has tags
  74839. * @param obj defines the object to use
  74840. * @returns a boolean
  74841. */
  74842. static HasTags(obj: any): boolean;
  74843. /**
  74844. * Gets the tags available on a given object
  74845. * @param obj defines the object to use
  74846. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74847. * @returns the tags
  74848. */
  74849. static GetTags(obj: any, asString?: boolean): any;
  74850. /**
  74851. * Adds tags to an object
  74852. * @param obj defines the object to use
  74853. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74854. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74855. */
  74856. static AddTagsTo(obj: any, tagsString: string): void;
  74857. /**
  74858. * @hidden
  74859. */
  74860. static _AddTagTo(obj: any, tag: string): void;
  74861. /**
  74862. * Removes specific tags from a specific object
  74863. * @param obj defines the object to use
  74864. * @param tagsString defines the tags to remove
  74865. */
  74866. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74867. /**
  74868. * @hidden
  74869. */
  74870. static _RemoveTagFrom(obj: any, tag: string): void;
  74871. /**
  74872. * Defines if tags hosted on an object match a given query
  74873. * @param obj defines the object to use
  74874. * @param tagsQuery defines the tag query
  74875. * @returns a boolean
  74876. */
  74877. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74878. }
  74879. }
  74880. declare module BABYLON {
  74881. /**
  74882. * Scalar computation library
  74883. */
  74884. export class Scalar {
  74885. /**
  74886. * Two pi constants convenient for computation.
  74887. */
  74888. static TwoPi: number;
  74889. /**
  74890. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74891. * @param a number
  74892. * @param b number
  74893. * @param epsilon (default = 1.401298E-45)
  74894. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74895. */
  74896. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74897. /**
  74898. * Returns a string : the upper case translation of the number i to hexadecimal.
  74899. * @param i number
  74900. * @returns the upper case translation of the number i to hexadecimal.
  74901. */
  74902. static ToHex(i: number): string;
  74903. /**
  74904. * Returns -1 if value is negative and +1 is value is positive.
  74905. * @param value the value
  74906. * @returns the value itself if it's equal to zero.
  74907. */
  74908. static Sign(value: number): number;
  74909. /**
  74910. * Returns the value itself if it's between min and max.
  74911. * Returns min if the value is lower than min.
  74912. * Returns max if the value is greater than max.
  74913. * @param value the value to clmap
  74914. * @param min the min value to clamp to (default: 0)
  74915. * @param max the max value to clamp to (default: 1)
  74916. * @returns the clamped value
  74917. */
  74918. static Clamp(value: number, min?: number, max?: number): number;
  74919. /**
  74920. * the log2 of value.
  74921. * @param value the value to compute log2 of
  74922. * @returns the log2 of value.
  74923. */
  74924. static Log2(value: number): number;
  74925. /**
  74926. * Loops the value, so that it is never larger than length and never smaller than 0.
  74927. *
  74928. * This is similar to the modulo operator but it works with floating point numbers.
  74929. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74930. * With t = 5 and length = 2.5, the result would be 0.0.
  74931. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74932. * @param value the value
  74933. * @param length the length
  74934. * @returns the looped value
  74935. */
  74936. static Repeat(value: number, length: number): number;
  74937. /**
  74938. * Normalize the value between 0.0 and 1.0 using min and max values
  74939. * @param value value to normalize
  74940. * @param min max to normalize between
  74941. * @param max min to normalize between
  74942. * @returns the normalized value
  74943. */
  74944. static Normalize(value: number, min: number, max: number): number;
  74945. /**
  74946. * Denormalize the value from 0.0 and 1.0 using min and max values
  74947. * @param normalized value to denormalize
  74948. * @param min max to denormalize between
  74949. * @param max min to denormalize between
  74950. * @returns the denormalized value
  74951. */
  74952. static Denormalize(normalized: number, min: number, max: number): number;
  74953. /**
  74954. * Calculates the shortest difference between two given angles given in degrees.
  74955. * @param current current angle in degrees
  74956. * @param target target angle in degrees
  74957. * @returns the delta
  74958. */
  74959. static DeltaAngle(current: number, target: number): number;
  74960. /**
  74961. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74962. * @param tx value
  74963. * @param length length
  74964. * @returns The returned value will move back and forth between 0 and length
  74965. */
  74966. static PingPong(tx: number, length: number): number;
  74967. /**
  74968. * Interpolates between min and max with smoothing at the limits.
  74969. *
  74970. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74971. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74972. * @param from from
  74973. * @param to to
  74974. * @param tx value
  74975. * @returns the smooth stepped value
  74976. */
  74977. static SmoothStep(from: number, to: number, tx: number): number;
  74978. /**
  74979. * Moves a value current towards target.
  74980. *
  74981. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74982. * Negative values of maxDelta pushes the value away from target.
  74983. * @param current current value
  74984. * @param target target value
  74985. * @param maxDelta max distance to move
  74986. * @returns resulting value
  74987. */
  74988. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74989. /**
  74990. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74991. *
  74992. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74993. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74994. * @param current current value
  74995. * @param target target value
  74996. * @param maxDelta max distance to move
  74997. * @returns resulting angle
  74998. */
  74999. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75000. /**
  75001. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75002. * @param start start value
  75003. * @param end target value
  75004. * @param amount amount to lerp between
  75005. * @returns the lerped value
  75006. */
  75007. static Lerp(start: number, end: number, amount: number): number;
  75008. /**
  75009. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75010. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75011. * @param start start value
  75012. * @param end target value
  75013. * @param amount amount to lerp between
  75014. * @returns the lerped value
  75015. */
  75016. static LerpAngle(start: number, end: number, amount: number): number;
  75017. /**
  75018. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75019. * @param a start value
  75020. * @param b target value
  75021. * @param value value between a and b
  75022. * @returns the inverseLerp value
  75023. */
  75024. static InverseLerp(a: number, b: number, value: number): number;
  75025. /**
  75026. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75027. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75028. * @param value1 spline value
  75029. * @param tangent1 spline value
  75030. * @param value2 spline value
  75031. * @param tangent2 spline value
  75032. * @param amount input value
  75033. * @returns hermite result
  75034. */
  75035. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75036. /**
  75037. * Returns a random float number between and min and max values
  75038. * @param min min value of random
  75039. * @param max max value of random
  75040. * @returns random value
  75041. */
  75042. static RandomRange(min: number, max: number): number;
  75043. /**
  75044. * This function returns percentage of a number in a given range.
  75045. *
  75046. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75047. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75048. * @param number to convert to percentage
  75049. * @param min min range
  75050. * @param max max range
  75051. * @returns the percentage
  75052. */
  75053. static RangeToPercent(number: number, min: number, max: number): number;
  75054. /**
  75055. * This function returns number that corresponds to the percentage in a given range.
  75056. *
  75057. * PercentToRange(0.34,0,100) will return 34.
  75058. * @param percent to convert to number
  75059. * @param min min range
  75060. * @param max max range
  75061. * @returns the number
  75062. */
  75063. static PercentToRange(percent: number, min: number, max: number): number;
  75064. /**
  75065. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75066. * @param angle The angle to normalize in radian.
  75067. * @return The converted angle.
  75068. */
  75069. static NormalizeRadians(angle: number): number;
  75070. }
  75071. }
  75072. declare module BABYLON {
  75073. /**
  75074. * Constant used to convert a value to gamma space
  75075. * @ignorenaming
  75076. */
  75077. export const ToGammaSpace: number;
  75078. /**
  75079. * Constant used to convert a value to linear space
  75080. * @ignorenaming
  75081. */
  75082. export const ToLinearSpace = 2.2;
  75083. /**
  75084. * Constant used to define the minimal number value in Babylon.js
  75085. * @ignorenaming
  75086. */
  75087. let Epsilon: number;
  75088. }
  75089. declare module BABYLON {
  75090. /**
  75091. * Class used to represent a viewport on screen
  75092. */
  75093. export class Viewport {
  75094. /** viewport left coordinate */
  75095. x: number;
  75096. /** viewport top coordinate */
  75097. y: number;
  75098. /**viewport width */
  75099. width: number;
  75100. /** viewport height */
  75101. height: number;
  75102. /**
  75103. * Creates a Viewport object located at (x, y) and sized (width, height)
  75104. * @param x defines viewport left coordinate
  75105. * @param y defines viewport top coordinate
  75106. * @param width defines the viewport width
  75107. * @param height defines the viewport height
  75108. */
  75109. constructor(
  75110. /** viewport left coordinate */
  75111. x: number,
  75112. /** viewport top coordinate */
  75113. y: number,
  75114. /**viewport width */
  75115. width: number,
  75116. /** viewport height */
  75117. height: number);
  75118. /**
  75119. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75120. * @param renderWidth defines the rendering width
  75121. * @param renderHeight defines the rendering height
  75122. * @returns a new Viewport
  75123. */
  75124. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75125. /**
  75126. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75127. * @param renderWidth defines the rendering width
  75128. * @param renderHeight defines the rendering height
  75129. * @param ref defines the target viewport
  75130. * @returns the current viewport
  75131. */
  75132. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75133. /**
  75134. * Returns a new Viewport copied from the current one
  75135. * @returns a new Viewport
  75136. */
  75137. clone(): Viewport;
  75138. }
  75139. }
  75140. declare module BABYLON {
  75141. /**
  75142. * Class containing a set of static utilities functions for arrays.
  75143. */
  75144. export class ArrayTools {
  75145. /**
  75146. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75147. * @param size the number of element to construct and put in the array
  75148. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75149. * @returns a new array filled with new objects
  75150. */
  75151. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75152. }
  75153. }
  75154. declare module BABYLON {
  75155. /**
  75156. * Class representing a vector containing 2 coordinates
  75157. */
  75158. export class Vector2 {
  75159. /** defines the first coordinate */
  75160. x: number;
  75161. /** defines the second coordinate */
  75162. y: number;
  75163. /**
  75164. * Creates a new Vector2 from the given x and y coordinates
  75165. * @param x defines the first coordinate
  75166. * @param y defines the second coordinate
  75167. */
  75168. constructor(
  75169. /** defines the first coordinate */
  75170. x?: number,
  75171. /** defines the second coordinate */
  75172. y?: number);
  75173. /**
  75174. * Gets a string with the Vector2 coordinates
  75175. * @returns a string with the Vector2 coordinates
  75176. */
  75177. toString(): string;
  75178. /**
  75179. * Gets class name
  75180. * @returns the string "Vector2"
  75181. */
  75182. getClassName(): string;
  75183. /**
  75184. * Gets current vector hash code
  75185. * @returns the Vector2 hash code as a number
  75186. */
  75187. getHashCode(): number;
  75188. /**
  75189. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75190. * @param array defines the source array
  75191. * @param index defines the offset in source array
  75192. * @returns the current Vector2
  75193. */
  75194. toArray(array: FloatArray, index?: number): Vector2;
  75195. /**
  75196. * Copy the current vector to an array
  75197. * @returns a new array with 2 elements: the Vector2 coordinates.
  75198. */
  75199. asArray(): number[];
  75200. /**
  75201. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75202. * @param source defines the source Vector2
  75203. * @returns the current updated Vector2
  75204. */
  75205. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75206. /**
  75207. * Sets the Vector2 coordinates with the given floats
  75208. * @param x defines the first coordinate
  75209. * @param y defines the second coordinate
  75210. * @returns the current updated Vector2
  75211. */
  75212. copyFromFloats(x: number, y: number): Vector2;
  75213. /**
  75214. * Sets the Vector2 coordinates with the given floats
  75215. * @param x defines the first coordinate
  75216. * @param y defines the second coordinate
  75217. * @returns the current updated Vector2
  75218. */
  75219. set(x: number, y: number): Vector2;
  75220. /**
  75221. * Add another vector with the current one
  75222. * @param otherVector defines the other vector
  75223. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75224. */
  75225. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75226. /**
  75227. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75228. * @param otherVector defines the other vector
  75229. * @param result defines the target vector
  75230. * @returns the unmodified current Vector2
  75231. */
  75232. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75233. /**
  75234. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75235. * @param otherVector defines the other vector
  75236. * @returns the current updated Vector2
  75237. */
  75238. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75239. /**
  75240. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75241. * @param otherVector defines the other vector
  75242. * @returns a new Vector2
  75243. */
  75244. addVector3(otherVector: Vector3): Vector2;
  75245. /**
  75246. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75247. * @param otherVector defines the other vector
  75248. * @returns a new Vector2
  75249. */
  75250. subtract(otherVector: Vector2): Vector2;
  75251. /**
  75252. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75253. * @param otherVector defines the other vector
  75254. * @param result defines the target vector
  75255. * @returns the unmodified current Vector2
  75256. */
  75257. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75258. /**
  75259. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75260. * @param otherVector defines the other vector
  75261. * @returns the current updated Vector2
  75262. */
  75263. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75264. /**
  75265. * Multiplies in place the current Vector2 coordinates by the given ones
  75266. * @param otherVector defines the other vector
  75267. * @returns the current updated Vector2
  75268. */
  75269. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75270. /**
  75271. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75272. * @param otherVector defines the other vector
  75273. * @returns a new Vector2
  75274. */
  75275. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75276. /**
  75277. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75278. * @param otherVector defines the other vector
  75279. * @param result defines the target vector
  75280. * @returns the unmodified current Vector2
  75281. */
  75282. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75283. /**
  75284. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75285. * @param x defines the first coordinate
  75286. * @param y defines the second coordinate
  75287. * @returns a new Vector2
  75288. */
  75289. multiplyByFloats(x: number, y: number): Vector2;
  75290. /**
  75291. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75292. * @param otherVector defines the other vector
  75293. * @returns a new Vector2
  75294. */
  75295. divide(otherVector: Vector2): Vector2;
  75296. /**
  75297. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75298. * @param otherVector defines the other vector
  75299. * @param result defines the target vector
  75300. * @returns the unmodified current Vector2
  75301. */
  75302. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75303. /**
  75304. * Divides the current Vector2 coordinates by the given ones
  75305. * @param otherVector defines the other vector
  75306. * @returns the current updated Vector2
  75307. */
  75308. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75309. /**
  75310. * Gets a new Vector2 with current Vector2 negated coordinates
  75311. * @returns a new Vector2
  75312. */
  75313. negate(): Vector2;
  75314. /**
  75315. * Negate this vector in place
  75316. * @returns this
  75317. */
  75318. negateInPlace(): Vector2;
  75319. /**
  75320. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75321. * @param result defines the Vector3 object where to store the result
  75322. * @returns the current Vector2
  75323. */
  75324. negateToRef(result: Vector2): Vector2;
  75325. /**
  75326. * Multiply the Vector2 coordinates by scale
  75327. * @param scale defines the scaling factor
  75328. * @returns the current updated Vector2
  75329. */
  75330. scaleInPlace(scale: number): Vector2;
  75331. /**
  75332. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75333. * @param scale defines the scaling factor
  75334. * @returns a new Vector2
  75335. */
  75336. scale(scale: number): Vector2;
  75337. /**
  75338. * Scale the current Vector2 values by a factor to a given Vector2
  75339. * @param scale defines the scale factor
  75340. * @param result defines the Vector2 object where to store the result
  75341. * @returns the unmodified current Vector2
  75342. */
  75343. scaleToRef(scale: number, result: Vector2): Vector2;
  75344. /**
  75345. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75346. * @param scale defines the scale factor
  75347. * @param result defines the Vector2 object where to store the result
  75348. * @returns the unmodified current Vector2
  75349. */
  75350. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75351. /**
  75352. * Gets a boolean if two vectors are equals
  75353. * @param otherVector defines the other vector
  75354. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75355. */
  75356. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75357. /**
  75358. * Gets a boolean if two vectors are equals (using an epsilon value)
  75359. * @param otherVector defines the other vector
  75360. * @param epsilon defines the minimal distance to consider equality
  75361. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75362. */
  75363. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75364. /**
  75365. * Gets a new Vector2 from current Vector2 floored values
  75366. * @returns a new Vector2
  75367. */
  75368. floor(): Vector2;
  75369. /**
  75370. * Gets a new Vector2 from current Vector2 floored values
  75371. * @returns a new Vector2
  75372. */
  75373. fract(): Vector2;
  75374. /**
  75375. * Gets the length of the vector
  75376. * @returns the vector length (float)
  75377. */
  75378. length(): number;
  75379. /**
  75380. * Gets the vector squared length
  75381. * @returns the vector squared length (float)
  75382. */
  75383. lengthSquared(): number;
  75384. /**
  75385. * Normalize the vector
  75386. * @returns the current updated Vector2
  75387. */
  75388. normalize(): Vector2;
  75389. /**
  75390. * Gets a new Vector2 copied from the Vector2
  75391. * @returns a new Vector2
  75392. */
  75393. clone(): Vector2;
  75394. /**
  75395. * Gets a new Vector2(0, 0)
  75396. * @returns a new Vector2
  75397. */
  75398. static Zero(): Vector2;
  75399. /**
  75400. * Gets a new Vector2(1, 1)
  75401. * @returns a new Vector2
  75402. */
  75403. static One(): Vector2;
  75404. /**
  75405. * Gets a new Vector2 set from the given index element of the given array
  75406. * @param array defines the data source
  75407. * @param offset defines the offset in the data source
  75408. * @returns a new Vector2
  75409. */
  75410. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75411. /**
  75412. * Sets "result" from the given index element of the given array
  75413. * @param array defines the data source
  75414. * @param offset defines the offset in the data source
  75415. * @param result defines the target vector
  75416. */
  75417. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75418. /**
  75419. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75420. * @param value1 defines 1st point of control
  75421. * @param value2 defines 2nd point of control
  75422. * @param value3 defines 3rd point of control
  75423. * @param value4 defines 4th point of control
  75424. * @param amount defines the interpolation factor
  75425. * @returns a new Vector2
  75426. */
  75427. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75428. /**
  75429. * 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".
  75430. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75431. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75432. * @param value defines the value to clamp
  75433. * @param min defines the lower limit
  75434. * @param max defines the upper limit
  75435. * @returns a new Vector2
  75436. */
  75437. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75438. /**
  75439. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75440. * @param value1 defines the 1st control point
  75441. * @param tangent1 defines the outgoing tangent
  75442. * @param value2 defines the 2nd control point
  75443. * @param tangent2 defines the incoming tangent
  75444. * @param amount defines the interpolation factor
  75445. * @returns a new Vector2
  75446. */
  75447. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75448. /**
  75449. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75450. * @param start defines the start vector
  75451. * @param end defines the end vector
  75452. * @param amount defines the interpolation factor
  75453. * @returns a new Vector2
  75454. */
  75455. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75456. /**
  75457. * Gets the dot product of the vector "left" and the vector "right"
  75458. * @param left defines first vector
  75459. * @param right defines second vector
  75460. * @returns the dot product (float)
  75461. */
  75462. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75463. /**
  75464. * Returns a new Vector2 equal to the normalized given vector
  75465. * @param vector defines the vector to normalize
  75466. * @returns a new Vector2
  75467. */
  75468. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75469. /**
  75470. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75471. * @param left defines 1st vector
  75472. * @param right defines 2nd vector
  75473. * @returns a new Vector2
  75474. */
  75475. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75476. /**
  75477. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75478. * @param left defines 1st vector
  75479. * @param right defines 2nd vector
  75480. * @returns a new Vector2
  75481. */
  75482. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75483. /**
  75484. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75485. * @param vector defines the vector to transform
  75486. * @param transformation defines the matrix to apply
  75487. * @returns a new Vector2
  75488. */
  75489. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75490. /**
  75491. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75492. * @param vector defines the vector to transform
  75493. * @param transformation defines the matrix to apply
  75494. * @param result defines the target vector
  75495. */
  75496. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75497. /**
  75498. * Determines if a given vector is included in a triangle
  75499. * @param p defines the vector to test
  75500. * @param p0 defines 1st triangle point
  75501. * @param p1 defines 2nd triangle point
  75502. * @param p2 defines 3rd triangle point
  75503. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75504. */
  75505. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75506. /**
  75507. * Gets the distance between the vectors "value1" and "value2"
  75508. * @param value1 defines first vector
  75509. * @param value2 defines second vector
  75510. * @returns the distance between vectors
  75511. */
  75512. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75513. /**
  75514. * Returns the squared distance between the vectors "value1" and "value2"
  75515. * @param value1 defines first vector
  75516. * @param value2 defines second vector
  75517. * @returns the squared distance between vectors
  75518. */
  75519. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75520. /**
  75521. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75522. * @param value1 defines first vector
  75523. * @param value2 defines second vector
  75524. * @returns a new Vector2
  75525. */
  75526. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75527. /**
  75528. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75529. * @param p defines the middle point
  75530. * @param segA defines one point of the segment
  75531. * @param segB defines the other point of the segment
  75532. * @returns the shortest distance
  75533. */
  75534. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75535. }
  75536. /**
  75537. * Class used to store (x,y,z) vector representation
  75538. * A Vector3 is the main object used in 3D geometry
  75539. * It can represent etiher the coordinates of a point the space, either a direction
  75540. * Reminder: js uses a left handed forward facing system
  75541. */
  75542. export class Vector3 {
  75543. /**
  75544. * Defines the first coordinates (on X axis)
  75545. */
  75546. x: number;
  75547. /**
  75548. * Defines the second coordinates (on Y axis)
  75549. */
  75550. y: number;
  75551. /**
  75552. * Defines the third coordinates (on Z axis)
  75553. */
  75554. z: number;
  75555. private static _UpReadOnly;
  75556. private static _ZeroReadOnly;
  75557. /**
  75558. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75559. * @param x defines the first coordinates (on X axis)
  75560. * @param y defines the second coordinates (on Y axis)
  75561. * @param z defines the third coordinates (on Z axis)
  75562. */
  75563. constructor(
  75564. /**
  75565. * Defines the first coordinates (on X axis)
  75566. */
  75567. x?: number,
  75568. /**
  75569. * Defines the second coordinates (on Y axis)
  75570. */
  75571. y?: number,
  75572. /**
  75573. * Defines the third coordinates (on Z axis)
  75574. */
  75575. z?: number);
  75576. /**
  75577. * Creates a string representation of the Vector3
  75578. * @returns a string with the Vector3 coordinates.
  75579. */
  75580. toString(): string;
  75581. /**
  75582. * Gets the class name
  75583. * @returns the string "Vector3"
  75584. */
  75585. getClassName(): string;
  75586. /**
  75587. * Creates the Vector3 hash code
  75588. * @returns a number which tends to be unique between Vector3 instances
  75589. */
  75590. getHashCode(): number;
  75591. /**
  75592. * Creates an array containing three elements : the coordinates of the Vector3
  75593. * @returns a new array of numbers
  75594. */
  75595. asArray(): number[];
  75596. /**
  75597. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75598. * @param array defines the destination array
  75599. * @param index defines the offset in the destination array
  75600. * @returns the current Vector3
  75601. */
  75602. toArray(array: FloatArray, index?: number): Vector3;
  75603. /**
  75604. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75605. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75606. */
  75607. toQuaternion(): Quaternion;
  75608. /**
  75609. * Adds the given vector to the current Vector3
  75610. * @param otherVector defines the second operand
  75611. * @returns the current updated Vector3
  75612. */
  75613. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75614. /**
  75615. * Adds the given coordinates to the current Vector3
  75616. * @param x defines the x coordinate of the operand
  75617. * @param y defines the y coordinate of the operand
  75618. * @param z defines the z coordinate of the operand
  75619. * @returns the current updated Vector3
  75620. */
  75621. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75622. /**
  75623. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75624. * @param otherVector defines the second operand
  75625. * @returns the resulting Vector3
  75626. */
  75627. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75628. /**
  75629. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75630. * @param otherVector defines the second operand
  75631. * @param result defines the Vector3 object where to store the result
  75632. * @returns the current Vector3
  75633. */
  75634. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75635. /**
  75636. * Subtract the given vector from the current Vector3
  75637. * @param otherVector defines the second operand
  75638. * @returns the current updated Vector3
  75639. */
  75640. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75641. /**
  75642. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75643. * @param otherVector defines the second operand
  75644. * @returns the resulting Vector3
  75645. */
  75646. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75647. /**
  75648. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75649. * @param otherVector defines the second operand
  75650. * @param result defines the Vector3 object where to store the result
  75651. * @returns the current Vector3
  75652. */
  75653. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75654. /**
  75655. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75656. * @param x defines the x coordinate of the operand
  75657. * @param y defines the y coordinate of the operand
  75658. * @param z defines the z coordinate of the operand
  75659. * @returns the resulting Vector3
  75660. */
  75661. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75662. /**
  75663. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75664. * @param x defines the x coordinate of the operand
  75665. * @param y defines the y coordinate of the operand
  75666. * @param z defines the z coordinate of the operand
  75667. * @param result defines the Vector3 object where to store the result
  75668. * @returns the current Vector3
  75669. */
  75670. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75671. /**
  75672. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75673. * @returns a new Vector3
  75674. */
  75675. negate(): Vector3;
  75676. /**
  75677. * Negate this vector in place
  75678. * @returns this
  75679. */
  75680. negateInPlace(): Vector3;
  75681. /**
  75682. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75683. * @param result defines the Vector3 object where to store the result
  75684. * @returns the current Vector3
  75685. */
  75686. negateToRef(result: Vector3): Vector3;
  75687. /**
  75688. * Multiplies the Vector3 coordinates by the float "scale"
  75689. * @param scale defines the multiplier factor
  75690. * @returns the current updated Vector3
  75691. */
  75692. scaleInPlace(scale: number): Vector3;
  75693. /**
  75694. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75695. * @param scale defines the multiplier factor
  75696. * @returns a new Vector3
  75697. */
  75698. scale(scale: number): Vector3;
  75699. /**
  75700. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75701. * @param scale defines the multiplier factor
  75702. * @param result defines the Vector3 object where to store the result
  75703. * @returns the current Vector3
  75704. */
  75705. scaleToRef(scale: number, result: Vector3): Vector3;
  75706. /**
  75707. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75708. * @param scale defines the scale factor
  75709. * @param result defines the Vector3 object where to store the result
  75710. * @returns the unmodified current Vector3
  75711. */
  75712. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75713. /**
  75714. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75715. * @param otherVector defines the second operand
  75716. * @returns true if both vectors are equals
  75717. */
  75718. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75719. /**
  75720. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75721. * @param otherVector defines the second operand
  75722. * @param epsilon defines the minimal distance to define values as equals
  75723. * @returns true if both vectors are distant less than epsilon
  75724. */
  75725. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75726. /**
  75727. * Returns true if the current Vector3 coordinates equals the given floats
  75728. * @param x defines the x coordinate of the operand
  75729. * @param y defines the y coordinate of the operand
  75730. * @param z defines the z coordinate of the operand
  75731. * @returns true if both vectors are equals
  75732. */
  75733. equalsToFloats(x: number, y: number, z: number): boolean;
  75734. /**
  75735. * Multiplies the current Vector3 coordinates by the given ones
  75736. * @param otherVector defines the second operand
  75737. * @returns the current updated Vector3
  75738. */
  75739. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75740. /**
  75741. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75742. * @param otherVector defines the second operand
  75743. * @returns the new Vector3
  75744. */
  75745. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75746. /**
  75747. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75748. * @param otherVector defines the second operand
  75749. * @param result defines the Vector3 object where to store the result
  75750. * @returns the current Vector3
  75751. */
  75752. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75753. /**
  75754. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75755. * @param x defines the x coordinate of the operand
  75756. * @param y defines the y coordinate of the operand
  75757. * @param z defines the z coordinate of the operand
  75758. * @returns the new Vector3
  75759. */
  75760. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75761. /**
  75762. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75763. * @param otherVector defines the second operand
  75764. * @returns the new Vector3
  75765. */
  75766. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75767. /**
  75768. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75769. * @param otherVector defines the second operand
  75770. * @param result defines the Vector3 object where to store the result
  75771. * @returns the current Vector3
  75772. */
  75773. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75774. /**
  75775. * Divides the current Vector3 coordinates by the given ones.
  75776. * @param otherVector defines the second operand
  75777. * @returns the current updated Vector3
  75778. */
  75779. divideInPlace(otherVector: Vector3): Vector3;
  75780. /**
  75781. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75782. * @param other defines the second operand
  75783. * @returns the current updated Vector3
  75784. */
  75785. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75786. /**
  75787. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75788. * @param other defines the second operand
  75789. * @returns the current updated Vector3
  75790. */
  75791. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75792. /**
  75793. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75794. * @param x defines the x coordinate of the operand
  75795. * @param y defines the y coordinate of the operand
  75796. * @param z defines the z coordinate of the operand
  75797. * @returns the current updated Vector3
  75798. */
  75799. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75800. /**
  75801. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75802. * @param x defines the x coordinate of the operand
  75803. * @param y defines the y coordinate of the operand
  75804. * @param z defines the z coordinate of the operand
  75805. * @returns the current updated Vector3
  75806. */
  75807. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75808. /**
  75809. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75810. * Check if is non uniform within a certain amount of decimal places to account for this
  75811. * @param epsilon the amount the values can differ
  75812. * @returns if the the vector is non uniform to a certain number of decimal places
  75813. */
  75814. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75815. /**
  75816. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75817. */
  75818. get isNonUniform(): boolean;
  75819. /**
  75820. * Gets a new Vector3 from current Vector3 floored values
  75821. * @returns a new Vector3
  75822. */
  75823. floor(): Vector3;
  75824. /**
  75825. * Gets a new Vector3 from current Vector3 floored values
  75826. * @returns a new Vector3
  75827. */
  75828. fract(): Vector3;
  75829. /**
  75830. * Gets the length of the Vector3
  75831. * @returns the length of the Vector3
  75832. */
  75833. length(): number;
  75834. /**
  75835. * Gets the squared length of the Vector3
  75836. * @returns squared length of the Vector3
  75837. */
  75838. lengthSquared(): number;
  75839. /**
  75840. * Normalize the current Vector3.
  75841. * Please note that this is an in place operation.
  75842. * @returns the current updated Vector3
  75843. */
  75844. normalize(): Vector3;
  75845. /**
  75846. * Reorders the x y z properties of the vector in place
  75847. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75848. * @returns the current updated vector
  75849. */
  75850. reorderInPlace(order: string): this;
  75851. /**
  75852. * Rotates the vector around 0,0,0 by a quaternion
  75853. * @param quaternion the rotation quaternion
  75854. * @param result vector to store the result
  75855. * @returns the resulting vector
  75856. */
  75857. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75858. /**
  75859. * Rotates a vector around a given point
  75860. * @param quaternion the rotation quaternion
  75861. * @param point the point to rotate around
  75862. * @param result vector to store the result
  75863. * @returns the resulting vector
  75864. */
  75865. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75866. /**
  75867. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75868. * The cross product is then orthogonal to both current and "other"
  75869. * @param other defines the right operand
  75870. * @returns the cross product
  75871. */
  75872. cross(other: Vector3): Vector3;
  75873. /**
  75874. * Normalize the current Vector3 with the given input length.
  75875. * Please note that this is an in place operation.
  75876. * @param len the length of the vector
  75877. * @returns the current updated Vector3
  75878. */
  75879. normalizeFromLength(len: number): Vector3;
  75880. /**
  75881. * Normalize the current Vector3 to a new vector
  75882. * @returns the new Vector3
  75883. */
  75884. normalizeToNew(): Vector3;
  75885. /**
  75886. * Normalize the current Vector3 to the reference
  75887. * @param reference define the Vector3 to update
  75888. * @returns the updated Vector3
  75889. */
  75890. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75891. /**
  75892. * Creates a new Vector3 copied from the current Vector3
  75893. * @returns the new Vector3
  75894. */
  75895. clone(): Vector3;
  75896. /**
  75897. * Copies the given vector coordinates to the current Vector3 ones
  75898. * @param source defines the source Vector3
  75899. * @returns the current updated Vector3
  75900. */
  75901. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75902. /**
  75903. * Copies the given floats to the current Vector3 coordinates
  75904. * @param x defines the x coordinate of the operand
  75905. * @param y defines the y coordinate of the operand
  75906. * @param z defines the z coordinate of the operand
  75907. * @returns the current updated Vector3
  75908. */
  75909. copyFromFloats(x: number, y: number, z: number): Vector3;
  75910. /**
  75911. * Copies the given floats to the current Vector3 coordinates
  75912. * @param x defines the x coordinate of the operand
  75913. * @param y defines the y coordinate of the operand
  75914. * @param z defines the z coordinate of the operand
  75915. * @returns the current updated Vector3
  75916. */
  75917. set(x: number, y: number, z: number): Vector3;
  75918. /**
  75919. * Copies the given float to the current Vector3 coordinates
  75920. * @param v defines the x, y and z coordinates of the operand
  75921. * @returns the current updated Vector3
  75922. */
  75923. setAll(v: number): Vector3;
  75924. /**
  75925. * Get the clip factor between two vectors
  75926. * @param vector0 defines the first operand
  75927. * @param vector1 defines the second operand
  75928. * @param axis defines the axis to use
  75929. * @param size defines the size along the axis
  75930. * @returns the clip factor
  75931. */
  75932. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75933. /**
  75934. * Get angle between two vectors
  75935. * @param vector0 angle between vector0 and vector1
  75936. * @param vector1 angle between vector0 and vector1
  75937. * @param normal direction of the normal
  75938. * @return the angle between vector0 and vector1
  75939. */
  75940. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75941. /**
  75942. * Returns a new Vector3 set from the index "offset" of the given array
  75943. * @param array defines the source array
  75944. * @param offset defines the offset in the source array
  75945. * @returns the new Vector3
  75946. */
  75947. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75948. /**
  75949. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75950. * @param array defines the source array
  75951. * @param offset defines the offset in the source array
  75952. * @returns the new Vector3
  75953. * @deprecated Please use FromArray instead.
  75954. */
  75955. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75956. /**
  75957. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75958. * @param array defines the source array
  75959. * @param offset defines the offset in the source array
  75960. * @param result defines the Vector3 where to store the result
  75961. */
  75962. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75963. /**
  75964. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75965. * @param array defines the source array
  75966. * @param offset defines the offset in the source array
  75967. * @param result defines the Vector3 where to store the result
  75968. * @deprecated Please use FromArrayToRef instead.
  75969. */
  75970. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75971. /**
  75972. * Sets the given vector "result" with the given floats.
  75973. * @param x defines the x coordinate of the source
  75974. * @param y defines the y coordinate of the source
  75975. * @param z defines the z coordinate of the source
  75976. * @param result defines the Vector3 where to store the result
  75977. */
  75978. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75979. /**
  75980. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75981. * @returns a new empty Vector3
  75982. */
  75983. static Zero(): Vector3;
  75984. /**
  75985. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75986. * @returns a new unit Vector3
  75987. */
  75988. static One(): Vector3;
  75989. /**
  75990. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75991. * @returns a new up Vector3
  75992. */
  75993. static Up(): Vector3;
  75994. /**
  75995. * Gets a up Vector3 that must not be updated
  75996. */
  75997. static get UpReadOnly(): DeepImmutable<Vector3>;
  75998. /**
  75999. * Gets a zero Vector3 that must not be updated
  76000. */
  76001. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76002. /**
  76003. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76004. * @returns a new down Vector3
  76005. */
  76006. static Down(): Vector3;
  76007. /**
  76008. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76009. * @returns a new forward Vector3
  76010. */
  76011. static Forward(): Vector3;
  76012. /**
  76013. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76014. * @returns a new forward Vector3
  76015. */
  76016. static Backward(): Vector3;
  76017. /**
  76018. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76019. * @returns a new right Vector3
  76020. */
  76021. static Right(): Vector3;
  76022. /**
  76023. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76024. * @returns a new left Vector3
  76025. */
  76026. static Left(): Vector3;
  76027. /**
  76028. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76030. * @param vector defines the Vector3 to transform
  76031. * @param transformation defines the transformation matrix
  76032. * @returns the transformed Vector3
  76033. */
  76034. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76035. /**
  76036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76037. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76038. * @param vector defines the Vector3 to transform
  76039. * @param transformation defines the transformation matrix
  76040. * @param result defines the Vector3 where to store the result
  76041. */
  76042. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76043. /**
  76044. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76045. * This method computes tranformed coordinates only, not transformed direction vectors
  76046. * @param x define the x coordinate of the source vector
  76047. * @param y define the y coordinate of the source vector
  76048. * @param z define the z coordinate of the source vector
  76049. * @param transformation defines the transformation matrix
  76050. * @param result defines the Vector3 where to store the result
  76051. */
  76052. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76053. /**
  76054. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76056. * @param vector defines the Vector3 to transform
  76057. * @param transformation defines the transformation matrix
  76058. * @returns the new Vector3
  76059. */
  76060. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76061. /**
  76062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76064. * @param vector defines the Vector3 to transform
  76065. * @param transformation defines the transformation matrix
  76066. * @param result defines the Vector3 where to store the result
  76067. */
  76068. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76069. /**
  76070. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76071. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76072. * @param x define the x coordinate of the source vector
  76073. * @param y define the y coordinate of the source vector
  76074. * @param z define the z coordinate of the source vector
  76075. * @param transformation defines the transformation matrix
  76076. * @param result defines the Vector3 where to store the result
  76077. */
  76078. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76079. /**
  76080. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76081. * @param value1 defines the first control point
  76082. * @param value2 defines the second control point
  76083. * @param value3 defines the third control point
  76084. * @param value4 defines the fourth control point
  76085. * @param amount defines the amount on the spline to use
  76086. * @returns the new Vector3
  76087. */
  76088. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76089. /**
  76090. * 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"
  76091. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76092. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76093. * @param value defines the current value
  76094. * @param min defines the lower range value
  76095. * @param max defines the upper range value
  76096. * @returns the new Vector3
  76097. */
  76098. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76099. /**
  76100. * 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"
  76101. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76102. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76103. * @param value defines the current value
  76104. * @param min defines the lower range value
  76105. * @param max defines the upper range value
  76106. * @param result defines the Vector3 where to store the result
  76107. */
  76108. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76109. /**
  76110. * Checks if a given vector is inside a specific range
  76111. * @param v defines the vector to test
  76112. * @param min defines the minimum range
  76113. * @param max defines the maximum range
  76114. */
  76115. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76116. /**
  76117. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76118. * @param value1 defines the first control point
  76119. * @param tangent1 defines the first tangent vector
  76120. * @param value2 defines the second control point
  76121. * @param tangent2 defines the second tangent vector
  76122. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76123. * @returns the new Vector3
  76124. */
  76125. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76126. /**
  76127. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76128. * @param start defines the start value
  76129. * @param end defines the end value
  76130. * @param amount max defines amount between both (between 0 and 1)
  76131. * @returns the new Vector3
  76132. */
  76133. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76134. /**
  76135. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76136. * @param start defines the start value
  76137. * @param end defines the end value
  76138. * @param amount max defines amount between both (between 0 and 1)
  76139. * @param result defines the Vector3 where to store the result
  76140. */
  76141. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76142. /**
  76143. * Returns the dot product (float) between the vectors "left" and "right"
  76144. * @param left defines the left operand
  76145. * @param right defines the right operand
  76146. * @returns the dot product
  76147. */
  76148. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76149. /**
  76150. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76151. * The cross product is then orthogonal to both "left" and "right"
  76152. * @param left defines the left operand
  76153. * @param right defines the right operand
  76154. * @returns the cross product
  76155. */
  76156. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76157. /**
  76158. * Sets the given vector "result" with the cross product of "left" and "right"
  76159. * The cross product is then orthogonal to both "left" and "right"
  76160. * @param left defines the left operand
  76161. * @param right defines the right operand
  76162. * @param result defines the Vector3 where to store the result
  76163. */
  76164. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76165. /**
  76166. * Returns a new Vector3 as the normalization of the given vector
  76167. * @param vector defines the Vector3 to normalize
  76168. * @returns the new Vector3
  76169. */
  76170. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76171. /**
  76172. * Sets the given vector "result" with the normalization of the given first vector
  76173. * @param vector defines the Vector3 to normalize
  76174. * @param result defines the Vector3 where to store the result
  76175. */
  76176. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76177. /**
  76178. * Project a Vector3 onto screen space
  76179. * @param vector defines the Vector3 to project
  76180. * @param world defines the world matrix to use
  76181. * @param transform defines the transform (view x projection) matrix to use
  76182. * @param viewport defines the screen viewport to use
  76183. * @returns the new Vector3
  76184. */
  76185. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76186. /** @hidden */
  76187. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76188. /**
  76189. * Unproject from screen space to object space
  76190. * @param source defines the screen space Vector3 to use
  76191. * @param viewportWidth defines the current width of the viewport
  76192. * @param viewportHeight defines the current height of the viewport
  76193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76194. * @param transform defines the transform (view x projection) matrix to use
  76195. * @returns the new Vector3
  76196. */
  76197. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76198. /**
  76199. * Unproject from screen space to object space
  76200. * @param source defines the screen space Vector3 to use
  76201. * @param viewportWidth defines the current width of the viewport
  76202. * @param viewportHeight defines the current height of the viewport
  76203. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76204. * @param view defines the view matrix to use
  76205. * @param projection defines the projection matrix to use
  76206. * @returns the new Vector3
  76207. */
  76208. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76209. /**
  76210. * Unproject from screen space to object space
  76211. * @param source defines the screen space Vector3 to use
  76212. * @param viewportWidth defines the current width of the viewport
  76213. * @param viewportHeight defines the current height of the viewport
  76214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76215. * @param view defines the view matrix to use
  76216. * @param projection defines the projection matrix to use
  76217. * @param result defines the Vector3 where to store the result
  76218. */
  76219. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76220. /**
  76221. * Unproject from screen space to object space
  76222. * @param sourceX defines the screen space x coordinate to use
  76223. * @param sourceY defines the screen space y coordinate to use
  76224. * @param sourceZ defines the screen space z coordinate to use
  76225. * @param viewportWidth defines the current width of the viewport
  76226. * @param viewportHeight defines the current height of the viewport
  76227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76228. * @param view defines the view matrix to use
  76229. * @param projection defines the projection matrix to use
  76230. * @param result defines the Vector3 where to store the result
  76231. */
  76232. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76233. /**
  76234. * Gets the minimal coordinate values between two Vector3
  76235. * @param left defines the first operand
  76236. * @param right defines the second operand
  76237. * @returns the new Vector3
  76238. */
  76239. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76240. /**
  76241. * Gets the maximal coordinate values between two Vector3
  76242. * @param left defines the first operand
  76243. * @param right defines the second operand
  76244. * @returns the new Vector3
  76245. */
  76246. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76247. /**
  76248. * Returns the distance between the vectors "value1" and "value2"
  76249. * @param value1 defines the first operand
  76250. * @param value2 defines the second operand
  76251. * @returns the distance
  76252. */
  76253. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76254. /**
  76255. * Returns the squared distance between the vectors "value1" and "value2"
  76256. * @param value1 defines the first operand
  76257. * @param value2 defines the second operand
  76258. * @returns the squared distance
  76259. */
  76260. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76261. /**
  76262. * Returns a new Vector3 located at the center between "value1" and "value2"
  76263. * @param value1 defines the first operand
  76264. * @param value2 defines the second operand
  76265. * @returns the new Vector3
  76266. */
  76267. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76268. /**
  76269. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76270. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76271. * to something in order to rotate it from its local system to the given target system
  76272. * Note: axis1, axis2 and axis3 are normalized during this operation
  76273. * @param axis1 defines the first axis
  76274. * @param axis2 defines the second axis
  76275. * @param axis3 defines the third axis
  76276. * @returns a new Vector3
  76277. */
  76278. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76279. /**
  76280. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76281. * @param axis1 defines the first axis
  76282. * @param axis2 defines the second axis
  76283. * @param axis3 defines the third axis
  76284. * @param ref defines the Vector3 where to store the result
  76285. */
  76286. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76287. }
  76288. /**
  76289. * Vector4 class created for EulerAngle class conversion to Quaternion
  76290. */
  76291. export class Vector4 {
  76292. /** x value of the vector */
  76293. x: number;
  76294. /** y value of the vector */
  76295. y: number;
  76296. /** z value of the vector */
  76297. z: number;
  76298. /** w value of the vector */
  76299. w: number;
  76300. /**
  76301. * Creates a Vector4 object from the given floats.
  76302. * @param x x value of the vector
  76303. * @param y y value of the vector
  76304. * @param z z value of the vector
  76305. * @param w w value of the vector
  76306. */
  76307. constructor(
  76308. /** x value of the vector */
  76309. x: number,
  76310. /** y value of the vector */
  76311. y: number,
  76312. /** z value of the vector */
  76313. z: number,
  76314. /** w value of the vector */
  76315. w: number);
  76316. /**
  76317. * Returns the string with the Vector4 coordinates.
  76318. * @returns a string containing all the vector values
  76319. */
  76320. toString(): string;
  76321. /**
  76322. * Returns the string "Vector4".
  76323. * @returns "Vector4"
  76324. */
  76325. getClassName(): string;
  76326. /**
  76327. * Returns the Vector4 hash code.
  76328. * @returns a unique hash code
  76329. */
  76330. getHashCode(): number;
  76331. /**
  76332. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76333. * @returns the resulting array
  76334. */
  76335. asArray(): number[];
  76336. /**
  76337. * Populates the given array from the given index with the Vector4 coordinates.
  76338. * @param array array to populate
  76339. * @param index index of the array to start at (default: 0)
  76340. * @returns the Vector4.
  76341. */
  76342. toArray(array: FloatArray, index?: number): Vector4;
  76343. /**
  76344. * Adds the given vector to the current Vector4.
  76345. * @param otherVector the vector to add
  76346. * @returns the updated Vector4.
  76347. */
  76348. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76349. /**
  76350. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76351. * @param otherVector the vector to add
  76352. * @returns the resulting vector
  76353. */
  76354. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76355. /**
  76356. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76357. * @param otherVector the vector to add
  76358. * @param result the vector to store the result
  76359. * @returns the current Vector4.
  76360. */
  76361. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76362. /**
  76363. * Subtract in place the given vector from the current Vector4.
  76364. * @param otherVector the vector to subtract
  76365. * @returns the updated Vector4.
  76366. */
  76367. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76368. /**
  76369. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76370. * @param otherVector the vector to add
  76371. * @returns the new vector with the result
  76372. */
  76373. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76374. /**
  76375. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76376. * @param otherVector the vector to subtract
  76377. * @param result the vector to store the result
  76378. * @returns the current Vector4.
  76379. */
  76380. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76381. /**
  76382. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76383. */
  76384. /**
  76385. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76386. * @param x value to subtract
  76387. * @param y value to subtract
  76388. * @param z value to subtract
  76389. * @param w value to subtract
  76390. * @returns new vector containing the result
  76391. */
  76392. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76393. /**
  76394. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76395. * @param x value to subtract
  76396. * @param y value to subtract
  76397. * @param z value to subtract
  76398. * @param w value to subtract
  76399. * @param result the vector to store the result in
  76400. * @returns the current Vector4.
  76401. */
  76402. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76403. /**
  76404. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76405. * @returns a new vector with the negated values
  76406. */
  76407. negate(): Vector4;
  76408. /**
  76409. * Negate this vector in place
  76410. * @returns this
  76411. */
  76412. negateInPlace(): Vector4;
  76413. /**
  76414. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76415. * @param result defines the Vector3 object where to store the result
  76416. * @returns the current Vector4
  76417. */
  76418. negateToRef(result: Vector4): Vector4;
  76419. /**
  76420. * Multiplies the current Vector4 coordinates by scale (float).
  76421. * @param scale the number to scale with
  76422. * @returns the updated Vector4.
  76423. */
  76424. scaleInPlace(scale: number): Vector4;
  76425. /**
  76426. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76427. * @param scale the number to scale with
  76428. * @returns a new vector with the result
  76429. */
  76430. scale(scale: number): Vector4;
  76431. /**
  76432. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76433. * @param scale the number to scale with
  76434. * @param result a vector to store the result in
  76435. * @returns the current Vector4.
  76436. */
  76437. scaleToRef(scale: number, result: Vector4): Vector4;
  76438. /**
  76439. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76440. * @param scale defines the scale factor
  76441. * @param result defines the Vector4 object where to store the result
  76442. * @returns the unmodified current Vector4
  76443. */
  76444. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76445. /**
  76446. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76447. * @param otherVector the vector to compare against
  76448. * @returns true if they are equal
  76449. */
  76450. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76451. /**
  76452. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76453. * @param otherVector vector to compare against
  76454. * @param epsilon (Default: very small number)
  76455. * @returns true if they are equal
  76456. */
  76457. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76458. /**
  76459. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76460. * @param x x value to compare against
  76461. * @param y y value to compare against
  76462. * @param z z value to compare against
  76463. * @param w w value to compare against
  76464. * @returns true if equal
  76465. */
  76466. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76467. /**
  76468. * Multiplies in place the current Vector4 by the given one.
  76469. * @param otherVector vector to multiple with
  76470. * @returns the updated Vector4.
  76471. */
  76472. multiplyInPlace(otherVector: Vector4): Vector4;
  76473. /**
  76474. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76475. * @param otherVector vector to multiple with
  76476. * @returns resulting new vector
  76477. */
  76478. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76479. /**
  76480. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76481. * @param otherVector vector to multiple with
  76482. * @param result vector to store the result
  76483. * @returns the current Vector4.
  76484. */
  76485. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76486. /**
  76487. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76488. * @param x x value multiply with
  76489. * @param y y value multiply with
  76490. * @param z z value multiply with
  76491. * @param w w value multiply with
  76492. * @returns resulting new vector
  76493. */
  76494. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76495. /**
  76496. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76497. * @param otherVector vector to devide with
  76498. * @returns resulting new vector
  76499. */
  76500. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76501. /**
  76502. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76503. * @param otherVector vector to devide with
  76504. * @param result vector to store the result
  76505. * @returns the current Vector4.
  76506. */
  76507. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76508. /**
  76509. * Divides the current Vector3 coordinates by the given ones.
  76510. * @param otherVector vector to devide with
  76511. * @returns the updated Vector3.
  76512. */
  76513. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76514. /**
  76515. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76516. * @param other defines the second operand
  76517. * @returns the current updated Vector4
  76518. */
  76519. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76520. /**
  76521. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76522. * @param other defines the second operand
  76523. * @returns the current updated Vector4
  76524. */
  76525. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76526. /**
  76527. * Gets a new Vector4 from current Vector4 floored values
  76528. * @returns a new Vector4
  76529. */
  76530. floor(): Vector4;
  76531. /**
  76532. * Gets a new Vector4 from current Vector3 floored values
  76533. * @returns a new Vector4
  76534. */
  76535. fract(): Vector4;
  76536. /**
  76537. * Returns the Vector4 length (float).
  76538. * @returns the length
  76539. */
  76540. length(): number;
  76541. /**
  76542. * Returns the Vector4 squared length (float).
  76543. * @returns the length squared
  76544. */
  76545. lengthSquared(): number;
  76546. /**
  76547. * Normalizes in place the Vector4.
  76548. * @returns the updated Vector4.
  76549. */
  76550. normalize(): Vector4;
  76551. /**
  76552. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76553. * @returns this converted to a new vector3
  76554. */
  76555. toVector3(): Vector3;
  76556. /**
  76557. * Returns a new Vector4 copied from the current one.
  76558. * @returns the new cloned vector
  76559. */
  76560. clone(): Vector4;
  76561. /**
  76562. * Updates the current Vector4 with the given one coordinates.
  76563. * @param source the source vector to copy from
  76564. * @returns the updated Vector4.
  76565. */
  76566. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76567. /**
  76568. * Updates the current Vector4 coordinates with the given floats.
  76569. * @param x float to copy from
  76570. * @param y float to copy from
  76571. * @param z float to copy from
  76572. * @param w float to copy from
  76573. * @returns the updated Vector4.
  76574. */
  76575. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76576. /**
  76577. * Updates the current Vector4 coordinates with the given floats.
  76578. * @param x float to set from
  76579. * @param y float to set from
  76580. * @param z float to set from
  76581. * @param w float to set from
  76582. * @returns the updated Vector4.
  76583. */
  76584. set(x: number, y: number, z: number, w: number): Vector4;
  76585. /**
  76586. * Copies the given float to the current Vector3 coordinates
  76587. * @param v defines the x, y, z and w coordinates of the operand
  76588. * @returns the current updated Vector3
  76589. */
  76590. setAll(v: number): Vector4;
  76591. /**
  76592. * Returns a new Vector4 set from the starting index of the given array.
  76593. * @param array the array to pull values from
  76594. * @param offset the offset into the array to start at
  76595. * @returns the new vector
  76596. */
  76597. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76598. /**
  76599. * Updates the given vector "result" from the starting index of the given array.
  76600. * @param array the array to pull values from
  76601. * @param offset the offset into the array to start at
  76602. * @param result the vector to store the result in
  76603. */
  76604. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76605. /**
  76606. * Updates the given vector "result" from the starting index of the given Float32Array.
  76607. * @param array the array to pull values from
  76608. * @param offset the offset into the array to start at
  76609. * @param result the vector to store the result in
  76610. */
  76611. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76612. /**
  76613. * Updates the given vector "result" coordinates from the given floats.
  76614. * @param x float to set from
  76615. * @param y float to set from
  76616. * @param z float to set from
  76617. * @param w float to set from
  76618. * @param result the vector to the floats in
  76619. */
  76620. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76621. /**
  76622. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76623. * @returns the new vector
  76624. */
  76625. static Zero(): Vector4;
  76626. /**
  76627. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76628. * @returns the new vector
  76629. */
  76630. static One(): Vector4;
  76631. /**
  76632. * Returns a new normalized Vector4 from the given one.
  76633. * @param vector the vector to normalize
  76634. * @returns the vector
  76635. */
  76636. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76637. /**
  76638. * Updates the given vector "result" from the normalization of the given one.
  76639. * @param vector the vector to normalize
  76640. * @param result the vector to store the result in
  76641. */
  76642. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76643. /**
  76644. * Returns a vector with the minimum values from the left and right vectors
  76645. * @param left left vector to minimize
  76646. * @param right right vector to minimize
  76647. * @returns a new vector with the minimum of the left and right vector values
  76648. */
  76649. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76650. /**
  76651. * Returns a vector with the maximum values from the left and right vectors
  76652. * @param left left vector to maximize
  76653. * @param right right vector to maximize
  76654. * @returns a new vector with the maximum of the left and right vector values
  76655. */
  76656. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76657. /**
  76658. * Returns the distance (float) between the vectors "value1" and "value2".
  76659. * @param value1 value to calulate the distance between
  76660. * @param value2 value to calulate the distance between
  76661. * @return the distance between the two vectors
  76662. */
  76663. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76664. /**
  76665. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76666. * @param value1 value to calulate the distance between
  76667. * @param value2 value to calulate the distance between
  76668. * @return the distance between the two vectors squared
  76669. */
  76670. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76671. /**
  76672. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76673. * @param value1 value to calulate the center between
  76674. * @param value2 value to calulate the center between
  76675. * @return the center between the two vectors
  76676. */
  76677. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76678. /**
  76679. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76680. * This methods computes transformed normalized direction vectors only.
  76681. * @param vector the vector to transform
  76682. * @param transformation the transformation matrix to apply
  76683. * @returns the new vector
  76684. */
  76685. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76686. /**
  76687. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76688. * This methods computes transformed normalized direction vectors only.
  76689. * @param vector the vector to transform
  76690. * @param transformation the transformation matrix to apply
  76691. * @param result the vector to store the result in
  76692. */
  76693. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76694. /**
  76695. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76696. * This methods computes transformed normalized direction vectors only.
  76697. * @param x value to transform
  76698. * @param y value to transform
  76699. * @param z value to transform
  76700. * @param w value to transform
  76701. * @param transformation the transformation matrix to apply
  76702. * @param result the vector to store the results in
  76703. */
  76704. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76705. /**
  76706. * Creates a new Vector4 from a Vector3
  76707. * @param source defines the source data
  76708. * @param w defines the 4th component (default is 0)
  76709. * @returns a new Vector4
  76710. */
  76711. static FromVector3(source: Vector3, w?: number): Vector4;
  76712. }
  76713. /**
  76714. * Class used to store quaternion data
  76715. * @see https://en.wikipedia.org/wiki/Quaternion
  76716. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76717. */
  76718. export class Quaternion {
  76719. /** defines the first component (0 by default) */
  76720. x: number;
  76721. /** defines the second component (0 by default) */
  76722. y: number;
  76723. /** defines the third component (0 by default) */
  76724. z: number;
  76725. /** defines the fourth component (1.0 by default) */
  76726. w: number;
  76727. /**
  76728. * Creates a new Quaternion from the given floats
  76729. * @param x defines the first component (0 by default)
  76730. * @param y defines the second component (0 by default)
  76731. * @param z defines the third component (0 by default)
  76732. * @param w defines the fourth component (1.0 by default)
  76733. */
  76734. constructor(
  76735. /** defines the first component (0 by default) */
  76736. x?: number,
  76737. /** defines the second component (0 by default) */
  76738. y?: number,
  76739. /** defines the third component (0 by default) */
  76740. z?: number,
  76741. /** defines the fourth component (1.0 by default) */
  76742. w?: number);
  76743. /**
  76744. * Gets a string representation for the current quaternion
  76745. * @returns a string with the Quaternion coordinates
  76746. */
  76747. toString(): string;
  76748. /**
  76749. * Gets the class name of the quaternion
  76750. * @returns the string "Quaternion"
  76751. */
  76752. getClassName(): string;
  76753. /**
  76754. * Gets a hash code for this quaternion
  76755. * @returns the quaternion hash code
  76756. */
  76757. getHashCode(): number;
  76758. /**
  76759. * Copy the quaternion to an array
  76760. * @returns a new array populated with 4 elements from the quaternion coordinates
  76761. */
  76762. asArray(): number[];
  76763. /**
  76764. * Check if two quaternions are equals
  76765. * @param otherQuaternion defines the second operand
  76766. * @return true if the current quaternion and the given one coordinates are strictly equals
  76767. */
  76768. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76769. /**
  76770. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76771. * @param otherQuaternion defines the other quaternion
  76772. * @param epsilon defines the minimal distance to consider equality
  76773. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76774. */
  76775. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76776. /**
  76777. * Clone the current quaternion
  76778. * @returns a new quaternion copied from the current one
  76779. */
  76780. clone(): Quaternion;
  76781. /**
  76782. * Copy a quaternion to the current one
  76783. * @param other defines the other quaternion
  76784. * @returns the updated current quaternion
  76785. */
  76786. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76787. /**
  76788. * Updates the current quaternion with the given float coordinates
  76789. * @param x defines the x coordinate
  76790. * @param y defines the y coordinate
  76791. * @param z defines the z coordinate
  76792. * @param w defines the w coordinate
  76793. * @returns the updated current quaternion
  76794. */
  76795. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76796. /**
  76797. * Updates the current quaternion from the given float coordinates
  76798. * @param x defines the x coordinate
  76799. * @param y defines the y coordinate
  76800. * @param z defines the z coordinate
  76801. * @param w defines the w coordinate
  76802. * @returns the updated current quaternion
  76803. */
  76804. set(x: number, y: number, z: number, w: number): Quaternion;
  76805. /**
  76806. * Adds two quaternions
  76807. * @param other defines the second operand
  76808. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76809. */
  76810. add(other: DeepImmutable<Quaternion>): Quaternion;
  76811. /**
  76812. * Add a quaternion to the current one
  76813. * @param other defines the quaternion to add
  76814. * @returns the current quaternion
  76815. */
  76816. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76817. /**
  76818. * Subtract two quaternions
  76819. * @param other defines the second operand
  76820. * @returns a new quaternion as the subtraction result of the given one from the current one
  76821. */
  76822. subtract(other: Quaternion): Quaternion;
  76823. /**
  76824. * Multiplies the current quaternion by a scale factor
  76825. * @param value defines the scale factor
  76826. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76827. */
  76828. scale(value: number): Quaternion;
  76829. /**
  76830. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76831. * @param scale defines the scale factor
  76832. * @param result defines the Quaternion object where to store the result
  76833. * @returns the unmodified current quaternion
  76834. */
  76835. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76836. /**
  76837. * Multiplies in place the current quaternion by a scale factor
  76838. * @param value defines the scale factor
  76839. * @returns the current modified quaternion
  76840. */
  76841. scaleInPlace(value: number): Quaternion;
  76842. /**
  76843. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76844. * @param scale defines the scale factor
  76845. * @param result defines the Quaternion object where to store the result
  76846. * @returns the unmodified current quaternion
  76847. */
  76848. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76849. /**
  76850. * Multiplies two quaternions
  76851. * @param q1 defines the second operand
  76852. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76853. */
  76854. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76855. /**
  76856. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76857. * @param q1 defines the second operand
  76858. * @param result defines the target quaternion
  76859. * @returns the current quaternion
  76860. */
  76861. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76862. /**
  76863. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76864. * @param q1 defines the second operand
  76865. * @returns the currentupdated quaternion
  76866. */
  76867. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76868. /**
  76869. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76870. * @param ref defines the target quaternion
  76871. * @returns the current quaternion
  76872. */
  76873. conjugateToRef(ref: Quaternion): Quaternion;
  76874. /**
  76875. * Conjugates in place (1-q) the current quaternion
  76876. * @returns the current updated quaternion
  76877. */
  76878. conjugateInPlace(): Quaternion;
  76879. /**
  76880. * Conjugates in place (1-q) the current quaternion
  76881. * @returns a new quaternion
  76882. */
  76883. conjugate(): Quaternion;
  76884. /**
  76885. * Gets length of current quaternion
  76886. * @returns the quaternion length (float)
  76887. */
  76888. length(): number;
  76889. /**
  76890. * Normalize in place the current quaternion
  76891. * @returns the current updated quaternion
  76892. */
  76893. normalize(): Quaternion;
  76894. /**
  76895. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76896. * @param order is a reserved parameter and is ignore for now
  76897. * @returns a new Vector3 containing the Euler angles
  76898. */
  76899. toEulerAngles(order?: string): Vector3;
  76900. /**
  76901. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76902. * @param result defines the vector which will be filled with the Euler angles
  76903. * @param order is a reserved parameter and is ignore for now
  76904. * @returns the current unchanged quaternion
  76905. */
  76906. toEulerAnglesToRef(result: Vector3): Quaternion;
  76907. /**
  76908. * Updates the given rotation matrix with the current quaternion values
  76909. * @param result defines the target matrix
  76910. * @returns the current unchanged quaternion
  76911. */
  76912. toRotationMatrix(result: Matrix): Quaternion;
  76913. /**
  76914. * Updates the current quaternion from the given rotation matrix values
  76915. * @param matrix defines the source matrix
  76916. * @returns the current updated quaternion
  76917. */
  76918. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76919. /**
  76920. * Creates a new quaternion from a rotation matrix
  76921. * @param matrix defines the source matrix
  76922. * @returns a new quaternion created from the given rotation matrix values
  76923. */
  76924. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76925. /**
  76926. * Updates the given quaternion with the given rotation matrix values
  76927. * @param matrix defines the source matrix
  76928. * @param result defines the target quaternion
  76929. */
  76930. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76931. /**
  76932. * Returns the dot product (float) between the quaternions "left" and "right"
  76933. * @param left defines the left operand
  76934. * @param right defines the right operand
  76935. * @returns the dot product
  76936. */
  76937. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76938. /**
  76939. * Checks if the two quaternions are close to each other
  76940. * @param quat0 defines the first quaternion to check
  76941. * @param quat1 defines the second quaternion to check
  76942. * @returns true if the two quaternions are close to each other
  76943. */
  76944. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76945. /**
  76946. * Creates an empty quaternion
  76947. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76948. */
  76949. static Zero(): Quaternion;
  76950. /**
  76951. * Inverse a given quaternion
  76952. * @param q defines the source quaternion
  76953. * @returns a new quaternion as the inverted current quaternion
  76954. */
  76955. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76956. /**
  76957. * Inverse a given quaternion
  76958. * @param q defines the source quaternion
  76959. * @param result the quaternion the result will be stored in
  76960. * @returns the result quaternion
  76961. */
  76962. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76963. /**
  76964. * Creates an identity quaternion
  76965. * @returns the identity quaternion
  76966. */
  76967. static Identity(): Quaternion;
  76968. /**
  76969. * Gets a boolean indicating if the given quaternion is identity
  76970. * @param quaternion defines the quaternion to check
  76971. * @returns true if the quaternion is identity
  76972. */
  76973. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76974. /**
  76975. * Creates a quaternion from a rotation around an axis
  76976. * @param axis defines the axis to use
  76977. * @param angle defines the angle to use
  76978. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76979. */
  76980. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76981. /**
  76982. * Creates a rotation around an axis and stores it into the given quaternion
  76983. * @param axis defines the axis to use
  76984. * @param angle defines the angle to use
  76985. * @param result defines the target quaternion
  76986. * @returns the target quaternion
  76987. */
  76988. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76989. /**
  76990. * Creates a new quaternion from data stored into an array
  76991. * @param array defines the data source
  76992. * @param offset defines the offset in the source array where the data starts
  76993. * @returns a new quaternion
  76994. */
  76995. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76996. /**
  76997. * Create a quaternion from Euler rotation angles
  76998. * @param x Pitch
  76999. * @param y Yaw
  77000. * @param z Roll
  77001. * @returns the new Quaternion
  77002. */
  77003. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77004. /**
  77005. * Updates a quaternion from Euler rotation angles
  77006. * @param x Pitch
  77007. * @param y Yaw
  77008. * @param z Roll
  77009. * @param result the quaternion to store the result
  77010. * @returns the updated quaternion
  77011. */
  77012. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77013. /**
  77014. * Create a quaternion from Euler rotation vector
  77015. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77016. * @returns the new Quaternion
  77017. */
  77018. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77019. /**
  77020. * Updates a quaternion from Euler rotation vector
  77021. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77022. * @param result the quaternion to store the result
  77023. * @returns the updated quaternion
  77024. */
  77025. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77026. /**
  77027. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77028. * @param yaw defines the rotation around Y axis
  77029. * @param pitch defines the rotation around X axis
  77030. * @param roll defines the rotation around Z axis
  77031. * @returns the new quaternion
  77032. */
  77033. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77034. /**
  77035. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77036. * @param yaw defines the rotation around Y axis
  77037. * @param pitch defines the rotation around X axis
  77038. * @param roll defines the rotation around Z axis
  77039. * @param result defines the target quaternion
  77040. */
  77041. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77042. /**
  77043. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77044. * @param alpha defines the rotation around first axis
  77045. * @param beta defines the rotation around second axis
  77046. * @param gamma defines the rotation around third axis
  77047. * @returns the new quaternion
  77048. */
  77049. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77050. /**
  77051. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77052. * @param alpha defines the rotation around first axis
  77053. * @param beta defines the rotation around second axis
  77054. * @param gamma defines the rotation around third axis
  77055. * @param result defines the target quaternion
  77056. */
  77057. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77058. /**
  77059. * 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)
  77060. * @param axis1 defines the first axis
  77061. * @param axis2 defines the second axis
  77062. * @param axis3 defines the third axis
  77063. * @returns the new quaternion
  77064. */
  77065. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77066. /**
  77067. * 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
  77068. * @param axis1 defines the first axis
  77069. * @param axis2 defines the second axis
  77070. * @param axis3 defines the third axis
  77071. * @param ref defines the target quaternion
  77072. */
  77073. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77074. /**
  77075. * Interpolates between two quaternions
  77076. * @param left defines first quaternion
  77077. * @param right defines second quaternion
  77078. * @param amount defines the gradient to use
  77079. * @returns the new interpolated quaternion
  77080. */
  77081. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77082. /**
  77083. * Interpolates between two quaternions and stores it into a target quaternion
  77084. * @param left defines first quaternion
  77085. * @param right defines second quaternion
  77086. * @param amount defines the gradient to use
  77087. * @param result defines the target quaternion
  77088. */
  77089. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77090. /**
  77091. * Interpolate between two quaternions using Hermite interpolation
  77092. * @param value1 defines first quaternion
  77093. * @param tangent1 defines the incoming tangent
  77094. * @param value2 defines second quaternion
  77095. * @param tangent2 defines the outgoing tangent
  77096. * @param amount defines the target quaternion
  77097. * @returns the new interpolated quaternion
  77098. */
  77099. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77100. }
  77101. /**
  77102. * Class used to store matrix data (4x4)
  77103. */
  77104. export class Matrix {
  77105. private static _updateFlagSeed;
  77106. private static _identityReadOnly;
  77107. private _isIdentity;
  77108. private _isIdentityDirty;
  77109. private _isIdentity3x2;
  77110. private _isIdentity3x2Dirty;
  77111. /**
  77112. * Gets the update flag of the matrix which is an unique number for the matrix.
  77113. * It will be incremented every time the matrix data change.
  77114. * You can use it to speed the comparison between two versions of the same matrix.
  77115. */
  77116. updateFlag: number;
  77117. private readonly _m;
  77118. /**
  77119. * Gets the internal data of the matrix
  77120. */
  77121. get m(): DeepImmutable<Float32Array>;
  77122. /** @hidden */
  77123. _markAsUpdated(): void;
  77124. /** @hidden */
  77125. private _updateIdentityStatus;
  77126. /**
  77127. * Creates an empty matrix (filled with zeros)
  77128. */
  77129. constructor();
  77130. /**
  77131. * Check if the current matrix is identity
  77132. * @returns true is the matrix is the identity matrix
  77133. */
  77134. isIdentity(): boolean;
  77135. /**
  77136. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77137. * @returns true is the matrix is the identity matrix
  77138. */
  77139. isIdentityAs3x2(): boolean;
  77140. /**
  77141. * Gets the determinant of the matrix
  77142. * @returns the matrix determinant
  77143. */
  77144. determinant(): number;
  77145. /**
  77146. * Returns the matrix as a Float32Array
  77147. * @returns the matrix underlying array
  77148. */
  77149. toArray(): DeepImmutable<Float32Array>;
  77150. /**
  77151. * Returns the matrix as a Float32Array
  77152. * @returns the matrix underlying array.
  77153. */
  77154. asArray(): DeepImmutable<Float32Array>;
  77155. /**
  77156. * Inverts the current matrix in place
  77157. * @returns the current inverted matrix
  77158. */
  77159. invert(): Matrix;
  77160. /**
  77161. * Sets all the matrix elements to zero
  77162. * @returns the current matrix
  77163. */
  77164. reset(): Matrix;
  77165. /**
  77166. * Adds the current matrix with a second one
  77167. * @param other defines the matrix to add
  77168. * @returns a new matrix as the addition of the current matrix and the given one
  77169. */
  77170. add(other: DeepImmutable<Matrix>): Matrix;
  77171. /**
  77172. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77173. * @param other defines the matrix to add
  77174. * @param result defines the target matrix
  77175. * @returns the current matrix
  77176. */
  77177. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77178. /**
  77179. * Adds in place the given matrix to the current matrix
  77180. * @param other defines the second operand
  77181. * @returns the current updated matrix
  77182. */
  77183. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77184. /**
  77185. * Sets the given matrix to the current inverted Matrix
  77186. * @param other defines the target matrix
  77187. * @returns the unmodified current matrix
  77188. */
  77189. invertToRef(other: Matrix): Matrix;
  77190. /**
  77191. * add a value at the specified position in the current Matrix
  77192. * @param index the index of the value within the matrix. between 0 and 15.
  77193. * @param value the value to be added
  77194. * @returns the current updated matrix
  77195. */
  77196. addAtIndex(index: number, value: number): Matrix;
  77197. /**
  77198. * mutiply the specified position in the current Matrix by a value
  77199. * @param index the index of the value within the matrix. between 0 and 15.
  77200. * @param value the value to be added
  77201. * @returns the current updated matrix
  77202. */
  77203. multiplyAtIndex(index: number, value: number): Matrix;
  77204. /**
  77205. * Inserts the translation vector (using 3 floats) in the current matrix
  77206. * @param x defines the 1st component of the translation
  77207. * @param y defines the 2nd component of the translation
  77208. * @param z defines the 3rd component of the translation
  77209. * @returns the current updated matrix
  77210. */
  77211. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77212. /**
  77213. * Adds the translation vector (using 3 floats) in the current matrix
  77214. * @param x defines the 1st component of the translation
  77215. * @param y defines the 2nd component of the translation
  77216. * @param z defines the 3rd component of the translation
  77217. * @returns the current updated matrix
  77218. */
  77219. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77220. /**
  77221. * Inserts the translation vector in the current matrix
  77222. * @param vector3 defines the translation to insert
  77223. * @returns the current updated matrix
  77224. */
  77225. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77226. /**
  77227. * Gets the translation value of the current matrix
  77228. * @returns a new Vector3 as the extracted translation from the matrix
  77229. */
  77230. getTranslation(): Vector3;
  77231. /**
  77232. * Fill a Vector3 with the extracted translation from the matrix
  77233. * @param result defines the Vector3 where to store the translation
  77234. * @returns the current matrix
  77235. */
  77236. getTranslationToRef(result: Vector3): Matrix;
  77237. /**
  77238. * Remove rotation and scaling part from the matrix
  77239. * @returns the updated matrix
  77240. */
  77241. removeRotationAndScaling(): Matrix;
  77242. /**
  77243. * Multiply two matrices
  77244. * @param other defines the second operand
  77245. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77246. */
  77247. multiply(other: DeepImmutable<Matrix>): Matrix;
  77248. /**
  77249. * Copy the current matrix from the given one
  77250. * @param other defines the source matrix
  77251. * @returns the current updated matrix
  77252. */
  77253. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77254. /**
  77255. * Populates the given array from the starting index with the current matrix values
  77256. * @param array defines the target array
  77257. * @param offset defines the offset in the target array where to start storing values
  77258. * @returns the current matrix
  77259. */
  77260. copyToArray(array: Float32Array, offset?: number): Matrix;
  77261. /**
  77262. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77263. * @param other defines the second operand
  77264. * @param result defines the matrix where to store the multiplication
  77265. * @returns the current matrix
  77266. */
  77267. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77268. /**
  77269. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77270. * @param other defines the second operand
  77271. * @param result defines the array where to store the multiplication
  77272. * @param offset defines the offset in the target array where to start storing values
  77273. * @returns the current matrix
  77274. */
  77275. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77276. /**
  77277. * Check equality between this matrix and a second one
  77278. * @param value defines the second matrix to compare
  77279. * @returns true is the current matrix and the given one values are strictly equal
  77280. */
  77281. equals(value: DeepImmutable<Matrix>): boolean;
  77282. /**
  77283. * Clone the current matrix
  77284. * @returns a new matrix from the current matrix
  77285. */
  77286. clone(): Matrix;
  77287. /**
  77288. * Returns the name of the current matrix class
  77289. * @returns the string "Matrix"
  77290. */
  77291. getClassName(): string;
  77292. /**
  77293. * Gets the hash code of the current matrix
  77294. * @returns the hash code
  77295. */
  77296. getHashCode(): number;
  77297. /**
  77298. * Decomposes the current Matrix into a translation, rotation and scaling components
  77299. * @param scale defines the scale vector3 given as a reference to update
  77300. * @param rotation defines the rotation quaternion given as a reference to update
  77301. * @param translation defines the translation vector3 given as a reference to update
  77302. * @returns true if operation was successful
  77303. */
  77304. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77305. /**
  77306. * Gets specific row of the matrix
  77307. * @param index defines the number of the row to get
  77308. * @returns the index-th row of the current matrix as a new Vector4
  77309. */
  77310. getRow(index: number): Nullable<Vector4>;
  77311. /**
  77312. * Sets the index-th row of the current matrix to the vector4 values
  77313. * @param index defines the number of the row to set
  77314. * @param row defines the target vector4
  77315. * @returns the updated current matrix
  77316. */
  77317. setRow(index: number, row: Vector4): Matrix;
  77318. /**
  77319. * Compute the transpose of the matrix
  77320. * @returns the new transposed matrix
  77321. */
  77322. transpose(): Matrix;
  77323. /**
  77324. * Compute the transpose of the matrix and store it in a given matrix
  77325. * @param result defines the target matrix
  77326. * @returns the current matrix
  77327. */
  77328. transposeToRef(result: Matrix): Matrix;
  77329. /**
  77330. * Sets the index-th row of the current matrix with the given 4 x float values
  77331. * @param index defines the row index
  77332. * @param x defines the x component to set
  77333. * @param y defines the y component to set
  77334. * @param z defines the z component to set
  77335. * @param w defines the w component to set
  77336. * @returns the updated current matrix
  77337. */
  77338. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77339. /**
  77340. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77341. * @param scale defines the scale factor
  77342. * @returns a new matrix
  77343. */
  77344. scale(scale: number): Matrix;
  77345. /**
  77346. * Scale the current matrix values by a factor to a given result matrix
  77347. * @param scale defines the scale factor
  77348. * @param result defines the matrix to store the result
  77349. * @returns the current matrix
  77350. */
  77351. scaleToRef(scale: number, result: Matrix): Matrix;
  77352. /**
  77353. * Scale the current matrix values by a factor and add the result to a given matrix
  77354. * @param scale defines the scale factor
  77355. * @param result defines the Matrix to store the result
  77356. * @returns the current matrix
  77357. */
  77358. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77359. /**
  77360. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77361. * @param ref matrix to store the result
  77362. */
  77363. toNormalMatrix(ref: Matrix): void;
  77364. /**
  77365. * Gets only rotation part of the current matrix
  77366. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77367. */
  77368. getRotationMatrix(): Matrix;
  77369. /**
  77370. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77371. * @param result defines the target matrix to store data to
  77372. * @returns the current matrix
  77373. */
  77374. getRotationMatrixToRef(result: Matrix): Matrix;
  77375. /**
  77376. * Toggles model matrix from being right handed to left handed in place and vice versa
  77377. */
  77378. toggleModelMatrixHandInPlace(): void;
  77379. /**
  77380. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77381. */
  77382. toggleProjectionMatrixHandInPlace(): void;
  77383. /**
  77384. * Creates a matrix from an array
  77385. * @param array defines the source array
  77386. * @param offset defines an offset in the source array
  77387. * @returns a new Matrix set from the starting index of the given array
  77388. */
  77389. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77390. /**
  77391. * Copy the content of an array into a given matrix
  77392. * @param array defines the source array
  77393. * @param offset defines an offset in the source array
  77394. * @param result defines the target matrix
  77395. */
  77396. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77397. /**
  77398. * Stores an array into a matrix after having multiplied each component by a given factor
  77399. * @param array defines the source array
  77400. * @param offset defines the offset in the source array
  77401. * @param scale defines the scaling factor
  77402. * @param result defines the target matrix
  77403. */
  77404. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77405. /**
  77406. * Gets an identity matrix that must not be updated
  77407. */
  77408. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77409. /**
  77410. * Stores a list of values (16) inside a given matrix
  77411. * @param initialM11 defines 1st value of 1st row
  77412. * @param initialM12 defines 2nd value of 1st row
  77413. * @param initialM13 defines 3rd value of 1st row
  77414. * @param initialM14 defines 4th value of 1st row
  77415. * @param initialM21 defines 1st value of 2nd row
  77416. * @param initialM22 defines 2nd value of 2nd row
  77417. * @param initialM23 defines 3rd value of 2nd row
  77418. * @param initialM24 defines 4th value of 2nd row
  77419. * @param initialM31 defines 1st value of 3rd row
  77420. * @param initialM32 defines 2nd value of 3rd row
  77421. * @param initialM33 defines 3rd value of 3rd row
  77422. * @param initialM34 defines 4th value of 3rd row
  77423. * @param initialM41 defines 1st value of 4th row
  77424. * @param initialM42 defines 2nd value of 4th row
  77425. * @param initialM43 defines 3rd value of 4th row
  77426. * @param initialM44 defines 4th value of 4th row
  77427. * @param result defines the target matrix
  77428. */
  77429. 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;
  77430. /**
  77431. * Creates new matrix from a list of values (16)
  77432. * @param initialM11 defines 1st value of 1st row
  77433. * @param initialM12 defines 2nd value of 1st row
  77434. * @param initialM13 defines 3rd value of 1st row
  77435. * @param initialM14 defines 4th value of 1st row
  77436. * @param initialM21 defines 1st value of 2nd row
  77437. * @param initialM22 defines 2nd value of 2nd row
  77438. * @param initialM23 defines 3rd value of 2nd row
  77439. * @param initialM24 defines 4th value of 2nd row
  77440. * @param initialM31 defines 1st value of 3rd row
  77441. * @param initialM32 defines 2nd value of 3rd row
  77442. * @param initialM33 defines 3rd value of 3rd row
  77443. * @param initialM34 defines 4th value of 3rd row
  77444. * @param initialM41 defines 1st value of 4th row
  77445. * @param initialM42 defines 2nd value of 4th row
  77446. * @param initialM43 defines 3rd value of 4th row
  77447. * @param initialM44 defines 4th value of 4th row
  77448. * @returns the new matrix
  77449. */
  77450. 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;
  77451. /**
  77452. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77453. * @param scale defines the scale vector3
  77454. * @param rotation defines the rotation quaternion
  77455. * @param translation defines the translation vector3
  77456. * @returns a new matrix
  77457. */
  77458. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77459. /**
  77460. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77461. * @param scale defines the scale vector3
  77462. * @param rotation defines the rotation quaternion
  77463. * @param translation defines the translation vector3
  77464. * @param result defines the target matrix
  77465. */
  77466. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77467. /**
  77468. * Creates a new identity matrix
  77469. * @returns a new identity matrix
  77470. */
  77471. static Identity(): Matrix;
  77472. /**
  77473. * Creates a new identity matrix and stores the result in a given matrix
  77474. * @param result defines the target matrix
  77475. */
  77476. static IdentityToRef(result: Matrix): void;
  77477. /**
  77478. * Creates a new zero matrix
  77479. * @returns a new zero matrix
  77480. */
  77481. static Zero(): Matrix;
  77482. /**
  77483. * Creates a new rotation matrix for "angle" radians around the X axis
  77484. * @param angle defines the angle (in radians) to use
  77485. * @return the new matrix
  77486. */
  77487. static RotationX(angle: number): Matrix;
  77488. /**
  77489. * Creates a new matrix as the invert of a given matrix
  77490. * @param source defines the source matrix
  77491. * @returns the new matrix
  77492. */
  77493. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77494. /**
  77495. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77496. * @param angle defines the angle (in radians) to use
  77497. * @param result defines the target matrix
  77498. */
  77499. static RotationXToRef(angle: number, result: Matrix): void;
  77500. /**
  77501. * Creates a new rotation matrix for "angle" radians around the Y axis
  77502. * @param angle defines the angle (in radians) to use
  77503. * @return the new matrix
  77504. */
  77505. static RotationY(angle: number): Matrix;
  77506. /**
  77507. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77508. * @param angle defines the angle (in radians) to use
  77509. * @param result defines the target matrix
  77510. */
  77511. static RotationYToRef(angle: number, result: Matrix): void;
  77512. /**
  77513. * Creates a new rotation matrix for "angle" radians around the Z axis
  77514. * @param angle defines the angle (in radians) to use
  77515. * @return the new matrix
  77516. */
  77517. static RotationZ(angle: number): Matrix;
  77518. /**
  77519. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77520. * @param angle defines the angle (in radians) to use
  77521. * @param result defines the target matrix
  77522. */
  77523. static RotationZToRef(angle: number, result: Matrix): void;
  77524. /**
  77525. * Creates a new rotation matrix for "angle" radians around the given axis
  77526. * @param axis defines the axis to use
  77527. * @param angle defines the angle (in radians) to use
  77528. * @return the new matrix
  77529. */
  77530. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77531. /**
  77532. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77533. * @param axis defines the axis to use
  77534. * @param angle defines the angle (in radians) to use
  77535. * @param result defines the target matrix
  77536. */
  77537. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77538. /**
  77539. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77540. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77541. * @param from defines the vector to align
  77542. * @param to defines the vector to align to
  77543. * @param result defines the target matrix
  77544. */
  77545. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77546. /**
  77547. * Creates a rotation matrix
  77548. * @param yaw defines the yaw angle in radians (Y axis)
  77549. * @param pitch defines the pitch angle in radians (X axis)
  77550. * @param roll defines the roll angle in radians (X axis)
  77551. * @returns the new rotation matrix
  77552. */
  77553. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77554. /**
  77555. * Creates a rotation matrix and stores it in a given matrix
  77556. * @param yaw defines the yaw angle in radians (Y axis)
  77557. * @param pitch defines the pitch angle in radians (X axis)
  77558. * @param roll defines the roll angle in radians (X axis)
  77559. * @param result defines the target matrix
  77560. */
  77561. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77562. /**
  77563. * Creates a scaling matrix
  77564. * @param x defines the scale factor on X axis
  77565. * @param y defines the scale factor on Y axis
  77566. * @param z defines the scale factor on Z axis
  77567. * @returns the new matrix
  77568. */
  77569. static Scaling(x: number, y: number, z: number): Matrix;
  77570. /**
  77571. * Creates a scaling matrix and stores it in a given matrix
  77572. * @param x defines the scale factor on X axis
  77573. * @param y defines the scale factor on Y axis
  77574. * @param z defines the scale factor on Z axis
  77575. * @param result defines the target matrix
  77576. */
  77577. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77578. /**
  77579. * Creates a translation matrix
  77580. * @param x defines the translation on X axis
  77581. * @param y defines the translation on Y axis
  77582. * @param z defines the translationon Z axis
  77583. * @returns the new matrix
  77584. */
  77585. static Translation(x: number, y: number, z: number): Matrix;
  77586. /**
  77587. * Creates a translation matrix and stores it in a given matrix
  77588. * @param x defines the translation on X axis
  77589. * @param y defines the translation on Y axis
  77590. * @param z defines the translationon Z axis
  77591. * @param result defines the target matrix
  77592. */
  77593. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77594. /**
  77595. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77596. * @param startValue defines the start value
  77597. * @param endValue defines the end value
  77598. * @param gradient defines the gradient factor
  77599. * @returns the new matrix
  77600. */
  77601. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77602. /**
  77603. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77604. * @param startValue defines the start value
  77605. * @param endValue defines the end value
  77606. * @param gradient defines the gradient factor
  77607. * @param result defines the Matrix object where to store data
  77608. */
  77609. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77610. /**
  77611. * Builds a new matrix whose values are computed by:
  77612. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77613. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77614. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77615. * @param startValue defines the first matrix
  77616. * @param endValue defines the second matrix
  77617. * @param gradient defines the gradient between the two matrices
  77618. * @returns the new matrix
  77619. */
  77620. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77621. /**
  77622. * Update a matrix to values which are computed by:
  77623. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77624. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77625. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77626. * @param startValue defines the first matrix
  77627. * @param endValue defines the second matrix
  77628. * @param gradient defines the gradient between the two matrices
  77629. * @param result defines the target matrix
  77630. */
  77631. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77632. /**
  77633. * 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"
  77634. * This function works in left handed mode
  77635. * @param eye defines the final position of the entity
  77636. * @param target defines where the entity should look at
  77637. * @param up defines the up vector for the entity
  77638. * @returns the new matrix
  77639. */
  77640. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77641. /**
  77642. * 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".
  77643. * This function works in left handed mode
  77644. * @param eye defines the final position of the entity
  77645. * @param target defines where the entity should look at
  77646. * @param up defines the up vector for the entity
  77647. * @param result defines the target matrix
  77648. */
  77649. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77650. /**
  77651. * 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"
  77652. * This function works in right handed mode
  77653. * @param eye defines the final position of the entity
  77654. * @param target defines where the entity should look at
  77655. * @param up defines the up vector for the entity
  77656. * @returns the new matrix
  77657. */
  77658. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77659. /**
  77660. * 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".
  77661. * This function works in right handed mode
  77662. * @param eye defines the final position of the entity
  77663. * @param target defines where the entity should look at
  77664. * @param up defines the up vector for the entity
  77665. * @param result defines the target matrix
  77666. */
  77667. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77668. /**
  77669. * Create a left-handed orthographic projection matrix
  77670. * @param width defines the viewport width
  77671. * @param height defines the viewport height
  77672. * @param znear defines the near clip plane
  77673. * @param zfar defines the far clip plane
  77674. * @returns a new matrix as a left-handed orthographic projection matrix
  77675. */
  77676. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77677. /**
  77678. * Store a left-handed orthographic projection to a given matrix
  77679. * @param width defines the viewport width
  77680. * @param height defines the viewport height
  77681. * @param znear defines the near clip plane
  77682. * @param zfar defines the far clip plane
  77683. * @param result defines the target matrix
  77684. */
  77685. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77686. /**
  77687. * Create a left-handed orthographic projection matrix
  77688. * @param left defines the viewport left coordinate
  77689. * @param right defines the viewport right coordinate
  77690. * @param bottom defines the viewport bottom coordinate
  77691. * @param top defines the viewport top coordinate
  77692. * @param znear defines the near clip plane
  77693. * @param zfar defines the far clip plane
  77694. * @returns a new matrix as a left-handed orthographic projection matrix
  77695. */
  77696. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77697. /**
  77698. * Stores a left-handed orthographic projection into a given matrix
  77699. * @param left defines the viewport left coordinate
  77700. * @param right defines the viewport right coordinate
  77701. * @param bottom defines the viewport bottom coordinate
  77702. * @param top defines the viewport top coordinate
  77703. * @param znear defines the near clip plane
  77704. * @param zfar defines the far clip plane
  77705. * @param result defines the target matrix
  77706. */
  77707. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77708. /**
  77709. * Creates a right-handed orthographic projection matrix
  77710. * @param left defines the viewport left coordinate
  77711. * @param right defines the viewport right coordinate
  77712. * @param bottom defines the viewport bottom coordinate
  77713. * @param top defines the viewport top coordinate
  77714. * @param znear defines the near clip plane
  77715. * @param zfar defines the far clip plane
  77716. * @returns a new matrix as a right-handed orthographic projection matrix
  77717. */
  77718. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77719. /**
  77720. * Stores a right-handed orthographic projection into a given matrix
  77721. * @param left defines the viewport left coordinate
  77722. * @param right defines the viewport right coordinate
  77723. * @param bottom defines the viewport bottom coordinate
  77724. * @param top defines the viewport top coordinate
  77725. * @param znear defines the near clip plane
  77726. * @param zfar defines the far clip plane
  77727. * @param result defines the target matrix
  77728. */
  77729. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77730. /**
  77731. * Creates a left-handed perspective projection matrix
  77732. * @param width defines the viewport width
  77733. * @param height defines the viewport height
  77734. * @param znear defines the near clip plane
  77735. * @param zfar defines the far clip plane
  77736. * @returns a new matrix as a left-handed perspective projection matrix
  77737. */
  77738. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77739. /**
  77740. * Creates a left-handed perspective projection matrix
  77741. * @param fov defines the horizontal field of view
  77742. * @param aspect defines the aspect ratio
  77743. * @param znear defines the near clip plane
  77744. * @param zfar defines the far clip plane
  77745. * @returns a new matrix as a left-handed perspective projection matrix
  77746. */
  77747. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77748. /**
  77749. * Stores a left-handed perspective projection into a given matrix
  77750. * @param fov defines the horizontal field of view
  77751. * @param aspect defines the aspect ratio
  77752. * @param znear defines the near clip plane
  77753. * @param zfar defines the far clip plane
  77754. * @param result defines the target matrix
  77755. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77756. */
  77757. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77758. /**
  77759. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77760. * @param fov defines the horizontal field of view
  77761. * @param aspect defines the aspect ratio
  77762. * @param znear defines the near clip plane
  77763. * @param zfar not used as infinity is used as far clip
  77764. * @param result defines the target matrix
  77765. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77766. */
  77767. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77768. /**
  77769. * Creates a right-handed perspective projection matrix
  77770. * @param fov defines the horizontal field of view
  77771. * @param aspect defines the aspect ratio
  77772. * @param znear defines the near clip plane
  77773. * @param zfar defines the far clip plane
  77774. * @returns a new matrix as a right-handed perspective projection matrix
  77775. */
  77776. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77777. /**
  77778. * Stores a right-handed perspective projection into a given matrix
  77779. * @param fov defines the horizontal field of view
  77780. * @param aspect defines the aspect ratio
  77781. * @param znear defines the near clip plane
  77782. * @param zfar defines the far clip plane
  77783. * @param result defines the target matrix
  77784. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77785. */
  77786. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77787. /**
  77788. * Stores a right-handed perspective projection into a given matrix
  77789. * @param fov defines the horizontal field of view
  77790. * @param aspect defines the aspect ratio
  77791. * @param znear defines the near clip plane
  77792. * @param zfar not used as infinity is used as far clip
  77793. * @param result defines the target matrix
  77794. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77795. */
  77796. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77797. /**
  77798. * Stores a perspective projection for WebVR info a given matrix
  77799. * @param fov defines the field of view
  77800. * @param znear defines the near clip plane
  77801. * @param zfar defines the far clip plane
  77802. * @param result defines the target matrix
  77803. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77804. */
  77805. static PerspectiveFovWebVRToRef(fov: {
  77806. upDegrees: number;
  77807. downDegrees: number;
  77808. leftDegrees: number;
  77809. rightDegrees: number;
  77810. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77811. /**
  77812. * Computes a complete transformation matrix
  77813. * @param viewport defines the viewport to use
  77814. * @param world defines the world matrix
  77815. * @param view defines the view matrix
  77816. * @param projection defines the projection matrix
  77817. * @param zmin defines the near clip plane
  77818. * @param zmax defines the far clip plane
  77819. * @returns the transformation matrix
  77820. */
  77821. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77822. /**
  77823. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77824. * @param matrix defines the matrix to use
  77825. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77826. */
  77827. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77828. /**
  77829. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77830. * @param matrix defines the matrix to use
  77831. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77832. */
  77833. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77834. /**
  77835. * Compute the transpose of a given matrix
  77836. * @param matrix defines the matrix to transpose
  77837. * @returns the new matrix
  77838. */
  77839. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77840. /**
  77841. * Compute the transpose of a matrix and store it in a target matrix
  77842. * @param matrix defines the matrix to transpose
  77843. * @param result defines the target matrix
  77844. */
  77845. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77846. /**
  77847. * Computes a reflection matrix from a plane
  77848. * @param plane defines the reflection plane
  77849. * @returns a new matrix
  77850. */
  77851. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77852. /**
  77853. * Computes a reflection matrix from a plane
  77854. * @param plane defines the reflection plane
  77855. * @param result defines the target matrix
  77856. */
  77857. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77858. /**
  77859. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77860. * @param xaxis defines the value of the 1st axis
  77861. * @param yaxis defines the value of the 2nd axis
  77862. * @param zaxis defines the value of the 3rd axis
  77863. * @param result defines the target matrix
  77864. */
  77865. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77866. /**
  77867. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77868. * @param quat defines the quaternion to use
  77869. * @param result defines the target matrix
  77870. */
  77871. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77872. }
  77873. /**
  77874. * @hidden
  77875. */
  77876. export class TmpVectors {
  77877. static Vector2: Vector2[];
  77878. static Vector3: Vector3[];
  77879. static Vector4: Vector4[];
  77880. static Quaternion: Quaternion[];
  77881. static Matrix: Matrix[];
  77882. }
  77883. }
  77884. declare module BABYLON {
  77885. /**
  77886. * Defines potential orientation for back face culling
  77887. */
  77888. export enum Orientation {
  77889. /**
  77890. * Clockwise
  77891. */
  77892. CW = 0,
  77893. /** Counter clockwise */
  77894. CCW = 1
  77895. }
  77896. /** Class used to represent a Bezier curve */
  77897. export class BezierCurve {
  77898. /**
  77899. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77900. * @param t defines the time
  77901. * @param x1 defines the left coordinate on X axis
  77902. * @param y1 defines the left coordinate on Y axis
  77903. * @param x2 defines the right coordinate on X axis
  77904. * @param y2 defines the right coordinate on Y axis
  77905. * @returns the interpolated value
  77906. */
  77907. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77908. }
  77909. /**
  77910. * Defines angle representation
  77911. */
  77912. export class Angle {
  77913. private _radians;
  77914. /**
  77915. * Creates an Angle object of "radians" radians (float).
  77916. * @param radians the angle in radians
  77917. */
  77918. constructor(radians: number);
  77919. /**
  77920. * Get value in degrees
  77921. * @returns the Angle value in degrees (float)
  77922. */
  77923. degrees(): number;
  77924. /**
  77925. * Get value in radians
  77926. * @returns the Angle value in radians (float)
  77927. */
  77928. radians(): number;
  77929. /**
  77930. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77931. * @param a defines first vector
  77932. * @param b defines second vector
  77933. * @returns a new Angle
  77934. */
  77935. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77936. /**
  77937. * Gets a new Angle object from the given float in radians
  77938. * @param radians defines the angle value in radians
  77939. * @returns a new Angle
  77940. */
  77941. static FromRadians(radians: number): Angle;
  77942. /**
  77943. * Gets a new Angle object from the given float in degrees
  77944. * @param degrees defines the angle value in degrees
  77945. * @returns a new Angle
  77946. */
  77947. static FromDegrees(degrees: number): Angle;
  77948. }
  77949. /**
  77950. * This represents an arc in a 2d space.
  77951. */
  77952. export class Arc2 {
  77953. /** Defines the start point of the arc */
  77954. startPoint: Vector2;
  77955. /** Defines the mid point of the arc */
  77956. midPoint: Vector2;
  77957. /** Defines the end point of the arc */
  77958. endPoint: Vector2;
  77959. /**
  77960. * Defines the center point of the arc.
  77961. */
  77962. centerPoint: Vector2;
  77963. /**
  77964. * Defines the radius of the arc.
  77965. */
  77966. radius: number;
  77967. /**
  77968. * Defines the angle of the arc (from mid point to end point).
  77969. */
  77970. angle: Angle;
  77971. /**
  77972. * Defines the start angle of the arc (from start point to middle point).
  77973. */
  77974. startAngle: Angle;
  77975. /**
  77976. * Defines the orientation of the arc (clock wise/counter clock wise).
  77977. */
  77978. orientation: Orientation;
  77979. /**
  77980. * Creates an Arc object from the three given points : start, middle and end.
  77981. * @param startPoint Defines the start point of the arc
  77982. * @param midPoint Defines the midlle point of the arc
  77983. * @param endPoint Defines the end point of the arc
  77984. */
  77985. constructor(
  77986. /** Defines the start point of the arc */
  77987. startPoint: Vector2,
  77988. /** Defines the mid point of the arc */
  77989. midPoint: Vector2,
  77990. /** Defines the end point of the arc */
  77991. endPoint: Vector2);
  77992. }
  77993. /**
  77994. * Represents a 2D path made up of multiple 2D points
  77995. */
  77996. export class Path2 {
  77997. private _points;
  77998. private _length;
  77999. /**
  78000. * If the path start and end point are the same
  78001. */
  78002. closed: boolean;
  78003. /**
  78004. * Creates a Path2 object from the starting 2D coordinates x and y.
  78005. * @param x the starting points x value
  78006. * @param y the starting points y value
  78007. */
  78008. constructor(x: number, y: number);
  78009. /**
  78010. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78011. * @param x the added points x value
  78012. * @param y the added points y value
  78013. * @returns the updated Path2.
  78014. */
  78015. addLineTo(x: number, y: number): Path2;
  78016. /**
  78017. * 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.
  78018. * @param midX middle point x value
  78019. * @param midY middle point y value
  78020. * @param endX end point x value
  78021. * @param endY end point y value
  78022. * @param numberOfSegments (default: 36)
  78023. * @returns the updated Path2.
  78024. */
  78025. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78026. /**
  78027. * Closes the Path2.
  78028. * @returns the Path2.
  78029. */
  78030. close(): Path2;
  78031. /**
  78032. * Gets the sum of the distance between each sequential point in the path
  78033. * @returns the Path2 total length (float).
  78034. */
  78035. length(): number;
  78036. /**
  78037. * Gets the points which construct the path
  78038. * @returns the Path2 internal array of points.
  78039. */
  78040. getPoints(): Vector2[];
  78041. /**
  78042. * Retreives the point at the distance aways from the starting point
  78043. * @param normalizedLengthPosition the length along the path to retreive the point from
  78044. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78045. */
  78046. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78047. /**
  78048. * Creates a new path starting from an x and y position
  78049. * @param x starting x value
  78050. * @param y starting y value
  78051. * @returns a new Path2 starting at the coordinates (x, y).
  78052. */
  78053. static StartingAt(x: number, y: number): Path2;
  78054. }
  78055. /**
  78056. * Represents a 3D path made up of multiple 3D points
  78057. */
  78058. export class Path3D {
  78059. /**
  78060. * an array of Vector3, the curve axis of the Path3D
  78061. */
  78062. path: Vector3[];
  78063. private _curve;
  78064. private _distances;
  78065. private _tangents;
  78066. private _normals;
  78067. private _binormals;
  78068. private _raw;
  78069. private _alignTangentsWithPath;
  78070. private readonly _pointAtData;
  78071. /**
  78072. * new Path3D(path, normal, raw)
  78073. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78074. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78075. * @param path an array of Vector3, the curve axis of the Path3D
  78076. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78077. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78078. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78079. */
  78080. constructor(
  78081. /**
  78082. * an array of Vector3, the curve axis of the Path3D
  78083. */
  78084. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78085. /**
  78086. * Returns the Path3D array of successive Vector3 designing its curve.
  78087. * @returns the Path3D array of successive Vector3 designing its curve.
  78088. */
  78089. getCurve(): Vector3[];
  78090. /**
  78091. * Returns the Path3D array of successive Vector3 designing its curve.
  78092. * @returns the Path3D array of successive Vector3 designing its curve.
  78093. */
  78094. getPoints(): Vector3[];
  78095. /**
  78096. * @returns the computed length (float) of the path.
  78097. */
  78098. length(): number;
  78099. /**
  78100. * Returns an array populated with tangent vectors on each Path3D curve point.
  78101. * @returns an array populated with tangent vectors on each Path3D curve point.
  78102. */
  78103. getTangents(): Vector3[];
  78104. /**
  78105. * Returns an array populated with normal vectors on each Path3D curve point.
  78106. * @returns an array populated with normal vectors on each Path3D curve point.
  78107. */
  78108. getNormals(): Vector3[];
  78109. /**
  78110. * Returns an array populated with binormal vectors on each Path3D curve point.
  78111. * @returns an array populated with binormal vectors on each Path3D curve point.
  78112. */
  78113. getBinormals(): Vector3[];
  78114. /**
  78115. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78116. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78117. */
  78118. getDistances(): number[];
  78119. /**
  78120. * Returns an interpolated point along this path
  78121. * @param position the position of the point along this path, from 0.0 to 1.0
  78122. * @returns a new Vector3 as the point
  78123. */
  78124. getPointAt(position: number): Vector3;
  78125. /**
  78126. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78127. * @param position the position of the point along this path, from 0.0 to 1.0
  78128. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78129. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78130. */
  78131. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78132. /**
  78133. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78134. * @param position the position of the point along this path, from 0.0 to 1.0
  78135. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78136. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78137. */
  78138. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78139. /**
  78140. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78141. * @param position the position of the point along this path, from 0.0 to 1.0
  78142. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78143. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78144. */
  78145. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78146. /**
  78147. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78148. * @param position the position of the point along this path, from 0.0 to 1.0
  78149. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78150. */
  78151. getDistanceAt(position: number): number;
  78152. /**
  78153. * Returns the array index of the previous point of an interpolated point along this path
  78154. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78155. * @returns the array index
  78156. */
  78157. getPreviousPointIndexAt(position: number): number;
  78158. /**
  78159. * 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)
  78160. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78161. * @returns the sub position
  78162. */
  78163. getSubPositionAt(position: number): number;
  78164. /**
  78165. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78166. * @param target the vector of which to get the closest position to
  78167. * @returns the position of the closest virtual point on this path to the target vector
  78168. */
  78169. getClosestPositionTo(target: Vector3): number;
  78170. /**
  78171. * Returns a sub path (slice) of this path
  78172. * @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
  78173. * @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
  78174. * @returns a sub path (slice) of this path
  78175. */
  78176. slice(start?: number, end?: number): Path3D;
  78177. /**
  78178. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78179. * @param path path which all values are copied into the curves points
  78180. * @param firstNormal which should be projected onto the curve
  78181. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78182. * @returns the same object updated.
  78183. */
  78184. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78185. private _compute;
  78186. private _getFirstNonNullVector;
  78187. private _getLastNonNullVector;
  78188. private _normalVector;
  78189. /**
  78190. * Updates the point at data for an interpolated point along this curve
  78191. * @param position the position of the point along this curve, from 0.0 to 1.0
  78192. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78193. * @returns the (updated) point at data
  78194. */
  78195. private _updatePointAtData;
  78196. /**
  78197. * Updates the point at data from the specified parameters
  78198. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78199. * @param point the interpolated point
  78200. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78201. */
  78202. private _setPointAtData;
  78203. /**
  78204. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78205. */
  78206. private _updateInterpolationMatrix;
  78207. }
  78208. /**
  78209. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78210. * A Curve3 is designed from a series of successive Vector3.
  78211. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78212. */
  78213. export class Curve3 {
  78214. private _points;
  78215. private _length;
  78216. /**
  78217. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78218. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78219. * @param v1 (Vector3) the control point
  78220. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78221. * @param nbPoints (integer) the wanted number of points in the curve
  78222. * @returns the created Curve3
  78223. */
  78224. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78225. /**
  78226. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78227. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78228. * @param v1 (Vector3) the first control point
  78229. * @param v2 (Vector3) the second control point
  78230. * @param v3 (Vector3) the end point of the Cubic Bezier
  78231. * @param nbPoints (integer) the wanted number of points in the curve
  78232. * @returns the created Curve3
  78233. */
  78234. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78235. /**
  78236. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78237. * @param p1 (Vector3) the origin point of the Hermite Spline
  78238. * @param t1 (Vector3) the tangent vector at the origin point
  78239. * @param p2 (Vector3) the end point of the Hermite Spline
  78240. * @param t2 (Vector3) the tangent vector at the end point
  78241. * @param nbPoints (integer) the wanted number of points in the curve
  78242. * @returns the created Curve3
  78243. */
  78244. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78245. /**
  78246. * Returns a Curve3 object along a CatmullRom Spline curve :
  78247. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78248. * @param nbPoints (integer) the wanted number of points between each curve control points
  78249. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78250. * @returns the created Curve3
  78251. */
  78252. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78253. /**
  78254. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78255. * A Curve3 is designed from a series of successive Vector3.
  78256. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78257. * @param points points which make up the curve
  78258. */
  78259. constructor(points: Vector3[]);
  78260. /**
  78261. * @returns the Curve3 stored array of successive Vector3
  78262. */
  78263. getPoints(): Vector3[];
  78264. /**
  78265. * @returns the computed length (float) of the curve.
  78266. */
  78267. length(): number;
  78268. /**
  78269. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78270. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78271. * curveA and curveB keep unchanged.
  78272. * @param curve the curve to continue from this curve
  78273. * @returns the newly constructed curve
  78274. */
  78275. continue(curve: DeepImmutable<Curve3>): Curve3;
  78276. private _computeLength;
  78277. }
  78278. }
  78279. declare module BABYLON {
  78280. /**
  78281. * This represents the main contract an easing function should follow.
  78282. * Easing functions are used throughout the animation system.
  78283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78284. */
  78285. export interface IEasingFunction {
  78286. /**
  78287. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78288. * of the easing function.
  78289. * The link below provides some of the most common examples of easing functions.
  78290. * @see https://easings.net/
  78291. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78292. * @returns the corresponding value on the curve defined by the easing function
  78293. */
  78294. ease(gradient: number): number;
  78295. }
  78296. /**
  78297. * Base class used for every default easing function.
  78298. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78299. */
  78300. export class EasingFunction implements IEasingFunction {
  78301. /**
  78302. * Interpolation follows the mathematical formula associated with the easing function.
  78303. */
  78304. static readonly EASINGMODE_EASEIN: number;
  78305. /**
  78306. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78307. */
  78308. static readonly EASINGMODE_EASEOUT: number;
  78309. /**
  78310. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78311. */
  78312. static readonly EASINGMODE_EASEINOUT: number;
  78313. private _easingMode;
  78314. /**
  78315. * Sets the easing mode of the current function.
  78316. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78317. */
  78318. setEasingMode(easingMode: number): void;
  78319. /**
  78320. * Gets the current easing mode.
  78321. * @returns the easing mode
  78322. */
  78323. getEasingMode(): number;
  78324. /**
  78325. * @hidden
  78326. */
  78327. easeInCore(gradient: number): number;
  78328. /**
  78329. * Given an input gradient between 0 and 1, this returns the corresponding value
  78330. * of the easing function.
  78331. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78332. * @returns the corresponding value on the curve defined by the easing function
  78333. */
  78334. ease(gradient: number): number;
  78335. }
  78336. /**
  78337. * Easing function with a circle shape (see link below).
  78338. * @see https://easings.net/#easeInCirc
  78339. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78340. */
  78341. export class CircleEase extends EasingFunction implements IEasingFunction {
  78342. /** @hidden */
  78343. easeInCore(gradient: number): number;
  78344. }
  78345. /**
  78346. * Easing function with a ease back shape (see link below).
  78347. * @see https://easings.net/#easeInBack
  78348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78349. */
  78350. export class BackEase extends EasingFunction implements IEasingFunction {
  78351. /** Defines the amplitude of the function */
  78352. amplitude: number;
  78353. /**
  78354. * Instantiates a back ease easing
  78355. * @see https://easings.net/#easeInBack
  78356. * @param amplitude Defines the amplitude of the function
  78357. */
  78358. constructor(
  78359. /** Defines the amplitude of the function */
  78360. amplitude?: number);
  78361. /** @hidden */
  78362. easeInCore(gradient: number): number;
  78363. }
  78364. /**
  78365. * Easing function with a bouncing shape (see link below).
  78366. * @see https://easings.net/#easeInBounce
  78367. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78368. */
  78369. export class BounceEase extends EasingFunction implements IEasingFunction {
  78370. /** Defines the number of bounces */
  78371. bounces: number;
  78372. /** Defines the amplitude of the bounce */
  78373. bounciness: number;
  78374. /**
  78375. * Instantiates a bounce easing
  78376. * @see https://easings.net/#easeInBounce
  78377. * @param bounces Defines the number of bounces
  78378. * @param bounciness Defines the amplitude of the bounce
  78379. */
  78380. constructor(
  78381. /** Defines the number of bounces */
  78382. bounces?: number,
  78383. /** Defines the amplitude of the bounce */
  78384. bounciness?: number);
  78385. /** @hidden */
  78386. easeInCore(gradient: number): number;
  78387. }
  78388. /**
  78389. * Easing function with a power of 3 shape (see link below).
  78390. * @see https://easings.net/#easeInCubic
  78391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78392. */
  78393. export class CubicEase extends EasingFunction implements IEasingFunction {
  78394. /** @hidden */
  78395. easeInCore(gradient: number): number;
  78396. }
  78397. /**
  78398. * Easing function with an elastic shape (see link below).
  78399. * @see https://easings.net/#easeInElastic
  78400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78401. */
  78402. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78403. /** Defines the number of oscillations*/
  78404. oscillations: number;
  78405. /** Defines the amplitude of the oscillations*/
  78406. springiness: number;
  78407. /**
  78408. * Instantiates an elastic easing function
  78409. * @see https://easings.net/#easeInElastic
  78410. * @param oscillations Defines the number of oscillations
  78411. * @param springiness Defines the amplitude of the oscillations
  78412. */
  78413. constructor(
  78414. /** Defines the number of oscillations*/
  78415. oscillations?: number,
  78416. /** Defines the amplitude of the oscillations*/
  78417. springiness?: number);
  78418. /** @hidden */
  78419. easeInCore(gradient: number): number;
  78420. }
  78421. /**
  78422. * Easing function with an exponential shape (see link below).
  78423. * @see https://easings.net/#easeInExpo
  78424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78425. */
  78426. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78427. /** Defines the exponent of the function */
  78428. exponent: number;
  78429. /**
  78430. * Instantiates an exponential easing function
  78431. * @see https://easings.net/#easeInExpo
  78432. * @param exponent Defines the exponent of the function
  78433. */
  78434. constructor(
  78435. /** Defines the exponent of the function */
  78436. exponent?: number);
  78437. /** @hidden */
  78438. easeInCore(gradient: number): number;
  78439. }
  78440. /**
  78441. * Easing function with a power shape (see link below).
  78442. * @see https://easings.net/#easeInQuad
  78443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78444. */
  78445. export class PowerEase extends EasingFunction implements IEasingFunction {
  78446. /** Defines the power of the function */
  78447. power: number;
  78448. /**
  78449. * Instantiates an power base easing function
  78450. * @see https://easings.net/#easeInQuad
  78451. * @param power Defines the power of the function
  78452. */
  78453. constructor(
  78454. /** Defines the power of the function */
  78455. power?: number);
  78456. /** @hidden */
  78457. easeInCore(gradient: number): number;
  78458. }
  78459. /**
  78460. * Easing function with a power of 2 shape (see link below).
  78461. * @see https://easings.net/#easeInQuad
  78462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78463. */
  78464. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78465. /** @hidden */
  78466. easeInCore(gradient: number): number;
  78467. }
  78468. /**
  78469. * Easing function with a power of 4 shape (see link below).
  78470. * @see https://easings.net/#easeInQuart
  78471. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78472. */
  78473. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78474. /** @hidden */
  78475. easeInCore(gradient: number): number;
  78476. }
  78477. /**
  78478. * Easing function with a power of 5 shape (see link below).
  78479. * @see https://easings.net/#easeInQuint
  78480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78481. */
  78482. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78483. /** @hidden */
  78484. easeInCore(gradient: number): number;
  78485. }
  78486. /**
  78487. * Easing function with a sin shape (see link below).
  78488. * @see https://easings.net/#easeInSine
  78489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78490. */
  78491. export class SineEase extends EasingFunction implements IEasingFunction {
  78492. /** @hidden */
  78493. easeInCore(gradient: number): number;
  78494. }
  78495. /**
  78496. * Easing function with a bezier shape (see link below).
  78497. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78499. */
  78500. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78501. /** Defines the x component of the start tangent in the bezier curve */
  78502. x1: number;
  78503. /** Defines the y component of the start tangent in the bezier curve */
  78504. y1: number;
  78505. /** Defines the x component of the end tangent in the bezier curve */
  78506. x2: number;
  78507. /** Defines the y component of the end tangent in the bezier curve */
  78508. y2: number;
  78509. /**
  78510. * Instantiates a bezier function
  78511. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78512. * @param x1 Defines the x component of the start tangent in the bezier curve
  78513. * @param y1 Defines the y component of the start tangent in the bezier curve
  78514. * @param x2 Defines the x component of the end tangent in the bezier curve
  78515. * @param y2 Defines the y component of the end tangent in the bezier curve
  78516. */
  78517. constructor(
  78518. /** Defines the x component of the start tangent in the bezier curve */
  78519. x1?: number,
  78520. /** Defines the y component of the start tangent in the bezier curve */
  78521. y1?: number,
  78522. /** Defines the x component of the end tangent in the bezier curve */
  78523. x2?: number,
  78524. /** Defines the y component of the end tangent in the bezier curve */
  78525. y2?: number);
  78526. /** @hidden */
  78527. easeInCore(gradient: number): number;
  78528. }
  78529. }
  78530. declare module BABYLON {
  78531. /**
  78532. * Class used to hold a RBG color
  78533. */
  78534. export class Color3 {
  78535. /**
  78536. * Defines the red component (between 0 and 1, default is 0)
  78537. */
  78538. r: number;
  78539. /**
  78540. * Defines the green component (between 0 and 1, default is 0)
  78541. */
  78542. g: number;
  78543. /**
  78544. * Defines the blue component (between 0 and 1, default is 0)
  78545. */
  78546. b: number;
  78547. /**
  78548. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78549. * @param r defines the red component (between 0 and 1, default is 0)
  78550. * @param g defines the green component (between 0 and 1, default is 0)
  78551. * @param b defines the blue component (between 0 and 1, default is 0)
  78552. */
  78553. constructor(
  78554. /**
  78555. * Defines the red component (between 0 and 1, default is 0)
  78556. */
  78557. r?: number,
  78558. /**
  78559. * Defines the green component (between 0 and 1, default is 0)
  78560. */
  78561. g?: number,
  78562. /**
  78563. * Defines the blue component (between 0 and 1, default is 0)
  78564. */
  78565. b?: number);
  78566. /**
  78567. * Creates a string with the Color3 current values
  78568. * @returns the string representation of the Color3 object
  78569. */
  78570. toString(): string;
  78571. /**
  78572. * Returns the string "Color3"
  78573. * @returns "Color3"
  78574. */
  78575. getClassName(): string;
  78576. /**
  78577. * Compute the Color3 hash code
  78578. * @returns an unique number that can be used to hash Color3 objects
  78579. */
  78580. getHashCode(): number;
  78581. /**
  78582. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78583. * @param array defines the array where to store the r,g,b components
  78584. * @param index defines an optional index in the target array to define where to start storing values
  78585. * @returns the current Color3 object
  78586. */
  78587. toArray(array: FloatArray, index?: number): Color3;
  78588. /**
  78589. * Returns a new Color4 object from the current Color3 and the given alpha
  78590. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78591. * @returns a new Color4 object
  78592. */
  78593. toColor4(alpha?: number): Color4;
  78594. /**
  78595. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78596. * @returns the new array
  78597. */
  78598. asArray(): number[];
  78599. /**
  78600. * Returns the luminance value
  78601. * @returns a float value
  78602. */
  78603. toLuminance(): number;
  78604. /**
  78605. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78606. * @param otherColor defines the second operand
  78607. * @returns the new Color3 object
  78608. */
  78609. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78610. /**
  78611. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78612. * @param otherColor defines the second operand
  78613. * @param result defines the Color3 object where to store the result
  78614. * @returns the current Color3
  78615. */
  78616. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78617. /**
  78618. * Determines equality between Color3 objects
  78619. * @param otherColor defines the second operand
  78620. * @returns true if the rgb values are equal to the given ones
  78621. */
  78622. equals(otherColor: DeepImmutable<Color3>): boolean;
  78623. /**
  78624. * Determines equality between the current Color3 object and a set of r,b,g values
  78625. * @param r defines the red component to check
  78626. * @param g defines the green component to check
  78627. * @param b defines the blue component to check
  78628. * @returns true if the rgb values are equal to the given ones
  78629. */
  78630. equalsFloats(r: number, g: number, b: number): boolean;
  78631. /**
  78632. * Multiplies in place each rgb value by scale
  78633. * @param scale defines the scaling factor
  78634. * @returns the updated Color3
  78635. */
  78636. scale(scale: number): Color3;
  78637. /**
  78638. * Multiplies the rgb values by scale and stores the result into "result"
  78639. * @param scale defines the scaling factor
  78640. * @param result defines the Color3 object where to store the result
  78641. * @returns the unmodified current Color3
  78642. */
  78643. scaleToRef(scale: number, result: Color3): Color3;
  78644. /**
  78645. * Scale the current Color3 values by a factor and add the result to a given Color3
  78646. * @param scale defines the scale factor
  78647. * @param result defines color to store the result into
  78648. * @returns the unmodified current Color3
  78649. */
  78650. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78651. /**
  78652. * Clamps the rgb values by the min and max values and stores the result into "result"
  78653. * @param min defines minimum clamping value (default is 0)
  78654. * @param max defines maximum clamping value (default is 1)
  78655. * @param result defines color to store the result into
  78656. * @returns the original Color3
  78657. */
  78658. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78659. /**
  78660. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78661. * @param otherColor defines the second operand
  78662. * @returns the new Color3
  78663. */
  78664. add(otherColor: DeepImmutable<Color3>): Color3;
  78665. /**
  78666. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78667. * @param otherColor defines the second operand
  78668. * @param result defines Color3 object to store the result into
  78669. * @returns the unmodified current Color3
  78670. */
  78671. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78672. /**
  78673. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78674. * @param otherColor defines the second operand
  78675. * @returns the new Color3
  78676. */
  78677. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78678. /**
  78679. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78680. * @param otherColor defines the second operand
  78681. * @param result defines Color3 object to store the result into
  78682. * @returns the unmodified current Color3
  78683. */
  78684. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78685. /**
  78686. * Copy the current object
  78687. * @returns a new Color3 copied the current one
  78688. */
  78689. clone(): Color3;
  78690. /**
  78691. * Copies the rgb values from the source in the current Color3
  78692. * @param source defines the source Color3 object
  78693. * @returns the updated Color3 object
  78694. */
  78695. copyFrom(source: DeepImmutable<Color3>): Color3;
  78696. /**
  78697. * Updates the Color3 rgb values from the given floats
  78698. * @param r defines the red component to read from
  78699. * @param g defines the green component to read from
  78700. * @param b defines the blue component to read from
  78701. * @returns the current Color3 object
  78702. */
  78703. copyFromFloats(r: number, g: number, b: number): Color3;
  78704. /**
  78705. * Updates the Color3 rgb values from the given floats
  78706. * @param r defines the red component to read from
  78707. * @param g defines the green component to read from
  78708. * @param b defines the blue component to read from
  78709. * @returns the current Color3 object
  78710. */
  78711. set(r: number, g: number, b: number): Color3;
  78712. /**
  78713. * Compute the Color3 hexadecimal code as a string
  78714. * @returns a string containing the hexadecimal representation of the Color3 object
  78715. */
  78716. toHexString(): string;
  78717. /**
  78718. * Computes a new Color3 converted from the current one to linear space
  78719. * @returns a new Color3 object
  78720. */
  78721. toLinearSpace(): Color3;
  78722. /**
  78723. * Converts current color in rgb space to HSV values
  78724. * @returns a new color3 representing the HSV values
  78725. */
  78726. toHSV(): Color3;
  78727. /**
  78728. * Converts current color in rgb space to HSV values
  78729. * @param result defines the Color3 where to store the HSV values
  78730. */
  78731. toHSVToRef(result: Color3): void;
  78732. /**
  78733. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78734. * @param convertedColor defines the Color3 object where to store the linear space version
  78735. * @returns the unmodified Color3
  78736. */
  78737. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78738. /**
  78739. * Computes a new Color3 converted from the current one to gamma space
  78740. * @returns a new Color3 object
  78741. */
  78742. toGammaSpace(): Color3;
  78743. /**
  78744. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78745. * @param convertedColor defines the Color3 object where to store the gamma space version
  78746. * @returns the unmodified Color3
  78747. */
  78748. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78749. private static _BlackReadOnly;
  78750. /**
  78751. * Convert Hue, saturation and value to a Color3 (RGB)
  78752. * @param hue defines the hue
  78753. * @param saturation defines the saturation
  78754. * @param value defines the value
  78755. * @param result defines the Color3 where to store the RGB values
  78756. */
  78757. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78758. /**
  78759. * Creates a new Color3 from the string containing valid hexadecimal values
  78760. * @param hex defines a string containing valid hexadecimal values
  78761. * @returns a new Color3 object
  78762. */
  78763. static FromHexString(hex: string): Color3;
  78764. /**
  78765. * Creates a new Color3 from the starting index of the given array
  78766. * @param array defines the source array
  78767. * @param offset defines an offset in the source array
  78768. * @returns a new Color3 object
  78769. */
  78770. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78771. /**
  78772. * Creates a new Color3 from integer values (< 256)
  78773. * @param r defines the red component to read from (value between 0 and 255)
  78774. * @param g defines the green component to read from (value between 0 and 255)
  78775. * @param b defines the blue component to read from (value between 0 and 255)
  78776. * @returns a new Color3 object
  78777. */
  78778. static FromInts(r: number, g: number, b: number): Color3;
  78779. /**
  78780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78781. * @param start defines the start Color3 value
  78782. * @param end defines the end Color3 value
  78783. * @param amount defines the gradient value between start and end
  78784. * @returns a new Color3 object
  78785. */
  78786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78787. /**
  78788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78789. * @param left defines the start value
  78790. * @param right defines the end value
  78791. * @param amount defines the gradient factor
  78792. * @param result defines the Color3 object where to store the result
  78793. */
  78794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78795. /**
  78796. * Returns a Color3 value containing a red color
  78797. * @returns a new Color3 object
  78798. */
  78799. static Red(): Color3;
  78800. /**
  78801. * Returns a Color3 value containing a green color
  78802. * @returns a new Color3 object
  78803. */
  78804. static Green(): Color3;
  78805. /**
  78806. * Returns a Color3 value containing a blue color
  78807. * @returns a new Color3 object
  78808. */
  78809. static Blue(): Color3;
  78810. /**
  78811. * Returns a Color3 value containing a black color
  78812. * @returns a new Color3 object
  78813. */
  78814. static Black(): Color3;
  78815. /**
  78816. * Gets a Color3 value containing a black color that must not be updated
  78817. */
  78818. static get BlackReadOnly(): DeepImmutable<Color3>;
  78819. /**
  78820. * Returns a Color3 value containing a white color
  78821. * @returns a new Color3 object
  78822. */
  78823. static White(): Color3;
  78824. /**
  78825. * Returns a Color3 value containing a purple color
  78826. * @returns a new Color3 object
  78827. */
  78828. static Purple(): Color3;
  78829. /**
  78830. * Returns a Color3 value containing a magenta color
  78831. * @returns a new Color3 object
  78832. */
  78833. static Magenta(): Color3;
  78834. /**
  78835. * Returns a Color3 value containing a yellow color
  78836. * @returns a new Color3 object
  78837. */
  78838. static Yellow(): Color3;
  78839. /**
  78840. * Returns a Color3 value containing a gray color
  78841. * @returns a new Color3 object
  78842. */
  78843. static Gray(): Color3;
  78844. /**
  78845. * Returns a Color3 value containing a teal color
  78846. * @returns a new Color3 object
  78847. */
  78848. static Teal(): Color3;
  78849. /**
  78850. * Returns a Color3 value containing a random color
  78851. * @returns a new Color3 object
  78852. */
  78853. static Random(): Color3;
  78854. }
  78855. /**
  78856. * Class used to hold a RBGA color
  78857. */
  78858. export class Color4 {
  78859. /**
  78860. * Defines the red component (between 0 and 1, default is 0)
  78861. */
  78862. r: number;
  78863. /**
  78864. * Defines the green component (between 0 and 1, default is 0)
  78865. */
  78866. g: number;
  78867. /**
  78868. * Defines the blue component (between 0 and 1, default is 0)
  78869. */
  78870. b: number;
  78871. /**
  78872. * Defines the alpha component (between 0 and 1, default is 1)
  78873. */
  78874. a: number;
  78875. /**
  78876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78877. * @param r defines the red component (between 0 and 1, default is 0)
  78878. * @param g defines the green component (between 0 and 1, default is 0)
  78879. * @param b defines the blue component (between 0 and 1, default is 0)
  78880. * @param a defines the alpha component (between 0 and 1, default is 1)
  78881. */
  78882. constructor(
  78883. /**
  78884. * Defines the red component (between 0 and 1, default is 0)
  78885. */
  78886. r?: number,
  78887. /**
  78888. * Defines the green component (between 0 and 1, default is 0)
  78889. */
  78890. g?: number,
  78891. /**
  78892. * Defines the blue component (between 0 and 1, default is 0)
  78893. */
  78894. b?: number,
  78895. /**
  78896. * Defines the alpha component (between 0 and 1, default is 1)
  78897. */
  78898. a?: number);
  78899. /**
  78900. * Adds in place the given Color4 values to the current Color4 object
  78901. * @param right defines the second operand
  78902. * @returns the current updated Color4 object
  78903. */
  78904. addInPlace(right: DeepImmutable<Color4>): Color4;
  78905. /**
  78906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78907. * @returns the new array
  78908. */
  78909. asArray(): number[];
  78910. /**
  78911. * Stores from the starting index in the given array the Color4 successive values
  78912. * @param array defines the array where to store the r,g,b components
  78913. * @param index defines an optional index in the target array to define where to start storing values
  78914. * @returns the current Color4 object
  78915. */
  78916. toArray(array: number[], index?: number): Color4;
  78917. /**
  78918. * Determines equality between Color4 objects
  78919. * @param otherColor defines the second operand
  78920. * @returns true if the rgba values are equal to the given ones
  78921. */
  78922. equals(otherColor: DeepImmutable<Color4>): boolean;
  78923. /**
  78924. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78925. * @param right defines the second operand
  78926. * @returns a new Color4 object
  78927. */
  78928. add(right: DeepImmutable<Color4>): Color4;
  78929. /**
  78930. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78931. * @param right defines the second operand
  78932. * @returns a new Color4 object
  78933. */
  78934. subtract(right: DeepImmutable<Color4>): Color4;
  78935. /**
  78936. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78937. * @param right defines the second operand
  78938. * @param result defines the Color4 object where to store the result
  78939. * @returns the current Color4 object
  78940. */
  78941. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78942. /**
  78943. * Creates a new Color4 with the current Color4 values multiplied by scale
  78944. * @param scale defines the scaling factor to apply
  78945. * @returns a new Color4 object
  78946. */
  78947. scale(scale: number): Color4;
  78948. /**
  78949. * Multiplies the current Color4 values by scale and stores the result in "result"
  78950. * @param scale defines the scaling factor to apply
  78951. * @param result defines the Color4 object where to store the result
  78952. * @returns the current unmodified Color4
  78953. */
  78954. scaleToRef(scale: number, result: Color4): Color4;
  78955. /**
  78956. * Scale the current Color4 values by a factor and add the result to a given Color4
  78957. * @param scale defines the scale factor
  78958. * @param result defines the Color4 object where to store the result
  78959. * @returns the unmodified current Color4
  78960. */
  78961. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78962. /**
  78963. * Clamps the rgb values by the min and max values and stores the result into "result"
  78964. * @param min defines minimum clamping value (default is 0)
  78965. * @param max defines maximum clamping value (default is 1)
  78966. * @param result defines color to store the result into.
  78967. * @returns the cuurent Color4
  78968. */
  78969. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78970. /**
  78971. * Multipy an Color4 value by another and return a new Color4 object
  78972. * @param color defines the Color4 value to multiply by
  78973. * @returns a new Color4 object
  78974. */
  78975. multiply(color: Color4): Color4;
  78976. /**
  78977. * Multipy a Color4 value by another and push the result in a reference value
  78978. * @param color defines the Color4 value to multiply by
  78979. * @param result defines the Color4 to fill the result in
  78980. * @returns the result Color4
  78981. */
  78982. multiplyToRef(color: Color4, result: Color4): Color4;
  78983. /**
  78984. * Creates a string with the Color4 current values
  78985. * @returns the string representation of the Color4 object
  78986. */
  78987. toString(): string;
  78988. /**
  78989. * Returns the string "Color4"
  78990. * @returns "Color4"
  78991. */
  78992. getClassName(): string;
  78993. /**
  78994. * Compute the Color4 hash code
  78995. * @returns an unique number that can be used to hash Color4 objects
  78996. */
  78997. getHashCode(): number;
  78998. /**
  78999. * Creates a new Color4 copied from the current one
  79000. * @returns a new Color4 object
  79001. */
  79002. clone(): Color4;
  79003. /**
  79004. * Copies the given Color4 values into the current one
  79005. * @param source defines the source Color4 object
  79006. * @returns the current updated Color4 object
  79007. */
  79008. copyFrom(source: Color4): Color4;
  79009. /**
  79010. * Copies the given float values into the current one
  79011. * @param r defines the red component to read from
  79012. * @param g defines the green component to read from
  79013. * @param b defines the blue component to read from
  79014. * @param a defines the alpha component to read from
  79015. * @returns the current updated Color4 object
  79016. */
  79017. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79018. /**
  79019. * Copies the given float values into the current one
  79020. * @param r defines the red component to read from
  79021. * @param g defines the green component to read from
  79022. * @param b defines the blue component to read from
  79023. * @param a defines the alpha component to read from
  79024. * @returns the current updated Color4 object
  79025. */
  79026. set(r: number, g: number, b: number, a: number): Color4;
  79027. /**
  79028. * Compute the Color4 hexadecimal code as a string
  79029. * @returns a string containing the hexadecimal representation of the Color4 object
  79030. */
  79031. toHexString(): string;
  79032. /**
  79033. * Computes a new Color4 converted from the current one to linear space
  79034. * @returns a new Color4 object
  79035. */
  79036. toLinearSpace(): Color4;
  79037. /**
  79038. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79039. * @param convertedColor defines the Color4 object where to store the linear space version
  79040. * @returns the unmodified Color4
  79041. */
  79042. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79043. /**
  79044. * Computes a new Color4 converted from the current one to gamma space
  79045. * @returns a new Color4 object
  79046. */
  79047. toGammaSpace(): Color4;
  79048. /**
  79049. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79050. * @param convertedColor defines the Color4 object where to store the gamma space version
  79051. * @returns the unmodified Color4
  79052. */
  79053. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79054. /**
  79055. * Creates a new Color4 from the string containing valid hexadecimal values
  79056. * @param hex defines a string containing valid hexadecimal values
  79057. * @returns a new Color4 object
  79058. */
  79059. static FromHexString(hex: string): Color4;
  79060. /**
  79061. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79062. * @param left defines the start value
  79063. * @param right defines the end value
  79064. * @param amount defines the gradient factor
  79065. * @returns a new Color4 object
  79066. */
  79067. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79068. /**
  79069. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79070. * @param left defines the start value
  79071. * @param right defines the end value
  79072. * @param amount defines the gradient factor
  79073. * @param result defines the Color4 object where to store data
  79074. */
  79075. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79076. /**
  79077. * Creates a new Color4 from a Color3 and an alpha value
  79078. * @param color3 defines the source Color3 to read from
  79079. * @param alpha defines the alpha component (1.0 by default)
  79080. * @returns a new Color4 object
  79081. */
  79082. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79083. /**
  79084. * Creates a new Color4 from the starting index element of the given array
  79085. * @param array defines the source array to read from
  79086. * @param offset defines the offset in the source array
  79087. * @returns a new Color4 object
  79088. */
  79089. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79090. /**
  79091. * Creates a new Color3 from integer values (< 256)
  79092. * @param r defines the red component to read from (value between 0 and 255)
  79093. * @param g defines the green component to read from (value between 0 and 255)
  79094. * @param b defines the blue component to read from (value between 0 and 255)
  79095. * @param a defines the alpha component to read from (value between 0 and 255)
  79096. * @returns a new Color3 object
  79097. */
  79098. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79099. /**
  79100. * Check the content of a given array and convert it to an array containing RGBA data
  79101. * If the original array was already containing count * 4 values then it is returned directly
  79102. * @param colors defines the array to check
  79103. * @param count defines the number of RGBA data to expect
  79104. * @returns an array containing count * 4 values (RGBA)
  79105. */
  79106. static CheckColors4(colors: number[], count: number): number[];
  79107. }
  79108. /**
  79109. * @hidden
  79110. */
  79111. export class TmpColors {
  79112. static Color3: Color3[];
  79113. static Color4: Color4[];
  79114. }
  79115. }
  79116. declare module BABYLON {
  79117. /**
  79118. * Defines an interface which represents an animation key frame
  79119. */
  79120. export interface IAnimationKey {
  79121. /**
  79122. * Frame of the key frame
  79123. */
  79124. frame: number;
  79125. /**
  79126. * Value at the specifies key frame
  79127. */
  79128. value: any;
  79129. /**
  79130. * The input tangent for the cubic hermite spline
  79131. */
  79132. inTangent?: any;
  79133. /**
  79134. * The output tangent for the cubic hermite spline
  79135. */
  79136. outTangent?: any;
  79137. /**
  79138. * The animation interpolation type
  79139. */
  79140. interpolation?: AnimationKeyInterpolation;
  79141. }
  79142. /**
  79143. * Enum for the animation key frame interpolation type
  79144. */
  79145. export enum AnimationKeyInterpolation {
  79146. /**
  79147. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79148. */
  79149. STEP = 1
  79150. }
  79151. }
  79152. declare module BABYLON {
  79153. /**
  79154. * Represents the range of an animation
  79155. */
  79156. export class AnimationRange {
  79157. /**The name of the animation range**/
  79158. name: string;
  79159. /**The starting frame of the animation */
  79160. from: number;
  79161. /**The ending frame of the animation*/
  79162. to: number;
  79163. /**
  79164. * Initializes the range of an animation
  79165. * @param name The name of the animation range
  79166. * @param from The starting frame of the animation
  79167. * @param to The ending frame of the animation
  79168. */
  79169. constructor(
  79170. /**The name of the animation range**/
  79171. name: string,
  79172. /**The starting frame of the animation */
  79173. from: number,
  79174. /**The ending frame of the animation*/
  79175. to: number);
  79176. /**
  79177. * Makes a copy of the animation range
  79178. * @returns A copy of the animation range
  79179. */
  79180. clone(): AnimationRange;
  79181. }
  79182. }
  79183. declare module BABYLON {
  79184. /**
  79185. * Composed of a frame, and an action function
  79186. */
  79187. export class AnimationEvent {
  79188. /** The frame for which the event is triggered **/
  79189. frame: number;
  79190. /** The event to perform when triggered **/
  79191. action: (currentFrame: number) => void;
  79192. /** Specifies if the event should be triggered only once**/
  79193. onlyOnce?: boolean | undefined;
  79194. /**
  79195. * Specifies if the animation event is done
  79196. */
  79197. isDone: boolean;
  79198. /**
  79199. * Initializes the animation event
  79200. * @param frame The frame for which the event is triggered
  79201. * @param action The event to perform when triggered
  79202. * @param onlyOnce Specifies if the event should be triggered only once
  79203. */
  79204. constructor(
  79205. /** The frame for which the event is triggered **/
  79206. frame: number,
  79207. /** The event to perform when triggered **/
  79208. action: (currentFrame: number) => void,
  79209. /** Specifies if the event should be triggered only once**/
  79210. onlyOnce?: boolean | undefined);
  79211. /** @hidden */
  79212. _clone(): AnimationEvent;
  79213. }
  79214. }
  79215. declare module BABYLON {
  79216. /**
  79217. * Interface used to define a behavior
  79218. */
  79219. export interface Behavior<T> {
  79220. /** gets or sets behavior's name */
  79221. name: string;
  79222. /**
  79223. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79224. */
  79225. init(): void;
  79226. /**
  79227. * Called when the behavior is attached to a target
  79228. * @param target defines the target where the behavior is attached to
  79229. */
  79230. attach(target: T): void;
  79231. /**
  79232. * Called when the behavior is detached from its target
  79233. */
  79234. detach(): void;
  79235. }
  79236. /**
  79237. * Interface implemented by classes supporting behaviors
  79238. */
  79239. export interface IBehaviorAware<T> {
  79240. /**
  79241. * Attach a behavior
  79242. * @param behavior defines the behavior to attach
  79243. * @returns the current host
  79244. */
  79245. addBehavior(behavior: Behavior<T>): T;
  79246. /**
  79247. * Remove a behavior from the current object
  79248. * @param behavior defines the behavior to detach
  79249. * @returns the current host
  79250. */
  79251. removeBehavior(behavior: Behavior<T>): T;
  79252. /**
  79253. * Gets a behavior using its name to search
  79254. * @param name defines the name to search
  79255. * @returns the behavior or null if not found
  79256. */
  79257. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79258. }
  79259. }
  79260. declare module BABYLON {
  79261. /**
  79262. * Defines an array and its length.
  79263. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79264. */
  79265. export interface ISmartArrayLike<T> {
  79266. /**
  79267. * The data of the array.
  79268. */
  79269. data: Array<T>;
  79270. /**
  79271. * The active length of the array.
  79272. */
  79273. length: number;
  79274. }
  79275. /**
  79276. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79277. */
  79278. export class SmartArray<T> implements ISmartArrayLike<T> {
  79279. /**
  79280. * The full set of data from the array.
  79281. */
  79282. data: Array<T>;
  79283. /**
  79284. * The active length of the array.
  79285. */
  79286. length: number;
  79287. protected _id: number;
  79288. /**
  79289. * Instantiates a Smart Array.
  79290. * @param capacity defines the default capacity of the array.
  79291. */
  79292. constructor(capacity: number);
  79293. /**
  79294. * Pushes a value at the end of the active data.
  79295. * @param value defines the object to push in the array.
  79296. */
  79297. push(value: T): void;
  79298. /**
  79299. * Iterates over the active data and apply the lambda to them.
  79300. * @param func defines the action to apply on each value.
  79301. */
  79302. forEach(func: (content: T) => void): void;
  79303. /**
  79304. * Sorts the full sets of data.
  79305. * @param compareFn defines the comparison function to apply.
  79306. */
  79307. sort(compareFn: (a: T, b: T) => number): void;
  79308. /**
  79309. * Resets the active data to an empty array.
  79310. */
  79311. reset(): void;
  79312. /**
  79313. * Releases all the data from the array as well as the array.
  79314. */
  79315. dispose(): void;
  79316. /**
  79317. * Concats the active data with a given array.
  79318. * @param array defines the data to concatenate with.
  79319. */
  79320. concat(array: any): void;
  79321. /**
  79322. * Returns the position of a value in the active data.
  79323. * @param value defines the value to find the index for
  79324. * @returns the index if found in the active data otherwise -1
  79325. */
  79326. indexOf(value: T): number;
  79327. /**
  79328. * Returns whether an element is part of the active data.
  79329. * @param value defines the value to look for
  79330. * @returns true if found in the active data otherwise false
  79331. */
  79332. contains(value: T): boolean;
  79333. private static _GlobalId;
  79334. }
  79335. /**
  79336. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79337. * The data in this array can only be present once
  79338. */
  79339. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79340. private _duplicateId;
  79341. /**
  79342. * Pushes a value at the end of the active data.
  79343. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79344. * @param value defines the object to push in the array.
  79345. */
  79346. push(value: T): void;
  79347. /**
  79348. * Pushes a value at the end of the active data.
  79349. * If the data is already present, it won t be added again
  79350. * @param value defines the object to push in the array.
  79351. * @returns true if added false if it was already present
  79352. */
  79353. pushNoDuplicate(value: T): boolean;
  79354. /**
  79355. * Resets the active data to an empty array.
  79356. */
  79357. reset(): void;
  79358. /**
  79359. * Concats the active data with a given array.
  79360. * This ensures no dupplicate will be present in the result.
  79361. * @param array defines the data to concatenate with.
  79362. */
  79363. concatWithNoDuplicate(array: any): void;
  79364. }
  79365. }
  79366. declare module BABYLON {
  79367. /**
  79368. * @ignore
  79369. * This is a list of all the different input types that are available in the application.
  79370. * Fo instance: ArcRotateCameraGamepadInput...
  79371. */
  79372. export var CameraInputTypes: {};
  79373. /**
  79374. * This is the contract to implement in order to create a new input class.
  79375. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79376. */
  79377. export interface ICameraInput<TCamera extends Camera> {
  79378. /**
  79379. * Defines the camera the input is attached to.
  79380. */
  79381. camera: Nullable<TCamera>;
  79382. /**
  79383. * Gets the class name of the current intput.
  79384. * @returns the class name
  79385. */
  79386. getClassName(): string;
  79387. /**
  79388. * Get the friendly name associated with the input class.
  79389. * @returns the input friendly name
  79390. */
  79391. getSimpleName(): string;
  79392. /**
  79393. * Attach the input controls to a specific dom element to get the input from.
  79394. * @param element Defines the element the controls should be listened from
  79395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79396. */
  79397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79398. /**
  79399. * Detach the current controls from the specified dom element.
  79400. * @param element Defines the element to stop listening the inputs from
  79401. */
  79402. detachControl(element: Nullable<HTMLElement>): void;
  79403. /**
  79404. * Update the current camera state depending on the inputs that have been used this frame.
  79405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79406. */
  79407. checkInputs?: () => void;
  79408. }
  79409. /**
  79410. * Represents a map of input types to input instance or input index to input instance.
  79411. */
  79412. export interface CameraInputsMap<TCamera extends Camera> {
  79413. /**
  79414. * Accessor to the input by input type.
  79415. */
  79416. [name: string]: ICameraInput<TCamera>;
  79417. /**
  79418. * Accessor to the input by input index.
  79419. */
  79420. [idx: number]: ICameraInput<TCamera>;
  79421. }
  79422. /**
  79423. * This represents the input manager used within a camera.
  79424. * It helps dealing with all the different kind of input attached to a camera.
  79425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79426. */
  79427. export class CameraInputsManager<TCamera extends Camera> {
  79428. /**
  79429. * Defines the list of inputs attahed to the camera.
  79430. */
  79431. attached: CameraInputsMap<TCamera>;
  79432. /**
  79433. * Defines the dom element the camera is collecting inputs from.
  79434. * This is null if the controls have not been attached.
  79435. */
  79436. attachedElement: Nullable<HTMLElement>;
  79437. /**
  79438. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79439. */
  79440. noPreventDefault: boolean;
  79441. /**
  79442. * Defined the camera the input manager belongs to.
  79443. */
  79444. camera: TCamera;
  79445. /**
  79446. * Update the current camera state depending on the inputs that have been used this frame.
  79447. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79448. */
  79449. checkInputs: () => void;
  79450. /**
  79451. * Instantiate a new Camera Input Manager.
  79452. * @param camera Defines the camera the input manager blongs to
  79453. */
  79454. constructor(camera: TCamera);
  79455. /**
  79456. * Add an input method to a camera
  79457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79458. * @param input camera input method
  79459. */
  79460. add(input: ICameraInput<TCamera>): void;
  79461. /**
  79462. * Remove a specific input method from a camera
  79463. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79464. * @param inputToRemove camera input method
  79465. */
  79466. remove(inputToRemove: ICameraInput<TCamera>): void;
  79467. /**
  79468. * Remove a specific input type from a camera
  79469. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79470. * @param inputType the type of the input to remove
  79471. */
  79472. removeByType(inputType: string): void;
  79473. private _addCheckInputs;
  79474. /**
  79475. * Attach the input controls to the currently attached dom element to listen the events from.
  79476. * @param input Defines the input to attach
  79477. */
  79478. attachInput(input: ICameraInput<TCamera>): void;
  79479. /**
  79480. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79481. * @param element Defines the dom element to collect the events from
  79482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79483. */
  79484. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79485. /**
  79486. * Detach the current manager inputs controls from a specific dom element.
  79487. * @param element Defines the dom element to collect the events from
  79488. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79489. */
  79490. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79491. /**
  79492. * Rebuild the dynamic inputCheck function from the current list of
  79493. * defined inputs in the manager.
  79494. */
  79495. rebuildInputCheck(): void;
  79496. /**
  79497. * Remove all attached input methods from a camera
  79498. */
  79499. clear(): void;
  79500. /**
  79501. * Serialize the current input manager attached to a camera.
  79502. * This ensures than once parsed,
  79503. * the input associated to the camera will be identical to the current ones
  79504. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79505. */
  79506. serialize(serializedCamera: any): void;
  79507. /**
  79508. * Parses an input manager serialized JSON to restore the previous list of inputs
  79509. * and states associated to a camera.
  79510. * @param parsedCamera Defines the JSON to parse
  79511. */
  79512. parse(parsedCamera: any): void;
  79513. }
  79514. }
  79515. declare module BABYLON {
  79516. /**
  79517. * Class used to store data that will be store in GPU memory
  79518. */
  79519. export class Buffer {
  79520. private _engine;
  79521. private _buffer;
  79522. /** @hidden */
  79523. _data: Nullable<DataArray>;
  79524. private _updatable;
  79525. private _instanced;
  79526. private _divisor;
  79527. /**
  79528. * Gets the byte stride.
  79529. */
  79530. readonly byteStride: number;
  79531. /**
  79532. * Constructor
  79533. * @param engine the engine
  79534. * @param data the data to use for this buffer
  79535. * @param updatable whether the data is updatable
  79536. * @param stride the stride (optional)
  79537. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79538. * @param instanced whether the buffer is instanced (optional)
  79539. * @param useBytes set to true if the stride in in bytes (optional)
  79540. * @param divisor sets an optional divisor for instances (1 by default)
  79541. */
  79542. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79543. /**
  79544. * Create a new VertexBuffer based on the current buffer
  79545. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79546. * @param offset defines offset in the buffer (0 by default)
  79547. * @param size defines the size in floats of attributes (position is 3 for instance)
  79548. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79549. * @param instanced defines if the vertex buffer contains indexed data
  79550. * @param useBytes defines if the offset and stride are in bytes *
  79551. * @param divisor sets an optional divisor for instances (1 by default)
  79552. * @returns the new vertex buffer
  79553. */
  79554. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79555. /**
  79556. * Gets a boolean indicating if the Buffer is updatable?
  79557. * @returns true if the buffer is updatable
  79558. */
  79559. isUpdatable(): boolean;
  79560. /**
  79561. * Gets current buffer's data
  79562. * @returns a DataArray or null
  79563. */
  79564. getData(): Nullable<DataArray>;
  79565. /**
  79566. * Gets underlying native buffer
  79567. * @returns underlying native buffer
  79568. */
  79569. getBuffer(): Nullable<DataBuffer>;
  79570. /**
  79571. * Gets the stride in float32 units (i.e. byte stride / 4).
  79572. * May not be an integer if the byte stride is not divisible by 4.
  79573. * @returns the stride in float32 units
  79574. * @deprecated Please use byteStride instead.
  79575. */
  79576. getStrideSize(): number;
  79577. /**
  79578. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79579. * @param data defines the data to store
  79580. */
  79581. create(data?: Nullable<DataArray>): void;
  79582. /** @hidden */
  79583. _rebuild(): void;
  79584. /**
  79585. * Update current buffer data
  79586. * @param data defines the data to store
  79587. */
  79588. update(data: DataArray): void;
  79589. /**
  79590. * Updates the data directly.
  79591. * @param data the new data
  79592. * @param offset the new offset
  79593. * @param vertexCount the vertex count (optional)
  79594. * @param useBytes set to true if the offset is in bytes
  79595. */
  79596. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79597. /**
  79598. * Release all resources
  79599. */
  79600. dispose(): void;
  79601. }
  79602. /**
  79603. * Specialized buffer used to store vertex data
  79604. */
  79605. export class VertexBuffer {
  79606. /** @hidden */
  79607. _buffer: Buffer;
  79608. private _kind;
  79609. private _size;
  79610. private _ownsBuffer;
  79611. private _instanced;
  79612. private _instanceDivisor;
  79613. /**
  79614. * The byte type.
  79615. */
  79616. static readonly BYTE: number;
  79617. /**
  79618. * The unsigned byte type.
  79619. */
  79620. static readonly UNSIGNED_BYTE: number;
  79621. /**
  79622. * The short type.
  79623. */
  79624. static readonly SHORT: number;
  79625. /**
  79626. * The unsigned short type.
  79627. */
  79628. static readonly UNSIGNED_SHORT: number;
  79629. /**
  79630. * The integer type.
  79631. */
  79632. static readonly INT: number;
  79633. /**
  79634. * The unsigned integer type.
  79635. */
  79636. static readonly UNSIGNED_INT: number;
  79637. /**
  79638. * The float type.
  79639. */
  79640. static readonly FLOAT: number;
  79641. /**
  79642. * Gets or sets the instance divisor when in instanced mode
  79643. */
  79644. get instanceDivisor(): number;
  79645. set instanceDivisor(value: number);
  79646. /**
  79647. * Gets the byte stride.
  79648. */
  79649. readonly byteStride: number;
  79650. /**
  79651. * Gets the byte offset.
  79652. */
  79653. readonly byteOffset: number;
  79654. /**
  79655. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79656. */
  79657. readonly normalized: boolean;
  79658. /**
  79659. * Gets the data type of each component in the array.
  79660. */
  79661. readonly type: number;
  79662. /**
  79663. * Constructor
  79664. * @param engine the engine
  79665. * @param data the data to use for this vertex buffer
  79666. * @param kind the vertex buffer kind
  79667. * @param updatable whether the data is updatable
  79668. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79669. * @param stride the stride (optional)
  79670. * @param instanced whether the buffer is instanced (optional)
  79671. * @param offset the offset of the data (optional)
  79672. * @param size the number of components (optional)
  79673. * @param type the type of the component (optional)
  79674. * @param normalized whether the data contains normalized data (optional)
  79675. * @param useBytes set to true if stride and offset are in bytes (optional)
  79676. * @param divisor defines the instance divisor to use (1 by default)
  79677. */
  79678. 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);
  79679. /** @hidden */
  79680. _rebuild(): void;
  79681. /**
  79682. * Returns the kind of the VertexBuffer (string)
  79683. * @returns a string
  79684. */
  79685. getKind(): string;
  79686. /**
  79687. * Gets a boolean indicating if the VertexBuffer is updatable?
  79688. * @returns true if the buffer is updatable
  79689. */
  79690. isUpdatable(): boolean;
  79691. /**
  79692. * Gets current buffer's data
  79693. * @returns a DataArray or null
  79694. */
  79695. getData(): Nullable<DataArray>;
  79696. /**
  79697. * Gets underlying native buffer
  79698. * @returns underlying native buffer
  79699. */
  79700. getBuffer(): Nullable<DataBuffer>;
  79701. /**
  79702. * Gets the stride in float32 units (i.e. byte stride / 4).
  79703. * May not be an integer if the byte stride is not divisible by 4.
  79704. * @returns the stride in float32 units
  79705. * @deprecated Please use byteStride instead.
  79706. */
  79707. getStrideSize(): number;
  79708. /**
  79709. * Returns the offset as a multiple of the type byte length.
  79710. * @returns the offset in bytes
  79711. * @deprecated Please use byteOffset instead.
  79712. */
  79713. getOffset(): number;
  79714. /**
  79715. * Returns the number of components per vertex attribute (integer)
  79716. * @returns the size in float
  79717. */
  79718. getSize(): number;
  79719. /**
  79720. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79721. * @returns true if this buffer is instanced
  79722. */
  79723. getIsInstanced(): boolean;
  79724. /**
  79725. * Returns the instancing divisor, zero for non-instanced (integer).
  79726. * @returns a number
  79727. */
  79728. getInstanceDivisor(): number;
  79729. /**
  79730. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79731. * @param data defines the data to store
  79732. */
  79733. create(data?: DataArray): void;
  79734. /**
  79735. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79736. * This function will create a new buffer if the current one is not updatable
  79737. * @param data defines the data to store
  79738. */
  79739. update(data: DataArray): void;
  79740. /**
  79741. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79742. * Returns the directly updated WebGLBuffer.
  79743. * @param data the new data
  79744. * @param offset the new offset
  79745. * @param useBytes set to true if the offset is in bytes
  79746. */
  79747. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79748. /**
  79749. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79750. */
  79751. dispose(): void;
  79752. /**
  79753. * Enumerates each value of this vertex buffer as numbers.
  79754. * @param count the number of values to enumerate
  79755. * @param callback the callback function called for each value
  79756. */
  79757. forEach(count: number, callback: (value: number, index: number) => void): void;
  79758. /**
  79759. * Positions
  79760. */
  79761. static readonly PositionKind: string;
  79762. /**
  79763. * Normals
  79764. */
  79765. static readonly NormalKind: string;
  79766. /**
  79767. * Tangents
  79768. */
  79769. static readonly TangentKind: string;
  79770. /**
  79771. * Texture coordinates
  79772. */
  79773. static readonly UVKind: string;
  79774. /**
  79775. * Texture coordinates 2
  79776. */
  79777. static readonly UV2Kind: string;
  79778. /**
  79779. * Texture coordinates 3
  79780. */
  79781. static readonly UV3Kind: string;
  79782. /**
  79783. * Texture coordinates 4
  79784. */
  79785. static readonly UV4Kind: string;
  79786. /**
  79787. * Texture coordinates 5
  79788. */
  79789. static readonly UV5Kind: string;
  79790. /**
  79791. * Texture coordinates 6
  79792. */
  79793. static readonly UV6Kind: string;
  79794. /**
  79795. * Colors
  79796. */
  79797. static readonly ColorKind: string;
  79798. /**
  79799. * Matrix indices (for bones)
  79800. */
  79801. static readonly MatricesIndicesKind: string;
  79802. /**
  79803. * Matrix weights (for bones)
  79804. */
  79805. static readonly MatricesWeightsKind: string;
  79806. /**
  79807. * Additional matrix indices (for bones)
  79808. */
  79809. static readonly MatricesIndicesExtraKind: string;
  79810. /**
  79811. * Additional matrix weights (for bones)
  79812. */
  79813. static readonly MatricesWeightsExtraKind: string;
  79814. /**
  79815. * Deduces the stride given a kind.
  79816. * @param kind The kind string to deduce
  79817. * @returns The deduced stride
  79818. */
  79819. static DeduceStride(kind: string): number;
  79820. /**
  79821. * Gets the byte length of the given type.
  79822. * @param type the type
  79823. * @returns the number of bytes
  79824. */
  79825. static GetTypeByteLength(type: number): number;
  79826. /**
  79827. * Enumerates each value of the given parameters as numbers.
  79828. * @param data the data to enumerate
  79829. * @param byteOffset the byte offset of the data
  79830. * @param byteStride the byte stride of the data
  79831. * @param componentCount the number of components per element
  79832. * @param componentType the type of the component
  79833. * @param count the number of values to enumerate
  79834. * @param normalized whether the data is normalized
  79835. * @param callback the callback function called for each value
  79836. */
  79837. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79838. private static _GetFloatValue;
  79839. }
  79840. }
  79841. declare module BABYLON {
  79842. /**
  79843. * @hidden
  79844. */
  79845. export class IntersectionInfo {
  79846. bu: Nullable<number>;
  79847. bv: Nullable<number>;
  79848. distance: number;
  79849. faceId: number;
  79850. subMeshId: number;
  79851. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79852. }
  79853. }
  79854. declare module BABYLON {
  79855. /**
  79856. * Represens a plane by the equation ax + by + cz + d = 0
  79857. */
  79858. export class Plane {
  79859. private static _TmpMatrix;
  79860. /**
  79861. * Normal of the plane (a,b,c)
  79862. */
  79863. normal: Vector3;
  79864. /**
  79865. * d component of the plane
  79866. */
  79867. d: number;
  79868. /**
  79869. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79870. * @param a a component of the plane
  79871. * @param b b component of the plane
  79872. * @param c c component of the plane
  79873. * @param d d component of the plane
  79874. */
  79875. constructor(a: number, b: number, c: number, d: number);
  79876. /**
  79877. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79878. */
  79879. asArray(): number[];
  79880. /**
  79881. * @returns a new plane copied from the current Plane.
  79882. */
  79883. clone(): Plane;
  79884. /**
  79885. * @returns the string "Plane".
  79886. */
  79887. getClassName(): string;
  79888. /**
  79889. * @returns the Plane hash code.
  79890. */
  79891. getHashCode(): number;
  79892. /**
  79893. * Normalize the current Plane in place.
  79894. * @returns the updated Plane.
  79895. */
  79896. normalize(): Plane;
  79897. /**
  79898. * Applies a transformation the plane and returns the result
  79899. * @param transformation the transformation matrix to be applied to the plane
  79900. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79901. */
  79902. transform(transformation: DeepImmutable<Matrix>): Plane;
  79903. /**
  79904. * Calcualtte the dot product between the point and the plane normal
  79905. * @param point point to calculate the dot product with
  79906. * @returns the dot product (float) of the point coordinates and the plane normal.
  79907. */
  79908. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79909. /**
  79910. * Updates the current Plane from the plane defined by the three given points.
  79911. * @param point1 one of the points used to contruct the plane
  79912. * @param point2 one of the points used to contruct the plane
  79913. * @param point3 one of the points used to contruct the plane
  79914. * @returns the updated Plane.
  79915. */
  79916. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79917. /**
  79918. * Checks if the plane is facing a given direction
  79919. * @param direction the direction to check if the plane is facing
  79920. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79921. * @returns True is the vector "direction" is the same side than the plane normal.
  79922. */
  79923. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79924. /**
  79925. * Calculates the distance to a point
  79926. * @param point point to calculate distance to
  79927. * @returns the signed distance (float) from the given point to the Plane.
  79928. */
  79929. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79930. /**
  79931. * Creates a plane from an array
  79932. * @param array the array to create a plane from
  79933. * @returns a new Plane from the given array.
  79934. */
  79935. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79936. /**
  79937. * Creates a plane from three points
  79938. * @param point1 point used to create the plane
  79939. * @param point2 point used to create the plane
  79940. * @param point3 point used to create the plane
  79941. * @returns a new Plane defined by the three given points.
  79942. */
  79943. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79944. /**
  79945. * Creates a plane from an origin point and a normal
  79946. * @param origin origin of the plane to be constructed
  79947. * @param normal normal of the plane to be constructed
  79948. * @returns a new Plane the normal vector to this plane at the given origin point.
  79949. * Note : the vector "normal" is updated because normalized.
  79950. */
  79951. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79952. /**
  79953. * Calculates the distance from a plane and a point
  79954. * @param origin origin of the plane to be constructed
  79955. * @param normal normal of the plane to be constructed
  79956. * @param point point to calculate distance to
  79957. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79958. */
  79959. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79960. }
  79961. }
  79962. declare module BABYLON {
  79963. /**
  79964. * Class used to store bounding sphere information
  79965. */
  79966. export class BoundingSphere {
  79967. /**
  79968. * Gets the center of the bounding sphere in local space
  79969. */
  79970. readonly center: Vector3;
  79971. /**
  79972. * Radius of the bounding sphere in local space
  79973. */
  79974. radius: number;
  79975. /**
  79976. * Gets the center of the bounding sphere in world space
  79977. */
  79978. readonly centerWorld: Vector3;
  79979. /**
  79980. * Radius of the bounding sphere in world space
  79981. */
  79982. radiusWorld: number;
  79983. /**
  79984. * Gets the minimum vector in local space
  79985. */
  79986. readonly minimum: Vector3;
  79987. /**
  79988. * Gets the maximum vector in local space
  79989. */
  79990. readonly maximum: Vector3;
  79991. private _worldMatrix;
  79992. private static readonly TmpVector3;
  79993. /**
  79994. * Creates a new bounding sphere
  79995. * @param min defines the minimum vector (in local space)
  79996. * @param max defines the maximum vector (in local space)
  79997. * @param worldMatrix defines the new world matrix
  79998. */
  79999. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80000. /**
  80001. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80002. * @param min defines the new minimum vector (in local space)
  80003. * @param max defines the new maximum vector (in local space)
  80004. * @param worldMatrix defines the new world matrix
  80005. */
  80006. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80007. /**
  80008. * Scale the current bounding sphere by applying a scale factor
  80009. * @param factor defines the scale factor to apply
  80010. * @returns the current bounding box
  80011. */
  80012. scale(factor: number): BoundingSphere;
  80013. /**
  80014. * Gets the world matrix of the bounding box
  80015. * @returns a matrix
  80016. */
  80017. getWorldMatrix(): DeepImmutable<Matrix>;
  80018. /** @hidden */
  80019. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80020. /**
  80021. * Tests if the bounding sphere is intersecting the frustum planes
  80022. * @param frustumPlanes defines the frustum planes to test
  80023. * @returns true if there is an intersection
  80024. */
  80025. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80026. /**
  80027. * Tests if the bounding sphere center is in between the frustum planes.
  80028. * Used for optimistic fast inclusion.
  80029. * @param frustumPlanes defines the frustum planes to test
  80030. * @returns true if the sphere center is in between the frustum planes
  80031. */
  80032. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80033. /**
  80034. * Tests if a point is inside the bounding sphere
  80035. * @param point defines the point to test
  80036. * @returns true if the point is inside the bounding sphere
  80037. */
  80038. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80039. /**
  80040. * Checks if two sphere intersct
  80041. * @param sphere0 sphere 0
  80042. * @param sphere1 sphere 1
  80043. * @returns true if the speres intersect
  80044. */
  80045. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80046. }
  80047. }
  80048. declare module BABYLON {
  80049. /**
  80050. * Class used to store bounding box information
  80051. */
  80052. export class BoundingBox implements ICullable {
  80053. /**
  80054. * Gets the 8 vectors representing the bounding box in local space
  80055. */
  80056. readonly vectors: Vector3[];
  80057. /**
  80058. * Gets the center of the bounding box in local space
  80059. */
  80060. readonly center: Vector3;
  80061. /**
  80062. * Gets the center of the bounding box in world space
  80063. */
  80064. readonly centerWorld: Vector3;
  80065. /**
  80066. * Gets the extend size in local space
  80067. */
  80068. readonly extendSize: Vector3;
  80069. /**
  80070. * Gets the extend size in world space
  80071. */
  80072. readonly extendSizeWorld: Vector3;
  80073. /**
  80074. * Gets the OBB (object bounding box) directions
  80075. */
  80076. readonly directions: Vector3[];
  80077. /**
  80078. * Gets the 8 vectors representing the bounding box in world space
  80079. */
  80080. readonly vectorsWorld: Vector3[];
  80081. /**
  80082. * Gets the minimum vector in world space
  80083. */
  80084. readonly minimumWorld: Vector3;
  80085. /**
  80086. * Gets the maximum vector in world space
  80087. */
  80088. readonly maximumWorld: Vector3;
  80089. /**
  80090. * Gets the minimum vector in local space
  80091. */
  80092. readonly minimum: Vector3;
  80093. /**
  80094. * Gets the maximum vector in local space
  80095. */
  80096. readonly maximum: Vector3;
  80097. private _worldMatrix;
  80098. private static readonly TmpVector3;
  80099. /**
  80100. * @hidden
  80101. */
  80102. _tag: number;
  80103. /**
  80104. * Creates a new bounding box
  80105. * @param min defines the minimum vector (in local space)
  80106. * @param max defines the maximum vector (in local space)
  80107. * @param worldMatrix defines the new world matrix
  80108. */
  80109. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80110. /**
  80111. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80112. * @param min defines the new minimum vector (in local space)
  80113. * @param max defines the new maximum vector (in local space)
  80114. * @param worldMatrix defines the new world matrix
  80115. */
  80116. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80117. /**
  80118. * Scale the current bounding box by applying a scale factor
  80119. * @param factor defines the scale factor to apply
  80120. * @returns the current bounding box
  80121. */
  80122. scale(factor: number): BoundingBox;
  80123. /**
  80124. * Gets the world matrix of the bounding box
  80125. * @returns a matrix
  80126. */
  80127. getWorldMatrix(): DeepImmutable<Matrix>;
  80128. /** @hidden */
  80129. _update(world: DeepImmutable<Matrix>): void;
  80130. /**
  80131. * Tests if the bounding box is intersecting the frustum planes
  80132. * @param frustumPlanes defines the frustum planes to test
  80133. * @returns true if there is an intersection
  80134. */
  80135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80136. /**
  80137. * Tests if the bounding box is entirely inside the frustum planes
  80138. * @param frustumPlanes defines the frustum planes to test
  80139. * @returns true if there is an inclusion
  80140. */
  80141. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80142. /**
  80143. * Tests if a point is inside the bounding box
  80144. * @param point defines the point to test
  80145. * @returns true if the point is inside the bounding box
  80146. */
  80147. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80148. /**
  80149. * Tests if the bounding box intersects with a bounding sphere
  80150. * @param sphere defines the sphere to test
  80151. * @returns true if there is an intersection
  80152. */
  80153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80154. /**
  80155. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80156. * @param min defines the min vector to use
  80157. * @param max defines the max vector to use
  80158. * @returns true if there is an intersection
  80159. */
  80160. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80161. /**
  80162. * Tests if two bounding boxes are intersections
  80163. * @param box0 defines the first box to test
  80164. * @param box1 defines the second box to test
  80165. * @returns true if there is an intersection
  80166. */
  80167. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80168. /**
  80169. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80170. * @param minPoint defines the minimum vector of the bounding box
  80171. * @param maxPoint defines the maximum vector of the bounding box
  80172. * @param sphereCenter defines the sphere center
  80173. * @param sphereRadius defines the sphere radius
  80174. * @returns true if there is an intersection
  80175. */
  80176. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80177. /**
  80178. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80179. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80180. * @param frustumPlanes defines the frustum planes to test
  80181. * @return true if there is an inclusion
  80182. */
  80183. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80184. /**
  80185. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80186. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80187. * @param frustumPlanes defines the frustum planes to test
  80188. * @return true if there is an intersection
  80189. */
  80190. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80191. }
  80192. }
  80193. declare module BABYLON {
  80194. /** @hidden */
  80195. export class Collider {
  80196. /** Define if a collision was found */
  80197. collisionFound: boolean;
  80198. /**
  80199. * Define last intersection point in local space
  80200. */
  80201. intersectionPoint: Vector3;
  80202. /**
  80203. * Define last collided mesh
  80204. */
  80205. collidedMesh: Nullable<AbstractMesh>;
  80206. private _collisionPoint;
  80207. private _planeIntersectionPoint;
  80208. private _tempVector;
  80209. private _tempVector2;
  80210. private _tempVector3;
  80211. private _tempVector4;
  80212. private _edge;
  80213. private _baseToVertex;
  80214. private _destinationPoint;
  80215. private _slidePlaneNormal;
  80216. private _displacementVector;
  80217. /** @hidden */
  80218. _radius: Vector3;
  80219. /** @hidden */
  80220. _retry: number;
  80221. private _velocity;
  80222. private _basePoint;
  80223. private _epsilon;
  80224. /** @hidden */
  80225. _velocityWorldLength: number;
  80226. /** @hidden */
  80227. _basePointWorld: Vector3;
  80228. private _velocityWorld;
  80229. private _normalizedVelocity;
  80230. /** @hidden */
  80231. _initialVelocity: Vector3;
  80232. /** @hidden */
  80233. _initialPosition: Vector3;
  80234. private _nearestDistance;
  80235. private _collisionMask;
  80236. get collisionMask(): number;
  80237. set collisionMask(mask: number);
  80238. /**
  80239. * Gets the plane normal used to compute the sliding response (in local space)
  80240. */
  80241. get slidePlaneNormal(): Vector3;
  80242. /** @hidden */
  80243. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80244. /** @hidden */
  80245. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80246. /** @hidden */
  80247. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80248. /** @hidden */
  80249. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80250. /** @hidden */
  80251. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80252. /** @hidden */
  80253. _getResponse(pos: Vector3, vel: Vector3): void;
  80254. }
  80255. }
  80256. declare module BABYLON {
  80257. /**
  80258. * Interface for cullable objects
  80259. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80260. */
  80261. export interface ICullable {
  80262. /**
  80263. * Checks if the object or part of the object is in the frustum
  80264. * @param frustumPlanes Camera near/planes
  80265. * @returns true if the object is in frustum otherwise false
  80266. */
  80267. isInFrustum(frustumPlanes: Plane[]): boolean;
  80268. /**
  80269. * Checks if a cullable object (mesh...) is in the camera frustum
  80270. * Unlike isInFrustum this cheks the full bounding box
  80271. * @param frustumPlanes Camera near/planes
  80272. * @returns true if the object is in frustum otherwise false
  80273. */
  80274. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80275. }
  80276. /**
  80277. * Info for a bounding data of a mesh
  80278. */
  80279. export class BoundingInfo implements ICullable {
  80280. /**
  80281. * Bounding box for the mesh
  80282. */
  80283. readonly boundingBox: BoundingBox;
  80284. /**
  80285. * Bounding sphere for the mesh
  80286. */
  80287. readonly boundingSphere: BoundingSphere;
  80288. private _isLocked;
  80289. private static readonly TmpVector3;
  80290. /**
  80291. * Constructs bounding info
  80292. * @param minimum min vector of the bounding box/sphere
  80293. * @param maximum max vector of the bounding box/sphere
  80294. * @param worldMatrix defines the new world matrix
  80295. */
  80296. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80297. /**
  80298. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80299. * @param min defines the new minimum vector (in local space)
  80300. * @param max defines the new maximum vector (in local space)
  80301. * @param worldMatrix defines the new world matrix
  80302. */
  80303. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80304. /**
  80305. * min vector of the bounding box/sphere
  80306. */
  80307. get minimum(): Vector3;
  80308. /**
  80309. * max vector of the bounding box/sphere
  80310. */
  80311. get maximum(): Vector3;
  80312. /**
  80313. * If the info is locked and won't be updated to avoid perf overhead
  80314. */
  80315. get isLocked(): boolean;
  80316. set isLocked(value: boolean);
  80317. /**
  80318. * Updates the bounding sphere and box
  80319. * @param world world matrix to be used to update
  80320. */
  80321. update(world: DeepImmutable<Matrix>): void;
  80322. /**
  80323. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80324. * @param center New center of the bounding info
  80325. * @param extend New extend of the bounding info
  80326. * @returns the current bounding info
  80327. */
  80328. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80329. /**
  80330. * Scale the current bounding info by applying a scale factor
  80331. * @param factor defines the scale factor to apply
  80332. * @returns the current bounding info
  80333. */
  80334. scale(factor: number): BoundingInfo;
  80335. /**
  80336. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80337. * @param frustumPlanes defines the frustum to test
  80338. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80339. * @returns true if the bounding info is in the frustum planes
  80340. */
  80341. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80342. /**
  80343. * Gets the world distance between the min and max points of the bounding box
  80344. */
  80345. get diagonalLength(): number;
  80346. /**
  80347. * Checks if a cullable object (mesh...) is in the camera frustum
  80348. * Unlike isInFrustum this cheks the full bounding box
  80349. * @param frustumPlanes Camera near/planes
  80350. * @returns true if the object is in frustum otherwise false
  80351. */
  80352. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80353. /** @hidden */
  80354. _checkCollision(collider: Collider): boolean;
  80355. /**
  80356. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80357. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80358. * @param point the point to check intersection with
  80359. * @returns if the point intersects
  80360. */
  80361. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80362. /**
  80363. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80364. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80365. * @param boundingInfo the bounding info to check intersection with
  80366. * @param precise if the intersection should be done using OBB
  80367. * @returns if the bounding info intersects
  80368. */
  80369. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80370. }
  80371. }
  80372. declare module BABYLON {
  80373. /**
  80374. * Extracts minimum and maximum values from a list of indexed positions
  80375. * @param positions defines the positions to use
  80376. * @param indices defines the indices to the positions
  80377. * @param indexStart defines the start index
  80378. * @param indexCount defines the end index
  80379. * @param bias defines bias value to add to the result
  80380. * @return minimum and maximum values
  80381. */
  80382. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80383. minimum: Vector3;
  80384. maximum: Vector3;
  80385. };
  80386. /**
  80387. * Extracts minimum and maximum values from a list of positions
  80388. * @param positions defines the positions to use
  80389. * @param start defines the start index in the positions array
  80390. * @param count defines the number of positions to handle
  80391. * @param bias defines bias value to add to the result
  80392. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80393. * @return minimum and maximum values
  80394. */
  80395. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80396. minimum: Vector3;
  80397. maximum: Vector3;
  80398. };
  80399. }
  80400. declare module BABYLON {
  80401. /** @hidden */
  80402. export class WebGLDataBuffer extends DataBuffer {
  80403. private _buffer;
  80404. constructor(resource: WebGLBuffer);
  80405. get underlyingResource(): any;
  80406. }
  80407. }
  80408. declare module BABYLON {
  80409. /** @hidden */
  80410. export class WebGLPipelineContext implements IPipelineContext {
  80411. engine: ThinEngine;
  80412. program: Nullable<WebGLProgram>;
  80413. context?: WebGLRenderingContext;
  80414. vertexShader?: WebGLShader;
  80415. fragmentShader?: WebGLShader;
  80416. isParallelCompiled: boolean;
  80417. onCompiled?: () => void;
  80418. transformFeedback?: WebGLTransformFeedback | null;
  80419. vertexCompilationError: Nullable<string>;
  80420. fragmentCompilationError: Nullable<string>;
  80421. programLinkError: Nullable<string>;
  80422. programValidationError: Nullable<string>;
  80423. get isAsync(): boolean;
  80424. get isReady(): boolean;
  80425. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80426. }
  80427. }
  80428. declare module BABYLON {
  80429. interface ThinEngine {
  80430. /**
  80431. * Create an uniform buffer
  80432. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80433. * @param elements defines the content of the uniform buffer
  80434. * @returns the webGL uniform buffer
  80435. */
  80436. createUniformBuffer(elements: FloatArray): DataBuffer;
  80437. /**
  80438. * Create a dynamic uniform buffer
  80439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80440. * @param elements defines the content of the uniform buffer
  80441. * @returns the webGL uniform buffer
  80442. */
  80443. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80444. /**
  80445. * Update an existing uniform buffer
  80446. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80447. * @param uniformBuffer defines the target uniform buffer
  80448. * @param elements defines the content to update
  80449. * @param offset defines the offset in the uniform buffer where update should start
  80450. * @param count defines the size of the data to update
  80451. */
  80452. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80453. /**
  80454. * Bind an uniform buffer to the current webGL context
  80455. * @param buffer defines the buffer to bind
  80456. */
  80457. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80458. /**
  80459. * Bind a buffer to the current webGL context at a given location
  80460. * @param buffer defines the buffer to bind
  80461. * @param location defines the index where to bind the buffer
  80462. */
  80463. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80464. /**
  80465. * Bind a specific block at a given index in a specific shader program
  80466. * @param pipelineContext defines the pipeline context to use
  80467. * @param blockName defines the block name
  80468. * @param index defines the index where to bind the block
  80469. */
  80470. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80471. }
  80472. }
  80473. declare module BABYLON {
  80474. /**
  80475. * Uniform buffer objects.
  80476. *
  80477. * Handles blocks of uniform on the GPU.
  80478. *
  80479. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80480. *
  80481. * For more information, please refer to :
  80482. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80483. */
  80484. export class UniformBuffer {
  80485. private _engine;
  80486. private _buffer;
  80487. private _data;
  80488. private _bufferData;
  80489. private _dynamic?;
  80490. private _uniformLocations;
  80491. private _uniformSizes;
  80492. private _uniformLocationPointer;
  80493. private _needSync;
  80494. private _noUBO;
  80495. private _currentEffect;
  80496. /** @hidden */
  80497. _alreadyBound: boolean;
  80498. private static _MAX_UNIFORM_SIZE;
  80499. private static _tempBuffer;
  80500. /**
  80501. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80502. * This is dynamic to allow compat with webgl 1 and 2.
  80503. * You will need to pass the name of the uniform as well as the value.
  80504. */
  80505. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80506. /**
  80507. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80508. * This is dynamic to allow compat with webgl 1 and 2.
  80509. * You will need to pass the name of the uniform as well as the value.
  80510. */
  80511. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80512. /**
  80513. * Lambda to Update a single float in a uniform buffer.
  80514. * This is dynamic to allow compat with webgl 1 and 2.
  80515. * You will need to pass the name of the uniform as well as the value.
  80516. */
  80517. updateFloat: (name: string, x: number) => void;
  80518. /**
  80519. * Lambda to Update a vec2 of float in a uniform buffer.
  80520. * This is dynamic to allow compat with webgl 1 and 2.
  80521. * You will need to pass the name of the uniform as well as the value.
  80522. */
  80523. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80524. /**
  80525. * Lambda to Update a vec3 of float in a uniform buffer.
  80526. * This is dynamic to allow compat with webgl 1 and 2.
  80527. * You will need to pass the name of the uniform as well as the value.
  80528. */
  80529. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80530. /**
  80531. * Lambda to Update a vec4 of float in a uniform buffer.
  80532. * This is dynamic to allow compat with webgl 1 and 2.
  80533. * You will need to pass the name of the uniform as well as the value.
  80534. */
  80535. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80536. /**
  80537. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80538. * This is dynamic to allow compat with webgl 1 and 2.
  80539. * You will need to pass the name of the uniform as well as the value.
  80540. */
  80541. updateMatrix: (name: string, mat: Matrix) => void;
  80542. /**
  80543. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80544. * This is dynamic to allow compat with webgl 1 and 2.
  80545. * You will need to pass the name of the uniform as well as the value.
  80546. */
  80547. updateVector3: (name: string, vector: Vector3) => void;
  80548. /**
  80549. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80550. * This is dynamic to allow compat with webgl 1 and 2.
  80551. * You will need to pass the name of the uniform as well as the value.
  80552. */
  80553. updateVector4: (name: string, vector: Vector4) => void;
  80554. /**
  80555. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80556. * This is dynamic to allow compat with webgl 1 and 2.
  80557. * You will need to pass the name of the uniform as well as the value.
  80558. */
  80559. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80560. /**
  80561. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80562. * This is dynamic to allow compat with webgl 1 and 2.
  80563. * You will need to pass the name of the uniform as well as the value.
  80564. */
  80565. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80566. /**
  80567. * Instantiates a new Uniform buffer objects.
  80568. *
  80569. * Handles blocks of uniform on the GPU.
  80570. *
  80571. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80572. *
  80573. * For more information, please refer to :
  80574. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80575. * @param engine Define the engine the buffer is associated with
  80576. * @param data Define the data contained in the buffer
  80577. * @param dynamic Define if the buffer is updatable
  80578. */
  80579. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80580. /**
  80581. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80582. * or just falling back on setUniformXXX calls.
  80583. */
  80584. get useUbo(): boolean;
  80585. /**
  80586. * Indicates if the WebGL underlying uniform buffer is in sync
  80587. * with the javascript cache data.
  80588. */
  80589. get isSync(): boolean;
  80590. /**
  80591. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80592. * Also, a dynamic UniformBuffer will disable cache verification and always
  80593. * update the underlying WebGL uniform buffer to the GPU.
  80594. * @returns if Dynamic, otherwise false
  80595. */
  80596. isDynamic(): boolean;
  80597. /**
  80598. * The data cache on JS side.
  80599. * @returns the underlying data as a float array
  80600. */
  80601. getData(): Float32Array;
  80602. /**
  80603. * The underlying WebGL Uniform buffer.
  80604. * @returns the webgl buffer
  80605. */
  80606. getBuffer(): Nullable<DataBuffer>;
  80607. /**
  80608. * std140 layout specifies how to align data within an UBO structure.
  80609. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80610. * for specs.
  80611. */
  80612. private _fillAlignment;
  80613. /**
  80614. * Adds an uniform in the buffer.
  80615. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80616. * for the layout to be correct !
  80617. * @param name Name of the uniform, as used in the uniform block in the shader.
  80618. * @param size Data size, or data directly.
  80619. */
  80620. addUniform(name: string, size: number | number[]): void;
  80621. /**
  80622. * Adds a Matrix 4x4 to the uniform buffer.
  80623. * @param name Name of the uniform, as used in the uniform block in the shader.
  80624. * @param mat A 4x4 matrix.
  80625. */
  80626. addMatrix(name: string, mat: Matrix): void;
  80627. /**
  80628. * Adds a vec2 to the uniform buffer.
  80629. * @param name Name of the uniform, as used in the uniform block in the shader.
  80630. * @param x Define the x component value of the vec2
  80631. * @param y Define the y component value of the vec2
  80632. */
  80633. addFloat2(name: string, x: number, y: number): void;
  80634. /**
  80635. * Adds a vec3 to the uniform buffer.
  80636. * @param name Name of the uniform, as used in the uniform block in the shader.
  80637. * @param x Define the x component value of the vec3
  80638. * @param y Define the y component value of the vec3
  80639. * @param z Define the z component value of the vec3
  80640. */
  80641. addFloat3(name: string, x: number, y: number, z: number): void;
  80642. /**
  80643. * Adds a vec3 to the uniform buffer.
  80644. * @param name Name of the uniform, as used in the uniform block in the shader.
  80645. * @param color Define the vec3 from a Color
  80646. */
  80647. addColor3(name: string, color: Color3): void;
  80648. /**
  80649. * Adds a vec4 to the uniform buffer.
  80650. * @param name Name of the uniform, as used in the uniform block in the shader.
  80651. * @param color Define the rgb components from a Color
  80652. * @param alpha Define the a component of the vec4
  80653. */
  80654. addColor4(name: string, color: Color3, alpha: number): void;
  80655. /**
  80656. * Adds a vec3 to the uniform buffer.
  80657. * @param name Name of the uniform, as used in the uniform block in the shader.
  80658. * @param vector Define the vec3 components from a Vector
  80659. */
  80660. addVector3(name: string, vector: Vector3): void;
  80661. /**
  80662. * Adds a Matrix 3x3 to the uniform buffer.
  80663. * @param name Name of the uniform, as used in the uniform block in the shader.
  80664. */
  80665. addMatrix3x3(name: string): void;
  80666. /**
  80667. * Adds a Matrix 2x2 to the uniform buffer.
  80668. * @param name Name of the uniform, as used in the uniform block in the shader.
  80669. */
  80670. addMatrix2x2(name: string): void;
  80671. /**
  80672. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80673. */
  80674. create(): void;
  80675. /** @hidden */
  80676. _rebuild(): void;
  80677. /**
  80678. * Updates the WebGL Uniform Buffer on the GPU.
  80679. * If the `dynamic` flag is set to true, no cache comparison is done.
  80680. * Otherwise, the buffer will be updated only if the cache differs.
  80681. */
  80682. update(): void;
  80683. /**
  80684. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80685. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80686. * @param data Define the flattened data
  80687. * @param size Define the size of the data.
  80688. */
  80689. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80690. private _valueCache;
  80691. private _cacheMatrix;
  80692. private _updateMatrix3x3ForUniform;
  80693. private _updateMatrix3x3ForEffect;
  80694. private _updateMatrix2x2ForEffect;
  80695. private _updateMatrix2x2ForUniform;
  80696. private _updateFloatForEffect;
  80697. private _updateFloatForUniform;
  80698. private _updateFloat2ForEffect;
  80699. private _updateFloat2ForUniform;
  80700. private _updateFloat3ForEffect;
  80701. private _updateFloat3ForUniform;
  80702. private _updateFloat4ForEffect;
  80703. private _updateFloat4ForUniform;
  80704. private _updateMatrixForEffect;
  80705. private _updateMatrixForUniform;
  80706. private _updateVector3ForEffect;
  80707. private _updateVector3ForUniform;
  80708. private _updateVector4ForEffect;
  80709. private _updateVector4ForUniform;
  80710. private _updateColor3ForEffect;
  80711. private _updateColor3ForUniform;
  80712. private _updateColor4ForEffect;
  80713. private _updateColor4ForUniform;
  80714. /**
  80715. * Sets a sampler uniform on the effect.
  80716. * @param name Define the name of the sampler.
  80717. * @param texture Define the texture to set in the sampler
  80718. */
  80719. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80720. /**
  80721. * Directly updates the value of the uniform in the cache AND on the GPU.
  80722. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80723. * @param data Define the flattened data
  80724. */
  80725. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80726. /**
  80727. * Binds this uniform buffer to an effect.
  80728. * @param effect Define the effect to bind the buffer to
  80729. * @param name Name of the uniform block in the shader.
  80730. */
  80731. bindToEffect(effect: Effect, name: string): void;
  80732. /**
  80733. * Disposes the uniform buffer.
  80734. */
  80735. dispose(): void;
  80736. }
  80737. }
  80738. declare module BABYLON {
  80739. /**
  80740. * Enum that determines the text-wrapping mode to use.
  80741. */
  80742. export enum InspectableType {
  80743. /**
  80744. * Checkbox for booleans
  80745. */
  80746. Checkbox = 0,
  80747. /**
  80748. * Sliders for numbers
  80749. */
  80750. Slider = 1,
  80751. /**
  80752. * Vector3
  80753. */
  80754. Vector3 = 2,
  80755. /**
  80756. * Quaternions
  80757. */
  80758. Quaternion = 3,
  80759. /**
  80760. * Color3
  80761. */
  80762. Color3 = 4,
  80763. /**
  80764. * String
  80765. */
  80766. String = 5
  80767. }
  80768. /**
  80769. * Interface used to define custom inspectable properties.
  80770. * This interface is used by the inspector to display custom property grids
  80771. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80772. */
  80773. export interface IInspectable {
  80774. /**
  80775. * Gets the label to display
  80776. */
  80777. label: string;
  80778. /**
  80779. * Gets the name of the property to edit
  80780. */
  80781. propertyName: string;
  80782. /**
  80783. * Gets the type of the editor to use
  80784. */
  80785. type: InspectableType;
  80786. /**
  80787. * Gets the minimum value of the property when using in "slider" mode
  80788. */
  80789. min?: number;
  80790. /**
  80791. * Gets the maximum value of the property when using in "slider" mode
  80792. */
  80793. max?: number;
  80794. /**
  80795. * Gets the setp to use when using in "slider" mode
  80796. */
  80797. step?: number;
  80798. }
  80799. }
  80800. declare module BABYLON {
  80801. /**
  80802. * Class used to provide helper for timing
  80803. */
  80804. export class TimingTools {
  80805. /**
  80806. * Polyfill for setImmediate
  80807. * @param action defines the action to execute after the current execution block
  80808. */
  80809. static SetImmediate(action: () => void): void;
  80810. }
  80811. }
  80812. declare module BABYLON {
  80813. /**
  80814. * Class used to enable instatition of objects by class name
  80815. */
  80816. export class InstantiationTools {
  80817. /**
  80818. * Use this object to register external classes like custom textures or material
  80819. * to allow the laoders to instantiate them
  80820. */
  80821. static RegisteredExternalClasses: {
  80822. [key: string]: Object;
  80823. };
  80824. /**
  80825. * Tries to instantiate a new object from a given class name
  80826. * @param className defines the class name to instantiate
  80827. * @returns the new object or null if the system was not able to do the instantiation
  80828. */
  80829. static Instantiate(className: string): any;
  80830. }
  80831. }
  80832. declare module BABYLON {
  80833. /**
  80834. * Define options used to create a depth texture
  80835. */
  80836. export class DepthTextureCreationOptions {
  80837. /** Specifies whether or not a stencil should be allocated in the texture */
  80838. generateStencil?: boolean;
  80839. /** Specifies whether or not bilinear filtering is enable on the texture */
  80840. bilinearFiltering?: boolean;
  80841. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80842. comparisonFunction?: number;
  80843. /** Specifies if the created texture is a cube texture */
  80844. isCube?: boolean;
  80845. }
  80846. }
  80847. declare module BABYLON {
  80848. interface ThinEngine {
  80849. /**
  80850. * Creates a depth stencil cube texture.
  80851. * This is only available in WebGL 2.
  80852. * @param size The size of face edge in the cube texture.
  80853. * @param options The options defining the cube texture.
  80854. * @returns The cube texture
  80855. */
  80856. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80857. /**
  80858. * Creates a cube texture
  80859. * @param rootUrl defines the url where the files to load is located
  80860. * @param scene defines the current scene
  80861. * @param files defines the list of files to load (1 per face)
  80862. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80863. * @param onLoad defines an optional callback raised when the texture is loaded
  80864. * @param onError defines an optional callback raised if there is an issue to load the texture
  80865. * @param format defines the format of the data
  80866. * @param forcedExtension defines the extension to use to pick the right loader
  80867. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80868. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80869. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80870. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80871. * @returns the cube texture as an InternalTexture
  80872. */
  80873. 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;
  80874. /**
  80875. * Creates a cube texture
  80876. * @param rootUrl defines the url where the files to load is located
  80877. * @param scene defines the current scene
  80878. * @param files defines the list of files to load (1 per face)
  80879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80880. * @param onLoad defines an optional callback raised when the texture is loaded
  80881. * @param onError defines an optional callback raised if there is an issue to load the texture
  80882. * @param format defines the format of the data
  80883. * @param forcedExtension defines the extension to use to pick the right loader
  80884. * @returns the cube texture as an InternalTexture
  80885. */
  80886. 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;
  80887. /**
  80888. * Creates a cube texture
  80889. * @param rootUrl defines the url where the files to load is located
  80890. * @param scene defines the current scene
  80891. * @param files defines the list of files to load (1 per face)
  80892. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80893. * @param onLoad defines an optional callback raised when the texture is loaded
  80894. * @param onError defines an optional callback raised if there is an issue to load the texture
  80895. * @param format defines the format of the data
  80896. * @param forcedExtension defines the extension to use to pick the right loader
  80897. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80898. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80899. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80900. * @returns the cube texture as an InternalTexture
  80901. */
  80902. 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;
  80903. /** @hidden */
  80904. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80905. /** @hidden */
  80906. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80907. /** @hidden */
  80908. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80909. /** @hidden */
  80910. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80911. /**
  80912. * @hidden
  80913. */
  80914. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80915. }
  80916. }
  80917. declare module BABYLON {
  80918. /**
  80919. * Class for creating a cube texture
  80920. */
  80921. export class CubeTexture extends BaseTexture {
  80922. private _delayedOnLoad;
  80923. /**
  80924. * Observable triggered once the texture has been loaded.
  80925. */
  80926. onLoadObservable: Observable<CubeTexture>;
  80927. /**
  80928. * The url of the texture
  80929. */
  80930. url: string;
  80931. /**
  80932. * Gets or sets the center of the bounding box associated with the cube texture.
  80933. * It must define where the camera used to render the texture was set
  80934. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80935. */
  80936. boundingBoxPosition: Vector3;
  80937. private _boundingBoxSize;
  80938. /**
  80939. * Gets or sets the size of the bounding box associated with the cube texture
  80940. * When defined, the cubemap will switch to local mode
  80941. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80942. * @example https://www.babylonjs-playground.com/#RNASML
  80943. */
  80944. set boundingBoxSize(value: Vector3);
  80945. /**
  80946. * Returns the bounding box size
  80947. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80948. */
  80949. get boundingBoxSize(): Vector3;
  80950. protected _rotationY: number;
  80951. /**
  80952. * Sets texture matrix rotation angle around Y axis in radians.
  80953. */
  80954. set rotationY(value: number);
  80955. /**
  80956. * Gets texture matrix rotation angle around Y axis radians.
  80957. */
  80958. get rotationY(): number;
  80959. /**
  80960. * Are mip maps generated for this texture or not.
  80961. */
  80962. get noMipmap(): boolean;
  80963. private _noMipmap;
  80964. private _files;
  80965. protected _forcedExtension: Nullable<string>;
  80966. private _extensions;
  80967. private _textureMatrix;
  80968. private _format;
  80969. private _createPolynomials;
  80970. /** @hidden */
  80971. _prefiltered: boolean;
  80972. /**
  80973. * Creates a cube texture from an array of image urls
  80974. * @param files defines an array of image urls
  80975. * @param scene defines the hosting scene
  80976. * @param noMipmap specifies if mip maps are not used
  80977. * @returns a cube texture
  80978. */
  80979. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80980. /**
  80981. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80982. * @param url defines the url of the prefiltered texture
  80983. * @param scene defines the scene the texture is attached to
  80984. * @param forcedExtension defines the extension of the file if different from the url
  80985. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80986. * @return the prefiltered texture
  80987. */
  80988. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80989. /**
  80990. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80991. * as prefiltered data.
  80992. * @param rootUrl defines the url of the texture or the root name of the six images
  80993. * @param scene defines the scene the texture is attached to
  80994. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80995. * @param noMipmap defines if mipmaps should be created or not
  80996. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80997. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80998. * @param onError defines a callback triggered in case of error during load
  80999. * @param format defines the internal format to use for the texture once loaded
  81000. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81001. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81002. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81005. * @return the cube texture
  81006. */
  81007. 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);
  81008. /**
  81009. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81010. */
  81011. get isPrefiltered(): boolean;
  81012. /**
  81013. * Get the current class name of the texture useful for serialization or dynamic coding.
  81014. * @returns "CubeTexture"
  81015. */
  81016. getClassName(): string;
  81017. /**
  81018. * Update the url (and optional buffer) of this texture if url was null during construction.
  81019. * @param url the url of the texture
  81020. * @param forcedExtension defines the extension to use
  81021. * @param onLoad callback called when the texture is loaded (defaults to null)
  81022. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81023. */
  81024. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81025. /**
  81026. * Delays loading of the cube texture
  81027. * @param forcedExtension defines the extension to use
  81028. */
  81029. delayLoad(forcedExtension?: string): void;
  81030. /**
  81031. * Returns the reflection texture matrix
  81032. * @returns the reflection texture matrix
  81033. */
  81034. getReflectionTextureMatrix(): Matrix;
  81035. /**
  81036. * Sets the reflection texture matrix
  81037. * @param value Reflection texture matrix
  81038. */
  81039. setReflectionTextureMatrix(value: Matrix): void;
  81040. /**
  81041. * Parses text to create a cube texture
  81042. * @param parsedTexture define the serialized text to read from
  81043. * @param scene defines the hosting scene
  81044. * @param rootUrl defines the root url of the cube texture
  81045. * @returns a cube texture
  81046. */
  81047. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81048. /**
  81049. * Makes a clone, or deep copy, of the cube texture
  81050. * @returns a new cube texture
  81051. */
  81052. clone(): CubeTexture;
  81053. }
  81054. }
  81055. declare module BABYLON {
  81056. /**
  81057. * Manages the defines for the Material
  81058. */
  81059. export class MaterialDefines {
  81060. /** @hidden */
  81061. protected _keys: string[];
  81062. private _isDirty;
  81063. /** @hidden */
  81064. _renderId: number;
  81065. /** @hidden */
  81066. _areLightsDirty: boolean;
  81067. /** @hidden */
  81068. _areLightsDisposed: boolean;
  81069. /** @hidden */
  81070. _areAttributesDirty: boolean;
  81071. /** @hidden */
  81072. _areTexturesDirty: boolean;
  81073. /** @hidden */
  81074. _areFresnelDirty: boolean;
  81075. /** @hidden */
  81076. _areMiscDirty: boolean;
  81077. /** @hidden */
  81078. _areImageProcessingDirty: boolean;
  81079. /** @hidden */
  81080. _normals: boolean;
  81081. /** @hidden */
  81082. _uvs: boolean;
  81083. /** @hidden */
  81084. _needNormals: boolean;
  81085. /** @hidden */
  81086. _needUVs: boolean;
  81087. [id: string]: any;
  81088. /**
  81089. * Specifies if the material needs to be re-calculated
  81090. */
  81091. get isDirty(): boolean;
  81092. /**
  81093. * Marks the material to indicate that it has been re-calculated
  81094. */
  81095. markAsProcessed(): void;
  81096. /**
  81097. * Marks the material to indicate that it needs to be re-calculated
  81098. */
  81099. markAsUnprocessed(): void;
  81100. /**
  81101. * Marks the material to indicate all of its defines need to be re-calculated
  81102. */
  81103. markAllAsDirty(): void;
  81104. /**
  81105. * Marks the material to indicate that image processing needs to be re-calculated
  81106. */
  81107. markAsImageProcessingDirty(): void;
  81108. /**
  81109. * Marks the material to indicate the lights need to be re-calculated
  81110. * @param disposed Defines whether the light is dirty due to dispose or not
  81111. */
  81112. markAsLightDirty(disposed?: boolean): void;
  81113. /**
  81114. * Marks the attribute state as changed
  81115. */
  81116. markAsAttributesDirty(): void;
  81117. /**
  81118. * Marks the texture state as changed
  81119. */
  81120. markAsTexturesDirty(): void;
  81121. /**
  81122. * Marks the fresnel state as changed
  81123. */
  81124. markAsFresnelDirty(): void;
  81125. /**
  81126. * Marks the misc state as changed
  81127. */
  81128. markAsMiscDirty(): void;
  81129. /**
  81130. * Rebuilds the material defines
  81131. */
  81132. rebuild(): void;
  81133. /**
  81134. * Specifies if two material defines are equal
  81135. * @param other - A material define instance to compare to
  81136. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81137. */
  81138. isEqual(other: MaterialDefines): boolean;
  81139. /**
  81140. * Clones this instance's defines to another instance
  81141. * @param other - material defines to clone values to
  81142. */
  81143. cloneTo(other: MaterialDefines): void;
  81144. /**
  81145. * Resets the material define values
  81146. */
  81147. reset(): void;
  81148. /**
  81149. * Converts the material define values to a string
  81150. * @returns - String of material define information
  81151. */
  81152. toString(): string;
  81153. }
  81154. }
  81155. declare module BABYLON {
  81156. /**
  81157. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81158. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81159. * 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;
  81160. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81161. */
  81162. export class ColorCurves {
  81163. private _dirty;
  81164. private _tempColor;
  81165. private _globalCurve;
  81166. private _highlightsCurve;
  81167. private _midtonesCurve;
  81168. private _shadowsCurve;
  81169. private _positiveCurve;
  81170. private _negativeCurve;
  81171. private _globalHue;
  81172. private _globalDensity;
  81173. private _globalSaturation;
  81174. private _globalExposure;
  81175. /**
  81176. * Gets the global Hue value.
  81177. * 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).
  81178. */
  81179. get globalHue(): number;
  81180. /**
  81181. * Sets the global Hue value.
  81182. * 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).
  81183. */
  81184. set globalHue(value: number);
  81185. /**
  81186. * Gets the global Density value.
  81187. * 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.
  81188. * Values less than zero provide a filter of opposite hue.
  81189. */
  81190. get globalDensity(): number;
  81191. /**
  81192. * Sets the global Density value.
  81193. * 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.
  81194. * Values less than zero provide a filter of opposite hue.
  81195. */
  81196. set globalDensity(value: number);
  81197. /**
  81198. * Gets the global Saturation value.
  81199. * 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.
  81200. */
  81201. get globalSaturation(): number;
  81202. /**
  81203. * Sets the global Saturation value.
  81204. * 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.
  81205. */
  81206. set globalSaturation(value: number);
  81207. /**
  81208. * Gets the global Exposure value.
  81209. * 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.
  81210. */
  81211. get globalExposure(): number;
  81212. /**
  81213. * Sets the global Exposure value.
  81214. * 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.
  81215. */
  81216. set globalExposure(value: number);
  81217. private _highlightsHue;
  81218. private _highlightsDensity;
  81219. private _highlightsSaturation;
  81220. private _highlightsExposure;
  81221. /**
  81222. * Gets the highlights Hue value.
  81223. * 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).
  81224. */
  81225. get highlightsHue(): number;
  81226. /**
  81227. * Sets the highlights Hue value.
  81228. * 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).
  81229. */
  81230. set highlightsHue(value: number);
  81231. /**
  81232. * Gets the highlights Density value.
  81233. * 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.
  81234. * Values less than zero provide a filter of opposite hue.
  81235. */
  81236. get highlightsDensity(): number;
  81237. /**
  81238. * Sets the highlights Density value.
  81239. * 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.
  81240. * Values less than zero provide a filter of opposite hue.
  81241. */
  81242. set highlightsDensity(value: number);
  81243. /**
  81244. * Gets the highlights Saturation value.
  81245. * 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.
  81246. */
  81247. get highlightsSaturation(): number;
  81248. /**
  81249. * Sets the highlights Saturation value.
  81250. * 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.
  81251. */
  81252. set highlightsSaturation(value: number);
  81253. /**
  81254. * Gets the highlights Exposure value.
  81255. * 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.
  81256. */
  81257. get highlightsExposure(): number;
  81258. /**
  81259. * Sets the highlights Exposure value.
  81260. * 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.
  81261. */
  81262. set highlightsExposure(value: number);
  81263. private _midtonesHue;
  81264. private _midtonesDensity;
  81265. private _midtonesSaturation;
  81266. private _midtonesExposure;
  81267. /**
  81268. * Gets the midtones Hue value.
  81269. * 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).
  81270. */
  81271. get midtonesHue(): number;
  81272. /**
  81273. * Sets the midtones Hue value.
  81274. * 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).
  81275. */
  81276. set midtonesHue(value: number);
  81277. /**
  81278. * Gets the midtones Density value.
  81279. * 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.
  81280. * Values less than zero provide a filter of opposite hue.
  81281. */
  81282. get midtonesDensity(): number;
  81283. /**
  81284. * Sets the midtones Density value.
  81285. * 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.
  81286. * Values less than zero provide a filter of opposite hue.
  81287. */
  81288. set midtonesDensity(value: number);
  81289. /**
  81290. * Gets the midtones Saturation value.
  81291. * 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.
  81292. */
  81293. get midtonesSaturation(): number;
  81294. /**
  81295. * Sets the midtones Saturation value.
  81296. * 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.
  81297. */
  81298. set midtonesSaturation(value: number);
  81299. /**
  81300. * Gets the midtones Exposure value.
  81301. * 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.
  81302. */
  81303. get midtonesExposure(): number;
  81304. /**
  81305. * Sets the midtones Exposure value.
  81306. * 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.
  81307. */
  81308. set midtonesExposure(value: number);
  81309. private _shadowsHue;
  81310. private _shadowsDensity;
  81311. private _shadowsSaturation;
  81312. private _shadowsExposure;
  81313. /**
  81314. * Gets the shadows Hue value.
  81315. * 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).
  81316. */
  81317. get shadowsHue(): number;
  81318. /**
  81319. * Sets the shadows Hue value.
  81320. * 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).
  81321. */
  81322. set shadowsHue(value: number);
  81323. /**
  81324. * Gets the shadows Density value.
  81325. * 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.
  81326. * Values less than zero provide a filter of opposite hue.
  81327. */
  81328. get shadowsDensity(): number;
  81329. /**
  81330. * Sets the shadows Density value.
  81331. * 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.
  81332. * Values less than zero provide a filter of opposite hue.
  81333. */
  81334. set shadowsDensity(value: number);
  81335. /**
  81336. * Gets the shadows Saturation value.
  81337. * 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.
  81338. */
  81339. get shadowsSaturation(): number;
  81340. /**
  81341. * Sets the shadows Saturation value.
  81342. * 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.
  81343. */
  81344. set shadowsSaturation(value: number);
  81345. /**
  81346. * Gets the shadows Exposure value.
  81347. * 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.
  81348. */
  81349. get shadowsExposure(): number;
  81350. /**
  81351. * Sets the shadows Exposure value.
  81352. * 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.
  81353. */
  81354. set shadowsExposure(value: number);
  81355. /**
  81356. * Returns the class name
  81357. * @returns The class name
  81358. */
  81359. getClassName(): string;
  81360. /**
  81361. * Binds the color curves to the shader.
  81362. * @param colorCurves The color curve to bind
  81363. * @param effect The effect to bind to
  81364. * @param positiveUniform The positive uniform shader parameter
  81365. * @param neutralUniform The neutral uniform shader parameter
  81366. * @param negativeUniform The negative uniform shader parameter
  81367. */
  81368. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81369. /**
  81370. * Prepare the list of uniforms associated with the ColorCurves effects.
  81371. * @param uniformsList The list of uniforms used in the effect
  81372. */
  81373. static PrepareUniforms(uniformsList: string[]): void;
  81374. /**
  81375. * Returns color grading data based on a hue, density, saturation and exposure value.
  81376. * @param filterHue The hue of the color filter.
  81377. * @param filterDensity The density of the color filter.
  81378. * @param saturation The saturation.
  81379. * @param exposure The exposure.
  81380. * @param result The result data container.
  81381. */
  81382. private getColorGradingDataToRef;
  81383. /**
  81384. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81385. * @param value The input slider value in range [-100,100].
  81386. * @returns Adjusted value.
  81387. */
  81388. private static applyColorGradingSliderNonlinear;
  81389. /**
  81390. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81391. * @param hue The hue (H) input.
  81392. * @param saturation The saturation (S) input.
  81393. * @param brightness The brightness (B) input.
  81394. * @result An RGBA color represented as Vector4.
  81395. */
  81396. private static fromHSBToRef;
  81397. /**
  81398. * Returns a value clamped between min and max
  81399. * @param value The value to clamp
  81400. * @param min The minimum of value
  81401. * @param max The maximum of value
  81402. * @returns The clamped value.
  81403. */
  81404. private static clamp;
  81405. /**
  81406. * Clones the current color curve instance.
  81407. * @return The cloned curves
  81408. */
  81409. clone(): ColorCurves;
  81410. /**
  81411. * Serializes the current color curve instance to a json representation.
  81412. * @return a JSON representation
  81413. */
  81414. serialize(): any;
  81415. /**
  81416. * Parses the color curve from a json representation.
  81417. * @param source the JSON source to parse
  81418. * @return The parsed curves
  81419. */
  81420. static Parse(source: any): ColorCurves;
  81421. }
  81422. }
  81423. declare module BABYLON {
  81424. /**
  81425. * Interface to follow in your material defines to integrate easily the
  81426. * Image proccessing functions.
  81427. * @hidden
  81428. */
  81429. export interface IImageProcessingConfigurationDefines {
  81430. IMAGEPROCESSING: boolean;
  81431. VIGNETTE: boolean;
  81432. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81433. VIGNETTEBLENDMODEOPAQUE: boolean;
  81434. TONEMAPPING: boolean;
  81435. TONEMAPPING_ACES: boolean;
  81436. CONTRAST: boolean;
  81437. EXPOSURE: boolean;
  81438. COLORCURVES: boolean;
  81439. COLORGRADING: boolean;
  81440. COLORGRADING3D: boolean;
  81441. SAMPLER3DGREENDEPTH: boolean;
  81442. SAMPLER3DBGRMAP: boolean;
  81443. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81444. }
  81445. /**
  81446. * @hidden
  81447. */
  81448. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81449. IMAGEPROCESSING: boolean;
  81450. VIGNETTE: boolean;
  81451. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81452. VIGNETTEBLENDMODEOPAQUE: boolean;
  81453. TONEMAPPING: boolean;
  81454. TONEMAPPING_ACES: boolean;
  81455. CONTRAST: boolean;
  81456. COLORCURVES: boolean;
  81457. COLORGRADING: boolean;
  81458. COLORGRADING3D: boolean;
  81459. SAMPLER3DGREENDEPTH: boolean;
  81460. SAMPLER3DBGRMAP: boolean;
  81461. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81462. EXPOSURE: boolean;
  81463. constructor();
  81464. }
  81465. /**
  81466. * This groups together the common properties used for image processing either in direct forward pass
  81467. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81468. * or not.
  81469. */
  81470. export class ImageProcessingConfiguration {
  81471. /**
  81472. * Default tone mapping applied in BabylonJS.
  81473. */
  81474. static readonly TONEMAPPING_STANDARD: number;
  81475. /**
  81476. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81477. * to other engines rendering to increase portability.
  81478. */
  81479. static readonly TONEMAPPING_ACES: number;
  81480. /**
  81481. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81482. */
  81483. colorCurves: Nullable<ColorCurves>;
  81484. private _colorCurvesEnabled;
  81485. /**
  81486. * Gets wether the color curves effect is enabled.
  81487. */
  81488. get colorCurvesEnabled(): boolean;
  81489. /**
  81490. * Sets wether the color curves effect is enabled.
  81491. */
  81492. set colorCurvesEnabled(value: boolean);
  81493. private _colorGradingTexture;
  81494. /**
  81495. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81496. */
  81497. get colorGradingTexture(): Nullable<BaseTexture>;
  81498. /**
  81499. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81500. */
  81501. set colorGradingTexture(value: Nullable<BaseTexture>);
  81502. private _colorGradingEnabled;
  81503. /**
  81504. * Gets wether the color grading effect is enabled.
  81505. */
  81506. get colorGradingEnabled(): boolean;
  81507. /**
  81508. * Sets wether the color grading effect is enabled.
  81509. */
  81510. set colorGradingEnabled(value: boolean);
  81511. private _colorGradingWithGreenDepth;
  81512. /**
  81513. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81514. */
  81515. get colorGradingWithGreenDepth(): boolean;
  81516. /**
  81517. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81518. */
  81519. set colorGradingWithGreenDepth(value: boolean);
  81520. private _colorGradingBGR;
  81521. /**
  81522. * Gets wether the color grading texture contains BGR values.
  81523. */
  81524. get colorGradingBGR(): boolean;
  81525. /**
  81526. * Sets wether the color grading texture contains BGR values.
  81527. */
  81528. set colorGradingBGR(value: boolean);
  81529. /** @hidden */
  81530. _exposure: number;
  81531. /**
  81532. * Gets the Exposure used in the effect.
  81533. */
  81534. get exposure(): number;
  81535. /**
  81536. * Sets the Exposure used in the effect.
  81537. */
  81538. set exposure(value: number);
  81539. private _toneMappingEnabled;
  81540. /**
  81541. * Gets wether the tone mapping effect is enabled.
  81542. */
  81543. get toneMappingEnabled(): boolean;
  81544. /**
  81545. * Sets wether the tone mapping effect is enabled.
  81546. */
  81547. set toneMappingEnabled(value: boolean);
  81548. private _toneMappingType;
  81549. /**
  81550. * Gets the type of tone mapping effect.
  81551. */
  81552. get toneMappingType(): number;
  81553. /**
  81554. * Sets the type of tone mapping effect used in BabylonJS.
  81555. */
  81556. set toneMappingType(value: number);
  81557. protected _contrast: number;
  81558. /**
  81559. * Gets the contrast used in the effect.
  81560. */
  81561. get contrast(): number;
  81562. /**
  81563. * Sets the contrast used in the effect.
  81564. */
  81565. set contrast(value: number);
  81566. /**
  81567. * Vignette stretch size.
  81568. */
  81569. vignetteStretch: number;
  81570. /**
  81571. * Vignette centre X Offset.
  81572. */
  81573. vignetteCentreX: number;
  81574. /**
  81575. * Vignette centre Y Offset.
  81576. */
  81577. vignetteCentreY: number;
  81578. /**
  81579. * Vignette weight or intensity of the vignette effect.
  81580. */
  81581. vignetteWeight: number;
  81582. /**
  81583. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81584. * if vignetteEnabled is set to true.
  81585. */
  81586. vignetteColor: Color4;
  81587. /**
  81588. * Camera field of view used by the Vignette effect.
  81589. */
  81590. vignetteCameraFov: number;
  81591. private _vignetteBlendMode;
  81592. /**
  81593. * Gets the vignette blend mode allowing different kind of effect.
  81594. */
  81595. get vignetteBlendMode(): number;
  81596. /**
  81597. * Sets the vignette blend mode allowing different kind of effect.
  81598. */
  81599. set vignetteBlendMode(value: number);
  81600. private _vignetteEnabled;
  81601. /**
  81602. * Gets wether the vignette effect is enabled.
  81603. */
  81604. get vignetteEnabled(): boolean;
  81605. /**
  81606. * Sets wether the vignette effect is enabled.
  81607. */
  81608. set vignetteEnabled(value: boolean);
  81609. private _applyByPostProcess;
  81610. /**
  81611. * Gets wether the image processing is applied through a post process or not.
  81612. */
  81613. get applyByPostProcess(): boolean;
  81614. /**
  81615. * Sets wether the image processing is applied through a post process or not.
  81616. */
  81617. set applyByPostProcess(value: boolean);
  81618. private _isEnabled;
  81619. /**
  81620. * Gets wether the image processing is enabled or not.
  81621. */
  81622. get isEnabled(): boolean;
  81623. /**
  81624. * Sets wether the image processing is enabled or not.
  81625. */
  81626. set isEnabled(value: boolean);
  81627. /**
  81628. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81629. */
  81630. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81631. /**
  81632. * Method called each time the image processing information changes requires to recompile the effect.
  81633. */
  81634. protected _updateParameters(): void;
  81635. /**
  81636. * Gets the current class name.
  81637. * @return "ImageProcessingConfiguration"
  81638. */
  81639. getClassName(): string;
  81640. /**
  81641. * Prepare the list of uniforms associated with the Image Processing effects.
  81642. * @param uniforms The list of uniforms used in the effect
  81643. * @param defines the list of defines currently in use
  81644. */
  81645. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81646. /**
  81647. * Prepare the list of samplers associated with the Image Processing effects.
  81648. * @param samplersList The list of uniforms used in the effect
  81649. * @param defines the list of defines currently in use
  81650. */
  81651. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81652. /**
  81653. * Prepare the list of defines associated to the shader.
  81654. * @param defines the list of defines to complete
  81655. * @param forPostProcess Define if we are currently in post process mode or not
  81656. */
  81657. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81658. /**
  81659. * Returns true if all the image processing information are ready.
  81660. * @returns True if ready, otherwise, false
  81661. */
  81662. isReady(): boolean;
  81663. /**
  81664. * Binds the image processing to the shader.
  81665. * @param effect The effect to bind to
  81666. * @param overrideAspectRatio Override the aspect ratio of the effect
  81667. */
  81668. bind(effect: Effect, overrideAspectRatio?: number): void;
  81669. /**
  81670. * Clones the current image processing instance.
  81671. * @return The cloned image processing
  81672. */
  81673. clone(): ImageProcessingConfiguration;
  81674. /**
  81675. * Serializes the current image processing instance to a json representation.
  81676. * @return a JSON representation
  81677. */
  81678. serialize(): any;
  81679. /**
  81680. * Parses the image processing from a json representation.
  81681. * @param source the JSON source to parse
  81682. * @return The parsed image processing
  81683. */
  81684. static Parse(source: any): ImageProcessingConfiguration;
  81685. private static _VIGNETTEMODE_MULTIPLY;
  81686. private static _VIGNETTEMODE_OPAQUE;
  81687. /**
  81688. * Used to apply the vignette as a mix with the pixel color.
  81689. */
  81690. static get VIGNETTEMODE_MULTIPLY(): number;
  81691. /**
  81692. * Used to apply the vignette as a replacement of the pixel color.
  81693. */
  81694. static get VIGNETTEMODE_OPAQUE(): number;
  81695. }
  81696. }
  81697. declare module BABYLON {
  81698. /** @hidden */
  81699. export var postprocessVertexShader: {
  81700. name: string;
  81701. shader: string;
  81702. };
  81703. }
  81704. declare module BABYLON {
  81705. interface ThinEngine {
  81706. /**
  81707. * Creates a new render target texture
  81708. * @param size defines the size of the texture
  81709. * @param options defines the options used to create the texture
  81710. * @returns a new render target texture stored in an InternalTexture
  81711. */
  81712. createRenderTargetTexture(size: number | {
  81713. width: number;
  81714. height: number;
  81715. layers?: number;
  81716. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81717. /**
  81718. * Creates a depth stencil texture.
  81719. * This is only available in WebGL 2 or with the depth texture extension available.
  81720. * @param size The size of face edge in the texture.
  81721. * @param options The options defining the texture.
  81722. * @returns The texture
  81723. */
  81724. createDepthStencilTexture(size: number | {
  81725. width: number;
  81726. height: number;
  81727. layers?: number;
  81728. }, options: DepthTextureCreationOptions): InternalTexture;
  81729. /** @hidden */
  81730. _createDepthStencilTexture(size: number | {
  81731. width: number;
  81732. height: number;
  81733. layers?: number;
  81734. }, options: DepthTextureCreationOptions): InternalTexture;
  81735. }
  81736. }
  81737. declare module BABYLON {
  81738. /** Defines supported spaces */
  81739. export enum Space {
  81740. /** Local (object) space */
  81741. LOCAL = 0,
  81742. /** World space */
  81743. WORLD = 1,
  81744. /** Bone space */
  81745. BONE = 2
  81746. }
  81747. /** Defines the 3 main axes */
  81748. export class Axis {
  81749. /** X axis */
  81750. static X: Vector3;
  81751. /** Y axis */
  81752. static Y: Vector3;
  81753. /** Z axis */
  81754. static Z: Vector3;
  81755. }
  81756. }
  81757. declare module BABYLON {
  81758. /**
  81759. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81760. * This is the base of the follow, arc rotate cameras and Free camera
  81761. * @see http://doc.babylonjs.com/features/cameras
  81762. */
  81763. export class TargetCamera extends Camera {
  81764. private static _RigCamTransformMatrix;
  81765. private static _TargetTransformMatrix;
  81766. private static _TargetFocalPoint;
  81767. /**
  81768. * Define the current direction the camera is moving to
  81769. */
  81770. cameraDirection: Vector3;
  81771. /**
  81772. * Define the current rotation the camera is rotating to
  81773. */
  81774. cameraRotation: Vector2;
  81775. /**
  81776. * When set, the up vector of the camera will be updated by the rotation of the camera
  81777. */
  81778. updateUpVectorFromRotation: boolean;
  81779. private _tmpQuaternion;
  81780. /**
  81781. * Define the current rotation of the camera
  81782. */
  81783. rotation: Vector3;
  81784. /**
  81785. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81786. */
  81787. rotationQuaternion: Quaternion;
  81788. /**
  81789. * Define the current speed of the camera
  81790. */
  81791. speed: number;
  81792. /**
  81793. * Add constraint to the camera to prevent it to move freely in all directions and
  81794. * around all axis.
  81795. */
  81796. noRotationConstraint: boolean;
  81797. /**
  81798. * Define the current target of the camera as an object or a position.
  81799. */
  81800. lockedTarget: any;
  81801. /** @hidden */
  81802. _currentTarget: Vector3;
  81803. /** @hidden */
  81804. _initialFocalDistance: number;
  81805. /** @hidden */
  81806. _viewMatrix: Matrix;
  81807. /** @hidden */
  81808. _camMatrix: Matrix;
  81809. /** @hidden */
  81810. _cameraTransformMatrix: Matrix;
  81811. /** @hidden */
  81812. _cameraRotationMatrix: Matrix;
  81813. /** @hidden */
  81814. _referencePoint: Vector3;
  81815. /** @hidden */
  81816. _transformedReferencePoint: Vector3;
  81817. protected _globalCurrentTarget: Vector3;
  81818. protected _globalCurrentUpVector: Vector3;
  81819. /** @hidden */
  81820. _reset: () => void;
  81821. private _defaultUp;
  81822. /**
  81823. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81824. * This is the base of the follow, arc rotate cameras and Free camera
  81825. * @see http://doc.babylonjs.com/features/cameras
  81826. * @param name Defines the name of the camera in the scene
  81827. * @param position Defines the start position of the camera in the scene
  81828. * @param scene Defines the scene the camera belongs to
  81829. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81830. */
  81831. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81832. /**
  81833. * Gets the position in front of the camera at a given distance.
  81834. * @param distance The distance from the camera we want the position to be
  81835. * @returns the position
  81836. */
  81837. getFrontPosition(distance: number): Vector3;
  81838. /** @hidden */
  81839. _getLockedTargetPosition(): Nullable<Vector3>;
  81840. private _storedPosition;
  81841. private _storedRotation;
  81842. private _storedRotationQuaternion;
  81843. /**
  81844. * Store current camera state of the camera (fov, position, rotation, etc..)
  81845. * @returns the camera
  81846. */
  81847. storeState(): Camera;
  81848. /**
  81849. * Restored camera state. You must call storeState() first
  81850. * @returns whether it was successful or not
  81851. * @hidden
  81852. */
  81853. _restoreStateValues(): boolean;
  81854. /** @hidden */
  81855. _initCache(): void;
  81856. /** @hidden */
  81857. _updateCache(ignoreParentClass?: boolean): void;
  81858. /** @hidden */
  81859. _isSynchronizedViewMatrix(): boolean;
  81860. /** @hidden */
  81861. _computeLocalCameraSpeed(): number;
  81862. /**
  81863. * Defines the target the camera should look at.
  81864. * @param target Defines the new target as a Vector or a mesh
  81865. */
  81866. setTarget(target: Vector3): void;
  81867. /**
  81868. * Return the current target position of the camera. This value is expressed in local space.
  81869. * @returns the target position
  81870. */
  81871. getTarget(): Vector3;
  81872. /** @hidden */
  81873. _decideIfNeedsToMove(): boolean;
  81874. /** @hidden */
  81875. _updatePosition(): void;
  81876. /** @hidden */
  81877. _checkInputs(): void;
  81878. protected _updateCameraRotationMatrix(): void;
  81879. /**
  81880. * 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)
  81881. * @returns the current camera
  81882. */
  81883. private _rotateUpVectorWithCameraRotationMatrix;
  81884. private _cachedRotationZ;
  81885. private _cachedQuaternionRotationZ;
  81886. /** @hidden */
  81887. _getViewMatrix(): Matrix;
  81888. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81889. /**
  81890. * @hidden
  81891. */
  81892. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81893. /**
  81894. * @hidden
  81895. */
  81896. _updateRigCameras(): void;
  81897. private _getRigCamPositionAndTarget;
  81898. /**
  81899. * Gets the current object class name.
  81900. * @return the class name
  81901. */
  81902. getClassName(): string;
  81903. }
  81904. }
  81905. declare module BABYLON {
  81906. /**
  81907. * Gather the list of keyboard event types as constants.
  81908. */
  81909. export class KeyboardEventTypes {
  81910. /**
  81911. * The keydown event is fired when a key becomes active (pressed).
  81912. */
  81913. static readonly KEYDOWN: number;
  81914. /**
  81915. * The keyup event is fired when a key has been released.
  81916. */
  81917. static readonly KEYUP: number;
  81918. }
  81919. /**
  81920. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81921. */
  81922. export class KeyboardInfo {
  81923. /**
  81924. * Defines the type of event (KeyboardEventTypes)
  81925. */
  81926. type: number;
  81927. /**
  81928. * Defines the related dom event
  81929. */
  81930. event: KeyboardEvent;
  81931. /**
  81932. * Instantiates a new keyboard info.
  81933. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81934. * @param type Defines the type of event (KeyboardEventTypes)
  81935. * @param event Defines the related dom event
  81936. */
  81937. constructor(
  81938. /**
  81939. * Defines the type of event (KeyboardEventTypes)
  81940. */
  81941. type: number,
  81942. /**
  81943. * Defines the related dom event
  81944. */
  81945. event: KeyboardEvent);
  81946. }
  81947. /**
  81948. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81949. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81950. */
  81951. export class KeyboardInfoPre extends KeyboardInfo {
  81952. /**
  81953. * Defines the type of event (KeyboardEventTypes)
  81954. */
  81955. type: number;
  81956. /**
  81957. * Defines the related dom event
  81958. */
  81959. event: KeyboardEvent;
  81960. /**
  81961. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81962. */
  81963. skipOnPointerObservable: boolean;
  81964. /**
  81965. * Instantiates a new keyboard pre info.
  81966. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81967. * @param type Defines the type of event (KeyboardEventTypes)
  81968. * @param event Defines the related dom event
  81969. */
  81970. constructor(
  81971. /**
  81972. * Defines the type of event (KeyboardEventTypes)
  81973. */
  81974. type: number,
  81975. /**
  81976. * Defines the related dom event
  81977. */
  81978. event: KeyboardEvent);
  81979. }
  81980. }
  81981. declare module BABYLON {
  81982. /**
  81983. * Manage the keyboard inputs to control the movement of a free camera.
  81984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81985. */
  81986. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81987. /**
  81988. * Defines the camera the input is attached to.
  81989. */
  81990. camera: FreeCamera;
  81991. /**
  81992. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81993. */
  81994. keysUp: number[];
  81995. /**
  81996. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81997. */
  81998. keysDown: number[];
  81999. /**
  82000. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82001. */
  82002. keysLeft: number[];
  82003. /**
  82004. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82005. */
  82006. keysRight: number[];
  82007. private _keys;
  82008. private _onCanvasBlurObserver;
  82009. private _onKeyboardObserver;
  82010. private _engine;
  82011. private _scene;
  82012. /**
  82013. * Attach the input controls to a specific dom element to get the input from.
  82014. * @param element Defines the element the controls should be listened from
  82015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82016. */
  82017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82018. /**
  82019. * Detach the current controls from the specified dom element.
  82020. * @param element Defines the element to stop listening the inputs from
  82021. */
  82022. detachControl(element: Nullable<HTMLElement>): void;
  82023. /**
  82024. * Update the current camera state depending on the inputs that have been used this frame.
  82025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82026. */
  82027. checkInputs(): void;
  82028. /**
  82029. * Gets the class name of the current intput.
  82030. * @returns the class name
  82031. */
  82032. getClassName(): string;
  82033. /** @hidden */
  82034. _onLostFocus(): void;
  82035. /**
  82036. * Get the friendly name associated with the input class.
  82037. * @returns the input friendly name
  82038. */
  82039. getSimpleName(): string;
  82040. }
  82041. }
  82042. declare module BABYLON {
  82043. /**
  82044. * Interface describing all the common properties and methods a shadow light needs to implement.
  82045. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82046. * as well as binding the different shadow properties to the effects.
  82047. */
  82048. export interface IShadowLight extends Light {
  82049. /**
  82050. * The light id in the scene (used in scene.findLighById for instance)
  82051. */
  82052. id: string;
  82053. /**
  82054. * The position the shdow will be casted from.
  82055. */
  82056. position: Vector3;
  82057. /**
  82058. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82059. */
  82060. direction: Vector3;
  82061. /**
  82062. * The transformed position. Position of the light in world space taking parenting in account.
  82063. */
  82064. transformedPosition: Vector3;
  82065. /**
  82066. * The transformed direction. Direction of the light in world space taking parenting in account.
  82067. */
  82068. transformedDirection: Vector3;
  82069. /**
  82070. * The friendly name of the light in the scene.
  82071. */
  82072. name: string;
  82073. /**
  82074. * Defines the shadow projection clipping minimum z value.
  82075. */
  82076. shadowMinZ: number;
  82077. /**
  82078. * Defines the shadow projection clipping maximum z value.
  82079. */
  82080. shadowMaxZ: number;
  82081. /**
  82082. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82083. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82084. */
  82085. computeTransformedInformation(): boolean;
  82086. /**
  82087. * Gets the scene the light belongs to.
  82088. * @returns The scene
  82089. */
  82090. getScene(): Scene;
  82091. /**
  82092. * Callback defining a custom Projection Matrix Builder.
  82093. * This can be used to override the default projection matrix computation.
  82094. */
  82095. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82096. /**
  82097. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82098. * @param matrix The materix to updated with the projection information
  82099. * @param viewMatrix The transform matrix of the light
  82100. * @param renderList The list of mesh to render in the map
  82101. * @returns The current light
  82102. */
  82103. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82104. /**
  82105. * Gets the current depth scale used in ESM.
  82106. * @returns The scale
  82107. */
  82108. getDepthScale(): number;
  82109. /**
  82110. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82111. * @returns true if a cube texture needs to be use
  82112. */
  82113. needCube(): boolean;
  82114. /**
  82115. * Detects if the projection matrix requires to be recomputed this frame.
  82116. * @returns true if it requires to be recomputed otherwise, false.
  82117. */
  82118. needProjectionMatrixCompute(): boolean;
  82119. /**
  82120. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82121. */
  82122. forceProjectionMatrixCompute(): void;
  82123. /**
  82124. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82125. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82126. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82127. */
  82128. getShadowDirection(faceIndex?: number): Vector3;
  82129. /**
  82130. * Gets the minZ used for shadow according to both the scene and the light.
  82131. * @param activeCamera The camera we are returning the min for
  82132. * @returns the depth min z
  82133. */
  82134. getDepthMinZ(activeCamera: Camera): number;
  82135. /**
  82136. * Gets the maxZ used for shadow according to both the scene and the light.
  82137. * @param activeCamera The camera we are returning the max for
  82138. * @returns the depth max z
  82139. */
  82140. getDepthMaxZ(activeCamera: Camera): number;
  82141. }
  82142. /**
  82143. * Base implementation IShadowLight
  82144. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82145. */
  82146. export abstract class ShadowLight extends Light implements IShadowLight {
  82147. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82148. protected _position: Vector3;
  82149. protected _setPosition(value: Vector3): void;
  82150. /**
  82151. * Sets the position the shadow will be casted from. Also use as the light position for both
  82152. * point and spot lights.
  82153. */
  82154. get position(): Vector3;
  82155. /**
  82156. * Sets the position the shadow will be casted from. Also use as the light position for both
  82157. * point and spot lights.
  82158. */
  82159. set position(value: Vector3);
  82160. protected _direction: Vector3;
  82161. protected _setDirection(value: Vector3): void;
  82162. /**
  82163. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82164. * Also use as the light direction on spot and directional lights.
  82165. */
  82166. get direction(): Vector3;
  82167. /**
  82168. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82169. * Also use as the light direction on spot and directional lights.
  82170. */
  82171. set direction(value: Vector3);
  82172. protected _shadowMinZ: number;
  82173. /**
  82174. * Gets the shadow projection clipping minimum z value.
  82175. */
  82176. get shadowMinZ(): number;
  82177. /**
  82178. * Sets the shadow projection clipping minimum z value.
  82179. */
  82180. set shadowMinZ(value: number);
  82181. protected _shadowMaxZ: number;
  82182. /**
  82183. * Sets the shadow projection clipping maximum z value.
  82184. */
  82185. get shadowMaxZ(): number;
  82186. /**
  82187. * Gets the shadow projection clipping maximum z value.
  82188. */
  82189. set shadowMaxZ(value: number);
  82190. /**
  82191. * Callback defining a custom Projection Matrix Builder.
  82192. * This can be used to override the default projection matrix computation.
  82193. */
  82194. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82195. /**
  82196. * The transformed position. Position of the light in world space taking parenting in account.
  82197. */
  82198. transformedPosition: Vector3;
  82199. /**
  82200. * The transformed direction. Direction of the light in world space taking parenting in account.
  82201. */
  82202. transformedDirection: Vector3;
  82203. private _needProjectionMatrixCompute;
  82204. /**
  82205. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82206. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82207. */
  82208. computeTransformedInformation(): boolean;
  82209. /**
  82210. * Return the depth scale used for the shadow map.
  82211. * @returns the depth scale.
  82212. */
  82213. getDepthScale(): number;
  82214. /**
  82215. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82216. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82217. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82218. */
  82219. getShadowDirection(faceIndex?: number): Vector3;
  82220. /**
  82221. * Returns the ShadowLight absolute position in the World.
  82222. * @returns the position vector in world space
  82223. */
  82224. getAbsolutePosition(): Vector3;
  82225. /**
  82226. * Sets the ShadowLight direction toward the passed target.
  82227. * @param target The point to target in local space
  82228. * @returns the updated ShadowLight direction
  82229. */
  82230. setDirectionToTarget(target: Vector3): Vector3;
  82231. /**
  82232. * Returns the light rotation in euler definition.
  82233. * @returns the x y z rotation in local space.
  82234. */
  82235. getRotation(): Vector3;
  82236. /**
  82237. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82238. * @returns true if a cube texture needs to be use
  82239. */
  82240. needCube(): boolean;
  82241. /**
  82242. * Detects if the projection matrix requires to be recomputed this frame.
  82243. * @returns true if it requires to be recomputed otherwise, false.
  82244. */
  82245. needProjectionMatrixCompute(): boolean;
  82246. /**
  82247. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82248. */
  82249. forceProjectionMatrixCompute(): void;
  82250. /** @hidden */
  82251. _initCache(): void;
  82252. /** @hidden */
  82253. _isSynchronized(): boolean;
  82254. /**
  82255. * Computes the world matrix of the node
  82256. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82257. * @returns the world matrix
  82258. */
  82259. computeWorldMatrix(force?: boolean): Matrix;
  82260. /**
  82261. * Gets the minZ used for shadow according to both the scene and the light.
  82262. * @param activeCamera The camera we are returning the min for
  82263. * @returns the depth min z
  82264. */
  82265. getDepthMinZ(activeCamera: Camera): number;
  82266. /**
  82267. * Gets the maxZ used for shadow according to both the scene and the light.
  82268. * @param activeCamera The camera we are returning the max for
  82269. * @returns the depth max z
  82270. */
  82271. getDepthMaxZ(activeCamera: Camera): number;
  82272. /**
  82273. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82274. * @param matrix The materix to updated with the projection information
  82275. * @param viewMatrix The transform matrix of the light
  82276. * @param renderList The list of mesh to render in the map
  82277. * @returns The current light
  82278. */
  82279. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82280. }
  82281. }
  82282. declare module BABYLON {
  82283. /**
  82284. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82285. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82286. */
  82287. export class EffectFallbacks implements IEffectFallbacks {
  82288. private _defines;
  82289. private _currentRank;
  82290. private _maxRank;
  82291. private _mesh;
  82292. /**
  82293. * Removes the fallback from the bound mesh.
  82294. */
  82295. unBindMesh(): void;
  82296. /**
  82297. * Adds a fallback on the specified property.
  82298. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82299. * @param define The name of the define in the shader
  82300. */
  82301. addFallback(rank: number, define: string): void;
  82302. /**
  82303. * Sets the mesh to use CPU skinning when needing to fallback.
  82304. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82305. * @param mesh The mesh to use the fallbacks.
  82306. */
  82307. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82308. /**
  82309. * Checks to see if more fallbacks are still availible.
  82310. */
  82311. get hasMoreFallbacks(): boolean;
  82312. /**
  82313. * Removes the defines that should be removed when falling back.
  82314. * @param currentDefines defines the current define statements for the shader.
  82315. * @param effect defines the current effect we try to compile
  82316. * @returns The resulting defines with defines of the current rank removed.
  82317. */
  82318. reduce(currentDefines: string, effect: Effect): string;
  82319. }
  82320. }
  82321. declare module BABYLON {
  82322. /**
  82323. * "Static Class" containing the most commonly used helper while dealing with material for
  82324. * rendering purpose.
  82325. *
  82326. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82327. *
  82328. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82329. */
  82330. export class MaterialHelper {
  82331. /**
  82332. * Bind the current view position to an effect.
  82333. * @param effect The effect to be bound
  82334. * @param scene The scene the eyes position is used from
  82335. */
  82336. static BindEyePosition(effect: Effect, scene: Scene): void;
  82337. /**
  82338. * Helps preparing the defines values about the UVs in used in the effect.
  82339. * UVs are shared as much as we can accross channels in the shaders.
  82340. * @param texture The texture we are preparing the UVs for
  82341. * @param defines The defines to update
  82342. * @param key The channel key "diffuse", "specular"... used in the shader
  82343. */
  82344. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82345. /**
  82346. * Binds a texture matrix value to its corrsponding uniform
  82347. * @param texture The texture to bind the matrix for
  82348. * @param uniformBuffer The uniform buffer receivin the data
  82349. * @param key The channel key "diffuse", "specular"... used in the shader
  82350. */
  82351. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82352. /**
  82353. * Gets the current status of the fog (should it be enabled?)
  82354. * @param mesh defines the mesh to evaluate for fog support
  82355. * @param scene defines the hosting scene
  82356. * @returns true if fog must be enabled
  82357. */
  82358. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82359. /**
  82360. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82361. * @param mesh defines the current mesh
  82362. * @param scene defines the current scene
  82363. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82364. * @param pointsCloud defines if point cloud rendering has to be turned on
  82365. * @param fogEnabled defines if fog has to be turned on
  82366. * @param alphaTest defines if alpha testing has to be turned on
  82367. * @param defines defines the current list of defines
  82368. */
  82369. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82370. /**
  82371. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82372. * @param scene defines the current scene
  82373. * @param engine defines the current engine
  82374. * @param defines specifies the list of active defines
  82375. * @param useInstances defines if instances have to be turned on
  82376. * @param useClipPlane defines if clip plane have to be turned on
  82377. */
  82378. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82379. /**
  82380. * Prepares the defines for bones
  82381. * @param mesh The mesh containing the geometry data we will draw
  82382. * @param defines The defines to update
  82383. */
  82384. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82385. /**
  82386. * Prepares the defines for morph targets
  82387. * @param mesh The mesh containing the geometry data we will draw
  82388. * @param defines The defines to update
  82389. */
  82390. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82391. /**
  82392. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82393. * @param mesh The mesh containing the geometry data we will draw
  82394. * @param defines The defines to update
  82395. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82396. * @param useBones Precise whether bones should be used or not (override mesh info)
  82397. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82398. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82399. * @returns false if defines are considered not dirty and have not been checked
  82400. */
  82401. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82402. /**
  82403. * Prepares the defines related to multiview
  82404. * @param scene The scene we are intending to draw
  82405. * @param defines The defines to update
  82406. */
  82407. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82408. /**
  82409. * Prepares the defines related to the light information passed in parameter
  82410. * @param scene The scene we are intending to draw
  82411. * @param mesh The mesh the effect is compiling for
  82412. * @param light The light the effect is compiling for
  82413. * @param lightIndex The index of the light
  82414. * @param defines The defines to update
  82415. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82416. * @param state Defines the current state regarding what is needed (normals, etc...)
  82417. */
  82418. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82419. needNormals: boolean;
  82420. needRebuild: boolean;
  82421. shadowEnabled: boolean;
  82422. specularEnabled: boolean;
  82423. lightmapMode: boolean;
  82424. }): void;
  82425. /**
  82426. * Prepares the defines related to the light information passed in parameter
  82427. * @param scene The scene we are intending to draw
  82428. * @param mesh The mesh the effect is compiling for
  82429. * @param defines The defines to update
  82430. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82431. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82432. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82433. * @returns true if normals will be required for the rest of the effect
  82434. */
  82435. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82436. /**
  82437. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82438. * @param lightIndex defines the light index
  82439. * @param uniformsList The uniform list
  82440. * @param samplersList The sampler list
  82441. * @param projectedLightTexture defines if projected texture must be used
  82442. * @param uniformBuffersList defines an optional list of uniform buffers
  82443. */
  82444. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82445. /**
  82446. * Prepares the uniforms and samplers list to be used in the effect
  82447. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82448. * @param samplersList The sampler list
  82449. * @param defines The defines helping in the list generation
  82450. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82451. */
  82452. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82453. /**
  82454. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82455. * @param defines The defines to update while falling back
  82456. * @param fallbacks The authorized effect fallbacks
  82457. * @param maxSimultaneousLights The maximum number of lights allowed
  82458. * @param rank the current rank of the Effect
  82459. * @returns The newly affected rank
  82460. */
  82461. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82462. private static _TmpMorphInfluencers;
  82463. /**
  82464. * Prepares the list of attributes required for morph targets according to the effect defines.
  82465. * @param attribs The current list of supported attribs
  82466. * @param mesh The mesh to prepare the morph targets attributes for
  82467. * @param influencers The number of influencers
  82468. */
  82469. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82470. /**
  82471. * Prepares the list of attributes required for morph targets according to the effect defines.
  82472. * @param attribs The current list of supported attribs
  82473. * @param mesh The mesh to prepare the morph targets attributes for
  82474. * @param defines The current Defines of the effect
  82475. */
  82476. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82477. /**
  82478. * Prepares the list of attributes required for bones according to the effect defines.
  82479. * @param attribs The current list of supported attribs
  82480. * @param mesh The mesh to prepare the bones attributes for
  82481. * @param defines The current Defines of the effect
  82482. * @param fallbacks The current efffect fallback strategy
  82483. */
  82484. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82485. /**
  82486. * Check and prepare the list of attributes required for instances according to the effect defines.
  82487. * @param attribs The current list of supported attribs
  82488. * @param defines The current MaterialDefines of the effect
  82489. */
  82490. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82491. /**
  82492. * Add the list of attributes required for instances to the attribs array.
  82493. * @param attribs The current list of supported attribs
  82494. */
  82495. static PushAttributesForInstances(attribs: string[]): void;
  82496. /**
  82497. * Binds the light information to the effect.
  82498. * @param light The light containing the generator
  82499. * @param effect The effect we are binding the data to
  82500. * @param lightIndex The light index in the effect used to render
  82501. */
  82502. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82503. /**
  82504. * Binds the lights information from the scene to the effect for the given mesh.
  82505. * @param light Light to bind
  82506. * @param lightIndex Light index
  82507. * @param scene The scene where the light belongs to
  82508. * @param effect The effect we are binding the data to
  82509. * @param useSpecular Defines if specular is supported
  82510. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82511. */
  82512. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82513. /**
  82514. * Binds the lights information from the scene to the effect for the given mesh.
  82515. * @param scene The scene the lights belongs to
  82516. * @param mesh The mesh we are binding the information to render
  82517. * @param effect The effect we are binding the data to
  82518. * @param defines The generated defines for the effect
  82519. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82520. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82521. */
  82522. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82523. private static _tempFogColor;
  82524. /**
  82525. * Binds the fog information from the scene to the effect for the given mesh.
  82526. * @param scene The scene the lights belongs to
  82527. * @param mesh The mesh we are binding the information to render
  82528. * @param effect The effect we are binding the data to
  82529. * @param linearSpace Defines if the fog effect is applied in linear space
  82530. */
  82531. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82532. /**
  82533. * Binds the bones information from the mesh to the effect.
  82534. * @param mesh The mesh we are binding the information to render
  82535. * @param effect The effect we are binding the data to
  82536. */
  82537. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82538. /**
  82539. * Binds the morph targets information from the mesh to the effect.
  82540. * @param abstractMesh The mesh we are binding the information to render
  82541. * @param effect The effect we are binding the data to
  82542. */
  82543. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82544. /**
  82545. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82546. * @param defines The generated defines used in the effect
  82547. * @param effect The effect we are binding the data to
  82548. * @param scene The scene we are willing to render with logarithmic scale for
  82549. */
  82550. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82551. /**
  82552. * Binds the clip plane information from the scene to the effect.
  82553. * @param scene The scene the clip plane information are extracted from
  82554. * @param effect The effect we are binding the data to
  82555. */
  82556. static BindClipPlane(effect: Effect, scene: Scene): void;
  82557. }
  82558. }
  82559. declare module BABYLON {
  82560. /** @hidden */
  82561. export var packingFunctions: {
  82562. name: string;
  82563. shader: string;
  82564. };
  82565. }
  82566. declare module BABYLON {
  82567. /** @hidden */
  82568. export var clipPlaneFragmentDeclaration: {
  82569. name: string;
  82570. shader: string;
  82571. };
  82572. }
  82573. declare module BABYLON {
  82574. /** @hidden */
  82575. export var clipPlaneFragment: {
  82576. name: string;
  82577. shader: string;
  82578. };
  82579. }
  82580. declare module BABYLON {
  82581. /** @hidden */
  82582. export var shadowMapPixelShader: {
  82583. name: string;
  82584. shader: string;
  82585. };
  82586. }
  82587. declare module BABYLON {
  82588. /** @hidden */
  82589. export var bonesDeclaration: {
  82590. name: string;
  82591. shader: string;
  82592. };
  82593. }
  82594. declare module BABYLON {
  82595. /** @hidden */
  82596. export var morphTargetsVertexGlobalDeclaration: {
  82597. name: string;
  82598. shader: string;
  82599. };
  82600. }
  82601. declare module BABYLON {
  82602. /** @hidden */
  82603. export var morphTargetsVertexDeclaration: {
  82604. name: string;
  82605. shader: string;
  82606. };
  82607. }
  82608. declare module BABYLON {
  82609. /** @hidden */
  82610. export var instancesDeclaration: {
  82611. name: string;
  82612. shader: string;
  82613. };
  82614. }
  82615. declare module BABYLON {
  82616. /** @hidden */
  82617. export var helperFunctions: {
  82618. name: string;
  82619. shader: string;
  82620. };
  82621. }
  82622. declare module BABYLON {
  82623. /** @hidden */
  82624. export var clipPlaneVertexDeclaration: {
  82625. name: string;
  82626. shader: string;
  82627. };
  82628. }
  82629. declare module BABYLON {
  82630. /** @hidden */
  82631. export var morphTargetsVertex: {
  82632. name: string;
  82633. shader: string;
  82634. };
  82635. }
  82636. declare module BABYLON {
  82637. /** @hidden */
  82638. export var instancesVertex: {
  82639. name: string;
  82640. shader: string;
  82641. };
  82642. }
  82643. declare module BABYLON {
  82644. /** @hidden */
  82645. export var bonesVertex: {
  82646. name: string;
  82647. shader: string;
  82648. };
  82649. }
  82650. declare module BABYLON {
  82651. /** @hidden */
  82652. export var clipPlaneVertex: {
  82653. name: string;
  82654. shader: string;
  82655. };
  82656. }
  82657. declare module BABYLON {
  82658. /** @hidden */
  82659. export var shadowMapVertexShader: {
  82660. name: string;
  82661. shader: string;
  82662. };
  82663. }
  82664. declare module BABYLON {
  82665. /** @hidden */
  82666. export var depthBoxBlurPixelShader: {
  82667. name: string;
  82668. shader: string;
  82669. };
  82670. }
  82671. declare module BABYLON {
  82672. /**
  82673. * Class representing a ray with position and direction
  82674. */
  82675. export class Ray {
  82676. /** origin point */
  82677. origin: Vector3;
  82678. /** direction */
  82679. direction: Vector3;
  82680. /** length of the ray */
  82681. length: number;
  82682. private static readonly TmpVector3;
  82683. private _tmpRay;
  82684. /**
  82685. * Creates a new ray
  82686. * @param origin origin point
  82687. * @param direction direction
  82688. * @param length length of the ray
  82689. */
  82690. constructor(
  82691. /** origin point */
  82692. origin: Vector3,
  82693. /** direction */
  82694. direction: Vector3,
  82695. /** length of the ray */
  82696. length?: number);
  82697. /**
  82698. * Checks if the ray intersects a box
  82699. * @param minimum bound of the box
  82700. * @param maximum bound of the box
  82701. * @param intersectionTreshold extra extend to be added to the box in all direction
  82702. * @returns if the box was hit
  82703. */
  82704. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82705. /**
  82706. * Checks if the ray intersects a box
  82707. * @param box the bounding box to check
  82708. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82709. * @returns if the box was hit
  82710. */
  82711. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82712. /**
  82713. * If the ray hits a sphere
  82714. * @param sphere the bounding sphere to check
  82715. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82716. * @returns true if it hits the sphere
  82717. */
  82718. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82719. /**
  82720. * If the ray hits a triange
  82721. * @param vertex0 triangle vertex
  82722. * @param vertex1 triangle vertex
  82723. * @param vertex2 triangle vertex
  82724. * @returns intersection information if hit
  82725. */
  82726. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82727. /**
  82728. * Checks if ray intersects a plane
  82729. * @param plane the plane to check
  82730. * @returns the distance away it was hit
  82731. */
  82732. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82733. /**
  82734. * Calculate the intercept of a ray on a given axis
  82735. * @param axis to check 'x' | 'y' | 'z'
  82736. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82737. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82738. */
  82739. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82740. /**
  82741. * Checks if ray intersects a mesh
  82742. * @param mesh the mesh to check
  82743. * @param fastCheck if only the bounding box should checked
  82744. * @returns picking info of the intersecton
  82745. */
  82746. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82747. /**
  82748. * Checks if ray intersects a mesh
  82749. * @param meshes the meshes to check
  82750. * @param fastCheck if only the bounding box should checked
  82751. * @param results array to store result in
  82752. * @returns Array of picking infos
  82753. */
  82754. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82755. private _comparePickingInfo;
  82756. private static smallnum;
  82757. private static rayl;
  82758. /**
  82759. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82760. * @param sega the first point of the segment to test the intersection against
  82761. * @param segb the second point of the segment to test the intersection against
  82762. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82763. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82764. */
  82765. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82766. /**
  82767. * Update the ray from viewport position
  82768. * @param x position
  82769. * @param y y position
  82770. * @param viewportWidth viewport width
  82771. * @param viewportHeight viewport height
  82772. * @param world world matrix
  82773. * @param view view matrix
  82774. * @param projection projection matrix
  82775. * @returns this ray updated
  82776. */
  82777. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82778. /**
  82779. * Creates a ray with origin and direction of 0,0,0
  82780. * @returns the new ray
  82781. */
  82782. static Zero(): Ray;
  82783. /**
  82784. * Creates a new ray from screen space and viewport
  82785. * @param x position
  82786. * @param y y position
  82787. * @param viewportWidth viewport width
  82788. * @param viewportHeight viewport height
  82789. * @param world world matrix
  82790. * @param view view matrix
  82791. * @param projection projection matrix
  82792. * @returns new ray
  82793. */
  82794. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82795. /**
  82796. * 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
  82797. * transformed to the given world matrix.
  82798. * @param origin The origin point
  82799. * @param end The end point
  82800. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82801. * @returns the new ray
  82802. */
  82803. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82804. /**
  82805. * Transforms a ray by a matrix
  82806. * @param ray ray to transform
  82807. * @param matrix matrix to apply
  82808. * @returns the resulting new ray
  82809. */
  82810. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82811. /**
  82812. * Transforms a ray by a matrix
  82813. * @param ray ray to transform
  82814. * @param matrix matrix to apply
  82815. * @param result ray to store result in
  82816. */
  82817. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82818. /**
  82819. * Unproject a ray from screen space to object space
  82820. * @param sourceX defines the screen space x coordinate to use
  82821. * @param sourceY defines the screen space y coordinate to use
  82822. * @param viewportWidth defines the current width of the viewport
  82823. * @param viewportHeight defines the current height of the viewport
  82824. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82825. * @param view defines the view matrix to use
  82826. * @param projection defines the projection matrix to use
  82827. */
  82828. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82829. }
  82830. /**
  82831. * Type used to define predicate used to select faces when a mesh intersection is detected
  82832. */
  82833. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82834. interface Scene {
  82835. /** @hidden */
  82836. _tempPickingRay: Nullable<Ray>;
  82837. /** @hidden */
  82838. _cachedRayForTransform: Ray;
  82839. /** @hidden */
  82840. _pickWithRayInverseMatrix: Matrix;
  82841. /** @hidden */
  82842. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82843. /** @hidden */
  82844. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82845. }
  82846. }
  82847. declare module BABYLON {
  82848. /**
  82849. * Groups all the scene component constants in one place to ease maintenance.
  82850. * @hidden
  82851. */
  82852. export class SceneComponentConstants {
  82853. static readonly NAME_EFFECTLAYER: string;
  82854. static readonly NAME_LAYER: string;
  82855. static readonly NAME_LENSFLARESYSTEM: string;
  82856. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82857. static readonly NAME_PARTICLESYSTEM: string;
  82858. static readonly NAME_GAMEPAD: string;
  82859. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82860. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82861. static readonly NAME_DEPTHRENDERER: string;
  82862. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82863. static readonly NAME_SPRITE: string;
  82864. static readonly NAME_OUTLINERENDERER: string;
  82865. static readonly NAME_PROCEDURALTEXTURE: string;
  82866. static readonly NAME_SHADOWGENERATOR: string;
  82867. static readonly NAME_OCTREE: string;
  82868. static readonly NAME_PHYSICSENGINE: string;
  82869. static readonly NAME_AUDIO: string;
  82870. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82871. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82872. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82873. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82874. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82875. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82876. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82877. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82878. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82879. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82880. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82881. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82882. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82883. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82884. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82885. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82886. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82887. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82888. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82889. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82890. static readonly STEP_AFTERRENDER_AUDIO: number;
  82891. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82892. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82893. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82894. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82895. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82896. static readonly STEP_POINTERMOVE_SPRITE: number;
  82897. static readonly STEP_POINTERDOWN_SPRITE: number;
  82898. static readonly STEP_POINTERUP_SPRITE: number;
  82899. }
  82900. /**
  82901. * This represents a scene component.
  82902. *
  82903. * This is used to decouple the dependency the scene is having on the different workloads like
  82904. * layers, post processes...
  82905. */
  82906. export interface ISceneComponent {
  82907. /**
  82908. * The name of the component. Each component must have a unique name.
  82909. */
  82910. name: string;
  82911. /**
  82912. * The scene the component belongs to.
  82913. */
  82914. scene: Scene;
  82915. /**
  82916. * Register the component to one instance of a scene.
  82917. */
  82918. register(): void;
  82919. /**
  82920. * Rebuilds the elements related to this component in case of
  82921. * context lost for instance.
  82922. */
  82923. rebuild(): void;
  82924. /**
  82925. * Disposes the component and the associated ressources.
  82926. */
  82927. dispose(): void;
  82928. }
  82929. /**
  82930. * This represents a SERIALIZABLE scene component.
  82931. *
  82932. * This extends Scene Component to add Serialization methods on top.
  82933. */
  82934. export interface ISceneSerializableComponent extends ISceneComponent {
  82935. /**
  82936. * Adds all the elements from the container to the scene
  82937. * @param container the container holding the elements
  82938. */
  82939. addFromContainer(container: AbstractScene): void;
  82940. /**
  82941. * Removes all the elements in the container from the scene
  82942. * @param container contains the elements to remove
  82943. * @param dispose if the removed element should be disposed (default: false)
  82944. */
  82945. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82946. /**
  82947. * Serializes the component data to the specified json object
  82948. * @param serializationObject The object to serialize to
  82949. */
  82950. serialize(serializationObject: any): void;
  82951. }
  82952. /**
  82953. * Strong typing of a Mesh related stage step action
  82954. */
  82955. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82956. /**
  82957. * Strong typing of a Evaluate Sub Mesh related stage step action
  82958. */
  82959. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82960. /**
  82961. * Strong typing of a Active Mesh related stage step action
  82962. */
  82963. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82964. /**
  82965. * Strong typing of a Camera related stage step action
  82966. */
  82967. export type CameraStageAction = (camera: Camera) => void;
  82968. /**
  82969. * Strong typing of a Camera Frame buffer related stage step action
  82970. */
  82971. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82972. /**
  82973. * Strong typing of a Render Target related stage step action
  82974. */
  82975. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82976. /**
  82977. * Strong typing of a RenderingGroup related stage step action
  82978. */
  82979. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82980. /**
  82981. * Strong typing of a Mesh Render related stage step action
  82982. */
  82983. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82984. /**
  82985. * Strong typing of a simple stage step action
  82986. */
  82987. export type SimpleStageAction = () => void;
  82988. /**
  82989. * Strong typing of a render target action.
  82990. */
  82991. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82992. /**
  82993. * Strong typing of a pointer move action.
  82994. */
  82995. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82996. /**
  82997. * Strong typing of a pointer up/down action.
  82998. */
  82999. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83000. /**
  83001. * Representation of a stage in the scene (Basically a list of ordered steps)
  83002. * @hidden
  83003. */
  83004. export class Stage<T extends Function> extends Array<{
  83005. index: number;
  83006. component: ISceneComponent;
  83007. action: T;
  83008. }> {
  83009. /**
  83010. * Hide ctor from the rest of the world.
  83011. * @param items The items to add.
  83012. */
  83013. private constructor();
  83014. /**
  83015. * Creates a new Stage.
  83016. * @returns A new instance of a Stage
  83017. */
  83018. static Create<T extends Function>(): Stage<T>;
  83019. /**
  83020. * Registers a step in an ordered way in the targeted stage.
  83021. * @param index Defines the position to register the step in
  83022. * @param component Defines the component attached to the step
  83023. * @param action Defines the action to launch during the step
  83024. */
  83025. registerStep(index: number, component: ISceneComponent, action: T): void;
  83026. /**
  83027. * Clears all the steps from the stage.
  83028. */
  83029. clear(): void;
  83030. }
  83031. }
  83032. declare module BABYLON {
  83033. interface Scene {
  83034. /** @hidden */
  83035. _pointerOverSprite: Nullable<Sprite>;
  83036. /** @hidden */
  83037. _pickedDownSprite: Nullable<Sprite>;
  83038. /** @hidden */
  83039. _tempSpritePickingRay: Nullable<Ray>;
  83040. /**
  83041. * All of the sprite managers added to this scene
  83042. * @see http://doc.babylonjs.com/babylon101/sprites
  83043. */
  83044. spriteManagers: Array<ISpriteManager>;
  83045. /**
  83046. * An event triggered when sprites rendering is about to start
  83047. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83048. */
  83049. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83050. /**
  83051. * An event triggered when sprites rendering is done
  83052. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83053. */
  83054. onAfterSpritesRenderingObservable: Observable<Scene>;
  83055. /** @hidden */
  83056. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83057. /** Launch a ray to try to pick a sprite in the scene
  83058. * @param x position on screen
  83059. * @param y position on screen
  83060. * @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
  83061. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83062. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83063. * @returns a PickingInfo
  83064. */
  83065. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83066. /** Use the given ray to pick a sprite in the scene
  83067. * @param ray The ray (in world space) to use to pick meshes
  83068. * @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
  83069. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83070. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83071. * @returns a PickingInfo
  83072. */
  83073. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83074. /** @hidden */
  83075. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83076. /** Launch a ray to try to pick sprites in the scene
  83077. * @param x position on screen
  83078. * @param y position on screen
  83079. * @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
  83080. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83081. * @returns a PickingInfo array
  83082. */
  83083. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83084. /** Use the given ray to pick sprites in the scene
  83085. * @param ray The ray (in world space) to use to pick meshes
  83086. * @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
  83087. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83088. * @returns a PickingInfo array
  83089. */
  83090. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83091. /**
  83092. * Force the sprite under the pointer
  83093. * @param sprite defines the sprite to use
  83094. */
  83095. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83096. /**
  83097. * Gets the sprite under the pointer
  83098. * @returns a Sprite or null if no sprite is under the pointer
  83099. */
  83100. getPointerOverSprite(): Nullable<Sprite>;
  83101. }
  83102. /**
  83103. * Defines the sprite scene component responsible to manage sprites
  83104. * in a given scene.
  83105. */
  83106. export class SpriteSceneComponent implements ISceneComponent {
  83107. /**
  83108. * The component name helpfull to identify the component in the list of scene components.
  83109. */
  83110. readonly name: string;
  83111. /**
  83112. * The scene the component belongs to.
  83113. */
  83114. scene: Scene;
  83115. /** @hidden */
  83116. private _spritePredicate;
  83117. /**
  83118. * Creates a new instance of the component for the given scene
  83119. * @param scene Defines the scene to register the component in
  83120. */
  83121. constructor(scene: Scene);
  83122. /**
  83123. * Registers the component in a given scene
  83124. */
  83125. register(): void;
  83126. /**
  83127. * Rebuilds the elements related to this component in case of
  83128. * context lost for instance.
  83129. */
  83130. rebuild(): void;
  83131. /**
  83132. * Disposes the component and the associated ressources.
  83133. */
  83134. dispose(): void;
  83135. private _pickSpriteButKeepRay;
  83136. private _pointerMove;
  83137. private _pointerDown;
  83138. private _pointerUp;
  83139. }
  83140. }
  83141. declare module BABYLON {
  83142. /** @hidden */
  83143. export var fogFragmentDeclaration: {
  83144. name: string;
  83145. shader: string;
  83146. };
  83147. }
  83148. declare module BABYLON {
  83149. /** @hidden */
  83150. export var fogFragment: {
  83151. name: string;
  83152. shader: string;
  83153. };
  83154. }
  83155. declare module BABYLON {
  83156. /** @hidden */
  83157. export var spritesPixelShader: {
  83158. name: string;
  83159. shader: string;
  83160. };
  83161. }
  83162. declare module BABYLON {
  83163. /** @hidden */
  83164. export var fogVertexDeclaration: {
  83165. name: string;
  83166. shader: string;
  83167. };
  83168. }
  83169. declare module BABYLON {
  83170. /** @hidden */
  83171. export var spritesVertexShader: {
  83172. name: string;
  83173. shader: string;
  83174. };
  83175. }
  83176. declare module BABYLON {
  83177. /**
  83178. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83179. */
  83180. export interface ISpriteManager extends IDisposable {
  83181. /**
  83182. * Restricts the camera to viewing objects with the same layerMask.
  83183. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83184. */
  83185. layerMask: number;
  83186. /**
  83187. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83188. */
  83189. isPickable: boolean;
  83190. /**
  83191. * Specifies the rendering group id for this mesh (0 by default)
  83192. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83193. */
  83194. renderingGroupId: number;
  83195. /**
  83196. * Defines the list of sprites managed by the manager.
  83197. */
  83198. sprites: Array<Sprite>;
  83199. /**
  83200. * Tests the intersection of a sprite with a specific ray.
  83201. * @param ray The ray we are sending to test the collision
  83202. * @param camera The camera space we are sending rays in
  83203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83204. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83205. * @returns picking info or null.
  83206. */
  83207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83208. /**
  83209. * Intersects the sprites with a ray
  83210. * @param ray defines the ray to intersect with
  83211. * @param camera defines the current active camera
  83212. * @param predicate defines a predicate used to select candidate sprites
  83213. * @returns null if no hit or a PickingInfo array
  83214. */
  83215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83216. /**
  83217. * Renders the list of sprites on screen.
  83218. */
  83219. render(): void;
  83220. }
  83221. /**
  83222. * Class used to manage multiple sprites on the same spritesheet
  83223. * @see http://doc.babylonjs.com/babylon101/sprites
  83224. */
  83225. export class SpriteManager implements ISpriteManager {
  83226. /** defines the manager's name */
  83227. name: string;
  83228. /** Gets the list of sprites */
  83229. sprites: Sprite[];
  83230. /** Gets or sets the rendering group id (0 by default) */
  83231. renderingGroupId: number;
  83232. /** Gets or sets camera layer mask */
  83233. layerMask: number;
  83234. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83235. fogEnabled: boolean;
  83236. /** Gets or sets a boolean indicating if the sprites are pickable */
  83237. isPickable: boolean;
  83238. /** Defines the default width of a cell in the spritesheet */
  83239. cellWidth: number;
  83240. /** Defines the default height of a cell in the spritesheet */
  83241. cellHeight: number;
  83242. /** Associative array from JSON sprite data file */
  83243. private _cellData;
  83244. /** Array of sprite names from JSON sprite data file */
  83245. private _spriteMap;
  83246. /** True when packed cell data from JSON file is ready*/
  83247. private _packedAndReady;
  83248. /**
  83249. * An event triggered when the manager is disposed.
  83250. */
  83251. onDisposeObservable: Observable<SpriteManager>;
  83252. private _onDisposeObserver;
  83253. /**
  83254. * Callback called when the manager is disposed
  83255. */
  83256. set onDispose(callback: () => void);
  83257. private _capacity;
  83258. private _fromPacked;
  83259. private _spriteTexture;
  83260. private _epsilon;
  83261. private _scene;
  83262. private _vertexData;
  83263. private _buffer;
  83264. private _vertexBuffers;
  83265. private _indexBuffer;
  83266. private _effectBase;
  83267. private _effectFog;
  83268. /**
  83269. * Gets or sets the spritesheet texture
  83270. */
  83271. get texture(): Texture;
  83272. set texture(value: Texture);
  83273. private _blendMode;
  83274. /**
  83275. * Blend mode use to render the particle, it can be any of
  83276. * the static Constants.ALPHA_x properties provided in this class.
  83277. * Default value is Constants.ALPHA_COMBINE
  83278. */
  83279. get blendMode(): number;
  83280. set blendMode(blendMode: number);
  83281. /** Disables writing to the depth buffer when rendering the sprites.
  83282. * It can be handy to disable depth writing when using textures without alpha channel
  83283. * and setting some specific blend modes.
  83284. */
  83285. disableDepthWrite: boolean;
  83286. /**
  83287. * Creates a new sprite manager
  83288. * @param name defines the manager's name
  83289. * @param imgUrl defines the sprite sheet url
  83290. * @param capacity defines the maximum allowed number of sprites
  83291. * @param cellSize defines the size of a sprite cell
  83292. * @param scene defines the hosting scene
  83293. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83294. * @param samplingMode defines the smapling mode to use with spritesheet
  83295. * @param fromPacked set to false; do not alter
  83296. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83297. */
  83298. constructor(
  83299. /** defines the manager's name */
  83300. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83301. private _makePacked;
  83302. private _appendSpriteVertex;
  83303. /**
  83304. * Intersects the sprites with a ray
  83305. * @param ray defines the ray to intersect with
  83306. * @param camera defines the current active camera
  83307. * @param predicate defines a predicate used to select candidate sprites
  83308. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83309. * @returns null if no hit or a PickingInfo
  83310. */
  83311. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83312. /**
  83313. * Intersects the sprites with a ray
  83314. * @param ray defines the ray to intersect with
  83315. * @param camera defines the current active camera
  83316. * @param predicate defines a predicate used to select candidate sprites
  83317. * @returns null if no hit or a PickingInfo array
  83318. */
  83319. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83320. /**
  83321. * Render all child sprites
  83322. */
  83323. render(): void;
  83324. /**
  83325. * Release associated resources
  83326. */
  83327. dispose(): void;
  83328. }
  83329. }
  83330. declare module BABYLON {
  83331. /** Interface used by value gradients (color, factor, ...) */
  83332. export interface IValueGradient {
  83333. /**
  83334. * Gets or sets the gradient value (between 0 and 1)
  83335. */
  83336. gradient: number;
  83337. }
  83338. /** Class used to store color4 gradient */
  83339. export class ColorGradient implements IValueGradient {
  83340. /**
  83341. * Gets or sets the gradient value (between 0 and 1)
  83342. */
  83343. gradient: number;
  83344. /**
  83345. * Gets or sets first associated color
  83346. */
  83347. color1: Color4;
  83348. /**
  83349. * Gets or sets second associated color
  83350. */
  83351. color2?: Color4;
  83352. /**
  83353. * Will get a color picked randomly between color1 and color2.
  83354. * If color2 is undefined then color1 will be used
  83355. * @param result defines the target Color4 to store the result in
  83356. */
  83357. getColorToRef(result: Color4): void;
  83358. }
  83359. /** Class used to store color 3 gradient */
  83360. export class Color3Gradient implements IValueGradient {
  83361. /**
  83362. * Gets or sets the gradient value (between 0 and 1)
  83363. */
  83364. gradient: number;
  83365. /**
  83366. * Gets or sets the associated color
  83367. */
  83368. color: Color3;
  83369. }
  83370. /** Class used to store factor gradient */
  83371. export class FactorGradient implements IValueGradient {
  83372. /**
  83373. * Gets or sets the gradient value (between 0 and 1)
  83374. */
  83375. gradient: number;
  83376. /**
  83377. * Gets or sets first associated factor
  83378. */
  83379. factor1: number;
  83380. /**
  83381. * Gets or sets second associated factor
  83382. */
  83383. factor2?: number;
  83384. /**
  83385. * Will get a number picked randomly between factor1 and factor2.
  83386. * If factor2 is undefined then factor1 will be used
  83387. * @returns the picked number
  83388. */
  83389. getFactor(): number;
  83390. }
  83391. /**
  83392. * Helper used to simplify some generic gradient tasks
  83393. */
  83394. export class GradientHelper {
  83395. /**
  83396. * Gets the current gradient from an array of IValueGradient
  83397. * @param ratio defines the current ratio to get
  83398. * @param gradients defines the array of IValueGradient
  83399. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83400. */
  83401. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83402. }
  83403. }
  83404. declare module BABYLON {
  83405. /**
  83406. * Interface for the size containing width and height
  83407. */
  83408. export interface ISize {
  83409. /**
  83410. * Width
  83411. */
  83412. width: number;
  83413. /**
  83414. * Heighht
  83415. */
  83416. height: number;
  83417. }
  83418. /**
  83419. * Size containing widht and height
  83420. */
  83421. export class Size implements ISize {
  83422. /**
  83423. * Width
  83424. */
  83425. width: number;
  83426. /**
  83427. * Height
  83428. */
  83429. height: number;
  83430. /**
  83431. * Creates a Size object from the given width and height (floats).
  83432. * @param width width of the new size
  83433. * @param height height of the new size
  83434. */
  83435. constructor(width: number, height: number);
  83436. /**
  83437. * Returns a string with the Size width and height
  83438. * @returns a string with the Size width and height
  83439. */
  83440. toString(): string;
  83441. /**
  83442. * "Size"
  83443. * @returns the string "Size"
  83444. */
  83445. getClassName(): string;
  83446. /**
  83447. * Returns the Size hash code.
  83448. * @returns a hash code for a unique width and height
  83449. */
  83450. getHashCode(): number;
  83451. /**
  83452. * Updates the current size from the given one.
  83453. * @param src the given size
  83454. */
  83455. copyFrom(src: Size): void;
  83456. /**
  83457. * Updates in place the current Size from the given floats.
  83458. * @param width width of the new size
  83459. * @param height height of the new size
  83460. * @returns the updated Size.
  83461. */
  83462. copyFromFloats(width: number, height: number): Size;
  83463. /**
  83464. * Updates in place the current Size from the given floats.
  83465. * @param width width to set
  83466. * @param height height to set
  83467. * @returns the updated Size.
  83468. */
  83469. set(width: number, height: number): Size;
  83470. /**
  83471. * Multiplies the width and height by numbers
  83472. * @param w factor to multiple the width by
  83473. * @param h factor to multiple the height by
  83474. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83475. */
  83476. multiplyByFloats(w: number, h: number): Size;
  83477. /**
  83478. * Clones the size
  83479. * @returns a new Size copied from the given one.
  83480. */
  83481. clone(): Size;
  83482. /**
  83483. * True if the current Size and the given one width and height are strictly equal.
  83484. * @param other the other size to compare against
  83485. * @returns True if the current Size and the given one width and height are strictly equal.
  83486. */
  83487. equals(other: Size): boolean;
  83488. /**
  83489. * The surface of the Size : width * height (float).
  83490. */
  83491. get surface(): number;
  83492. /**
  83493. * Create a new size of zero
  83494. * @returns a new Size set to (0.0, 0.0)
  83495. */
  83496. static Zero(): Size;
  83497. /**
  83498. * Sums the width and height of two sizes
  83499. * @param otherSize size to add to this size
  83500. * @returns a new Size set as the addition result of the current Size and the given one.
  83501. */
  83502. add(otherSize: Size): Size;
  83503. /**
  83504. * Subtracts the width and height of two
  83505. * @param otherSize size to subtract to this size
  83506. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83507. */
  83508. subtract(otherSize: Size): Size;
  83509. /**
  83510. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83511. * @param start starting size to lerp between
  83512. * @param end end size to lerp between
  83513. * @param amount amount to lerp between the start and end values
  83514. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83515. */
  83516. static Lerp(start: Size, end: Size, amount: number): Size;
  83517. }
  83518. }
  83519. declare module BABYLON {
  83520. interface ThinEngine {
  83521. /**
  83522. * Creates a dynamic texture
  83523. * @param width defines the width of the texture
  83524. * @param height defines the height of the texture
  83525. * @param generateMipMaps defines if the engine should generate the mip levels
  83526. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83527. * @returns the dynamic texture inside an InternalTexture
  83528. */
  83529. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83530. /**
  83531. * Update the content of a dynamic texture
  83532. * @param texture defines the texture to update
  83533. * @param canvas defines the canvas containing the source
  83534. * @param invertY defines if data must be stored with Y axis inverted
  83535. * @param premulAlpha defines if alpha is stored as premultiplied
  83536. * @param format defines the format of the data
  83537. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83538. */
  83539. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83540. }
  83541. }
  83542. declare module BABYLON {
  83543. /**
  83544. * Helper class used to generate a canvas to manipulate images
  83545. */
  83546. export class CanvasGenerator {
  83547. /**
  83548. * Create a new canvas (or offscreen canvas depending on the context)
  83549. * @param width defines the expected width
  83550. * @param height defines the expected height
  83551. * @return a new canvas or offscreen canvas
  83552. */
  83553. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83554. }
  83555. }
  83556. declare module BABYLON {
  83557. /**
  83558. * A class extending Texture allowing drawing on a texture
  83559. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83560. */
  83561. export class DynamicTexture extends Texture {
  83562. private _generateMipMaps;
  83563. private _canvas;
  83564. private _context;
  83565. private _engine;
  83566. /**
  83567. * Creates a DynamicTexture
  83568. * @param name defines the name of the texture
  83569. * @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
  83570. * @param scene defines the scene where you want the texture
  83571. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83572. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83573. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83574. */
  83575. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83576. /**
  83577. * Get the current class name of the texture useful for serialization or dynamic coding.
  83578. * @returns "DynamicTexture"
  83579. */
  83580. getClassName(): string;
  83581. /**
  83582. * Gets the current state of canRescale
  83583. */
  83584. get canRescale(): boolean;
  83585. private _recreate;
  83586. /**
  83587. * Scales the texture
  83588. * @param ratio the scale factor to apply to both width and height
  83589. */
  83590. scale(ratio: number): void;
  83591. /**
  83592. * Resizes the texture
  83593. * @param width the new width
  83594. * @param height the new height
  83595. */
  83596. scaleTo(width: number, height: number): void;
  83597. /**
  83598. * Gets the context of the canvas used by the texture
  83599. * @returns the canvas context of the dynamic texture
  83600. */
  83601. getContext(): CanvasRenderingContext2D;
  83602. /**
  83603. * Clears the texture
  83604. */
  83605. clear(): void;
  83606. /**
  83607. * Updates the texture
  83608. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83609. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83610. */
  83611. update(invertY?: boolean, premulAlpha?: boolean): void;
  83612. /**
  83613. * Draws text onto the texture
  83614. * @param text defines the text to be drawn
  83615. * @param x defines the placement of the text from the left
  83616. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83617. * @param font defines the font to be used with font-style, font-size, font-name
  83618. * @param color defines the color used for the text
  83619. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83620. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83621. * @param update defines whether texture is immediately update (default is true)
  83622. */
  83623. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83624. /**
  83625. * Clones the texture
  83626. * @returns the clone of the texture.
  83627. */
  83628. clone(): DynamicTexture;
  83629. /**
  83630. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83631. * @returns a serialized dynamic texture object
  83632. */
  83633. serialize(): any;
  83634. /** @hidden */
  83635. _rebuild(): void;
  83636. }
  83637. }
  83638. declare module BABYLON {
  83639. interface Engine {
  83640. /**
  83641. * Creates a raw texture
  83642. * @param data defines the data to store in the texture
  83643. * @param width defines the width of the texture
  83644. * @param height defines the height of the texture
  83645. * @param format defines the format of the data
  83646. * @param generateMipMaps defines if the engine should generate the mip levels
  83647. * @param invertY defines if data must be stored with Y axis inverted
  83648. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83649. * @param compression defines the compression used (null by default)
  83650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83651. * @returns the raw texture inside an InternalTexture
  83652. */
  83653. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83654. /**
  83655. * Update a raw texture
  83656. * @param texture defines the texture to update
  83657. * @param data defines the data to store in the texture
  83658. * @param format defines the format of the data
  83659. * @param invertY defines if data must be stored with Y axis inverted
  83660. */
  83661. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83662. /**
  83663. * Update a raw texture
  83664. * @param texture defines the texture to update
  83665. * @param data defines the data to store in the texture
  83666. * @param format defines the format of the data
  83667. * @param invertY defines if data must be stored with Y axis inverted
  83668. * @param compression defines the compression used (null by default)
  83669. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83670. */
  83671. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83672. /**
  83673. * Creates a new raw cube texture
  83674. * @param data defines the array of data to use to create each face
  83675. * @param size defines the size of the textures
  83676. * @param format defines the format of the data
  83677. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83678. * @param generateMipMaps defines if the engine should generate the mip levels
  83679. * @param invertY defines if data must be stored with Y axis inverted
  83680. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83681. * @param compression defines the compression used (null by default)
  83682. * @returns the cube texture as an InternalTexture
  83683. */
  83684. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83685. /**
  83686. * Update a raw cube texture
  83687. * @param texture defines the texture to udpdate
  83688. * @param data defines the data to store
  83689. * @param format defines the data format
  83690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83691. * @param invertY defines if data must be stored with Y axis inverted
  83692. */
  83693. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83694. /**
  83695. * Update a raw cube texture
  83696. * @param texture defines the texture to udpdate
  83697. * @param data defines the data to store
  83698. * @param format defines the data format
  83699. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83700. * @param invertY defines if data must be stored with Y axis inverted
  83701. * @param compression defines the compression used (null by default)
  83702. */
  83703. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83704. /**
  83705. * Update a raw cube texture
  83706. * @param texture defines the texture to udpdate
  83707. * @param data defines the data to store
  83708. * @param format defines the data format
  83709. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83710. * @param invertY defines if data must be stored with Y axis inverted
  83711. * @param compression defines the compression used (null by default)
  83712. * @param level defines which level of the texture to update
  83713. */
  83714. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83715. /**
  83716. * Creates a new raw cube texture from a specified url
  83717. * @param url defines the url where the data is located
  83718. * @param scene defines the current scene
  83719. * @param size defines the size of the textures
  83720. * @param format defines the format of the data
  83721. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83722. * @param noMipmap defines if the engine should avoid generating the mip levels
  83723. * @param callback defines a callback used to extract texture data from loaded data
  83724. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83725. * @param onLoad defines a callback called when texture is loaded
  83726. * @param onError defines a callback called if there is an error
  83727. * @returns the cube texture as an InternalTexture
  83728. */
  83729. 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;
  83730. /**
  83731. * Creates a new raw cube texture from a specified url
  83732. * @param url defines the url where the data is located
  83733. * @param scene defines the current scene
  83734. * @param size defines the size of the textures
  83735. * @param format defines the format of the data
  83736. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83737. * @param noMipmap defines if the engine should avoid generating the mip levels
  83738. * @param callback defines a callback used to extract texture data from loaded data
  83739. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83740. * @param onLoad defines a callback called when texture is loaded
  83741. * @param onError defines a callback called if there is an error
  83742. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83743. * @param invertY defines if data must be stored with Y axis inverted
  83744. * @returns the cube texture as an InternalTexture
  83745. */
  83746. 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;
  83747. /**
  83748. * Creates a new raw 3D texture
  83749. * @param data defines the data used to create the texture
  83750. * @param width defines the width of the texture
  83751. * @param height defines the height of the texture
  83752. * @param depth defines the depth of the texture
  83753. * @param format defines the format of the texture
  83754. * @param generateMipMaps defines if the engine must generate mip levels
  83755. * @param invertY defines if data must be stored with Y axis inverted
  83756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83757. * @param compression defines the compressed used (can be null)
  83758. * @param textureType defines the compressed used (can be null)
  83759. * @returns a new raw 3D texture (stored in an InternalTexture)
  83760. */
  83761. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83762. /**
  83763. * Update a raw 3D texture
  83764. * @param texture defines the texture to update
  83765. * @param data defines the data to store
  83766. * @param format defines the data format
  83767. * @param invertY defines if data must be stored with Y axis inverted
  83768. */
  83769. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83770. /**
  83771. * Update a raw 3D texture
  83772. * @param texture defines the texture to update
  83773. * @param data defines the data to store
  83774. * @param format defines the data format
  83775. * @param invertY defines if data must be stored with Y axis inverted
  83776. * @param compression defines the used compression (can be null)
  83777. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83778. */
  83779. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83780. /**
  83781. * Creates a new raw 2D array texture
  83782. * @param data defines the data used to create the texture
  83783. * @param width defines the width of the texture
  83784. * @param height defines the height of the texture
  83785. * @param depth defines the number of layers of the texture
  83786. * @param format defines the format of the texture
  83787. * @param generateMipMaps defines if the engine must generate mip levels
  83788. * @param invertY defines if data must be stored with Y axis inverted
  83789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83790. * @param compression defines the compressed used (can be null)
  83791. * @param textureType defines the compressed used (can be null)
  83792. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83793. */
  83794. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83795. /**
  83796. * Update a raw 2D array texture
  83797. * @param texture defines the texture to update
  83798. * @param data defines the data to store
  83799. * @param format defines the data format
  83800. * @param invertY defines if data must be stored with Y axis inverted
  83801. */
  83802. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83803. /**
  83804. * Update a raw 2D array texture
  83805. * @param texture defines the texture to update
  83806. * @param data defines the data to store
  83807. * @param format defines the data format
  83808. * @param invertY defines if data must be stored with Y axis inverted
  83809. * @param compression defines the used compression (can be null)
  83810. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83811. */
  83812. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83813. }
  83814. }
  83815. declare module BABYLON {
  83816. /**
  83817. * Raw texture can help creating a texture directly from an array of data.
  83818. * This can be super useful if you either get the data from an uncompressed source or
  83819. * if you wish to create your texture pixel by pixel.
  83820. */
  83821. export class RawTexture extends Texture {
  83822. /**
  83823. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83824. */
  83825. format: number;
  83826. private _engine;
  83827. /**
  83828. * Instantiates a new RawTexture.
  83829. * Raw texture can help creating a texture directly from an array of data.
  83830. * This can be super useful if you either get the data from an uncompressed source or
  83831. * if you wish to create your texture pixel by pixel.
  83832. * @param data define the array of data to use to create the texture
  83833. * @param width define the width of the texture
  83834. * @param height define the height of the texture
  83835. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83836. * @param scene define the scene the texture belongs to
  83837. * @param generateMipMaps define whether mip maps should be generated or not
  83838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83840. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83841. */
  83842. constructor(data: ArrayBufferView, width: number, height: number,
  83843. /**
  83844. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83845. */
  83846. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83847. /**
  83848. * Updates the texture underlying data.
  83849. * @param data Define the new data of the texture
  83850. */
  83851. update(data: ArrayBufferView): void;
  83852. /**
  83853. * Creates a luminance texture from some data.
  83854. * @param data Define the texture data
  83855. * @param width Define the width of the texture
  83856. * @param height Define the height of the texture
  83857. * @param scene Define the scene the texture belongs to
  83858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83861. * @returns the luminance texture
  83862. */
  83863. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83864. /**
  83865. * Creates a luminance alpha texture from some data.
  83866. * @param data Define the texture data
  83867. * @param width Define the width of the texture
  83868. * @param height Define the height of the texture
  83869. * @param scene Define the scene the texture belongs to
  83870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83873. * @returns the luminance alpha texture
  83874. */
  83875. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83876. /**
  83877. * Creates an alpha texture from some data.
  83878. * @param data Define the texture data
  83879. * @param width Define the width of the texture
  83880. * @param height Define the height of the texture
  83881. * @param scene Define the scene the texture belongs to
  83882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83885. * @returns the alpha texture
  83886. */
  83887. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83888. /**
  83889. * Creates a RGB texture from some data.
  83890. * @param data Define the texture data
  83891. * @param width Define the width of the texture
  83892. * @param height Define the height of the texture
  83893. * @param scene Define the scene the texture belongs to
  83894. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83895. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83896. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83897. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83898. * @returns the RGB alpha texture
  83899. */
  83900. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83901. /**
  83902. * Creates a RGBA texture from some data.
  83903. * @param data Define the texture data
  83904. * @param width Define the width of the texture
  83905. * @param height Define the height of the texture
  83906. * @param scene Define the scene the texture belongs to
  83907. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83908. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83909. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83910. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83911. * @returns the RGBA texture
  83912. */
  83913. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83914. /**
  83915. * Creates a R texture from some data.
  83916. * @param data Define the texture data
  83917. * @param width Define the width of the texture
  83918. * @param height Define the height of the texture
  83919. * @param scene Define the scene the texture belongs to
  83920. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83921. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83922. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83923. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83924. * @returns the R texture
  83925. */
  83926. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83927. }
  83928. }
  83929. declare module BABYLON {
  83930. interface AbstractScene {
  83931. /**
  83932. * The list of procedural textures added to the scene
  83933. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83934. */
  83935. proceduralTextures: Array<ProceduralTexture>;
  83936. }
  83937. /**
  83938. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83939. * in a given scene.
  83940. */
  83941. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83942. /**
  83943. * The component name helpfull to identify the component in the list of scene components.
  83944. */
  83945. readonly name: string;
  83946. /**
  83947. * The scene the component belongs to.
  83948. */
  83949. scene: Scene;
  83950. /**
  83951. * Creates a new instance of the component for the given scene
  83952. * @param scene Defines the scene to register the component in
  83953. */
  83954. constructor(scene: Scene);
  83955. /**
  83956. * Registers the component in a given scene
  83957. */
  83958. register(): void;
  83959. /**
  83960. * Rebuilds the elements related to this component in case of
  83961. * context lost for instance.
  83962. */
  83963. rebuild(): void;
  83964. /**
  83965. * Disposes the component and the associated ressources.
  83966. */
  83967. dispose(): void;
  83968. private _beforeClear;
  83969. }
  83970. }
  83971. declare module BABYLON {
  83972. interface ThinEngine {
  83973. /**
  83974. * Creates a new render target cube texture
  83975. * @param size defines the size of the texture
  83976. * @param options defines the options used to create the texture
  83977. * @returns a new render target cube texture stored in an InternalTexture
  83978. */
  83979. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83980. }
  83981. }
  83982. declare module BABYLON {
  83983. /** @hidden */
  83984. export var proceduralVertexShader: {
  83985. name: string;
  83986. shader: string;
  83987. };
  83988. }
  83989. declare module BABYLON {
  83990. /**
  83991. * 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.
  83992. * This is the base class of any Procedural texture and contains most of the shareable code.
  83993. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83994. */
  83995. export class ProceduralTexture extends Texture {
  83996. isCube: boolean;
  83997. /**
  83998. * Define if the texture is enabled or not (disabled texture will not render)
  83999. */
  84000. isEnabled: boolean;
  84001. /**
  84002. * Define if the texture must be cleared before rendering (default is true)
  84003. */
  84004. autoClear: boolean;
  84005. /**
  84006. * Callback called when the texture is generated
  84007. */
  84008. onGenerated: () => void;
  84009. /**
  84010. * Event raised when the texture is generated
  84011. */
  84012. onGeneratedObservable: Observable<ProceduralTexture>;
  84013. /** @hidden */
  84014. _generateMipMaps: boolean;
  84015. /** @hidden **/
  84016. _effect: Effect;
  84017. /** @hidden */
  84018. _textures: {
  84019. [key: string]: Texture;
  84020. };
  84021. private _size;
  84022. private _currentRefreshId;
  84023. private _frameId;
  84024. private _refreshRate;
  84025. private _vertexBuffers;
  84026. private _indexBuffer;
  84027. private _uniforms;
  84028. private _samplers;
  84029. private _fragment;
  84030. private _floats;
  84031. private _ints;
  84032. private _floatsArrays;
  84033. private _colors3;
  84034. private _colors4;
  84035. private _vectors2;
  84036. private _vectors3;
  84037. private _matrices;
  84038. private _fallbackTexture;
  84039. private _fallbackTextureUsed;
  84040. private _engine;
  84041. private _cachedDefines;
  84042. private _contentUpdateId;
  84043. private _contentData;
  84044. /**
  84045. * Instantiates a new procedural texture.
  84046. * 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.
  84047. * This is the base class of any Procedural texture and contains most of the shareable code.
  84048. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84049. * @param name Define the name of the texture
  84050. * @param size Define the size of the texture to create
  84051. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84052. * @param scene Define the scene the texture belongs to
  84053. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84054. * @param generateMipMaps Define if the texture should creates mip maps or not
  84055. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84056. */
  84057. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84058. /**
  84059. * The effect that is created when initializing the post process.
  84060. * @returns The created effect corresponding the the postprocess.
  84061. */
  84062. getEffect(): Effect;
  84063. /**
  84064. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84065. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84066. */
  84067. getContent(): Nullable<ArrayBufferView>;
  84068. private _createIndexBuffer;
  84069. /** @hidden */
  84070. _rebuild(): void;
  84071. /**
  84072. * Resets the texture in order to recreate its associated resources.
  84073. * This can be called in case of context loss
  84074. */
  84075. reset(): void;
  84076. protected _getDefines(): string;
  84077. /**
  84078. * Is the texture ready to be used ? (rendered at least once)
  84079. * @returns true if ready, otherwise, false.
  84080. */
  84081. isReady(): boolean;
  84082. /**
  84083. * Resets the refresh counter of the texture and start bak from scratch.
  84084. * Could be useful to regenerate the texture if it is setup to render only once.
  84085. */
  84086. resetRefreshCounter(): void;
  84087. /**
  84088. * Set the fragment shader to use in order to render the texture.
  84089. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84090. */
  84091. setFragment(fragment: any): void;
  84092. /**
  84093. * Define the refresh rate of the texture or the rendering frequency.
  84094. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84095. */
  84096. get refreshRate(): number;
  84097. set refreshRate(value: number);
  84098. /** @hidden */
  84099. _shouldRender(): boolean;
  84100. /**
  84101. * Get the size the texture is rendering at.
  84102. * @returns the size (texture is always squared)
  84103. */
  84104. getRenderSize(): number;
  84105. /**
  84106. * Resize the texture to new value.
  84107. * @param size Define the new size the texture should have
  84108. * @param generateMipMaps Define whether the new texture should create mip maps
  84109. */
  84110. resize(size: number, generateMipMaps: boolean): void;
  84111. private _checkUniform;
  84112. /**
  84113. * Set a texture in the shader program used to render.
  84114. * @param name Define the name of the uniform samplers as defined in the shader
  84115. * @param texture Define the texture to bind to this sampler
  84116. * @return the texture itself allowing "fluent" like uniform updates
  84117. */
  84118. setTexture(name: string, texture: Texture): ProceduralTexture;
  84119. /**
  84120. * Set a float in the shader.
  84121. * @param name Define the name of the uniform as defined in the shader
  84122. * @param value Define the value to give to the uniform
  84123. * @return the texture itself allowing "fluent" like uniform updates
  84124. */
  84125. setFloat(name: string, value: number): ProceduralTexture;
  84126. /**
  84127. * Set a int in the shader.
  84128. * @param name Define the name of the uniform as defined in the shader
  84129. * @param value Define the value to give to the uniform
  84130. * @return the texture itself allowing "fluent" like uniform updates
  84131. */
  84132. setInt(name: string, value: number): ProceduralTexture;
  84133. /**
  84134. * Set an array of floats in the shader.
  84135. * @param name Define the name of the uniform as defined in the shader
  84136. * @param value Define the value to give to the uniform
  84137. * @return the texture itself allowing "fluent" like uniform updates
  84138. */
  84139. setFloats(name: string, value: number[]): ProceduralTexture;
  84140. /**
  84141. * Set a vec3 in the shader from a Color3.
  84142. * @param name Define the name of the uniform as defined in the shader
  84143. * @param value Define the value to give to the uniform
  84144. * @return the texture itself allowing "fluent" like uniform updates
  84145. */
  84146. setColor3(name: string, value: Color3): ProceduralTexture;
  84147. /**
  84148. * Set a vec4 in the shader from a Color4.
  84149. * @param name Define the name of the uniform as defined in the shader
  84150. * @param value Define the value to give to the uniform
  84151. * @return the texture itself allowing "fluent" like uniform updates
  84152. */
  84153. setColor4(name: string, value: Color4): ProceduralTexture;
  84154. /**
  84155. * Set a vec2 in the shader from a Vector2.
  84156. * @param name Define the name of the uniform as defined in the shader
  84157. * @param value Define the value to give to the uniform
  84158. * @return the texture itself allowing "fluent" like uniform updates
  84159. */
  84160. setVector2(name: string, value: Vector2): ProceduralTexture;
  84161. /**
  84162. * Set a vec3 in the shader from a Vector3.
  84163. * @param name Define the name of the uniform as defined in the shader
  84164. * @param value Define the value to give to the uniform
  84165. * @return the texture itself allowing "fluent" like uniform updates
  84166. */
  84167. setVector3(name: string, value: Vector3): ProceduralTexture;
  84168. /**
  84169. * Set a mat4 in the shader from a MAtrix.
  84170. * @param name Define the name of the uniform as defined in the shader
  84171. * @param value Define the value to give to the uniform
  84172. * @return the texture itself allowing "fluent" like uniform updates
  84173. */
  84174. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84175. /**
  84176. * Render the texture to its associated render target.
  84177. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84178. */
  84179. render(useCameraPostProcess?: boolean): void;
  84180. /**
  84181. * Clone the texture.
  84182. * @returns the cloned texture
  84183. */
  84184. clone(): ProceduralTexture;
  84185. /**
  84186. * Dispose the texture and release its asoociated resources.
  84187. */
  84188. dispose(): void;
  84189. }
  84190. }
  84191. declare module BABYLON {
  84192. /**
  84193. * This represents the base class for particle system in Babylon.
  84194. * 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.
  84195. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84196. * @example https://doc.babylonjs.com/babylon101/particles
  84197. */
  84198. export class BaseParticleSystem {
  84199. /**
  84200. * Source color is added to the destination color without alpha affecting the result
  84201. */
  84202. static BLENDMODE_ONEONE: number;
  84203. /**
  84204. * Blend current color and particle color using particle’s alpha
  84205. */
  84206. static BLENDMODE_STANDARD: number;
  84207. /**
  84208. * Add current color and particle color multiplied by particle’s alpha
  84209. */
  84210. static BLENDMODE_ADD: number;
  84211. /**
  84212. * Multiply current color with particle color
  84213. */
  84214. static BLENDMODE_MULTIPLY: number;
  84215. /**
  84216. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84217. */
  84218. static BLENDMODE_MULTIPLYADD: number;
  84219. /**
  84220. * List of animations used by the particle system.
  84221. */
  84222. animations: Animation[];
  84223. /**
  84224. * The id of the Particle system.
  84225. */
  84226. id: string;
  84227. /**
  84228. * The friendly name of the Particle system.
  84229. */
  84230. name: string;
  84231. /**
  84232. * The rendering group used by the Particle system to chose when to render.
  84233. */
  84234. renderingGroupId: number;
  84235. /**
  84236. * The emitter represents the Mesh or position we are attaching the particle system to.
  84237. */
  84238. emitter: Nullable<AbstractMesh | Vector3>;
  84239. /**
  84240. * The maximum number of particles to emit per frame
  84241. */
  84242. emitRate: number;
  84243. /**
  84244. * If you want to launch only a few particles at once, that can be done, as well.
  84245. */
  84246. manualEmitCount: number;
  84247. /**
  84248. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84249. */
  84250. updateSpeed: number;
  84251. /**
  84252. * The amount of time the particle system is running (depends of the overall update speed).
  84253. */
  84254. targetStopDuration: number;
  84255. /**
  84256. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84257. */
  84258. disposeOnStop: boolean;
  84259. /**
  84260. * Minimum power of emitting particles.
  84261. */
  84262. minEmitPower: number;
  84263. /**
  84264. * Maximum power of emitting particles.
  84265. */
  84266. maxEmitPower: number;
  84267. /**
  84268. * Minimum life time of emitting particles.
  84269. */
  84270. minLifeTime: number;
  84271. /**
  84272. * Maximum life time of emitting particles.
  84273. */
  84274. maxLifeTime: number;
  84275. /**
  84276. * Minimum Size of emitting particles.
  84277. */
  84278. minSize: number;
  84279. /**
  84280. * Maximum Size of emitting particles.
  84281. */
  84282. maxSize: number;
  84283. /**
  84284. * Minimum scale of emitting particles on X axis.
  84285. */
  84286. minScaleX: number;
  84287. /**
  84288. * Maximum scale of emitting particles on X axis.
  84289. */
  84290. maxScaleX: number;
  84291. /**
  84292. * Minimum scale of emitting particles on Y axis.
  84293. */
  84294. minScaleY: number;
  84295. /**
  84296. * Maximum scale of emitting particles on Y axis.
  84297. */
  84298. maxScaleY: number;
  84299. /**
  84300. * Gets or sets the minimal initial rotation in radians.
  84301. */
  84302. minInitialRotation: number;
  84303. /**
  84304. * Gets or sets the maximal initial rotation in radians.
  84305. */
  84306. maxInitialRotation: number;
  84307. /**
  84308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84309. */
  84310. minAngularSpeed: number;
  84311. /**
  84312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84313. */
  84314. maxAngularSpeed: number;
  84315. /**
  84316. * The texture used to render each particle. (this can be a spritesheet)
  84317. */
  84318. particleTexture: Nullable<Texture>;
  84319. /**
  84320. * The layer mask we are rendering the particles through.
  84321. */
  84322. layerMask: number;
  84323. /**
  84324. * This can help using your own shader to render the particle system.
  84325. * The according effect will be created
  84326. */
  84327. customShader: any;
  84328. /**
  84329. * By default particle system starts as soon as they are created. This prevents the
  84330. * automatic start to happen and let you decide when to start emitting particles.
  84331. */
  84332. preventAutoStart: boolean;
  84333. private _noiseTexture;
  84334. /**
  84335. * Gets or sets a texture used to add random noise to particle positions
  84336. */
  84337. get noiseTexture(): Nullable<ProceduralTexture>;
  84338. set noiseTexture(value: Nullable<ProceduralTexture>);
  84339. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84340. noiseStrength: Vector3;
  84341. /**
  84342. * Callback triggered when the particle animation is ending.
  84343. */
  84344. onAnimationEnd: Nullable<() => void>;
  84345. /**
  84346. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84347. */
  84348. blendMode: number;
  84349. /**
  84350. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84351. * to override the particles.
  84352. */
  84353. forceDepthWrite: boolean;
  84354. /** 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 */
  84355. preWarmCycles: number;
  84356. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84357. preWarmStepOffset: number;
  84358. /**
  84359. * 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)
  84360. */
  84361. spriteCellChangeSpeed: number;
  84362. /**
  84363. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84364. */
  84365. startSpriteCellID: number;
  84366. /**
  84367. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84368. */
  84369. endSpriteCellID: number;
  84370. /**
  84371. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84372. */
  84373. spriteCellWidth: number;
  84374. /**
  84375. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84376. */
  84377. spriteCellHeight: number;
  84378. /**
  84379. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84380. */
  84381. spriteRandomStartCell: boolean;
  84382. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84383. translationPivot: Vector2;
  84384. /** @hidden */
  84385. protected _isAnimationSheetEnabled: boolean;
  84386. /**
  84387. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84388. */
  84389. beginAnimationOnStart: boolean;
  84390. /**
  84391. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84392. */
  84393. beginAnimationFrom: number;
  84394. /**
  84395. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84396. */
  84397. beginAnimationTo: number;
  84398. /**
  84399. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84400. */
  84401. beginAnimationLoop: boolean;
  84402. /**
  84403. * Gets or sets a world offset applied to all particles
  84404. */
  84405. worldOffset: Vector3;
  84406. /**
  84407. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84408. */
  84409. get isAnimationSheetEnabled(): boolean;
  84410. set isAnimationSheetEnabled(value: boolean);
  84411. /**
  84412. * Get hosting scene
  84413. * @returns the scene
  84414. */
  84415. getScene(): Scene;
  84416. /**
  84417. * You can use gravity if you want to give an orientation to your particles.
  84418. */
  84419. gravity: Vector3;
  84420. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84421. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84422. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84423. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84424. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84425. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84426. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84427. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84428. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84429. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84430. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84431. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84432. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84433. /**
  84434. * Defines the delay in milliseconds before starting the system (0 by default)
  84435. */
  84436. startDelay: number;
  84437. /**
  84438. * Gets the current list of drag gradients.
  84439. * You must use addDragGradient and removeDragGradient to udpate this list
  84440. * @returns the list of drag gradients
  84441. */
  84442. getDragGradients(): Nullable<Array<FactorGradient>>;
  84443. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84444. limitVelocityDamping: number;
  84445. /**
  84446. * Gets the current list of limit velocity gradients.
  84447. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84448. * @returns the list of limit velocity gradients
  84449. */
  84450. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84451. /**
  84452. * Gets the current list of color gradients.
  84453. * You must use addColorGradient and removeColorGradient to udpate this list
  84454. * @returns the list of color gradients
  84455. */
  84456. getColorGradients(): Nullable<Array<ColorGradient>>;
  84457. /**
  84458. * Gets the current list of size gradients.
  84459. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84460. * @returns the list of size gradients
  84461. */
  84462. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84463. /**
  84464. * Gets the current list of color remap gradients.
  84465. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84466. * @returns the list of color remap gradients
  84467. */
  84468. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84469. /**
  84470. * Gets the current list of alpha remap gradients.
  84471. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84472. * @returns the list of alpha remap gradients
  84473. */
  84474. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84475. /**
  84476. * Gets the current list of life time gradients.
  84477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84478. * @returns the list of life time gradients
  84479. */
  84480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84481. /**
  84482. * Gets the current list of angular speed gradients.
  84483. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84484. * @returns the list of angular speed gradients
  84485. */
  84486. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84487. /**
  84488. * Gets the current list of velocity gradients.
  84489. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84490. * @returns the list of velocity gradients
  84491. */
  84492. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84493. /**
  84494. * Gets the current list of start size gradients.
  84495. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84496. * @returns the list of start size gradients
  84497. */
  84498. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84499. /**
  84500. * Gets the current list of emit rate gradients.
  84501. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84502. * @returns the list of emit rate gradients
  84503. */
  84504. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84505. /**
  84506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84507. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84508. */
  84509. get direction1(): Vector3;
  84510. set direction1(value: Vector3);
  84511. /**
  84512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84514. */
  84515. get direction2(): Vector3;
  84516. set direction2(value: Vector3);
  84517. /**
  84518. * 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.
  84519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84520. */
  84521. get minEmitBox(): Vector3;
  84522. set minEmitBox(value: Vector3);
  84523. /**
  84524. * 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.
  84525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84526. */
  84527. get maxEmitBox(): Vector3;
  84528. set maxEmitBox(value: Vector3);
  84529. /**
  84530. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84531. */
  84532. color1: Color4;
  84533. /**
  84534. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84535. */
  84536. color2: Color4;
  84537. /**
  84538. * Color the particle will have at the end of its lifetime
  84539. */
  84540. colorDead: Color4;
  84541. /**
  84542. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84543. */
  84544. textureMask: Color4;
  84545. /**
  84546. * The particle emitter type defines the emitter used by the particle system.
  84547. * It can be for example box, sphere, or cone...
  84548. */
  84549. particleEmitterType: IParticleEmitterType;
  84550. /** @hidden */
  84551. _isSubEmitter: boolean;
  84552. /**
  84553. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84554. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84555. */
  84556. billboardMode: number;
  84557. protected _isBillboardBased: boolean;
  84558. /**
  84559. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84560. */
  84561. get isBillboardBased(): boolean;
  84562. set isBillboardBased(value: boolean);
  84563. /**
  84564. * The scene the particle system belongs to.
  84565. */
  84566. protected _scene: Scene;
  84567. /**
  84568. * Local cache of defines for image processing.
  84569. */
  84570. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84571. /**
  84572. * Default configuration related to image processing available in the standard Material.
  84573. */
  84574. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84575. /**
  84576. * Gets the image processing configuration used either in this material.
  84577. */
  84578. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84579. /**
  84580. * Sets the Default image processing configuration used either in the this material.
  84581. *
  84582. * If sets to null, the scene one is in use.
  84583. */
  84584. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84585. /**
  84586. * Attaches a new image processing configuration to the Standard Material.
  84587. * @param configuration
  84588. */
  84589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84590. /** @hidden */
  84591. protected _reset(): void;
  84592. /** @hidden */
  84593. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84594. /**
  84595. * Instantiates a particle system.
  84596. * 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.
  84597. * @param name The name of the particle system
  84598. */
  84599. constructor(name: string);
  84600. /**
  84601. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84604. * @returns the emitter
  84605. */
  84606. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84607. /**
  84608. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84609. * @param radius The radius of the hemisphere to emit from
  84610. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84611. * @returns the emitter
  84612. */
  84613. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84614. /**
  84615. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84616. * @param radius The radius of the sphere to emit from
  84617. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84618. * @returns the emitter
  84619. */
  84620. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84621. /**
  84622. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84623. * @param radius The radius of the sphere to emit from
  84624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84626. * @returns the emitter
  84627. */
  84628. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84629. /**
  84630. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84631. * @param radius The radius of the emission cylinder
  84632. * @param height The height of the emission cylinder
  84633. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84634. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84635. * @returns the emitter
  84636. */
  84637. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84638. /**
  84639. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84640. * @param radius The radius of the cylinder to emit from
  84641. * @param height The height of the emission cylinder
  84642. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84645. * @returns the emitter
  84646. */
  84647. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84648. /**
  84649. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84650. * @param radius The radius of the cone to emit from
  84651. * @param angle The base angle of the cone
  84652. * @returns the emitter
  84653. */
  84654. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84655. /**
  84656. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84659. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84660. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84661. * @returns the emitter
  84662. */
  84663. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84664. }
  84665. }
  84666. declare module BABYLON {
  84667. /**
  84668. * Type of sub emitter
  84669. */
  84670. export enum SubEmitterType {
  84671. /**
  84672. * Attached to the particle over it's lifetime
  84673. */
  84674. ATTACHED = 0,
  84675. /**
  84676. * Created when the particle dies
  84677. */
  84678. END = 1
  84679. }
  84680. /**
  84681. * Sub emitter class used to emit particles from an existing particle
  84682. */
  84683. export class SubEmitter {
  84684. /**
  84685. * the particle system to be used by the sub emitter
  84686. */
  84687. particleSystem: ParticleSystem;
  84688. /**
  84689. * Type of the submitter (Default: END)
  84690. */
  84691. type: SubEmitterType;
  84692. /**
  84693. * 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)
  84694. * Note: This only is supported when using an emitter of type Mesh
  84695. */
  84696. inheritDirection: boolean;
  84697. /**
  84698. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84699. */
  84700. inheritedVelocityAmount: number;
  84701. /**
  84702. * Creates a sub emitter
  84703. * @param particleSystem the particle system to be used by the sub emitter
  84704. */
  84705. constructor(
  84706. /**
  84707. * the particle system to be used by the sub emitter
  84708. */
  84709. particleSystem: ParticleSystem);
  84710. /**
  84711. * Clones the sub emitter
  84712. * @returns the cloned sub emitter
  84713. */
  84714. clone(): SubEmitter;
  84715. /**
  84716. * Serialize current object to a JSON object
  84717. * @returns the serialized object
  84718. */
  84719. serialize(): any;
  84720. /** @hidden */
  84721. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84722. /**
  84723. * Creates a new SubEmitter from a serialized JSON version
  84724. * @param serializationObject defines the JSON object to read from
  84725. * @param scene defines the hosting scene
  84726. * @param rootUrl defines the rootUrl for data loading
  84727. * @returns a new SubEmitter
  84728. */
  84729. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84730. /** Release associated resources */
  84731. dispose(): void;
  84732. }
  84733. }
  84734. declare module BABYLON {
  84735. /** @hidden */
  84736. export var imageProcessingDeclaration: {
  84737. name: string;
  84738. shader: string;
  84739. };
  84740. }
  84741. declare module BABYLON {
  84742. /** @hidden */
  84743. export var imageProcessingFunctions: {
  84744. name: string;
  84745. shader: string;
  84746. };
  84747. }
  84748. declare module BABYLON {
  84749. /** @hidden */
  84750. export var particlesPixelShader: {
  84751. name: string;
  84752. shader: string;
  84753. };
  84754. }
  84755. declare module BABYLON {
  84756. /** @hidden */
  84757. export var particlesVertexShader: {
  84758. name: string;
  84759. shader: string;
  84760. };
  84761. }
  84762. declare module BABYLON {
  84763. /**
  84764. * This represents a particle system in Babylon.
  84765. * 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.
  84766. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84767. * @example https://doc.babylonjs.com/babylon101/particles
  84768. */
  84769. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84770. /**
  84771. * Billboard mode will only apply to Y axis
  84772. */
  84773. static readonly BILLBOARDMODE_Y: number;
  84774. /**
  84775. * Billboard mode will apply to all axes
  84776. */
  84777. static readonly BILLBOARDMODE_ALL: number;
  84778. /**
  84779. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84780. */
  84781. static readonly BILLBOARDMODE_STRETCHED: number;
  84782. /**
  84783. * This function can be defined to provide custom update for active particles.
  84784. * This function will be called instead of regular update (age, position, color, etc.).
  84785. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84786. */
  84787. updateFunction: (particles: Particle[]) => void;
  84788. private _emitterWorldMatrix;
  84789. /**
  84790. * This function can be defined to specify initial direction for every new particle.
  84791. * It by default use the emitterType defined function
  84792. */
  84793. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84794. /**
  84795. * This function can be defined to specify initial position for every new particle.
  84796. * It by default use the emitterType defined function
  84797. */
  84798. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84799. /**
  84800. * @hidden
  84801. */
  84802. _inheritedVelocityOffset: Vector3;
  84803. /**
  84804. * An event triggered when the system is disposed
  84805. */
  84806. onDisposeObservable: Observable<ParticleSystem>;
  84807. private _onDisposeObserver;
  84808. /**
  84809. * Sets a callback that will be triggered when the system is disposed
  84810. */
  84811. set onDispose(callback: () => void);
  84812. private _particles;
  84813. private _epsilon;
  84814. private _capacity;
  84815. private _stockParticles;
  84816. private _newPartsExcess;
  84817. private _vertexData;
  84818. private _vertexBuffer;
  84819. private _vertexBuffers;
  84820. private _spriteBuffer;
  84821. private _indexBuffer;
  84822. private _effect;
  84823. private _customEffect;
  84824. private _cachedDefines;
  84825. private _scaledColorStep;
  84826. private _colorDiff;
  84827. private _scaledDirection;
  84828. private _scaledGravity;
  84829. private _currentRenderId;
  84830. private _alive;
  84831. private _useInstancing;
  84832. private _started;
  84833. private _stopped;
  84834. private _actualFrame;
  84835. private _scaledUpdateSpeed;
  84836. private _vertexBufferSize;
  84837. /** @hidden */
  84838. _currentEmitRateGradient: Nullable<FactorGradient>;
  84839. /** @hidden */
  84840. _currentEmitRate1: number;
  84841. /** @hidden */
  84842. _currentEmitRate2: number;
  84843. /** @hidden */
  84844. _currentStartSizeGradient: Nullable<FactorGradient>;
  84845. /** @hidden */
  84846. _currentStartSize1: number;
  84847. /** @hidden */
  84848. _currentStartSize2: number;
  84849. private readonly _rawTextureWidth;
  84850. private _rampGradientsTexture;
  84851. private _useRampGradients;
  84852. /** Gets or sets a boolean indicating that ramp gradients must be used
  84853. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84854. */
  84855. get useRampGradients(): boolean;
  84856. set useRampGradients(value: boolean);
  84857. /**
  84858. * 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.
  84859. * 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: [])
  84860. */
  84861. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84862. private _subEmitters;
  84863. /**
  84864. * @hidden
  84865. * If the particle systems emitter should be disposed when the particle system is disposed
  84866. */
  84867. _disposeEmitterOnDispose: boolean;
  84868. /**
  84869. * The current active Sub-systems, this property is used by the root particle system only.
  84870. */
  84871. activeSubSystems: Array<ParticleSystem>;
  84872. /**
  84873. * Specifies if the particles are updated in emitter local space or world space
  84874. */
  84875. isLocal: boolean;
  84876. private _rootParticleSystem;
  84877. /**
  84878. * Gets the current list of active particles
  84879. */
  84880. get particles(): Particle[];
  84881. /**
  84882. * Returns the string "ParticleSystem"
  84883. * @returns a string containing the class name
  84884. */
  84885. getClassName(): string;
  84886. /**
  84887. * Instantiates a particle system.
  84888. * 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.
  84889. * @param name The name of the particle system
  84890. * @param capacity The max number of particles alive at the same time
  84891. * @param scene The scene the particle system belongs to
  84892. * @param customEffect a custom effect used to change the way particles are rendered by default
  84893. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84894. * @param epsilon Offset used to render the particles
  84895. */
  84896. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84897. private _addFactorGradient;
  84898. private _removeFactorGradient;
  84899. /**
  84900. * Adds a new life time gradient
  84901. * @param gradient defines the gradient to use (between 0 and 1)
  84902. * @param factor defines the life time factor to affect to the specified gradient
  84903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84904. * @returns the current particle system
  84905. */
  84906. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84907. /**
  84908. * Remove a specific life time gradient
  84909. * @param gradient defines the gradient to remove
  84910. * @returns the current particle system
  84911. */
  84912. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84913. /**
  84914. * Adds a new size gradient
  84915. * @param gradient defines the gradient to use (between 0 and 1)
  84916. * @param factor defines the size factor to affect to the specified gradient
  84917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84918. * @returns the current particle system
  84919. */
  84920. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84921. /**
  84922. * Remove a specific size gradient
  84923. * @param gradient defines the gradient to remove
  84924. * @returns the current particle system
  84925. */
  84926. removeSizeGradient(gradient: number): IParticleSystem;
  84927. /**
  84928. * Adds a new color remap gradient
  84929. * @param gradient defines the gradient to use (between 0 and 1)
  84930. * @param min defines the color remap minimal range
  84931. * @param max defines the color remap maximal range
  84932. * @returns the current particle system
  84933. */
  84934. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84935. /**
  84936. * Remove a specific color remap gradient
  84937. * @param gradient defines the gradient to remove
  84938. * @returns the current particle system
  84939. */
  84940. removeColorRemapGradient(gradient: number): IParticleSystem;
  84941. /**
  84942. * Adds a new alpha remap gradient
  84943. * @param gradient defines the gradient to use (between 0 and 1)
  84944. * @param min defines the alpha remap minimal range
  84945. * @param max defines the alpha remap maximal range
  84946. * @returns the current particle system
  84947. */
  84948. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84949. /**
  84950. * Remove a specific alpha remap gradient
  84951. * @param gradient defines the gradient to remove
  84952. * @returns the current particle system
  84953. */
  84954. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84955. /**
  84956. * Adds a new angular speed gradient
  84957. * @param gradient defines the gradient to use (between 0 and 1)
  84958. * @param factor defines the angular speed to affect to the specified gradient
  84959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84960. * @returns the current particle system
  84961. */
  84962. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84963. /**
  84964. * Remove a specific angular speed gradient
  84965. * @param gradient defines the gradient to remove
  84966. * @returns the current particle system
  84967. */
  84968. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84969. /**
  84970. * Adds a new velocity gradient
  84971. * @param gradient defines the gradient to use (between 0 and 1)
  84972. * @param factor defines the velocity to affect to the specified gradient
  84973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84974. * @returns the current particle system
  84975. */
  84976. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84977. /**
  84978. * Remove a specific velocity gradient
  84979. * @param gradient defines the gradient to remove
  84980. * @returns the current particle system
  84981. */
  84982. removeVelocityGradient(gradient: number): IParticleSystem;
  84983. /**
  84984. * Adds a new limit velocity gradient
  84985. * @param gradient defines the gradient to use (between 0 and 1)
  84986. * @param factor defines the limit velocity value to affect to the specified gradient
  84987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84988. * @returns the current particle system
  84989. */
  84990. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84991. /**
  84992. * Remove a specific limit velocity gradient
  84993. * @param gradient defines the gradient to remove
  84994. * @returns the current particle system
  84995. */
  84996. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84997. /**
  84998. * Adds a new drag gradient
  84999. * @param gradient defines the gradient to use (between 0 and 1)
  85000. * @param factor defines the drag value to affect to the specified gradient
  85001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85002. * @returns the current particle system
  85003. */
  85004. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85005. /**
  85006. * Remove a specific drag gradient
  85007. * @param gradient defines the gradient to remove
  85008. * @returns the current particle system
  85009. */
  85010. removeDragGradient(gradient: number): IParticleSystem;
  85011. /**
  85012. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85013. * @param gradient defines the gradient to use (between 0 and 1)
  85014. * @param factor defines the emit rate value to affect to the specified gradient
  85015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85016. * @returns the current particle system
  85017. */
  85018. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85019. /**
  85020. * Remove a specific emit rate gradient
  85021. * @param gradient defines the gradient to remove
  85022. * @returns the current particle system
  85023. */
  85024. removeEmitRateGradient(gradient: number): IParticleSystem;
  85025. /**
  85026. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85027. * @param gradient defines the gradient to use (between 0 and 1)
  85028. * @param factor defines the start size value to affect to the specified gradient
  85029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85030. * @returns the current particle system
  85031. */
  85032. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85033. /**
  85034. * Remove a specific start size gradient
  85035. * @param gradient defines the gradient to remove
  85036. * @returns the current particle system
  85037. */
  85038. removeStartSizeGradient(gradient: number): IParticleSystem;
  85039. private _createRampGradientTexture;
  85040. /**
  85041. * Gets the current list of ramp gradients.
  85042. * You must use addRampGradient and removeRampGradient to udpate this list
  85043. * @returns the list of ramp gradients
  85044. */
  85045. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85046. /**
  85047. * Adds a new ramp gradient used to remap particle colors
  85048. * @param gradient defines the gradient to use (between 0 and 1)
  85049. * @param color defines the color to affect to the specified gradient
  85050. * @returns the current particle system
  85051. */
  85052. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85053. /**
  85054. * Remove a specific ramp gradient
  85055. * @param gradient defines the gradient to remove
  85056. * @returns the current particle system
  85057. */
  85058. removeRampGradient(gradient: number): ParticleSystem;
  85059. /**
  85060. * Adds a new color gradient
  85061. * @param gradient defines the gradient to use (between 0 and 1)
  85062. * @param color1 defines the color to affect to the specified gradient
  85063. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85064. * @returns this particle system
  85065. */
  85066. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85067. /**
  85068. * Remove a specific color gradient
  85069. * @param gradient defines the gradient to remove
  85070. * @returns this particle system
  85071. */
  85072. removeColorGradient(gradient: number): IParticleSystem;
  85073. private _fetchR;
  85074. protected _reset(): void;
  85075. private _resetEffect;
  85076. private _createVertexBuffers;
  85077. private _createIndexBuffer;
  85078. /**
  85079. * Gets the maximum number of particles active at the same time.
  85080. * @returns The max number of active particles.
  85081. */
  85082. getCapacity(): number;
  85083. /**
  85084. * Gets whether there are still active particles in the system.
  85085. * @returns True if it is alive, otherwise false.
  85086. */
  85087. isAlive(): boolean;
  85088. /**
  85089. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85090. * @returns True if it has been started, otherwise false.
  85091. */
  85092. isStarted(): boolean;
  85093. private _prepareSubEmitterInternalArray;
  85094. /**
  85095. * Starts the particle system and begins to emit
  85096. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85097. */
  85098. start(delay?: number): void;
  85099. /**
  85100. * Stops the particle system.
  85101. * @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.
  85102. */
  85103. stop(stopSubEmitters?: boolean): void;
  85104. /**
  85105. * Remove all active particles
  85106. */
  85107. reset(): void;
  85108. /**
  85109. * @hidden (for internal use only)
  85110. */
  85111. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85112. /**
  85113. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85114. * Its lifetime will start back at 0.
  85115. */
  85116. recycleParticle: (particle: Particle) => void;
  85117. private _stopSubEmitters;
  85118. private _createParticle;
  85119. private _removeFromRoot;
  85120. private _emitFromParticle;
  85121. private _update;
  85122. /** @hidden */
  85123. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85124. /** @hidden */
  85125. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85126. /** @hidden */
  85127. private _getEffect;
  85128. /**
  85129. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85130. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85131. */
  85132. animate(preWarmOnly?: boolean): void;
  85133. private _appendParticleVertices;
  85134. /**
  85135. * Rebuilds the particle system.
  85136. */
  85137. rebuild(): void;
  85138. /**
  85139. * Is this system ready to be used/rendered
  85140. * @return true if the system is ready
  85141. */
  85142. isReady(): boolean;
  85143. private _render;
  85144. /**
  85145. * Renders the particle system in its current state.
  85146. * @returns the current number of particles
  85147. */
  85148. render(): number;
  85149. /**
  85150. * Disposes the particle system and free the associated resources
  85151. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85152. */
  85153. dispose(disposeTexture?: boolean): void;
  85154. /**
  85155. * Clones the particle system.
  85156. * @param name The name of the cloned object
  85157. * @param newEmitter The new emitter to use
  85158. * @returns the cloned particle system
  85159. */
  85160. clone(name: string, newEmitter: any): ParticleSystem;
  85161. /**
  85162. * Serializes the particle system to a JSON object.
  85163. * @returns the JSON object
  85164. */
  85165. serialize(): any;
  85166. /** @hidden */
  85167. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85168. /** @hidden */
  85169. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85170. /**
  85171. * Parses a JSON object to create a particle system.
  85172. * @param parsedParticleSystem The JSON object to parse
  85173. * @param scene The scene to create the particle system in
  85174. * @param rootUrl The root url to use to load external dependencies like texture
  85175. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85176. * @returns the Parsed particle system
  85177. */
  85178. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85179. }
  85180. }
  85181. declare module BABYLON {
  85182. /**
  85183. * A particle represents one of the element emitted by a particle system.
  85184. * This is mainly define by its coordinates, direction, velocity and age.
  85185. */
  85186. export class Particle {
  85187. /**
  85188. * The particle system the particle belongs to.
  85189. */
  85190. particleSystem: ParticleSystem;
  85191. private static _Count;
  85192. /**
  85193. * Unique ID of the particle
  85194. */
  85195. id: number;
  85196. /**
  85197. * The world position of the particle in the scene.
  85198. */
  85199. position: Vector3;
  85200. /**
  85201. * The world direction of the particle in the scene.
  85202. */
  85203. direction: Vector3;
  85204. /**
  85205. * The color of the particle.
  85206. */
  85207. color: Color4;
  85208. /**
  85209. * The color change of the particle per step.
  85210. */
  85211. colorStep: Color4;
  85212. /**
  85213. * Defines how long will the life of the particle be.
  85214. */
  85215. lifeTime: number;
  85216. /**
  85217. * The current age of the particle.
  85218. */
  85219. age: number;
  85220. /**
  85221. * The current size of the particle.
  85222. */
  85223. size: number;
  85224. /**
  85225. * The current scale of the particle.
  85226. */
  85227. scale: Vector2;
  85228. /**
  85229. * The current angle of the particle.
  85230. */
  85231. angle: number;
  85232. /**
  85233. * Defines how fast is the angle changing.
  85234. */
  85235. angularSpeed: number;
  85236. /**
  85237. * Defines the cell index used by the particle to be rendered from a sprite.
  85238. */
  85239. cellIndex: number;
  85240. /**
  85241. * The information required to support color remapping
  85242. */
  85243. remapData: Vector4;
  85244. /** @hidden */
  85245. _randomCellOffset?: number;
  85246. /** @hidden */
  85247. _initialDirection: Nullable<Vector3>;
  85248. /** @hidden */
  85249. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85250. /** @hidden */
  85251. _initialStartSpriteCellID: number;
  85252. /** @hidden */
  85253. _initialEndSpriteCellID: number;
  85254. /** @hidden */
  85255. _currentColorGradient: Nullable<ColorGradient>;
  85256. /** @hidden */
  85257. _currentColor1: Color4;
  85258. /** @hidden */
  85259. _currentColor2: Color4;
  85260. /** @hidden */
  85261. _currentSizeGradient: Nullable<FactorGradient>;
  85262. /** @hidden */
  85263. _currentSize1: number;
  85264. /** @hidden */
  85265. _currentSize2: number;
  85266. /** @hidden */
  85267. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85268. /** @hidden */
  85269. _currentAngularSpeed1: number;
  85270. /** @hidden */
  85271. _currentAngularSpeed2: number;
  85272. /** @hidden */
  85273. _currentVelocityGradient: Nullable<FactorGradient>;
  85274. /** @hidden */
  85275. _currentVelocity1: number;
  85276. /** @hidden */
  85277. _currentVelocity2: number;
  85278. /** @hidden */
  85279. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85280. /** @hidden */
  85281. _currentLimitVelocity1: number;
  85282. /** @hidden */
  85283. _currentLimitVelocity2: number;
  85284. /** @hidden */
  85285. _currentDragGradient: Nullable<FactorGradient>;
  85286. /** @hidden */
  85287. _currentDrag1: number;
  85288. /** @hidden */
  85289. _currentDrag2: number;
  85290. /** @hidden */
  85291. _randomNoiseCoordinates1: Vector3;
  85292. /** @hidden */
  85293. _randomNoiseCoordinates2: Vector3;
  85294. /** @hidden */
  85295. _localPosition?: Vector3;
  85296. /**
  85297. * Creates a new instance Particle
  85298. * @param particleSystem the particle system the particle belongs to
  85299. */
  85300. constructor(
  85301. /**
  85302. * The particle system the particle belongs to.
  85303. */
  85304. particleSystem: ParticleSystem);
  85305. private updateCellInfoFromSystem;
  85306. /**
  85307. * Defines how the sprite cell index is updated for the particle
  85308. */
  85309. updateCellIndex(): void;
  85310. /** @hidden */
  85311. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85312. /** @hidden */
  85313. _inheritParticleInfoToSubEmitters(): void;
  85314. /** @hidden */
  85315. _reset(): void;
  85316. /**
  85317. * Copy the properties of particle to another one.
  85318. * @param other the particle to copy the information to.
  85319. */
  85320. copyTo(other: Particle): void;
  85321. }
  85322. }
  85323. declare module BABYLON {
  85324. /**
  85325. * Particle emitter represents a volume emitting particles.
  85326. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85327. */
  85328. export interface IParticleEmitterType {
  85329. /**
  85330. * Called by the particle System when the direction is computed for the created particle.
  85331. * @param worldMatrix is the world matrix of the particle system
  85332. * @param directionToUpdate is the direction vector to update with the result
  85333. * @param particle is the particle we are computed the direction for
  85334. * @param isLocal defines if the direction should be set in local space
  85335. */
  85336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85337. /**
  85338. * Called by the particle System when the position is computed for the created particle.
  85339. * @param worldMatrix is the world matrix of the particle system
  85340. * @param positionToUpdate is the position vector to update with the result
  85341. * @param particle is the particle we are computed the position for
  85342. * @param isLocal defines if the position should be set in local space
  85343. */
  85344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85345. /**
  85346. * Clones the current emitter and returns a copy of it
  85347. * @returns the new emitter
  85348. */
  85349. clone(): IParticleEmitterType;
  85350. /**
  85351. * Called by the GPUParticleSystem to setup the update shader
  85352. * @param effect defines the update shader
  85353. */
  85354. applyToShader(effect: Effect): void;
  85355. /**
  85356. * Returns a string to use to update the GPU particles update shader
  85357. * @returns the effect defines string
  85358. */
  85359. getEffectDefines(): string;
  85360. /**
  85361. * Returns a string representing the class name
  85362. * @returns a string containing the class name
  85363. */
  85364. getClassName(): string;
  85365. /**
  85366. * Serializes the particle system to a JSON object.
  85367. * @returns the JSON object
  85368. */
  85369. serialize(): any;
  85370. /**
  85371. * Parse properties from a JSON object
  85372. * @param serializationObject defines the JSON object
  85373. * @param scene defines the hosting scene
  85374. */
  85375. parse(serializationObject: any, scene: Scene): void;
  85376. }
  85377. }
  85378. declare module BABYLON {
  85379. /**
  85380. * Particle emitter emitting particles from the inside of a box.
  85381. * It emits the particles randomly between 2 given directions.
  85382. */
  85383. export class BoxParticleEmitter implements IParticleEmitterType {
  85384. /**
  85385. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85386. */
  85387. direction1: Vector3;
  85388. /**
  85389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85390. */
  85391. direction2: Vector3;
  85392. /**
  85393. * 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.
  85394. */
  85395. minEmitBox: Vector3;
  85396. /**
  85397. * 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.
  85398. */
  85399. maxEmitBox: Vector3;
  85400. /**
  85401. * Creates a new instance BoxParticleEmitter
  85402. */
  85403. constructor();
  85404. /**
  85405. * Called by the particle System when the direction is computed for the created particle.
  85406. * @param worldMatrix is the world matrix of the particle system
  85407. * @param directionToUpdate is the direction vector to update with the result
  85408. * @param particle is the particle we are computed the direction for
  85409. * @param isLocal defines if the direction should be set in local space
  85410. */
  85411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85412. /**
  85413. * Called by the particle System when the position is computed for the created particle.
  85414. * @param worldMatrix is the world matrix of the particle system
  85415. * @param positionToUpdate is the position vector to update with the result
  85416. * @param particle is the particle we are computed the position for
  85417. * @param isLocal defines if the position should be set in local space
  85418. */
  85419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85420. /**
  85421. * Clones the current emitter and returns a copy of it
  85422. * @returns the new emitter
  85423. */
  85424. clone(): BoxParticleEmitter;
  85425. /**
  85426. * Called by the GPUParticleSystem to setup the update shader
  85427. * @param effect defines the update shader
  85428. */
  85429. applyToShader(effect: Effect): void;
  85430. /**
  85431. * Returns a string to use to update the GPU particles update shader
  85432. * @returns a string containng the defines string
  85433. */
  85434. getEffectDefines(): string;
  85435. /**
  85436. * Returns the string "BoxParticleEmitter"
  85437. * @returns a string containing the class name
  85438. */
  85439. getClassName(): string;
  85440. /**
  85441. * Serializes the particle system to a JSON object.
  85442. * @returns the JSON object
  85443. */
  85444. serialize(): any;
  85445. /**
  85446. * Parse properties from a JSON object
  85447. * @param serializationObject defines the JSON object
  85448. */
  85449. parse(serializationObject: any): void;
  85450. }
  85451. }
  85452. declare module BABYLON {
  85453. /**
  85454. * Particle emitter emitting particles from the inside of a cone.
  85455. * It emits the particles alongside the cone volume from the base to the particle.
  85456. * The emission direction might be randomized.
  85457. */
  85458. export class ConeParticleEmitter implements IParticleEmitterType {
  85459. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85460. directionRandomizer: number;
  85461. private _radius;
  85462. private _angle;
  85463. private _height;
  85464. /**
  85465. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85466. */
  85467. radiusRange: number;
  85468. /**
  85469. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85470. */
  85471. heightRange: number;
  85472. /**
  85473. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85474. */
  85475. emitFromSpawnPointOnly: boolean;
  85476. /**
  85477. * Gets or sets the radius of the emission cone
  85478. */
  85479. get radius(): number;
  85480. set radius(value: number);
  85481. /**
  85482. * Gets or sets the angle of the emission cone
  85483. */
  85484. get angle(): number;
  85485. set angle(value: number);
  85486. private _buildHeight;
  85487. /**
  85488. * Creates a new instance ConeParticleEmitter
  85489. * @param radius the radius of the emission cone (1 by default)
  85490. * @param angle the cone base angle (PI by default)
  85491. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85492. */
  85493. constructor(radius?: number, angle?: number,
  85494. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85495. directionRandomizer?: number);
  85496. /**
  85497. * Called by the particle System when the direction is computed for the created particle.
  85498. * @param worldMatrix is the world matrix of the particle system
  85499. * @param directionToUpdate is the direction vector to update with the result
  85500. * @param particle is the particle we are computed the direction for
  85501. * @param isLocal defines if the direction should be set in local space
  85502. */
  85503. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85504. /**
  85505. * Called by the particle System when the position is computed for the created particle.
  85506. * @param worldMatrix is the world matrix of the particle system
  85507. * @param positionToUpdate is the position vector to update with the result
  85508. * @param particle is the particle we are computed the position for
  85509. * @param isLocal defines if the position should be set in local space
  85510. */
  85511. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85512. /**
  85513. * Clones the current emitter and returns a copy of it
  85514. * @returns the new emitter
  85515. */
  85516. clone(): ConeParticleEmitter;
  85517. /**
  85518. * Called by the GPUParticleSystem to setup the update shader
  85519. * @param effect defines the update shader
  85520. */
  85521. applyToShader(effect: Effect): void;
  85522. /**
  85523. * Returns a string to use to update the GPU particles update shader
  85524. * @returns a string containng the defines string
  85525. */
  85526. getEffectDefines(): string;
  85527. /**
  85528. * Returns the string "ConeParticleEmitter"
  85529. * @returns a string containing the class name
  85530. */
  85531. getClassName(): string;
  85532. /**
  85533. * Serializes the particle system to a JSON object.
  85534. * @returns the JSON object
  85535. */
  85536. serialize(): any;
  85537. /**
  85538. * Parse properties from a JSON object
  85539. * @param serializationObject defines the JSON object
  85540. */
  85541. parse(serializationObject: any): void;
  85542. }
  85543. }
  85544. declare module BABYLON {
  85545. /**
  85546. * Particle emitter emitting particles from the inside of a cylinder.
  85547. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85548. */
  85549. export class CylinderParticleEmitter implements IParticleEmitterType {
  85550. /**
  85551. * The radius of the emission cylinder.
  85552. */
  85553. radius: number;
  85554. /**
  85555. * The height of the emission cylinder.
  85556. */
  85557. height: number;
  85558. /**
  85559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85560. */
  85561. radiusRange: number;
  85562. /**
  85563. * How much to randomize the particle direction [0-1].
  85564. */
  85565. directionRandomizer: number;
  85566. /**
  85567. * Creates a new instance CylinderParticleEmitter
  85568. * @param radius the radius of the emission cylinder (1 by default)
  85569. * @param height the height of the emission cylinder (1 by default)
  85570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85571. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85572. */
  85573. constructor(
  85574. /**
  85575. * The radius of the emission cylinder.
  85576. */
  85577. radius?: number,
  85578. /**
  85579. * The height of the emission cylinder.
  85580. */
  85581. height?: number,
  85582. /**
  85583. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85584. */
  85585. radiusRange?: number,
  85586. /**
  85587. * How much to randomize the particle direction [0-1].
  85588. */
  85589. directionRandomizer?: number);
  85590. /**
  85591. * Called by the particle System when the direction is computed for the created particle.
  85592. * @param worldMatrix is the world matrix of the particle system
  85593. * @param directionToUpdate is the direction vector to update with the result
  85594. * @param particle is the particle we are computed the direction for
  85595. * @param isLocal defines if the direction should be set in local space
  85596. */
  85597. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85598. /**
  85599. * Called by the particle System when the position is computed for the created particle.
  85600. * @param worldMatrix is the world matrix of the particle system
  85601. * @param positionToUpdate is the position vector to update with the result
  85602. * @param particle is the particle we are computed the position for
  85603. * @param isLocal defines if the position should be set in local space
  85604. */
  85605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85606. /**
  85607. * Clones the current emitter and returns a copy of it
  85608. * @returns the new emitter
  85609. */
  85610. clone(): CylinderParticleEmitter;
  85611. /**
  85612. * Called by the GPUParticleSystem to setup the update shader
  85613. * @param effect defines the update shader
  85614. */
  85615. applyToShader(effect: Effect): void;
  85616. /**
  85617. * Returns a string to use to update the GPU particles update shader
  85618. * @returns a string containng the defines string
  85619. */
  85620. getEffectDefines(): string;
  85621. /**
  85622. * Returns the string "CylinderParticleEmitter"
  85623. * @returns a string containing the class name
  85624. */
  85625. getClassName(): string;
  85626. /**
  85627. * Serializes the particle system to a JSON object.
  85628. * @returns the JSON object
  85629. */
  85630. serialize(): any;
  85631. /**
  85632. * Parse properties from a JSON object
  85633. * @param serializationObject defines the JSON object
  85634. */
  85635. parse(serializationObject: any): void;
  85636. }
  85637. /**
  85638. * Particle emitter emitting particles from the inside of a cylinder.
  85639. * It emits the particles randomly between two vectors.
  85640. */
  85641. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85642. /**
  85643. * The min limit of the emission direction.
  85644. */
  85645. direction1: Vector3;
  85646. /**
  85647. * The max limit of the emission direction.
  85648. */
  85649. direction2: Vector3;
  85650. /**
  85651. * Creates a new instance CylinderDirectedParticleEmitter
  85652. * @param radius the radius of the emission cylinder (1 by default)
  85653. * @param height the height of the emission cylinder (1 by default)
  85654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85655. * @param direction1 the min limit of the emission direction (up vector by default)
  85656. * @param direction2 the max limit of the emission direction (up vector by default)
  85657. */
  85658. constructor(radius?: number, height?: number, radiusRange?: number,
  85659. /**
  85660. * The min limit of the emission direction.
  85661. */
  85662. direction1?: Vector3,
  85663. /**
  85664. * The max limit of the emission direction.
  85665. */
  85666. direction2?: Vector3);
  85667. /**
  85668. * Called by the particle System when the direction is computed for the created particle.
  85669. * @param worldMatrix is the world matrix of the particle system
  85670. * @param directionToUpdate is the direction vector to update with the result
  85671. * @param particle is the particle we are computed the direction for
  85672. */
  85673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85674. /**
  85675. * Clones the current emitter and returns a copy of it
  85676. * @returns the new emitter
  85677. */
  85678. clone(): CylinderDirectedParticleEmitter;
  85679. /**
  85680. * Called by the GPUParticleSystem to setup the update shader
  85681. * @param effect defines the update shader
  85682. */
  85683. applyToShader(effect: Effect): void;
  85684. /**
  85685. * Returns a string to use to update the GPU particles update shader
  85686. * @returns a string containng the defines string
  85687. */
  85688. getEffectDefines(): string;
  85689. /**
  85690. * Returns the string "CylinderDirectedParticleEmitter"
  85691. * @returns a string containing the class name
  85692. */
  85693. getClassName(): string;
  85694. /**
  85695. * Serializes the particle system to a JSON object.
  85696. * @returns the JSON object
  85697. */
  85698. serialize(): any;
  85699. /**
  85700. * Parse properties from a JSON object
  85701. * @param serializationObject defines the JSON object
  85702. */
  85703. parse(serializationObject: any): void;
  85704. }
  85705. }
  85706. declare module BABYLON {
  85707. /**
  85708. * Particle emitter emitting particles from the inside of a hemisphere.
  85709. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85710. */
  85711. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85712. /**
  85713. * The radius of the emission hemisphere.
  85714. */
  85715. radius: number;
  85716. /**
  85717. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85718. */
  85719. radiusRange: number;
  85720. /**
  85721. * How much to randomize the particle direction [0-1].
  85722. */
  85723. directionRandomizer: number;
  85724. /**
  85725. * Creates a new instance HemisphericParticleEmitter
  85726. * @param radius the radius of the emission hemisphere (1 by default)
  85727. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85728. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85729. */
  85730. constructor(
  85731. /**
  85732. * The radius of the emission hemisphere.
  85733. */
  85734. radius?: number,
  85735. /**
  85736. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85737. */
  85738. radiusRange?: number,
  85739. /**
  85740. * How much to randomize the particle direction [0-1].
  85741. */
  85742. directionRandomizer?: number);
  85743. /**
  85744. * Called by the particle System when the direction is computed for the created particle.
  85745. * @param worldMatrix is the world matrix of the particle system
  85746. * @param directionToUpdate is the direction vector to update with the result
  85747. * @param particle is the particle we are computed the direction for
  85748. * @param isLocal defines if the direction should be set in local space
  85749. */
  85750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85751. /**
  85752. * Called by the particle System when the position is computed for the created particle.
  85753. * @param worldMatrix is the world matrix of the particle system
  85754. * @param positionToUpdate is the position vector to update with the result
  85755. * @param particle is the particle we are computed the position for
  85756. * @param isLocal defines if the position should be set in local space
  85757. */
  85758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85759. /**
  85760. * Clones the current emitter and returns a copy of it
  85761. * @returns the new emitter
  85762. */
  85763. clone(): HemisphericParticleEmitter;
  85764. /**
  85765. * Called by the GPUParticleSystem to setup the update shader
  85766. * @param effect defines the update shader
  85767. */
  85768. applyToShader(effect: Effect): void;
  85769. /**
  85770. * Returns a string to use to update the GPU particles update shader
  85771. * @returns a string containng the defines string
  85772. */
  85773. getEffectDefines(): string;
  85774. /**
  85775. * Returns the string "HemisphericParticleEmitter"
  85776. * @returns a string containing the class name
  85777. */
  85778. getClassName(): string;
  85779. /**
  85780. * Serializes the particle system to a JSON object.
  85781. * @returns the JSON object
  85782. */
  85783. serialize(): any;
  85784. /**
  85785. * Parse properties from a JSON object
  85786. * @param serializationObject defines the JSON object
  85787. */
  85788. parse(serializationObject: any): void;
  85789. }
  85790. }
  85791. declare module BABYLON {
  85792. /**
  85793. * Particle emitter emitting particles from a point.
  85794. * It emits the particles randomly between 2 given directions.
  85795. */
  85796. export class PointParticleEmitter implements IParticleEmitterType {
  85797. /**
  85798. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85799. */
  85800. direction1: Vector3;
  85801. /**
  85802. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85803. */
  85804. direction2: Vector3;
  85805. /**
  85806. * Creates a new instance PointParticleEmitter
  85807. */
  85808. constructor();
  85809. /**
  85810. * Called by the particle System when the direction is computed for the created particle.
  85811. * @param worldMatrix is the world matrix of the particle system
  85812. * @param directionToUpdate is the direction vector to update with the result
  85813. * @param particle is the particle we are computed the direction for
  85814. * @param isLocal defines if the direction should be set in local space
  85815. */
  85816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85817. /**
  85818. * Called by the particle System when the position is computed for the created particle.
  85819. * @param worldMatrix is the world matrix of the particle system
  85820. * @param positionToUpdate is the position vector to update with the result
  85821. * @param particle is the particle we are computed the position for
  85822. * @param isLocal defines if the position should be set in local space
  85823. */
  85824. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85825. /**
  85826. * Clones the current emitter and returns a copy of it
  85827. * @returns the new emitter
  85828. */
  85829. clone(): PointParticleEmitter;
  85830. /**
  85831. * Called by the GPUParticleSystem to setup the update shader
  85832. * @param effect defines the update shader
  85833. */
  85834. applyToShader(effect: Effect): void;
  85835. /**
  85836. * Returns a string to use to update the GPU particles update shader
  85837. * @returns a string containng the defines string
  85838. */
  85839. getEffectDefines(): string;
  85840. /**
  85841. * Returns the string "PointParticleEmitter"
  85842. * @returns a string containing the class name
  85843. */
  85844. getClassName(): string;
  85845. /**
  85846. * Serializes the particle system to a JSON object.
  85847. * @returns the JSON object
  85848. */
  85849. serialize(): any;
  85850. /**
  85851. * Parse properties from a JSON object
  85852. * @param serializationObject defines the JSON object
  85853. */
  85854. parse(serializationObject: any): void;
  85855. }
  85856. }
  85857. declare module BABYLON {
  85858. /**
  85859. * Particle emitter emitting particles from the inside of a sphere.
  85860. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85861. */
  85862. export class SphereParticleEmitter implements IParticleEmitterType {
  85863. /**
  85864. * The radius of the emission sphere.
  85865. */
  85866. radius: number;
  85867. /**
  85868. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85869. */
  85870. radiusRange: number;
  85871. /**
  85872. * How much to randomize the particle direction [0-1].
  85873. */
  85874. directionRandomizer: number;
  85875. /**
  85876. * Creates a new instance SphereParticleEmitter
  85877. * @param radius the radius of the emission sphere (1 by default)
  85878. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85879. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85880. */
  85881. constructor(
  85882. /**
  85883. * The radius of the emission sphere.
  85884. */
  85885. radius?: number,
  85886. /**
  85887. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85888. */
  85889. radiusRange?: number,
  85890. /**
  85891. * How much to randomize the particle direction [0-1].
  85892. */
  85893. directionRandomizer?: number);
  85894. /**
  85895. * Called by the particle System when the direction is computed for the created particle.
  85896. * @param worldMatrix is the world matrix of the particle system
  85897. * @param directionToUpdate is the direction vector to update with the result
  85898. * @param particle is the particle we are computed the direction for
  85899. * @param isLocal defines if the direction should be set in local space
  85900. */
  85901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85902. /**
  85903. * Called by the particle System when the position is computed for the created particle.
  85904. * @param worldMatrix is the world matrix of the particle system
  85905. * @param positionToUpdate is the position vector to update with the result
  85906. * @param particle is the particle we are computed the position for
  85907. * @param isLocal defines if the position should be set in local space
  85908. */
  85909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  85910. /**
  85911. * Clones the current emitter and returns a copy of it
  85912. * @returns the new emitter
  85913. */
  85914. clone(): SphereParticleEmitter;
  85915. /**
  85916. * Called by the GPUParticleSystem to setup the update shader
  85917. * @param effect defines the update shader
  85918. */
  85919. applyToShader(effect: Effect): void;
  85920. /**
  85921. * Returns a string to use to update the GPU particles update shader
  85922. * @returns a string containng the defines string
  85923. */
  85924. getEffectDefines(): string;
  85925. /**
  85926. * Returns the string "SphereParticleEmitter"
  85927. * @returns a string containing the class name
  85928. */
  85929. getClassName(): string;
  85930. /**
  85931. * Serializes the particle system to a JSON object.
  85932. * @returns the JSON object
  85933. */
  85934. serialize(): any;
  85935. /**
  85936. * Parse properties from a JSON object
  85937. * @param serializationObject defines the JSON object
  85938. */
  85939. parse(serializationObject: any): void;
  85940. }
  85941. /**
  85942. * Particle emitter emitting particles from the inside of a sphere.
  85943. * It emits the particles randomly between two vectors.
  85944. */
  85945. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85946. /**
  85947. * The min limit of the emission direction.
  85948. */
  85949. direction1: Vector3;
  85950. /**
  85951. * The max limit of the emission direction.
  85952. */
  85953. direction2: Vector3;
  85954. /**
  85955. * Creates a new instance SphereDirectedParticleEmitter
  85956. * @param radius the radius of the emission sphere (1 by default)
  85957. * @param direction1 the min limit of the emission direction (up vector by default)
  85958. * @param direction2 the max limit of the emission direction (up vector by default)
  85959. */
  85960. constructor(radius?: number,
  85961. /**
  85962. * The min limit of the emission direction.
  85963. */
  85964. direction1?: Vector3,
  85965. /**
  85966. * The max limit of the emission direction.
  85967. */
  85968. direction2?: Vector3);
  85969. /**
  85970. * Called by the particle System when the direction is computed for the created particle.
  85971. * @param worldMatrix is the world matrix of the particle system
  85972. * @param directionToUpdate is the direction vector to update with the result
  85973. * @param particle is the particle we are computed the direction for
  85974. */
  85975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85976. /**
  85977. * Clones the current emitter and returns a copy of it
  85978. * @returns the new emitter
  85979. */
  85980. clone(): SphereDirectedParticleEmitter;
  85981. /**
  85982. * Called by the GPUParticleSystem to setup the update shader
  85983. * @param effect defines the update shader
  85984. */
  85985. applyToShader(effect: Effect): void;
  85986. /**
  85987. * Returns a string to use to update the GPU particles update shader
  85988. * @returns a string containng the defines string
  85989. */
  85990. getEffectDefines(): string;
  85991. /**
  85992. * Returns the string "SphereDirectedParticleEmitter"
  85993. * @returns a string containing the class name
  85994. */
  85995. getClassName(): string;
  85996. /**
  85997. * Serializes the particle system to a JSON object.
  85998. * @returns the JSON object
  85999. */
  86000. serialize(): any;
  86001. /**
  86002. * Parse properties from a JSON object
  86003. * @param serializationObject defines the JSON object
  86004. */
  86005. parse(serializationObject: any): void;
  86006. }
  86007. }
  86008. declare module BABYLON {
  86009. /**
  86010. * Particle emitter emitting particles from a custom list of positions.
  86011. */
  86012. export class CustomParticleEmitter implements IParticleEmitterType {
  86013. /**
  86014. * Gets or sets the position generator that will create the inital position of each particle.
  86015. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86016. */
  86017. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86018. /**
  86019. * Gets or sets the destination generator that will create the final destination of each particle.
  86020. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86021. */
  86022. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86023. /**
  86024. * Creates a new instance CustomParticleEmitter
  86025. */
  86026. constructor();
  86027. /**
  86028. * Called by the particle System when the direction is computed for the created particle.
  86029. * @param worldMatrix is the world matrix of the particle system
  86030. * @param directionToUpdate is the direction vector to update with the result
  86031. * @param particle is the particle we are computed the direction for
  86032. * @param isLocal defines if the direction should be set in local space
  86033. */
  86034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86035. /**
  86036. * Called by the particle System when the position is computed for the created particle.
  86037. * @param worldMatrix is the world matrix of the particle system
  86038. * @param positionToUpdate is the position vector to update with the result
  86039. * @param particle is the particle we are computed the position for
  86040. * @param isLocal defines if the position should be set in local space
  86041. */
  86042. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86043. /**
  86044. * Clones the current emitter and returns a copy of it
  86045. * @returns the new emitter
  86046. */
  86047. clone(): CustomParticleEmitter;
  86048. /**
  86049. * Called by the GPUParticleSystem to setup the update shader
  86050. * @param effect defines the update shader
  86051. */
  86052. applyToShader(effect: Effect): void;
  86053. /**
  86054. * Returns a string to use to update the GPU particles update shader
  86055. * @returns a string containng the defines string
  86056. */
  86057. getEffectDefines(): string;
  86058. /**
  86059. * Returns the string "PointParticleEmitter"
  86060. * @returns a string containing the class name
  86061. */
  86062. getClassName(): string;
  86063. /**
  86064. * Serializes the particle system to a JSON object.
  86065. * @returns the JSON object
  86066. */
  86067. serialize(): any;
  86068. /**
  86069. * Parse properties from a JSON object
  86070. * @param serializationObject defines the JSON object
  86071. */
  86072. parse(serializationObject: any): void;
  86073. }
  86074. }
  86075. declare module BABYLON {
  86076. /**
  86077. * Particle emitter emitting particles from the inside of a box.
  86078. * It emits the particles randomly between 2 given directions.
  86079. */
  86080. export class MeshParticleEmitter implements IParticleEmitterType {
  86081. /** Defines the mesh to use as source */
  86082. mesh?: AbstractMesh | undefined;
  86083. private _indices;
  86084. private _positions;
  86085. private _normals;
  86086. private _storedNormal;
  86087. /**
  86088. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86089. */
  86090. direction1: Vector3;
  86091. /**
  86092. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86093. */
  86094. direction2: Vector3;
  86095. /**
  86096. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86097. */
  86098. useMeshNormalsForDirection: boolean;
  86099. /**
  86100. * Creates a new instance MeshParticleEmitter
  86101. * @param mesh defines the mesh to use as source
  86102. */
  86103. constructor(
  86104. /** Defines the mesh to use as source */
  86105. mesh?: AbstractMesh | undefined);
  86106. /**
  86107. * Called by the particle System when the direction is computed for the created particle.
  86108. * @param worldMatrix is the world matrix of the particle system
  86109. * @param directionToUpdate is the direction vector to update with the result
  86110. * @param particle is the particle we are computed the direction for
  86111. * @param isLocal defines if the direction should be set in local space
  86112. */
  86113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86114. /**
  86115. * Called by the particle System when the position is computed for the created particle.
  86116. * @param worldMatrix is the world matrix of the particle system
  86117. * @param positionToUpdate is the position vector to update with the result
  86118. * @param particle is the particle we are computed the position for
  86119. * @param isLocal defines if the position should be set in local space
  86120. */
  86121. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86122. /**
  86123. * Clones the current emitter and returns a copy of it
  86124. * @returns the new emitter
  86125. */
  86126. clone(): MeshParticleEmitter;
  86127. /**
  86128. * Called by the GPUParticleSystem to setup the update shader
  86129. * @param effect defines the update shader
  86130. */
  86131. applyToShader(effect: Effect): void;
  86132. /**
  86133. * Returns a string to use to update the GPU particles update shader
  86134. * @returns a string containng the defines string
  86135. */
  86136. getEffectDefines(): string;
  86137. /**
  86138. * Returns the string "BoxParticleEmitter"
  86139. * @returns a string containing the class name
  86140. */
  86141. getClassName(): string;
  86142. /**
  86143. * Serializes the particle system to a JSON object.
  86144. * @returns the JSON object
  86145. */
  86146. serialize(): any;
  86147. /**
  86148. * Parse properties from a JSON object
  86149. * @param serializationObject defines the JSON object
  86150. * @param scene defines the hosting scene
  86151. */
  86152. parse(serializationObject: any, scene: Scene): void;
  86153. }
  86154. }
  86155. declare module BABYLON {
  86156. /**
  86157. * Interface representing a particle system in Babylon.js.
  86158. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86159. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86160. */
  86161. export interface IParticleSystem {
  86162. /**
  86163. * List of animations used by the particle system.
  86164. */
  86165. animations: Animation[];
  86166. /**
  86167. * The id of the Particle system.
  86168. */
  86169. id: string;
  86170. /**
  86171. * The name of the Particle system.
  86172. */
  86173. name: string;
  86174. /**
  86175. * The emitter represents the Mesh or position we are attaching the particle system to.
  86176. */
  86177. emitter: Nullable<AbstractMesh | Vector3>;
  86178. /**
  86179. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86180. */
  86181. isBillboardBased: boolean;
  86182. /**
  86183. * The rendering group used by the Particle system to chose when to render.
  86184. */
  86185. renderingGroupId: number;
  86186. /**
  86187. * The layer mask we are rendering the particles through.
  86188. */
  86189. layerMask: number;
  86190. /**
  86191. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86192. */
  86193. updateSpeed: number;
  86194. /**
  86195. * The amount of time the particle system is running (depends of the overall update speed).
  86196. */
  86197. targetStopDuration: number;
  86198. /**
  86199. * The texture used to render each particle. (this can be a spritesheet)
  86200. */
  86201. particleTexture: Nullable<Texture>;
  86202. /**
  86203. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86204. */
  86205. blendMode: number;
  86206. /**
  86207. * Minimum life time of emitting particles.
  86208. */
  86209. minLifeTime: number;
  86210. /**
  86211. * Maximum life time of emitting particles.
  86212. */
  86213. maxLifeTime: number;
  86214. /**
  86215. * Minimum Size of emitting particles.
  86216. */
  86217. minSize: number;
  86218. /**
  86219. * Maximum Size of emitting particles.
  86220. */
  86221. maxSize: number;
  86222. /**
  86223. * Minimum scale of emitting particles on X axis.
  86224. */
  86225. minScaleX: number;
  86226. /**
  86227. * Maximum scale of emitting particles on X axis.
  86228. */
  86229. maxScaleX: number;
  86230. /**
  86231. * Minimum scale of emitting particles on Y axis.
  86232. */
  86233. minScaleY: number;
  86234. /**
  86235. * Maximum scale of emitting particles on Y axis.
  86236. */
  86237. maxScaleY: number;
  86238. /**
  86239. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86240. */
  86241. color1: Color4;
  86242. /**
  86243. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86244. */
  86245. color2: Color4;
  86246. /**
  86247. * Color the particle will have at the end of its lifetime.
  86248. */
  86249. colorDead: Color4;
  86250. /**
  86251. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86252. */
  86253. emitRate: number;
  86254. /**
  86255. * You can use gravity if you want to give an orientation to your particles.
  86256. */
  86257. gravity: Vector3;
  86258. /**
  86259. * Minimum power of emitting particles.
  86260. */
  86261. minEmitPower: number;
  86262. /**
  86263. * Maximum power of emitting particles.
  86264. */
  86265. maxEmitPower: number;
  86266. /**
  86267. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86268. */
  86269. minAngularSpeed: number;
  86270. /**
  86271. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86272. */
  86273. maxAngularSpeed: number;
  86274. /**
  86275. * Gets or sets the minimal initial rotation in radians.
  86276. */
  86277. minInitialRotation: number;
  86278. /**
  86279. * Gets or sets the maximal initial rotation in radians.
  86280. */
  86281. maxInitialRotation: number;
  86282. /**
  86283. * The particle emitter type defines the emitter used by the particle system.
  86284. * It can be for example box, sphere, or cone...
  86285. */
  86286. particleEmitterType: Nullable<IParticleEmitterType>;
  86287. /**
  86288. * Defines the delay in milliseconds before starting the system (0 by default)
  86289. */
  86290. startDelay: number;
  86291. /**
  86292. * 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
  86293. */
  86294. preWarmCycles: number;
  86295. /**
  86296. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86297. */
  86298. preWarmStepOffset: number;
  86299. /**
  86300. * 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)
  86301. */
  86302. spriteCellChangeSpeed: number;
  86303. /**
  86304. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86305. */
  86306. startSpriteCellID: number;
  86307. /**
  86308. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86309. */
  86310. endSpriteCellID: number;
  86311. /**
  86312. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86313. */
  86314. spriteCellWidth: number;
  86315. /**
  86316. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86317. */
  86318. spriteCellHeight: number;
  86319. /**
  86320. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86321. */
  86322. spriteRandomStartCell: boolean;
  86323. /**
  86324. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86325. */
  86326. isAnimationSheetEnabled: boolean;
  86327. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86328. translationPivot: Vector2;
  86329. /**
  86330. * Gets or sets a texture used to add random noise to particle positions
  86331. */
  86332. noiseTexture: Nullable<BaseTexture>;
  86333. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86334. noiseStrength: Vector3;
  86335. /**
  86336. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86337. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86338. */
  86339. billboardMode: number;
  86340. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86341. limitVelocityDamping: number;
  86342. /**
  86343. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86344. */
  86345. beginAnimationOnStart: boolean;
  86346. /**
  86347. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86348. */
  86349. beginAnimationFrom: number;
  86350. /**
  86351. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86352. */
  86353. beginAnimationTo: number;
  86354. /**
  86355. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86356. */
  86357. beginAnimationLoop: boolean;
  86358. /**
  86359. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86360. */
  86361. disposeOnStop: boolean;
  86362. /**
  86363. * Specifies if the particles are updated in emitter local space or world space
  86364. */
  86365. isLocal: boolean;
  86366. /**
  86367. * Gets the maximum number of particles active at the same time.
  86368. * @returns The max number of active particles.
  86369. */
  86370. getCapacity(): number;
  86371. /**
  86372. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86373. * @returns True if it has been started, otherwise false.
  86374. */
  86375. isStarted(): boolean;
  86376. /**
  86377. * Animates the particle system for this frame.
  86378. */
  86379. animate(): void;
  86380. /**
  86381. * Renders the particle system in its current state.
  86382. * @returns the current number of particles
  86383. */
  86384. render(): number;
  86385. /**
  86386. * Dispose the particle system and frees its associated resources.
  86387. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86388. */
  86389. dispose(disposeTexture?: boolean): void;
  86390. /**
  86391. * Clones the particle system.
  86392. * @param name The name of the cloned object
  86393. * @param newEmitter The new emitter to use
  86394. * @returns the cloned particle system
  86395. */
  86396. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86397. /**
  86398. * Serializes the particle system to a JSON object.
  86399. * @returns the JSON object
  86400. */
  86401. serialize(): any;
  86402. /**
  86403. * Rebuild the particle system
  86404. */
  86405. rebuild(): void;
  86406. /**
  86407. * Starts the particle system and begins to emit
  86408. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86409. */
  86410. start(delay?: number): void;
  86411. /**
  86412. * Stops the particle system.
  86413. */
  86414. stop(): void;
  86415. /**
  86416. * Remove all active particles
  86417. */
  86418. reset(): void;
  86419. /**
  86420. * Is this system ready to be used/rendered
  86421. * @return true if the system is ready
  86422. */
  86423. isReady(): boolean;
  86424. /**
  86425. * Adds a new color gradient
  86426. * @param gradient defines the gradient to use (between 0 and 1)
  86427. * @param color1 defines the color to affect to the specified gradient
  86428. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86429. * @returns the current particle system
  86430. */
  86431. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86432. /**
  86433. * Remove a specific color gradient
  86434. * @param gradient defines the gradient to remove
  86435. * @returns the current particle system
  86436. */
  86437. removeColorGradient(gradient: number): IParticleSystem;
  86438. /**
  86439. * Adds a new size gradient
  86440. * @param gradient defines the gradient to use (between 0 and 1)
  86441. * @param factor defines the size factor to affect to the specified gradient
  86442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86443. * @returns the current particle system
  86444. */
  86445. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86446. /**
  86447. * Remove a specific size gradient
  86448. * @param gradient defines the gradient to remove
  86449. * @returns the current particle system
  86450. */
  86451. removeSizeGradient(gradient: number): IParticleSystem;
  86452. /**
  86453. * Gets the current list of color gradients.
  86454. * You must use addColorGradient and removeColorGradient to udpate this list
  86455. * @returns the list of color gradients
  86456. */
  86457. getColorGradients(): Nullable<Array<ColorGradient>>;
  86458. /**
  86459. * Gets the current list of size gradients.
  86460. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86461. * @returns the list of size gradients
  86462. */
  86463. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86464. /**
  86465. * Gets the current list of angular speed gradients.
  86466. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86467. * @returns the list of angular speed gradients
  86468. */
  86469. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86470. /**
  86471. * Adds a new angular speed gradient
  86472. * @param gradient defines the gradient to use (between 0 and 1)
  86473. * @param factor defines the angular speed to affect to the specified gradient
  86474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86475. * @returns the current particle system
  86476. */
  86477. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86478. /**
  86479. * Remove a specific angular speed gradient
  86480. * @param gradient defines the gradient to remove
  86481. * @returns the current particle system
  86482. */
  86483. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86484. /**
  86485. * Gets the current list of velocity gradients.
  86486. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86487. * @returns the list of velocity gradients
  86488. */
  86489. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86490. /**
  86491. * Adds a new velocity gradient
  86492. * @param gradient defines the gradient to use (between 0 and 1)
  86493. * @param factor defines the velocity to affect to the specified gradient
  86494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86495. * @returns the current particle system
  86496. */
  86497. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86498. /**
  86499. * Remove a specific velocity gradient
  86500. * @param gradient defines the gradient to remove
  86501. * @returns the current particle system
  86502. */
  86503. removeVelocityGradient(gradient: number): IParticleSystem;
  86504. /**
  86505. * Gets the current list of limit velocity gradients.
  86506. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86507. * @returns the list of limit velocity gradients
  86508. */
  86509. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86510. /**
  86511. * Adds a new limit velocity gradient
  86512. * @param gradient defines the gradient to use (between 0 and 1)
  86513. * @param factor defines the limit velocity to affect to the specified gradient
  86514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86515. * @returns the current particle system
  86516. */
  86517. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86518. /**
  86519. * Remove a specific limit velocity gradient
  86520. * @param gradient defines the gradient to remove
  86521. * @returns the current particle system
  86522. */
  86523. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86524. /**
  86525. * Adds a new drag gradient
  86526. * @param gradient defines the gradient to use (between 0 and 1)
  86527. * @param factor defines the drag to affect to the specified gradient
  86528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86529. * @returns the current particle system
  86530. */
  86531. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86532. /**
  86533. * Remove a specific drag gradient
  86534. * @param gradient defines the gradient to remove
  86535. * @returns the current particle system
  86536. */
  86537. removeDragGradient(gradient: number): IParticleSystem;
  86538. /**
  86539. * Gets the current list of drag gradients.
  86540. * You must use addDragGradient and removeDragGradient to udpate this list
  86541. * @returns the list of drag gradients
  86542. */
  86543. getDragGradients(): Nullable<Array<FactorGradient>>;
  86544. /**
  86545. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86546. * @param gradient defines the gradient to use (between 0 and 1)
  86547. * @param factor defines the emit rate to affect to the specified gradient
  86548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86549. * @returns the current particle system
  86550. */
  86551. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86552. /**
  86553. * Remove a specific emit rate gradient
  86554. * @param gradient defines the gradient to remove
  86555. * @returns the current particle system
  86556. */
  86557. removeEmitRateGradient(gradient: number): IParticleSystem;
  86558. /**
  86559. * Gets the current list of emit rate gradients.
  86560. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86561. * @returns the list of emit rate gradients
  86562. */
  86563. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86564. /**
  86565. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86566. * @param gradient defines the gradient to use (between 0 and 1)
  86567. * @param factor defines the start size to affect to the specified gradient
  86568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86569. * @returns the current particle system
  86570. */
  86571. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86572. /**
  86573. * Remove a specific start size gradient
  86574. * @param gradient defines the gradient to remove
  86575. * @returns the current particle system
  86576. */
  86577. removeStartSizeGradient(gradient: number): IParticleSystem;
  86578. /**
  86579. * Gets the current list of start size gradients.
  86580. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86581. * @returns the list of start size gradients
  86582. */
  86583. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86584. /**
  86585. * Adds a new life time gradient
  86586. * @param gradient defines the gradient to use (between 0 and 1)
  86587. * @param factor defines the life time factor to affect to the specified gradient
  86588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86589. * @returns the current particle system
  86590. */
  86591. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86592. /**
  86593. * Remove a specific life time gradient
  86594. * @param gradient defines the gradient to remove
  86595. * @returns the current particle system
  86596. */
  86597. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86598. /**
  86599. * Gets the current list of life time gradients.
  86600. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86601. * @returns the list of life time gradients
  86602. */
  86603. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  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. * Adds a new ramp gradient used to remap particle colors
  86612. * @param gradient defines the gradient to use (between 0 and 1)
  86613. * @param color defines the color to affect to the specified gradient
  86614. * @returns the current particle system
  86615. */
  86616. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86617. /**
  86618. * Gets the current list of ramp gradients.
  86619. * You must use addRampGradient and removeRampGradient to udpate this list
  86620. * @returns the list of ramp gradients
  86621. */
  86622. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86623. /** Gets or sets a boolean indicating that ramp gradients must be used
  86624. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86625. */
  86626. useRampGradients: boolean;
  86627. /**
  86628. * Adds a new color remap gradient
  86629. * @param gradient defines the gradient to use (between 0 and 1)
  86630. * @param min defines the color remap minimal range
  86631. * @param max defines the color remap maximal range
  86632. * @returns the current particle system
  86633. */
  86634. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86635. /**
  86636. * Gets the current list of color remap gradients.
  86637. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86638. * @returns the list of color remap gradients
  86639. */
  86640. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86641. /**
  86642. * Adds a new alpha remap gradient
  86643. * @param gradient defines the gradient to use (between 0 and 1)
  86644. * @param min defines the alpha remap minimal range
  86645. * @param max defines the alpha remap maximal range
  86646. * @returns the current particle system
  86647. */
  86648. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86649. /**
  86650. * Gets the current list of alpha remap gradients.
  86651. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86652. * @returns the list of alpha remap gradients
  86653. */
  86654. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86655. /**
  86656. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86659. * @returns the emitter
  86660. */
  86661. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86662. /**
  86663. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86664. * @param radius The radius of the hemisphere to emit from
  86665. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86666. * @returns the emitter
  86667. */
  86668. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86669. /**
  86670. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86671. * @param radius The radius of the sphere to emit from
  86672. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86673. * @returns the emitter
  86674. */
  86675. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86676. /**
  86677. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86678. * @param radius The radius of the sphere to emit from
  86679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86681. * @returns the emitter
  86682. */
  86683. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86684. /**
  86685. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86686. * @param radius The radius of the emission cylinder
  86687. * @param height The height of the emission cylinder
  86688. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86689. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86690. * @returns the emitter
  86691. */
  86692. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86693. /**
  86694. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86695. * @param radius The radius of the cylinder to emit from
  86696. * @param height The height of the emission cylinder
  86697. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86698. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86699. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86700. * @returns the emitter
  86701. */
  86702. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86703. /**
  86704. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86705. * @param radius The radius of the cone to emit from
  86706. * @param angle The base angle of the cone
  86707. * @returns the emitter
  86708. */
  86709. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86710. /**
  86711. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86714. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86715. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86716. * @returns the emitter
  86717. */
  86718. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86719. /**
  86720. * Get hosting scene
  86721. * @returns the scene
  86722. */
  86723. getScene(): Scene;
  86724. }
  86725. }
  86726. declare module BABYLON {
  86727. /**
  86728. * 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.
  86729. * @see https://doc.babylonjs.com/how_to/transformnode
  86730. */
  86731. export class TransformNode extends Node {
  86732. /**
  86733. * Object will not rotate to face the camera
  86734. */
  86735. static BILLBOARDMODE_NONE: number;
  86736. /**
  86737. * Object will rotate to face the camera but only on the x axis
  86738. */
  86739. static BILLBOARDMODE_X: number;
  86740. /**
  86741. * Object will rotate to face the camera but only on the y axis
  86742. */
  86743. static BILLBOARDMODE_Y: number;
  86744. /**
  86745. * Object will rotate to face the camera but only on the z axis
  86746. */
  86747. static BILLBOARDMODE_Z: number;
  86748. /**
  86749. * Object will rotate to face the camera
  86750. */
  86751. static BILLBOARDMODE_ALL: number;
  86752. /**
  86753. * Object will rotate to face the camera's position instead of orientation
  86754. */
  86755. static BILLBOARDMODE_USE_POSITION: number;
  86756. private _forward;
  86757. private _forwardInverted;
  86758. private _up;
  86759. private _right;
  86760. private _rightInverted;
  86761. private _position;
  86762. private _rotation;
  86763. private _rotationQuaternion;
  86764. protected _scaling: Vector3;
  86765. protected _isDirty: boolean;
  86766. private _transformToBoneReferal;
  86767. private _isAbsoluteSynced;
  86768. private _billboardMode;
  86769. /**
  86770. * Gets or sets the billboard mode. Default is 0.
  86771. *
  86772. * | Value | Type | Description |
  86773. * | --- | --- | --- |
  86774. * | 0 | BILLBOARDMODE_NONE | |
  86775. * | 1 | BILLBOARDMODE_X | |
  86776. * | 2 | BILLBOARDMODE_Y | |
  86777. * | 4 | BILLBOARDMODE_Z | |
  86778. * | 7 | BILLBOARDMODE_ALL | |
  86779. *
  86780. */
  86781. get billboardMode(): number;
  86782. set billboardMode(value: number);
  86783. private _preserveParentRotationForBillboard;
  86784. /**
  86785. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86786. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86787. */
  86788. get preserveParentRotationForBillboard(): boolean;
  86789. set preserveParentRotationForBillboard(value: boolean);
  86790. /**
  86791. * 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
  86792. */
  86793. scalingDeterminant: number;
  86794. private _infiniteDistance;
  86795. /**
  86796. * Gets or sets the distance of the object to max, often used by skybox
  86797. */
  86798. get infiniteDistance(): boolean;
  86799. set infiniteDistance(value: boolean);
  86800. /**
  86801. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86802. * By default the system will update normals to compensate
  86803. */
  86804. ignoreNonUniformScaling: boolean;
  86805. /**
  86806. * 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
  86807. */
  86808. reIntegrateRotationIntoRotationQuaternion: boolean;
  86809. /** @hidden */
  86810. _poseMatrix: Nullable<Matrix>;
  86811. /** @hidden */
  86812. _localMatrix: Matrix;
  86813. private _usePivotMatrix;
  86814. private _absolutePosition;
  86815. private _absoluteScaling;
  86816. private _absoluteRotationQuaternion;
  86817. private _pivotMatrix;
  86818. private _pivotMatrixInverse;
  86819. protected _postMultiplyPivotMatrix: boolean;
  86820. protected _isWorldMatrixFrozen: boolean;
  86821. /** @hidden */
  86822. _indexInSceneTransformNodesArray: number;
  86823. /**
  86824. * An event triggered after the world matrix is updated
  86825. */
  86826. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86827. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86828. /**
  86829. * Gets a string identifying the name of the class
  86830. * @returns "TransformNode" string
  86831. */
  86832. getClassName(): string;
  86833. /**
  86834. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86835. */
  86836. get position(): Vector3;
  86837. set position(newPosition: Vector3);
  86838. /**
  86839. * 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)).
  86840. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86841. */
  86842. get rotation(): Vector3;
  86843. set rotation(newRotation: Vector3);
  86844. /**
  86845. * 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)).
  86846. */
  86847. get scaling(): Vector3;
  86848. set scaling(newScaling: Vector3);
  86849. /**
  86850. * 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).
  86851. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86852. */
  86853. get rotationQuaternion(): Nullable<Quaternion>;
  86854. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86855. /**
  86856. * The forward direction of that transform in world space.
  86857. */
  86858. get forward(): Vector3;
  86859. /**
  86860. * The up direction of that transform in world space.
  86861. */
  86862. get up(): Vector3;
  86863. /**
  86864. * The right direction of that transform in world space.
  86865. */
  86866. get right(): Vector3;
  86867. /**
  86868. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86869. * @param matrix the matrix to copy the pose from
  86870. * @returns this TransformNode.
  86871. */
  86872. updatePoseMatrix(matrix: Matrix): TransformNode;
  86873. /**
  86874. * Returns the mesh Pose matrix.
  86875. * @returns the pose matrix
  86876. */
  86877. getPoseMatrix(): Matrix;
  86878. /** @hidden */
  86879. _isSynchronized(): boolean;
  86880. /** @hidden */
  86881. _initCache(): void;
  86882. /**
  86883. * Flag the transform node as dirty (Forcing it to update everything)
  86884. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86885. * @returns this transform node
  86886. */
  86887. markAsDirty(property: string): TransformNode;
  86888. /**
  86889. * Returns the current mesh absolute position.
  86890. * Returns a Vector3.
  86891. */
  86892. get absolutePosition(): Vector3;
  86893. /**
  86894. * Returns the current mesh absolute scaling.
  86895. * Returns a Vector3.
  86896. */
  86897. get absoluteScaling(): Vector3;
  86898. /**
  86899. * Returns the current mesh absolute rotation.
  86900. * Returns a Quaternion.
  86901. */
  86902. get absoluteRotationQuaternion(): Quaternion;
  86903. /**
  86904. * Sets a new matrix to apply before all other transformation
  86905. * @param matrix defines the transform matrix
  86906. * @returns the current TransformNode
  86907. */
  86908. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86909. /**
  86910. * Sets a new pivot matrix to the current node
  86911. * @param matrix defines the new pivot matrix to use
  86912. * @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
  86913. * @returns the current TransformNode
  86914. */
  86915. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86916. /**
  86917. * Returns the mesh pivot matrix.
  86918. * Default : Identity.
  86919. * @returns the matrix
  86920. */
  86921. getPivotMatrix(): Matrix;
  86922. /**
  86923. * Instantiate (when possible) or clone that node with its hierarchy
  86924. * @param newParent defines the new parent to use for the instance (or clone)
  86925. * @param options defines options to configure how copy is done
  86926. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86927. * @returns an instance (or a clone) of the current node with its hiearchy
  86928. */
  86929. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86930. doNotInstantiate: boolean;
  86931. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86932. /**
  86933. * Prevents the World matrix to be computed any longer
  86934. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86935. * @returns the TransformNode.
  86936. */
  86937. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86938. /**
  86939. * Allows back the World matrix computation.
  86940. * @returns the TransformNode.
  86941. */
  86942. unfreezeWorldMatrix(): this;
  86943. /**
  86944. * True if the World matrix has been frozen.
  86945. */
  86946. get isWorldMatrixFrozen(): boolean;
  86947. /**
  86948. * Retuns the mesh absolute position in the World.
  86949. * @returns a Vector3.
  86950. */
  86951. getAbsolutePosition(): Vector3;
  86952. /**
  86953. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86954. * @param absolutePosition the absolute position to set
  86955. * @returns the TransformNode.
  86956. */
  86957. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86958. /**
  86959. * Sets the mesh position in its local space.
  86960. * @param vector3 the position to set in localspace
  86961. * @returns the TransformNode.
  86962. */
  86963. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86964. /**
  86965. * Returns the mesh position in the local space from the current World matrix values.
  86966. * @returns a new Vector3.
  86967. */
  86968. getPositionExpressedInLocalSpace(): Vector3;
  86969. /**
  86970. * Translates the mesh along the passed Vector3 in its local space.
  86971. * @param vector3 the distance to translate in localspace
  86972. * @returns the TransformNode.
  86973. */
  86974. locallyTranslate(vector3: Vector3): TransformNode;
  86975. private static _lookAtVectorCache;
  86976. /**
  86977. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86978. * @param targetPoint the position (must be in same space as current mesh) to look at
  86979. * @param yawCor optional yaw (y-axis) correction in radians
  86980. * @param pitchCor optional pitch (x-axis) correction in radians
  86981. * @param rollCor optional roll (z-axis) correction in radians
  86982. * @param space the choosen space of the target
  86983. * @returns the TransformNode.
  86984. */
  86985. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86986. /**
  86987. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86988. * This Vector3 is expressed in the World space.
  86989. * @param localAxis axis to rotate
  86990. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86991. */
  86992. getDirection(localAxis: Vector3): Vector3;
  86993. /**
  86994. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86995. * localAxis is expressed in the mesh local space.
  86996. * result is computed in the Wordl space from the mesh World matrix.
  86997. * @param localAxis axis to rotate
  86998. * @param result the resulting transformnode
  86999. * @returns this TransformNode.
  87000. */
  87001. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87002. /**
  87003. * Sets this transform node rotation to the given local axis.
  87004. * @param localAxis the axis in local space
  87005. * @param yawCor optional yaw (y-axis) correction in radians
  87006. * @param pitchCor optional pitch (x-axis) correction in radians
  87007. * @param rollCor optional roll (z-axis) correction in radians
  87008. * @returns this TransformNode
  87009. */
  87010. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87011. /**
  87012. * Sets a new pivot point to the current node
  87013. * @param point defines the new pivot point to use
  87014. * @param space defines if the point is in world or local space (local by default)
  87015. * @returns the current TransformNode
  87016. */
  87017. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87018. /**
  87019. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87020. * @returns the pivot point
  87021. */
  87022. getPivotPoint(): Vector3;
  87023. /**
  87024. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87025. * @param result the vector3 to store the result
  87026. * @returns this TransformNode.
  87027. */
  87028. getPivotPointToRef(result: Vector3): TransformNode;
  87029. /**
  87030. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87031. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87032. */
  87033. getAbsolutePivotPoint(): Vector3;
  87034. /**
  87035. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87036. * @param result vector3 to store the result
  87037. * @returns this TransformNode.
  87038. */
  87039. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87040. /**
  87041. * Defines the passed node as the parent of the current node.
  87042. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87043. * @see https://doc.babylonjs.com/how_to/parenting
  87044. * @param node the node ot set as the parent
  87045. * @returns this TransformNode.
  87046. */
  87047. setParent(node: Nullable<Node>): TransformNode;
  87048. private _nonUniformScaling;
  87049. /**
  87050. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87051. */
  87052. get nonUniformScaling(): boolean;
  87053. /** @hidden */
  87054. _updateNonUniformScalingState(value: boolean): boolean;
  87055. /**
  87056. * Attach the current TransformNode to another TransformNode associated with a bone
  87057. * @param bone Bone affecting the TransformNode
  87058. * @param affectedTransformNode TransformNode associated with the bone
  87059. * @returns this object
  87060. */
  87061. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87062. /**
  87063. * Detach the transform node if its associated with a bone
  87064. * @returns this object
  87065. */
  87066. detachFromBone(): TransformNode;
  87067. private static _rotationAxisCache;
  87068. /**
  87069. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87070. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87071. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87072. * The passed axis is also normalized.
  87073. * @param axis the axis to rotate around
  87074. * @param amount the amount to rotate in radians
  87075. * @param space Space to rotate in (Default: local)
  87076. * @returns the TransformNode.
  87077. */
  87078. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87079. /**
  87080. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87081. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87082. * The passed axis is also normalized. .
  87083. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87084. * @param point the point to rotate around
  87085. * @param axis the axis to rotate around
  87086. * @param amount the amount to rotate in radians
  87087. * @returns the TransformNode
  87088. */
  87089. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87090. /**
  87091. * Translates the mesh along the axis vector for the passed distance in the given space.
  87092. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87093. * @param axis the axis to translate in
  87094. * @param distance the distance to translate
  87095. * @param space Space to rotate in (Default: local)
  87096. * @returns the TransformNode.
  87097. */
  87098. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87099. /**
  87100. * Adds a rotation step to the mesh current rotation.
  87101. * x, y, z are Euler angles expressed in radians.
  87102. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87103. * This means this rotation is made in the mesh local space only.
  87104. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87105. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87106. * ```javascript
  87107. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87108. * ```
  87109. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87110. * 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.
  87111. * @param x Rotation to add
  87112. * @param y Rotation to add
  87113. * @param z Rotation to add
  87114. * @returns the TransformNode.
  87115. */
  87116. addRotation(x: number, y: number, z: number): TransformNode;
  87117. /**
  87118. * @hidden
  87119. */
  87120. protected _getEffectiveParent(): Nullable<Node>;
  87121. /**
  87122. * Computes the world matrix of the node
  87123. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87124. * @returns the world matrix
  87125. */
  87126. computeWorldMatrix(force?: boolean): Matrix;
  87127. /**
  87128. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87129. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87130. */
  87131. resetLocalMatrix(independentOfChildren?: boolean): void;
  87132. protected _afterComputeWorldMatrix(): void;
  87133. /**
  87134. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87135. * @param func callback function to add
  87136. *
  87137. * @returns the TransformNode.
  87138. */
  87139. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87140. /**
  87141. * Removes a registered callback function.
  87142. * @param func callback function to remove
  87143. * @returns the TransformNode.
  87144. */
  87145. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87146. /**
  87147. * Gets the position of the current mesh in camera space
  87148. * @param camera defines the camera to use
  87149. * @returns a position
  87150. */
  87151. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87152. /**
  87153. * Returns the distance from the mesh to the active camera
  87154. * @param camera defines the camera to use
  87155. * @returns the distance
  87156. */
  87157. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87158. /**
  87159. * Clone the current transform node
  87160. * @param name Name of the new clone
  87161. * @param newParent New parent for the clone
  87162. * @param doNotCloneChildren Do not clone children hierarchy
  87163. * @returns the new transform node
  87164. */
  87165. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87166. /**
  87167. * Serializes the objects information.
  87168. * @param currentSerializationObject defines the object to serialize in
  87169. * @returns the serialized object
  87170. */
  87171. serialize(currentSerializationObject?: any): any;
  87172. /**
  87173. * Returns a new TransformNode object parsed from the source provided.
  87174. * @param parsedTransformNode is the source.
  87175. * @param scene the scne the object belongs to
  87176. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87177. * @returns a new TransformNode object parsed from the source provided.
  87178. */
  87179. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87180. /**
  87181. * Get all child-transformNodes of this node
  87182. * @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
  87183. * @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
  87184. * @returns an array of TransformNode
  87185. */
  87186. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87187. /**
  87188. * Releases resources associated with this transform node.
  87189. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87190. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87191. */
  87192. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87193. /**
  87194. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87195. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87196. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87197. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87198. * @returns the current mesh
  87199. */
  87200. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87201. private _syncAbsoluteScalingAndRotation;
  87202. }
  87203. }
  87204. declare module BABYLON {
  87205. /**
  87206. * Class used to override all child animations of a given target
  87207. */
  87208. export class AnimationPropertiesOverride {
  87209. /**
  87210. * Gets or sets a value indicating if animation blending must be used
  87211. */
  87212. enableBlending: boolean;
  87213. /**
  87214. * Gets or sets the blending speed to use when enableBlending is true
  87215. */
  87216. blendingSpeed: number;
  87217. /**
  87218. * Gets or sets the default loop mode to use
  87219. */
  87220. loopMode: number;
  87221. }
  87222. }
  87223. declare module BABYLON {
  87224. /**
  87225. * Class used to store bone information
  87226. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87227. */
  87228. export class Bone extends Node {
  87229. /**
  87230. * defines the bone name
  87231. */
  87232. name: string;
  87233. private static _tmpVecs;
  87234. private static _tmpQuat;
  87235. private static _tmpMats;
  87236. /**
  87237. * Gets the list of child bones
  87238. */
  87239. children: Bone[];
  87240. /** Gets the animations associated with this bone */
  87241. animations: Animation[];
  87242. /**
  87243. * Gets or sets bone length
  87244. */
  87245. length: number;
  87246. /**
  87247. * @hidden Internal only
  87248. * Set this value to map this bone to a different index in the transform matrices
  87249. * Set this value to -1 to exclude the bone from the transform matrices
  87250. */
  87251. _index: Nullable<number>;
  87252. private _skeleton;
  87253. private _localMatrix;
  87254. private _restPose;
  87255. private _baseMatrix;
  87256. private _absoluteTransform;
  87257. private _invertedAbsoluteTransform;
  87258. private _parent;
  87259. private _scalingDeterminant;
  87260. private _worldTransform;
  87261. private _localScaling;
  87262. private _localRotation;
  87263. private _localPosition;
  87264. private _needToDecompose;
  87265. private _needToCompose;
  87266. /** @hidden */
  87267. _linkedTransformNode: Nullable<TransformNode>;
  87268. /** @hidden */
  87269. _waitingTransformNodeId: Nullable<string>;
  87270. /** @hidden */
  87271. get _matrix(): Matrix;
  87272. /** @hidden */
  87273. set _matrix(value: Matrix);
  87274. /**
  87275. * Create a new bone
  87276. * @param name defines the bone name
  87277. * @param skeleton defines the parent skeleton
  87278. * @param parentBone defines the parent (can be null if the bone is the root)
  87279. * @param localMatrix defines the local matrix
  87280. * @param restPose defines the rest pose matrix
  87281. * @param baseMatrix defines the base matrix
  87282. * @param index defines index of the bone in the hiearchy
  87283. */
  87284. constructor(
  87285. /**
  87286. * defines the bone name
  87287. */
  87288. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87289. /**
  87290. * Gets the current object class name.
  87291. * @return the class name
  87292. */
  87293. getClassName(): string;
  87294. /**
  87295. * Gets the parent skeleton
  87296. * @returns a skeleton
  87297. */
  87298. getSkeleton(): Skeleton;
  87299. /**
  87300. * Gets parent bone
  87301. * @returns a bone or null if the bone is the root of the bone hierarchy
  87302. */
  87303. getParent(): Nullable<Bone>;
  87304. /**
  87305. * Returns an array containing the root bones
  87306. * @returns an array containing the root bones
  87307. */
  87308. getChildren(): Array<Bone>;
  87309. /**
  87310. * Gets the node index in matrix array generated for rendering
  87311. * @returns the node index
  87312. */
  87313. getIndex(): number;
  87314. /**
  87315. * Sets the parent bone
  87316. * @param parent defines the parent (can be null if the bone is the root)
  87317. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87318. */
  87319. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87320. /**
  87321. * Gets the local matrix
  87322. * @returns a matrix
  87323. */
  87324. getLocalMatrix(): Matrix;
  87325. /**
  87326. * Gets the base matrix (initial matrix which remains unchanged)
  87327. * @returns a matrix
  87328. */
  87329. getBaseMatrix(): Matrix;
  87330. /**
  87331. * Gets the rest pose matrix
  87332. * @returns a matrix
  87333. */
  87334. getRestPose(): Matrix;
  87335. /**
  87336. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87337. */
  87338. getWorldMatrix(): Matrix;
  87339. /**
  87340. * Sets the local matrix to rest pose matrix
  87341. */
  87342. returnToRest(): void;
  87343. /**
  87344. * Gets the inverse of the absolute transform matrix.
  87345. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87346. * @returns a matrix
  87347. */
  87348. getInvertedAbsoluteTransform(): Matrix;
  87349. /**
  87350. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87351. * @returns a matrix
  87352. */
  87353. getAbsoluteTransform(): Matrix;
  87354. /**
  87355. * Links with the given transform node.
  87356. * The local matrix of this bone is copied from the transform node every frame.
  87357. * @param transformNode defines the transform node to link to
  87358. */
  87359. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87360. /**
  87361. * Gets the node used to drive the bone's transformation
  87362. * @returns a transform node or null
  87363. */
  87364. getTransformNode(): Nullable<TransformNode>;
  87365. /** Gets or sets current position (in local space) */
  87366. get position(): Vector3;
  87367. set position(newPosition: Vector3);
  87368. /** Gets or sets current rotation (in local space) */
  87369. get rotation(): Vector3;
  87370. set rotation(newRotation: Vector3);
  87371. /** Gets or sets current rotation quaternion (in local space) */
  87372. get rotationQuaternion(): Quaternion;
  87373. set rotationQuaternion(newRotation: Quaternion);
  87374. /** Gets or sets current scaling (in local space) */
  87375. get scaling(): Vector3;
  87376. set scaling(newScaling: Vector3);
  87377. /**
  87378. * Gets the animation properties override
  87379. */
  87380. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87381. private _decompose;
  87382. private _compose;
  87383. /**
  87384. * Update the base and local matrices
  87385. * @param matrix defines the new base or local matrix
  87386. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87387. * @param updateLocalMatrix defines if the local matrix should be updated
  87388. */
  87389. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87390. /** @hidden */
  87391. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87392. /**
  87393. * Flag the bone as dirty (Forcing it to update everything)
  87394. */
  87395. markAsDirty(): void;
  87396. /** @hidden */
  87397. _markAsDirtyAndCompose(): void;
  87398. private _markAsDirtyAndDecompose;
  87399. /**
  87400. * Translate the bone in local or world space
  87401. * @param vec The amount to translate the bone
  87402. * @param space The space that the translation is in
  87403. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87404. */
  87405. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87406. /**
  87407. * Set the postion of the bone in local or world space
  87408. * @param position The position to set the bone
  87409. * @param space The space that the position is in
  87410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87411. */
  87412. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87413. /**
  87414. * Set the absolute position of the bone (world space)
  87415. * @param position The position to set the bone
  87416. * @param mesh The mesh that this bone is attached to
  87417. */
  87418. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87419. /**
  87420. * Scale the bone on the x, y and z axes (in local space)
  87421. * @param x The amount to scale the bone on the x axis
  87422. * @param y The amount to scale the bone on the y axis
  87423. * @param z The amount to scale the bone on the z axis
  87424. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87425. */
  87426. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87427. /**
  87428. * Set the bone scaling in local space
  87429. * @param scale defines the scaling vector
  87430. */
  87431. setScale(scale: Vector3): void;
  87432. /**
  87433. * Gets the current scaling in local space
  87434. * @returns the current scaling vector
  87435. */
  87436. getScale(): Vector3;
  87437. /**
  87438. * Gets the current scaling in local space and stores it in a target vector
  87439. * @param result defines the target vector
  87440. */
  87441. getScaleToRef(result: Vector3): void;
  87442. /**
  87443. * Set the yaw, pitch, and roll of the bone in local or world space
  87444. * @param yaw The rotation of the bone on the y axis
  87445. * @param pitch The rotation of the bone on the x axis
  87446. * @param roll The rotation of the bone on the z axis
  87447. * @param space The space that the axes of rotation are in
  87448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87449. */
  87450. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87451. /**
  87452. * Add a rotation to the bone on an axis in local or world space
  87453. * @param axis The axis to rotate the bone on
  87454. * @param amount The amount to rotate the bone
  87455. * @param space The space that the axis is in
  87456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87457. */
  87458. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87459. /**
  87460. * Set the rotation of the bone to a particular axis angle in local or world space
  87461. * @param axis The axis to rotate the bone on
  87462. * @param angle The angle that the bone should be rotated to
  87463. * @param space The space that the axis is in
  87464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87465. */
  87466. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87467. /**
  87468. * Set the euler rotation of the bone in local of world space
  87469. * @param rotation The euler rotation that the bone should be set to
  87470. * @param space The space that the rotation is in
  87471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87472. */
  87473. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87474. /**
  87475. * Set the quaternion rotation of the bone in local of world space
  87476. * @param quat The quaternion rotation that the bone should be set to
  87477. * @param space The space that the rotation is in
  87478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87479. */
  87480. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87481. /**
  87482. * Set the rotation matrix of the bone in local of world space
  87483. * @param rotMat The rotation matrix that the bone should be set to
  87484. * @param space The space that the rotation is in
  87485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87486. */
  87487. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87488. private _rotateWithMatrix;
  87489. private _getNegativeRotationToRef;
  87490. /**
  87491. * Get the position of the bone in local or world space
  87492. * @param space The space that the returned position is in
  87493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87494. * @returns The position of the bone
  87495. */
  87496. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87497. /**
  87498. * Copy the position of the bone to a vector3 in local or world space
  87499. * @param space The space that the returned position is in
  87500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87501. * @param result The vector3 to copy the position to
  87502. */
  87503. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87504. /**
  87505. * Get the absolute position of the bone (world space)
  87506. * @param mesh The mesh that this bone is attached to
  87507. * @returns The absolute position of the bone
  87508. */
  87509. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87510. /**
  87511. * Copy the absolute position of the bone (world space) to the result param
  87512. * @param mesh The mesh that this bone is attached to
  87513. * @param result The vector3 to copy the absolute position to
  87514. */
  87515. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87516. /**
  87517. * Compute the absolute transforms of this bone and its children
  87518. */
  87519. computeAbsoluteTransforms(): void;
  87520. /**
  87521. * Get the world direction from an axis that is in the local space of the bone
  87522. * @param localAxis The local direction that is used to compute the world direction
  87523. * @param mesh The mesh that this bone is attached to
  87524. * @returns The world direction
  87525. */
  87526. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87527. /**
  87528. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87529. * @param localAxis The local direction that is used to compute the world direction
  87530. * @param mesh The mesh that this bone is attached to
  87531. * @param result The vector3 that the world direction will be copied to
  87532. */
  87533. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87534. /**
  87535. * Get the euler rotation of the bone in local or world space
  87536. * @param space The space that the rotation should be in
  87537. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87538. * @returns The euler rotation
  87539. */
  87540. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87541. /**
  87542. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87543. * @param space The space that the rotation should be in
  87544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87545. * @param result The vector3 that the rotation should be copied to
  87546. */
  87547. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87548. /**
  87549. * Get the quaternion rotation of the bone in either local or world space
  87550. * @param space The space that the rotation should be in
  87551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87552. * @returns The quaternion rotation
  87553. */
  87554. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87555. /**
  87556. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87557. * @param space The space that the rotation should be in
  87558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87559. * @param result The quaternion that the rotation should be copied to
  87560. */
  87561. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87562. /**
  87563. * Get the rotation matrix of the bone in local or world space
  87564. * @param space The space that the rotation should be in
  87565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87566. * @returns The rotation matrix
  87567. */
  87568. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87569. /**
  87570. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87571. * @param space The space that the rotation should be in
  87572. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87573. * @param result The quaternion that the rotation should be copied to
  87574. */
  87575. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87576. /**
  87577. * Get the world position of a point that is in the local space of the bone
  87578. * @param position The local position
  87579. * @param mesh The mesh that this bone is attached to
  87580. * @returns The world position
  87581. */
  87582. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87583. /**
  87584. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87585. * @param position The local position
  87586. * @param mesh The mesh that this bone is attached to
  87587. * @param result The vector3 that the world position should be copied to
  87588. */
  87589. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87590. /**
  87591. * Get the local position of a point that is in world space
  87592. * @param position The world position
  87593. * @param mesh The mesh that this bone is attached to
  87594. * @returns The local position
  87595. */
  87596. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87597. /**
  87598. * Get the local position of a point that is in world space and copy it to the result param
  87599. * @param position The world position
  87600. * @param mesh The mesh that this bone is attached to
  87601. * @param result The vector3 that the local position should be copied to
  87602. */
  87603. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87604. }
  87605. }
  87606. declare module BABYLON {
  87607. /**
  87608. * Defines a runtime animation
  87609. */
  87610. export class RuntimeAnimation {
  87611. private _events;
  87612. /**
  87613. * The current frame of the runtime animation
  87614. */
  87615. private _currentFrame;
  87616. /**
  87617. * The animation used by the runtime animation
  87618. */
  87619. private _animation;
  87620. /**
  87621. * The target of the runtime animation
  87622. */
  87623. private _target;
  87624. /**
  87625. * The initiating animatable
  87626. */
  87627. private _host;
  87628. /**
  87629. * The original value of the runtime animation
  87630. */
  87631. private _originalValue;
  87632. /**
  87633. * The original blend value of the runtime animation
  87634. */
  87635. private _originalBlendValue;
  87636. /**
  87637. * The offsets cache of the runtime animation
  87638. */
  87639. private _offsetsCache;
  87640. /**
  87641. * The high limits cache of the runtime animation
  87642. */
  87643. private _highLimitsCache;
  87644. /**
  87645. * Specifies if the runtime animation has been stopped
  87646. */
  87647. private _stopped;
  87648. /**
  87649. * The blending factor of the runtime animation
  87650. */
  87651. private _blendingFactor;
  87652. /**
  87653. * The BabylonJS scene
  87654. */
  87655. private _scene;
  87656. /**
  87657. * The current value of the runtime animation
  87658. */
  87659. private _currentValue;
  87660. /** @hidden */
  87661. _animationState: _IAnimationState;
  87662. /**
  87663. * The active target of the runtime animation
  87664. */
  87665. private _activeTargets;
  87666. private _currentActiveTarget;
  87667. private _directTarget;
  87668. /**
  87669. * The target path of the runtime animation
  87670. */
  87671. private _targetPath;
  87672. /**
  87673. * The weight of the runtime animation
  87674. */
  87675. private _weight;
  87676. /**
  87677. * The ratio offset of the runtime animation
  87678. */
  87679. private _ratioOffset;
  87680. /**
  87681. * The previous delay of the runtime animation
  87682. */
  87683. private _previousDelay;
  87684. /**
  87685. * The previous ratio of the runtime animation
  87686. */
  87687. private _previousRatio;
  87688. private _enableBlending;
  87689. private _keys;
  87690. private _minFrame;
  87691. private _maxFrame;
  87692. private _minValue;
  87693. private _maxValue;
  87694. private _targetIsArray;
  87695. /**
  87696. * Gets the current frame of the runtime animation
  87697. */
  87698. get currentFrame(): number;
  87699. /**
  87700. * Gets the weight of the runtime animation
  87701. */
  87702. get weight(): number;
  87703. /**
  87704. * Gets the current value of the runtime animation
  87705. */
  87706. get currentValue(): any;
  87707. /**
  87708. * Gets the target path of the runtime animation
  87709. */
  87710. get targetPath(): string;
  87711. /**
  87712. * Gets the actual target of the runtime animation
  87713. */
  87714. get target(): any;
  87715. /** @hidden */
  87716. _onLoop: () => void;
  87717. /**
  87718. * Create a new RuntimeAnimation object
  87719. * @param target defines the target of the animation
  87720. * @param animation defines the source animation object
  87721. * @param scene defines the hosting scene
  87722. * @param host defines the initiating Animatable
  87723. */
  87724. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87725. private _preparePath;
  87726. /**
  87727. * Gets the animation from the runtime animation
  87728. */
  87729. get animation(): Animation;
  87730. /**
  87731. * Resets the runtime animation to the beginning
  87732. * @param restoreOriginal defines whether to restore the target property to the original value
  87733. */
  87734. reset(restoreOriginal?: boolean): void;
  87735. /**
  87736. * Specifies if the runtime animation is stopped
  87737. * @returns Boolean specifying if the runtime animation is stopped
  87738. */
  87739. isStopped(): boolean;
  87740. /**
  87741. * Disposes of the runtime animation
  87742. */
  87743. dispose(): void;
  87744. /**
  87745. * Apply the interpolated value to the target
  87746. * @param currentValue defines the value computed by the animation
  87747. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87748. */
  87749. setValue(currentValue: any, weight: number): void;
  87750. private _getOriginalValues;
  87751. private _setValue;
  87752. /**
  87753. * Gets the loop pmode of the runtime animation
  87754. * @returns Loop Mode
  87755. */
  87756. private _getCorrectLoopMode;
  87757. /**
  87758. * Move the current animation to a given frame
  87759. * @param frame defines the frame to move to
  87760. */
  87761. goToFrame(frame: number): void;
  87762. /**
  87763. * @hidden Internal use only
  87764. */
  87765. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87766. /**
  87767. * Execute the current animation
  87768. * @param delay defines the delay to add to the current frame
  87769. * @param from defines the lower bound of the animation range
  87770. * @param to defines the upper bound of the animation range
  87771. * @param loop defines if the current animation must loop
  87772. * @param speedRatio defines the current speed ratio
  87773. * @param weight defines the weight of the animation (default is -1 so no weight)
  87774. * @param onLoop optional callback called when animation loops
  87775. * @returns a boolean indicating if the animation is running
  87776. */
  87777. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87778. }
  87779. }
  87780. declare module BABYLON {
  87781. /**
  87782. * Class used to store an actual running animation
  87783. */
  87784. export class Animatable {
  87785. /** defines the target object */
  87786. target: any;
  87787. /** defines the starting frame number (default is 0) */
  87788. fromFrame: number;
  87789. /** defines the ending frame number (default is 100) */
  87790. toFrame: number;
  87791. /** defines if the animation must loop (default is false) */
  87792. loopAnimation: boolean;
  87793. /** defines a callback to call when animation ends if it is not looping */
  87794. onAnimationEnd?: (() => void) | null | undefined;
  87795. /** defines a callback to call when animation loops */
  87796. onAnimationLoop?: (() => void) | null | undefined;
  87797. private _localDelayOffset;
  87798. private _pausedDelay;
  87799. private _runtimeAnimations;
  87800. private _paused;
  87801. private _scene;
  87802. private _speedRatio;
  87803. private _weight;
  87804. private _syncRoot;
  87805. /**
  87806. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87807. * This will only apply for non looping animation (default is true)
  87808. */
  87809. disposeOnEnd: boolean;
  87810. /**
  87811. * Gets a boolean indicating if the animation has started
  87812. */
  87813. animationStarted: boolean;
  87814. /**
  87815. * Observer raised when the animation ends
  87816. */
  87817. onAnimationEndObservable: Observable<Animatable>;
  87818. /**
  87819. * Observer raised when the animation loops
  87820. */
  87821. onAnimationLoopObservable: Observable<Animatable>;
  87822. /**
  87823. * Gets the root Animatable used to synchronize and normalize animations
  87824. */
  87825. get syncRoot(): Nullable<Animatable>;
  87826. /**
  87827. * Gets the current frame of the first RuntimeAnimation
  87828. * Used to synchronize Animatables
  87829. */
  87830. get masterFrame(): number;
  87831. /**
  87832. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87833. */
  87834. get weight(): number;
  87835. set weight(value: number);
  87836. /**
  87837. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87838. */
  87839. get speedRatio(): number;
  87840. set speedRatio(value: number);
  87841. /**
  87842. * Creates a new Animatable
  87843. * @param scene defines the hosting scene
  87844. * @param target defines the target object
  87845. * @param fromFrame defines the starting frame number (default is 0)
  87846. * @param toFrame defines the ending frame number (default is 100)
  87847. * @param loopAnimation defines if the animation must loop (default is false)
  87848. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87849. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87850. * @param animations defines a group of animation to add to the new Animatable
  87851. * @param onAnimationLoop defines a callback to call when animation loops
  87852. */
  87853. constructor(scene: Scene,
  87854. /** defines the target object */
  87855. target: any,
  87856. /** defines the starting frame number (default is 0) */
  87857. fromFrame?: number,
  87858. /** defines the ending frame number (default is 100) */
  87859. toFrame?: number,
  87860. /** defines if the animation must loop (default is false) */
  87861. loopAnimation?: boolean, speedRatio?: number,
  87862. /** defines a callback to call when animation ends if it is not looping */
  87863. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87864. /** defines a callback to call when animation loops */
  87865. onAnimationLoop?: (() => void) | null | undefined);
  87866. /**
  87867. * Synchronize and normalize current Animatable with a source Animatable
  87868. * This is useful when using animation weights and when animations are not of the same length
  87869. * @param root defines the root Animatable to synchronize with
  87870. * @returns the current Animatable
  87871. */
  87872. syncWith(root: Animatable): Animatable;
  87873. /**
  87874. * Gets the list of runtime animations
  87875. * @returns an array of RuntimeAnimation
  87876. */
  87877. getAnimations(): RuntimeAnimation[];
  87878. /**
  87879. * Adds more animations to the current animatable
  87880. * @param target defines the target of the animations
  87881. * @param animations defines the new animations to add
  87882. */
  87883. appendAnimations(target: any, animations: Animation[]): void;
  87884. /**
  87885. * Gets the source animation for a specific property
  87886. * @param property defines the propertyu to look for
  87887. * @returns null or the source animation for the given property
  87888. */
  87889. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87890. /**
  87891. * Gets the runtime animation for a specific property
  87892. * @param property defines the propertyu to look for
  87893. * @returns null or the runtime animation for the given property
  87894. */
  87895. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87896. /**
  87897. * Resets the animatable to its original state
  87898. */
  87899. reset(): void;
  87900. /**
  87901. * Allows the animatable to blend with current running animations
  87902. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87903. * @param blendingSpeed defines the blending speed to use
  87904. */
  87905. enableBlending(blendingSpeed: number): void;
  87906. /**
  87907. * Disable animation blending
  87908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87909. */
  87910. disableBlending(): void;
  87911. /**
  87912. * Jump directly to a given frame
  87913. * @param frame defines the frame to jump to
  87914. */
  87915. goToFrame(frame: number): void;
  87916. /**
  87917. * Pause the animation
  87918. */
  87919. pause(): void;
  87920. /**
  87921. * Restart the animation
  87922. */
  87923. restart(): void;
  87924. private _raiseOnAnimationEnd;
  87925. /**
  87926. * Stop and delete the current animation
  87927. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87928. * @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)
  87929. */
  87930. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87931. /**
  87932. * Wait asynchronously for the animation to end
  87933. * @returns a promise which will be fullfilled when the animation ends
  87934. */
  87935. waitAsync(): Promise<Animatable>;
  87936. /** @hidden */
  87937. _animate(delay: number): boolean;
  87938. }
  87939. interface Scene {
  87940. /** @hidden */
  87941. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87942. /** @hidden */
  87943. _processLateAnimationBindingsForMatrices(holder: {
  87944. totalWeight: number;
  87945. animations: RuntimeAnimation[];
  87946. originalValue: Matrix;
  87947. }): any;
  87948. /** @hidden */
  87949. _processLateAnimationBindingsForQuaternions(holder: {
  87950. totalWeight: number;
  87951. animations: RuntimeAnimation[];
  87952. originalValue: Quaternion;
  87953. }, refQuaternion: Quaternion): Quaternion;
  87954. /** @hidden */
  87955. _processLateAnimationBindings(): void;
  87956. /**
  87957. * Will start the animation sequence of a given target
  87958. * @param target defines the target
  87959. * @param from defines from which frame should animation start
  87960. * @param to defines until which frame should animation run.
  87961. * @param weight defines the weight to apply to the animation (1.0 by default)
  87962. * @param loop defines if the animation loops
  87963. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87964. * @param onAnimationEnd defines the function to be executed when the animation ends
  87965. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87966. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87967. * @param onAnimationLoop defines the callback to call when an animation loops
  87968. * @returns the animatable object created for this animation
  87969. */
  87970. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87971. /**
  87972. * Will start the animation sequence of a given target
  87973. * @param target defines the target
  87974. * @param from defines from which frame should animation start
  87975. * @param to defines until which frame should animation run.
  87976. * @param loop defines if the animation loops
  87977. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87978. * @param onAnimationEnd defines the function to be executed when the animation ends
  87979. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87980. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87981. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87982. * @param onAnimationLoop defines the callback to call when an animation loops
  87983. * @returns the animatable object created for this animation
  87984. */
  87985. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87986. /**
  87987. * Will start the animation sequence of a given target and its hierarchy
  87988. * @param target defines the target
  87989. * @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.
  87990. * @param from defines from which frame should animation start
  87991. * @param to defines until which frame should animation run.
  87992. * @param loop defines if the animation loops
  87993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87994. * @param onAnimationEnd defines the function to be executed when the animation ends
  87995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87997. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87998. * @param onAnimationLoop defines the callback to call when an animation loops
  87999. * @returns the list of created animatables
  88000. */
  88001. 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[];
  88002. /**
  88003. * Begin a new animation on a given node
  88004. * @param target defines the target where the animation will take place
  88005. * @param animations defines the list of animations to start
  88006. * @param from defines the initial value
  88007. * @param to defines the final value
  88008. * @param loop defines if you want animation to loop (off by default)
  88009. * @param speedRatio defines the speed ratio to apply to all animations
  88010. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88011. * @param onAnimationLoop defines the callback to call when an animation loops
  88012. * @returns the list of created animatables
  88013. */
  88014. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88015. /**
  88016. * Begin a new animation on a given node and its hierarchy
  88017. * @param target defines the root node where the animation will take place
  88018. * @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.
  88019. * @param animations defines the list of animations to start
  88020. * @param from defines the initial value
  88021. * @param to defines the final value
  88022. * @param loop defines if you want animation to loop (off by default)
  88023. * @param speedRatio defines the speed ratio to apply to all animations
  88024. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88025. * @param onAnimationLoop defines the callback to call when an animation loops
  88026. * @returns the list of animatables created for all nodes
  88027. */
  88028. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88029. /**
  88030. * Gets the animatable associated with a specific target
  88031. * @param target defines the target of the animatable
  88032. * @returns the required animatable if found
  88033. */
  88034. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88035. /**
  88036. * Gets all animatables associated with a given target
  88037. * @param target defines the target to look animatables for
  88038. * @returns an array of Animatables
  88039. */
  88040. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88041. /**
  88042. * Stops and removes all animations that have been applied to the scene
  88043. */
  88044. stopAllAnimations(): void;
  88045. /**
  88046. * Gets the current delta time used by animation engine
  88047. */
  88048. deltaTime: number;
  88049. }
  88050. interface Bone {
  88051. /**
  88052. * Copy an animation range from another bone
  88053. * @param source defines the source bone
  88054. * @param rangeName defines the range name to copy
  88055. * @param frameOffset defines the frame offset
  88056. * @param rescaleAsRequired defines if rescaling must be applied if required
  88057. * @param skelDimensionsRatio defines the scaling ratio
  88058. * @returns true if operation was successful
  88059. */
  88060. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88061. }
  88062. }
  88063. declare module BABYLON {
  88064. /**
  88065. * Class used to handle skinning animations
  88066. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88067. */
  88068. export class Skeleton implements IAnimatable {
  88069. /** defines the skeleton name */
  88070. name: string;
  88071. /** defines the skeleton Id */
  88072. id: string;
  88073. /**
  88074. * Defines the list of child bones
  88075. */
  88076. bones: Bone[];
  88077. /**
  88078. * Defines an estimate of the dimension of the skeleton at rest
  88079. */
  88080. dimensionsAtRest: Vector3;
  88081. /**
  88082. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88083. */
  88084. needInitialSkinMatrix: boolean;
  88085. /**
  88086. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88087. */
  88088. overrideMesh: Nullable<AbstractMesh>;
  88089. /**
  88090. * Gets the list of animations attached to this skeleton
  88091. */
  88092. animations: Array<Animation>;
  88093. private _scene;
  88094. private _isDirty;
  88095. private _transformMatrices;
  88096. private _transformMatrixTexture;
  88097. private _meshesWithPoseMatrix;
  88098. private _animatables;
  88099. private _identity;
  88100. private _synchronizedWithMesh;
  88101. private _ranges;
  88102. private _lastAbsoluteTransformsUpdateId;
  88103. private _canUseTextureForBones;
  88104. private _uniqueId;
  88105. /** @hidden */
  88106. _numBonesWithLinkedTransformNode: number;
  88107. /** @hidden */
  88108. _hasWaitingData: Nullable<boolean>;
  88109. /**
  88110. * Specifies if the skeleton should be serialized
  88111. */
  88112. doNotSerialize: boolean;
  88113. private _useTextureToStoreBoneMatrices;
  88114. /**
  88115. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88116. * Please note that this option is not available if the hardware does not support it
  88117. */
  88118. get useTextureToStoreBoneMatrices(): boolean;
  88119. set useTextureToStoreBoneMatrices(value: boolean);
  88120. private _animationPropertiesOverride;
  88121. /**
  88122. * Gets or sets the animation properties override
  88123. */
  88124. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88125. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88126. /**
  88127. * List of inspectable custom properties (used by the Inspector)
  88128. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88129. */
  88130. inspectableCustomProperties: IInspectable[];
  88131. /**
  88132. * An observable triggered before computing the skeleton's matrices
  88133. */
  88134. onBeforeComputeObservable: Observable<Skeleton>;
  88135. /**
  88136. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88137. */
  88138. get isUsingTextureForMatrices(): boolean;
  88139. /**
  88140. * Gets the unique ID of this skeleton
  88141. */
  88142. get uniqueId(): number;
  88143. /**
  88144. * Creates a new skeleton
  88145. * @param name defines the skeleton name
  88146. * @param id defines the skeleton Id
  88147. * @param scene defines the hosting scene
  88148. */
  88149. constructor(
  88150. /** defines the skeleton name */
  88151. name: string,
  88152. /** defines the skeleton Id */
  88153. id: string, scene: Scene);
  88154. /**
  88155. * Gets the current object class name.
  88156. * @return the class name
  88157. */
  88158. getClassName(): string;
  88159. /**
  88160. * Returns an array containing the root bones
  88161. * @returns an array containing the root bones
  88162. */
  88163. getChildren(): Array<Bone>;
  88164. /**
  88165. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88166. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88167. * @returns a Float32Array containing matrices data
  88168. */
  88169. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88170. /**
  88171. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88172. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88173. * @returns a raw texture containing the data
  88174. */
  88175. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88176. /**
  88177. * Gets the current hosting scene
  88178. * @returns a scene object
  88179. */
  88180. getScene(): Scene;
  88181. /**
  88182. * Gets a string representing the current skeleton data
  88183. * @param fullDetails defines a boolean indicating if we want a verbose version
  88184. * @returns a string representing the current skeleton data
  88185. */
  88186. toString(fullDetails?: boolean): string;
  88187. /**
  88188. * Get bone's index searching by name
  88189. * @param name defines bone's name to search for
  88190. * @return the indice of the bone. Returns -1 if not found
  88191. */
  88192. getBoneIndexByName(name: string): number;
  88193. /**
  88194. * Creater a new animation range
  88195. * @param name defines the name of the range
  88196. * @param from defines the start key
  88197. * @param to defines the end key
  88198. */
  88199. createAnimationRange(name: string, from: number, to: number): void;
  88200. /**
  88201. * Delete a specific animation range
  88202. * @param name defines the name of the range
  88203. * @param deleteFrames defines if frames must be removed as well
  88204. */
  88205. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88206. /**
  88207. * Gets a specific animation range
  88208. * @param name defines the name of the range to look for
  88209. * @returns the requested animation range or null if not found
  88210. */
  88211. getAnimationRange(name: string): Nullable<AnimationRange>;
  88212. /**
  88213. * Gets the list of all animation ranges defined on this skeleton
  88214. * @returns an array
  88215. */
  88216. getAnimationRanges(): Nullable<AnimationRange>[];
  88217. /**
  88218. * Copy animation range from a source skeleton.
  88219. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88220. * @param source defines the source skeleton
  88221. * @param name defines the name of the range to copy
  88222. * @param rescaleAsRequired defines if rescaling must be applied if required
  88223. * @returns true if operation was successful
  88224. */
  88225. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88226. /**
  88227. * Forces the skeleton to go to rest pose
  88228. */
  88229. returnToRest(): void;
  88230. private _getHighestAnimationFrame;
  88231. /**
  88232. * Begin a specific animation range
  88233. * @param name defines the name of the range to start
  88234. * @param loop defines if looping must be turned on (false by default)
  88235. * @param speedRatio defines the speed ratio to apply (1 by default)
  88236. * @param onAnimationEnd defines a callback which will be called when animation will end
  88237. * @returns a new animatable
  88238. */
  88239. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88240. /** @hidden */
  88241. _markAsDirty(): void;
  88242. /** @hidden */
  88243. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88244. /** @hidden */
  88245. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88246. private _computeTransformMatrices;
  88247. /**
  88248. * Build all resources required to render a skeleton
  88249. */
  88250. prepare(): void;
  88251. /**
  88252. * Gets the list of animatables currently running for this skeleton
  88253. * @returns an array of animatables
  88254. */
  88255. getAnimatables(): IAnimatable[];
  88256. /**
  88257. * Clone the current skeleton
  88258. * @param name defines the name of the new skeleton
  88259. * @param id defines the id of the new skeleton
  88260. * @returns the new skeleton
  88261. */
  88262. clone(name: string, id?: string): Skeleton;
  88263. /**
  88264. * Enable animation blending for this skeleton
  88265. * @param blendingSpeed defines the blending speed to apply
  88266. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88267. */
  88268. enableBlending(blendingSpeed?: number): void;
  88269. /**
  88270. * Releases all resources associated with the current skeleton
  88271. */
  88272. dispose(): void;
  88273. /**
  88274. * Serialize the skeleton in a JSON object
  88275. * @returns a JSON object
  88276. */
  88277. serialize(): any;
  88278. /**
  88279. * Creates a new skeleton from serialized data
  88280. * @param parsedSkeleton defines the serialized data
  88281. * @param scene defines the hosting scene
  88282. * @returns a new skeleton
  88283. */
  88284. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88285. /**
  88286. * Compute all node absolute transforms
  88287. * @param forceUpdate defines if computation must be done even if cache is up to date
  88288. */
  88289. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88290. /**
  88291. * Gets the root pose matrix
  88292. * @returns a matrix
  88293. */
  88294. getPoseMatrix(): Nullable<Matrix>;
  88295. /**
  88296. * Sorts bones per internal index
  88297. */
  88298. sortBones(): void;
  88299. private _sortBones;
  88300. }
  88301. }
  88302. declare module BABYLON {
  88303. /**
  88304. * Creates an instance based on a source mesh.
  88305. */
  88306. export class InstancedMesh extends AbstractMesh {
  88307. private _sourceMesh;
  88308. private _currentLOD;
  88309. /** @hidden */
  88310. _indexInSourceMeshInstanceArray: number;
  88311. constructor(name: string, source: Mesh);
  88312. /**
  88313. * Returns the string "InstancedMesh".
  88314. */
  88315. getClassName(): string;
  88316. /** Gets the list of lights affecting that mesh */
  88317. get lightSources(): Light[];
  88318. _resyncLightSources(): void;
  88319. _resyncLightSource(light: Light): void;
  88320. _removeLightSource(light: Light, dispose: boolean): void;
  88321. /**
  88322. * If the source mesh receives shadows
  88323. */
  88324. get receiveShadows(): boolean;
  88325. /**
  88326. * The material of the source mesh
  88327. */
  88328. get material(): Nullable<Material>;
  88329. /**
  88330. * Visibility of the source mesh
  88331. */
  88332. get visibility(): number;
  88333. /**
  88334. * Skeleton of the source mesh
  88335. */
  88336. get skeleton(): Nullable<Skeleton>;
  88337. /**
  88338. * Rendering ground id of the source mesh
  88339. */
  88340. get renderingGroupId(): number;
  88341. set renderingGroupId(value: number);
  88342. /**
  88343. * Returns the total number of vertices (integer).
  88344. */
  88345. getTotalVertices(): number;
  88346. /**
  88347. * Returns a positive integer : the total number of indices in this mesh geometry.
  88348. * @returns the numner of indices or zero if the mesh has no geometry.
  88349. */
  88350. getTotalIndices(): number;
  88351. /**
  88352. * The source mesh of the instance
  88353. */
  88354. get sourceMesh(): Mesh;
  88355. /**
  88356. * Is this node ready to be used/rendered
  88357. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88358. * @return {boolean} is it ready
  88359. */
  88360. isReady(completeCheck?: boolean): boolean;
  88361. /**
  88362. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88363. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88364. * @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.
  88365. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88366. */
  88367. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88368. /**
  88369. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88370. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88371. * The `data` are either a numeric array either a Float32Array.
  88372. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88373. * 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).
  88374. * Note that a new underlying VertexBuffer object is created each call.
  88375. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88376. *
  88377. * Possible `kind` values :
  88378. * - VertexBuffer.PositionKind
  88379. * - VertexBuffer.UVKind
  88380. * - VertexBuffer.UV2Kind
  88381. * - VertexBuffer.UV3Kind
  88382. * - VertexBuffer.UV4Kind
  88383. * - VertexBuffer.UV5Kind
  88384. * - VertexBuffer.UV6Kind
  88385. * - VertexBuffer.ColorKind
  88386. * - VertexBuffer.MatricesIndicesKind
  88387. * - VertexBuffer.MatricesIndicesExtraKind
  88388. * - VertexBuffer.MatricesWeightsKind
  88389. * - VertexBuffer.MatricesWeightsExtraKind
  88390. *
  88391. * Returns the Mesh.
  88392. */
  88393. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88394. /**
  88395. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88396. * If the mesh has no geometry, it is simply returned as it is.
  88397. * The `data` are either a numeric array either a Float32Array.
  88398. * No new underlying VertexBuffer object is created.
  88399. * 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.
  88400. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88401. *
  88402. * Possible `kind` values :
  88403. * - VertexBuffer.PositionKind
  88404. * - VertexBuffer.UVKind
  88405. * - VertexBuffer.UV2Kind
  88406. * - VertexBuffer.UV3Kind
  88407. * - VertexBuffer.UV4Kind
  88408. * - VertexBuffer.UV5Kind
  88409. * - VertexBuffer.UV6Kind
  88410. * - VertexBuffer.ColorKind
  88411. * - VertexBuffer.MatricesIndicesKind
  88412. * - VertexBuffer.MatricesIndicesExtraKind
  88413. * - VertexBuffer.MatricesWeightsKind
  88414. * - VertexBuffer.MatricesWeightsExtraKind
  88415. *
  88416. * Returns the Mesh.
  88417. */
  88418. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88419. /**
  88420. * Sets the mesh indices.
  88421. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88422. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88423. * This method creates a new index buffer each call.
  88424. * Returns the Mesh.
  88425. */
  88426. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88427. /**
  88428. * Boolean : True if the mesh owns the requested kind of data.
  88429. */
  88430. isVerticesDataPresent(kind: string): boolean;
  88431. /**
  88432. * Returns an array of indices (IndicesArray).
  88433. */
  88434. getIndices(): Nullable<IndicesArray>;
  88435. get _positions(): Nullable<Vector3[]>;
  88436. /**
  88437. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88438. * This means the mesh underlying bounding box and sphere are recomputed.
  88439. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88440. * @returns the current mesh
  88441. */
  88442. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88443. /** @hidden */
  88444. _preActivate(): InstancedMesh;
  88445. /** @hidden */
  88446. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88447. /** @hidden */
  88448. _postActivate(): void;
  88449. getWorldMatrix(): Matrix;
  88450. get isAnInstance(): boolean;
  88451. /**
  88452. * Returns the current associated LOD AbstractMesh.
  88453. */
  88454. getLOD(camera: Camera): AbstractMesh;
  88455. /** @hidden */
  88456. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88457. /** @hidden */
  88458. _syncSubMeshes(): InstancedMesh;
  88459. /** @hidden */
  88460. _generatePointsArray(): boolean;
  88461. /**
  88462. * Creates a new InstancedMesh from the current mesh.
  88463. * - name (string) : the cloned mesh name
  88464. * - newParent (optional Node) : the optional Node to parent the clone to.
  88465. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88466. *
  88467. * Returns the clone.
  88468. */
  88469. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88470. /**
  88471. * Disposes the InstancedMesh.
  88472. * Returns nothing.
  88473. */
  88474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88475. }
  88476. interface Mesh {
  88477. /**
  88478. * Register a custom buffer that will be instanced
  88479. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88480. * @param kind defines the buffer kind
  88481. * @param stride defines the stride in floats
  88482. */
  88483. registerInstancedBuffer(kind: string, stride: number): void;
  88484. /** @hidden */
  88485. _userInstancedBuffersStorage: {
  88486. data: {
  88487. [key: string]: Float32Array;
  88488. };
  88489. sizes: {
  88490. [key: string]: number;
  88491. };
  88492. vertexBuffers: {
  88493. [key: string]: Nullable<VertexBuffer>;
  88494. };
  88495. strides: {
  88496. [key: string]: number;
  88497. };
  88498. };
  88499. }
  88500. interface AbstractMesh {
  88501. /**
  88502. * Object used to store instanced buffers defined by user
  88503. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88504. */
  88505. instancedBuffers: {
  88506. [key: string]: any;
  88507. };
  88508. }
  88509. }
  88510. declare module BABYLON {
  88511. /**
  88512. * Defines the options associated with the creation of a shader material.
  88513. */
  88514. export interface IShaderMaterialOptions {
  88515. /**
  88516. * Does the material work in alpha blend mode
  88517. */
  88518. needAlphaBlending: boolean;
  88519. /**
  88520. * Does the material work in alpha test mode
  88521. */
  88522. needAlphaTesting: boolean;
  88523. /**
  88524. * The list of attribute names used in the shader
  88525. */
  88526. attributes: string[];
  88527. /**
  88528. * The list of unifrom names used in the shader
  88529. */
  88530. uniforms: string[];
  88531. /**
  88532. * The list of UBO names used in the shader
  88533. */
  88534. uniformBuffers: string[];
  88535. /**
  88536. * The list of sampler names used in the shader
  88537. */
  88538. samplers: string[];
  88539. /**
  88540. * The list of defines used in the shader
  88541. */
  88542. defines: string[];
  88543. }
  88544. /**
  88545. * 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.
  88546. *
  88547. * This returned material effects how the mesh will look based on the code in the shaders.
  88548. *
  88549. * @see http://doc.babylonjs.com/how_to/shader_material
  88550. */
  88551. export class ShaderMaterial extends Material {
  88552. private _shaderPath;
  88553. private _options;
  88554. private _textures;
  88555. private _textureArrays;
  88556. private _floats;
  88557. private _ints;
  88558. private _floatsArrays;
  88559. private _colors3;
  88560. private _colors3Arrays;
  88561. private _colors4;
  88562. private _colors4Arrays;
  88563. private _vectors2;
  88564. private _vectors3;
  88565. private _vectors4;
  88566. private _matrices;
  88567. private _matrixArrays;
  88568. private _matrices3x3;
  88569. private _matrices2x2;
  88570. private _vectors2Arrays;
  88571. private _vectors3Arrays;
  88572. private _vectors4Arrays;
  88573. private _cachedWorldViewMatrix;
  88574. private _cachedWorldViewProjectionMatrix;
  88575. private _renderId;
  88576. private _multiview;
  88577. /**
  88578. * Instantiate a new shader material.
  88579. * 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.
  88580. * This returned material effects how the mesh will look based on the code in the shaders.
  88581. * @see http://doc.babylonjs.com/how_to/shader_material
  88582. * @param name Define the name of the material in the scene
  88583. * @param scene Define the scene the material belongs to
  88584. * @param shaderPath Defines the route to the shader code in one of three ways:
  88585. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88586. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88587. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88588. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88589. * @param options Define the options used to create the shader
  88590. */
  88591. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88592. /**
  88593. * Gets the shader path used to define the shader code
  88594. * It can be modified to trigger a new compilation
  88595. */
  88596. get shaderPath(): any;
  88597. /**
  88598. * Sets the shader path used to define the shader code
  88599. * It can be modified to trigger a new compilation
  88600. */
  88601. set shaderPath(shaderPath: any);
  88602. /**
  88603. * Gets the options used to compile the shader.
  88604. * They can be modified to trigger a new compilation
  88605. */
  88606. get options(): IShaderMaterialOptions;
  88607. /**
  88608. * Gets the current class name of the material e.g. "ShaderMaterial"
  88609. * Mainly use in serialization.
  88610. * @returns the class name
  88611. */
  88612. getClassName(): string;
  88613. /**
  88614. * Specifies if the material will require alpha blending
  88615. * @returns a boolean specifying if alpha blending is needed
  88616. */
  88617. needAlphaBlending(): boolean;
  88618. /**
  88619. * Specifies if this material should be rendered in alpha test mode
  88620. * @returns a boolean specifying if an alpha test is needed.
  88621. */
  88622. needAlphaTesting(): boolean;
  88623. private _checkUniform;
  88624. /**
  88625. * Set a texture in the shader.
  88626. * @param name Define the name of the uniform samplers as defined in the shader
  88627. * @param texture Define the texture to bind to this sampler
  88628. * @return the material itself allowing "fluent" like uniform updates
  88629. */
  88630. setTexture(name: string, texture: Texture): ShaderMaterial;
  88631. /**
  88632. * Set a texture array in the shader.
  88633. * @param name Define the name of the uniform sampler array as defined in the shader
  88634. * @param textures Define the list of textures to bind to this sampler
  88635. * @return the material itself allowing "fluent" like uniform updates
  88636. */
  88637. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88638. /**
  88639. * Set a float in the shader.
  88640. * @param name Define the name of the uniform as defined in the shader
  88641. * @param value Define the value to give to the uniform
  88642. * @return the material itself allowing "fluent" like uniform updates
  88643. */
  88644. setFloat(name: string, value: number): ShaderMaterial;
  88645. /**
  88646. * Set a int in the shader.
  88647. * @param name Define the name of the uniform as defined in the shader
  88648. * @param value Define the value to give to the uniform
  88649. * @return the material itself allowing "fluent" like uniform updates
  88650. */
  88651. setInt(name: string, value: number): ShaderMaterial;
  88652. /**
  88653. * Set an array of floats in the shader.
  88654. * @param name Define the name of the uniform as defined in the shader
  88655. * @param value Define the value to give to the uniform
  88656. * @return the material itself allowing "fluent" like uniform updates
  88657. */
  88658. setFloats(name: string, value: number[]): ShaderMaterial;
  88659. /**
  88660. * Set a vec3 in the shader from a Color3.
  88661. * @param name Define the name of the uniform as defined in the shader
  88662. * @param value Define the value to give to the uniform
  88663. * @return the material itself allowing "fluent" like uniform updates
  88664. */
  88665. setColor3(name: string, value: Color3): ShaderMaterial;
  88666. /**
  88667. * Set a vec3 array in the shader from a Color3 array.
  88668. * @param name Define the name of the uniform as defined in the shader
  88669. * @param value Define the value to give to the uniform
  88670. * @return the material itself allowing "fluent" like uniform updates
  88671. */
  88672. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88673. /**
  88674. * Set a vec4 in the shader from a Color4.
  88675. * @param name Define the name of the uniform as defined in the shader
  88676. * @param value Define the value to give to the uniform
  88677. * @return the material itself allowing "fluent" like uniform updates
  88678. */
  88679. setColor4(name: string, value: Color4): ShaderMaterial;
  88680. /**
  88681. * Set a vec4 array in the shader from a Color4 array.
  88682. * @param name Define the name of the uniform as defined in the shader
  88683. * @param value Define the value to give to the uniform
  88684. * @return the material itself allowing "fluent" like uniform updates
  88685. */
  88686. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88687. /**
  88688. * Set a vec2 in the shader from a Vector2.
  88689. * @param name Define the name of the uniform as defined in the shader
  88690. * @param value Define the value to give to the uniform
  88691. * @return the material itself allowing "fluent" like uniform updates
  88692. */
  88693. setVector2(name: string, value: Vector2): ShaderMaterial;
  88694. /**
  88695. * Set a vec3 in the shader from a Vector3.
  88696. * @param name Define the name of the uniform as defined in the shader
  88697. * @param value Define the value to give to the uniform
  88698. * @return the material itself allowing "fluent" like uniform updates
  88699. */
  88700. setVector3(name: string, value: Vector3): ShaderMaterial;
  88701. /**
  88702. * Set a vec4 in the shader from a Vector4.
  88703. * @param name Define the name of the uniform as defined in the shader
  88704. * @param value Define the value to give to the uniform
  88705. * @return the material itself allowing "fluent" like uniform updates
  88706. */
  88707. setVector4(name: string, value: Vector4): ShaderMaterial;
  88708. /**
  88709. * Set a mat4 in the shader from a Matrix.
  88710. * @param name Define the name of the uniform as defined in the shader
  88711. * @param value Define the value to give to the uniform
  88712. * @return the material itself allowing "fluent" like uniform updates
  88713. */
  88714. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88715. /**
  88716. * Set a float32Array in the shader from a matrix array.
  88717. * @param name Define the name of the uniform as defined in the shader
  88718. * @param value Define the value to give to the uniform
  88719. * @return the material itself allowing "fluent" like uniform updates
  88720. */
  88721. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88722. /**
  88723. * Set a mat3 in the shader from a Float32Array.
  88724. * @param name Define the name of the uniform as defined in the shader
  88725. * @param value Define the value to give to the uniform
  88726. * @return the material itself allowing "fluent" like uniform updates
  88727. */
  88728. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88729. /**
  88730. * Set a mat2 in the shader from a Float32Array.
  88731. * @param name Define the name of the uniform as defined in the shader
  88732. * @param value Define the value to give to the uniform
  88733. * @return the material itself allowing "fluent" like uniform updates
  88734. */
  88735. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88736. /**
  88737. * Set a vec2 array in the shader from a number array.
  88738. * @param name Define the name of the uniform as defined in the shader
  88739. * @param value Define the value to give to the uniform
  88740. * @return the material itself allowing "fluent" like uniform updates
  88741. */
  88742. setArray2(name: string, value: number[]): ShaderMaterial;
  88743. /**
  88744. * Set a vec3 array in the shader from a number array.
  88745. * @param name Define the name of the uniform as defined in the shader
  88746. * @param value Define the value to give to the uniform
  88747. * @return the material itself allowing "fluent" like uniform updates
  88748. */
  88749. setArray3(name: string, value: number[]): ShaderMaterial;
  88750. /**
  88751. * Set a vec4 array in the shader from a number array.
  88752. * @param name Define the name of the uniform as defined in the shader
  88753. * @param value Define the value to give to the uniform
  88754. * @return the material itself allowing "fluent" like uniform updates
  88755. */
  88756. setArray4(name: string, value: number[]): ShaderMaterial;
  88757. private _checkCache;
  88758. /**
  88759. * Specifies that the submesh is ready to be used
  88760. * @param mesh defines the mesh to check
  88761. * @param subMesh defines which submesh to check
  88762. * @param useInstances specifies that instances should be used
  88763. * @returns a boolean indicating that the submesh is ready or not
  88764. */
  88765. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88766. /**
  88767. * Checks if the material is ready to render the requested mesh
  88768. * @param mesh Define the mesh to render
  88769. * @param useInstances Define whether or not the material is used with instances
  88770. * @returns true if ready, otherwise false
  88771. */
  88772. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88773. /**
  88774. * Binds the world matrix to the material
  88775. * @param world defines the world transformation matrix
  88776. */
  88777. bindOnlyWorldMatrix(world: Matrix): void;
  88778. /**
  88779. * Binds the material to the mesh
  88780. * @param world defines the world transformation matrix
  88781. * @param mesh defines the mesh to bind the material to
  88782. */
  88783. bind(world: Matrix, mesh?: Mesh): void;
  88784. /**
  88785. * Gets the active textures from the material
  88786. * @returns an array of textures
  88787. */
  88788. getActiveTextures(): BaseTexture[];
  88789. /**
  88790. * Specifies if the material uses a texture
  88791. * @param texture defines the texture to check against the material
  88792. * @returns a boolean specifying if the material uses the texture
  88793. */
  88794. hasTexture(texture: BaseTexture): boolean;
  88795. /**
  88796. * Makes a duplicate of the material, and gives it a new name
  88797. * @param name defines the new name for the duplicated material
  88798. * @returns the cloned material
  88799. */
  88800. clone(name: string): ShaderMaterial;
  88801. /**
  88802. * Disposes the material
  88803. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88804. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88805. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88806. */
  88807. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88808. /**
  88809. * Serializes this material in a JSON representation
  88810. * @returns the serialized material object
  88811. */
  88812. serialize(): any;
  88813. /**
  88814. * Creates a shader material from parsed shader material data
  88815. * @param source defines the JSON represnetation of the material
  88816. * @param scene defines the hosting scene
  88817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88818. * @returns a new material
  88819. */
  88820. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88821. }
  88822. }
  88823. declare module BABYLON {
  88824. /** @hidden */
  88825. export var colorPixelShader: {
  88826. name: string;
  88827. shader: string;
  88828. };
  88829. }
  88830. declare module BABYLON {
  88831. /** @hidden */
  88832. export var colorVertexShader: {
  88833. name: string;
  88834. shader: string;
  88835. };
  88836. }
  88837. declare module BABYLON {
  88838. /**
  88839. * Line mesh
  88840. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88841. */
  88842. export class LinesMesh extends Mesh {
  88843. /**
  88844. * If vertex color should be applied to the mesh
  88845. */
  88846. readonly useVertexColor?: boolean | undefined;
  88847. /**
  88848. * If vertex alpha should be applied to the mesh
  88849. */
  88850. readonly useVertexAlpha?: boolean | undefined;
  88851. /**
  88852. * Color of the line (Default: White)
  88853. */
  88854. color: Color3;
  88855. /**
  88856. * Alpha of the line (Default: 1)
  88857. */
  88858. alpha: number;
  88859. /**
  88860. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88861. * This margin is expressed in world space coordinates, so its value may vary.
  88862. * Default value is 0.1
  88863. */
  88864. intersectionThreshold: number;
  88865. private _colorShader;
  88866. private color4;
  88867. /**
  88868. * Creates a new LinesMesh
  88869. * @param name defines the name
  88870. * @param scene defines the hosting scene
  88871. * @param parent defines the parent mesh if any
  88872. * @param source defines the optional source LinesMesh used to clone data from
  88873. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88874. * When false, achieved by calling a clone(), also passing False.
  88875. * This will make creation of children, recursive.
  88876. * @param useVertexColor defines if this LinesMesh supports vertex color
  88877. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88878. */
  88879. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88880. /**
  88881. * If vertex color should be applied to the mesh
  88882. */
  88883. useVertexColor?: boolean | undefined,
  88884. /**
  88885. * If vertex alpha should be applied to the mesh
  88886. */
  88887. useVertexAlpha?: boolean | undefined);
  88888. private _addClipPlaneDefine;
  88889. private _removeClipPlaneDefine;
  88890. isReady(): boolean;
  88891. /**
  88892. * Returns the string "LineMesh"
  88893. */
  88894. getClassName(): string;
  88895. /**
  88896. * @hidden
  88897. */
  88898. get material(): Material;
  88899. /**
  88900. * @hidden
  88901. */
  88902. set material(value: Material);
  88903. /**
  88904. * @hidden
  88905. */
  88906. get checkCollisions(): boolean;
  88907. /** @hidden */
  88908. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88909. /** @hidden */
  88910. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88911. /**
  88912. * Disposes of the line mesh
  88913. * @param doNotRecurse If children should be disposed
  88914. */
  88915. dispose(doNotRecurse?: boolean): void;
  88916. /**
  88917. * Returns a new LineMesh object cloned from the current one.
  88918. */
  88919. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88920. /**
  88921. * Creates a new InstancedLinesMesh object from the mesh model.
  88922. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88923. * @param name defines the name of the new instance
  88924. * @returns a new InstancedLinesMesh
  88925. */
  88926. createInstance(name: string): InstancedLinesMesh;
  88927. }
  88928. /**
  88929. * Creates an instance based on a source LinesMesh
  88930. */
  88931. export class InstancedLinesMesh extends InstancedMesh {
  88932. /**
  88933. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88934. * This margin is expressed in world space coordinates, so its value may vary.
  88935. * Initilized with the intersectionThreshold value of the source LinesMesh
  88936. */
  88937. intersectionThreshold: number;
  88938. constructor(name: string, source: LinesMesh);
  88939. /**
  88940. * Returns the string "InstancedLinesMesh".
  88941. */
  88942. getClassName(): string;
  88943. }
  88944. }
  88945. declare module BABYLON {
  88946. /** @hidden */
  88947. export var linePixelShader: {
  88948. name: string;
  88949. shader: string;
  88950. };
  88951. }
  88952. declare module BABYLON {
  88953. /** @hidden */
  88954. export var lineVertexShader: {
  88955. name: string;
  88956. shader: string;
  88957. };
  88958. }
  88959. declare module BABYLON {
  88960. interface AbstractMesh {
  88961. /**
  88962. * Gets the edgesRenderer associated with the mesh
  88963. */
  88964. edgesRenderer: Nullable<EdgesRenderer>;
  88965. }
  88966. interface LinesMesh {
  88967. /**
  88968. * Enables the edge rendering mode on the mesh.
  88969. * This mode makes the mesh edges visible
  88970. * @param epsilon defines the maximal distance between two angles to detect a face
  88971. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88972. * @returns the currentAbstractMesh
  88973. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88974. */
  88975. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88976. }
  88977. interface InstancedLinesMesh {
  88978. /**
  88979. * Enables the edge rendering mode on the mesh.
  88980. * This mode makes the mesh edges visible
  88981. * @param epsilon defines the maximal distance between two angles to detect a face
  88982. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88983. * @returns the current InstancedLinesMesh
  88984. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88985. */
  88986. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88987. }
  88988. /**
  88989. * Defines the minimum contract an Edges renderer should follow.
  88990. */
  88991. export interface IEdgesRenderer extends IDisposable {
  88992. /**
  88993. * Gets or sets a boolean indicating if the edgesRenderer is active
  88994. */
  88995. isEnabled: boolean;
  88996. /**
  88997. * Renders the edges of the attached mesh,
  88998. */
  88999. render(): void;
  89000. /**
  89001. * Checks wether or not the edges renderer is ready to render.
  89002. * @return true if ready, otherwise false.
  89003. */
  89004. isReady(): boolean;
  89005. }
  89006. /**
  89007. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89008. */
  89009. export class EdgesRenderer implements IEdgesRenderer {
  89010. /**
  89011. * Define the size of the edges with an orthographic camera
  89012. */
  89013. edgesWidthScalerForOrthographic: number;
  89014. /**
  89015. * Define the size of the edges with a perspective camera
  89016. */
  89017. edgesWidthScalerForPerspective: number;
  89018. protected _source: AbstractMesh;
  89019. protected _linesPositions: number[];
  89020. protected _linesNormals: number[];
  89021. protected _linesIndices: number[];
  89022. protected _epsilon: number;
  89023. protected _indicesCount: number;
  89024. protected _lineShader: ShaderMaterial;
  89025. protected _ib: DataBuffer;
  89026. protected _buffers: {
  89027. [key: string]: Nullable<VertexBuffer>;
  89028. };
  89029. protected _checkVerticesInsteadOfIndices: boolean;
  89030. private _meshRebuildObserver;
  89031. private _meshDisposeObserver;
  89032. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89033. isEnabled: boolean;
  89034. /**
  89035. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89036. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89037. * @param source Mesh used to create edges
  89038. * @param epsilon sum of angles in adjacency to check for edge
  89039. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89040. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89041. */
  89042. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89043. protected _prepareRessources(): void;
  89044. /** @hidden */
  89045. _rebuild(): void;
  89046. /**
  89047. * Releases the required resources for the edges renderer
  89048. */
  89049. dispose(): void;
  89050. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89051. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89052. /**
  89053. * Checks if the pair of p0 and p1 is en edge
  89054. * @param faceIndex
  89055. * @param edge
  89056. * @param faceNormals
  89057. * @param p0
  89058. * @param p1
  89059. * @private
  89060. */
  89061. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89062. /**
  89063. * push line into the position, normal and index buffer
  89064. * @protected
  89065. */
  89066. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89067. /**
  89068. * Generates lines edges from adjacencjes
  89069. * @private
  89070. */
  89071. _generateEdgesLines(): void;
  89072. /**
  89073. * Checks wether or not the edges renderer is ready to render.
  89074. * @return true if ready, otherwise false.
  89075. */
  89076. isReady(): boolean;
  89077. /**
  89078. * Renders the edges of the attached mesh,
  89079. */
  89080. render(): void;
  89081. }
  89082. /**
  89083. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89084. */
  89085. export class LineEdgesRenderer extends EdgesRenderer {
  89086. /**
  89087. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89088. * @param source LineMesh used to generate edges
  89089. * @param epsilon not important (specified angle for edge detection)
  89090. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89091. */
  89092. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89093. /**
  89094. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89095. */
  89096. _generateEdgesLines(): void;
  89097. }
  89098. }
  89099. declare module BABYLON {
  89100. /**
  89101. * This represents the object necessary to create a rendering group.
  89102. * This is exclusively used and created by the rendering manager.
  89103. * To modify the behavior, you use the available helpers in your scene or meshes.
  89104. * @hidden
  89105. */
  89106. export class RenderingGroup {
  89107. index: number;
  89108. private static _zeroVector;
  89109. private _scene;
  89110. private _opaqueSubMeshes;
  89111. private _transparentSubMeshes;
  89112. private _alphaTestSubMeshes;
  89113. private _depthOnlySubMeshes;
  89114. private _particleSystems;
  89115. private _spriteManagers;
  89116. private _opaqueSortCompareFn;
  89117. private _alphaTestSortCompareFn;
  89118. private _transparentSortCompareFn;
  89119. private _renderOpaque;
  89120. private _renderAlphaTest;
  89121. private _renderTransparent;
  89122. /** @hidden */
  89123. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89124. onBeforeTransparentRendering: () => void;
  89125. /**
  89126. * Set the opaque sort comparison function.
  89127. * If null the sub meshes will be render in the order they were created
  89128. */
  89129. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89130. /**
  89131. * Set the alpha test sort comparison function.
  89132. * If null the sub meshes will be render in the order they were created
  89133. */
  89134. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89135. /**
  89136. * Set the transparent sort comparison function.
  89137. * If null the sub meshes will be render in the order they were created
  89138. */
  89139. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89140. /**
  89141. * Creates a new rendering group.
  89142. * @param index The rendering group index
  89143. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89144. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89145. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89146. */
  89147. 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>);
  89148. /**
  89149. * Render all the sub meshes contained in the group.
  89150. * @param customRenderFunction Used to override the default render behaviour of the group.
  89151. * @returns true if rendered some submeshes.
  89152. */
  89153. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89154. /**
  89155. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89156. * @param subMeshes The submeshes to render
  89157. */
  89158. private renderOpaqueSorted;
  89159. /**
  89160. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89161. * @param subMeshes The submeshes to render
  89162. */
  89163. private renderAlphaTestSorted;
  89164. /**
  89165. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89166. * @param subMeshes The submeshes to render
  89167. */
  89168. private renderTransparentSorted;
  89169. /**
  89170. * Renders the submeshes in a specified order.
  89171. * @param subMeshes The submeshes to sort before render
  89172. * @param sortCompareFn The comparison function use to sort
  89173. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89174. * @param transparent Specifies to activate blending if true
  89175. */
  89176. private static renderSorted;
  89177. /**
  89178. * Renders the submeshes in the order they were dispatched (no sort applied).
  89179. * @param subMeshes The submeshes to render
  89180. */
  89181. private static renderUnsorted;
  89182. /**
  89183. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89184. * are rendered back to front if in the same alpha index.
  89185. *
  89186. * @param a The first submesh
  89187. * @param b The second submesh
  89188. * @returns The result of the comparison
  89189. */
  89190. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89191. /**
  89192. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89193. * are rendered back to front.
  89194. *
  89195. * @param a The first submesh
  89196. * @param b The second submesh
  89197. * @returns The result of the comparison
  89198. */
  89199. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89200. /**
  89201. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89202. * are rendered front to back (prevent overdraw).
  89203. *
  89204. * @param a The first submesh
  89205. * @param b The second submesh
  89206. * @returns The result of the comparison
  89207. */
  89208. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89209. /**
  89210. * Resets the different lists of submeshes to prepare a new frame.
  89211. */
  89212. prepare(): void;
  89213. dispose(): void;
  89214. /**
  89215. * Inserts the submesh in its correct queue depending on its material.
  89216. * @param subMesh The submesh to dispatch
  89217. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89218. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89219. */
  89220. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89221. dispatchSprites(spriteManager: ISpriteManager): void;
  89222. dispatchParticles(particleSystem: IParticleSystem): void;
  89223. private _renderParticles;
  89224. private _renderSprites;
  89225. }
  89226. }
  89227. declare module BABYLON {
  89228. /**
  89229. * Interface describing the different options available in the rendering manager
  89230. * regarding Auto Clear between groups.
  89231. */
  89232. export interface IRenderingManagerAutoClearSetup {
  89233. /**
  89234. * Defines whether or not autoclear is enable.
  89235. */
  89236. autoClear: boolean;
  89237. /**
  89238. * Defines whether or not to autoclear the depth buffer.
  89239. */
  89240. depth: boolean;
  89241. /**
  89242. * Defines whether or not to autoclear the stencil buffer.
  89243. */
  89244. stencil: boolean;
  89245. }
  89246. /**
  89247. * This class is used by the onRenderingGroupObservable
  89248. */
  89249. export class RenderingGroupInfo {
  89250. /**
  89251. * The Scene that being rendered
  89252. */
  89253. scene: Scene;
  89254. /**
  89255. * The camera currently used for the rendering pass
  89256. */
  89257. camera: Nullable<Camera>;
  89258. /**
  89259. * The ID of the renderingGroup being processed
  89260. */
  89261. renderingGroupId: number;
  89262. }
  89263. /**
  89264. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89265. * It is enable to manage the different groups as well as the different necessary sort functions.
  89266. * This should not be used directly aside of the few static configurations
  89267. */
  89268. export class RenderingManager {
  89269. /**
  89270. * The max id used for rendering groups (not included)
  89271. */
  89272. static MAX_RENDERINGGROUPS: number;
  89273. /**
  89274. * The min id used for rendering groups (included)
  89275. */
  89276. static MIN_RENDERINGGROUPS: number;
  89277. /**
  89278. * Used to globally prevent autoclearing scenes.
  89279. */
  89280. static AUTOCLEAR: boolean;
  89281. /**
  89282. * @hidden
  89283. */
  89284. _useSceneAutoClearSetup: boolean;
  89285. private _scene;
  89286. private _renderingGroups;
  89287. private _depthStencilBufferAlreadyCleaned;
  89288. private _autoClearDepthStencil;
  89289. private _customOpaqueSortCompareFn;
  89290. private _customAlphaTestSortCompareFn;
  89291. private _customTransparentSortCompareFn;
  89292. private _renderingGroupInfo;
  89293. /**
  89294. * Instantiates a new rendering group for a particular scene
  89295. * @param scene Defines the scene the groups belongs to
  89296. */
  89297. constructor(scene: Scene);
  89298. private _clearDepthStencilBuffer;
  89299. /**
  89300. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89301. * @hidden
  89302. */
  89303. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89304. /**
  89305. * Resets the different information of the group to prepare a new frame
  89306. * @hidden
  89307. */
  89308. reset(): void;
  89309. /**
  89310. * Dispose and release the group and its associated resources.
  89311. * @hidden
  89312. */
  89313. dispose(): void;
  89314. /**
  89315. * Clear the info related to rendering groups preventing retention points during dispose.
  89316. */
  89317. freeRenderingGroups(): void;
  89318. private _prepareRenderingGroup;
  89319. /**
  89320. * Add a sprite manager to the rendering manager in order to render it this frame.
  89321. * @param spriteManager Define the sprite manager to render
  89322. */
  89323. dispatchSprites(spriteManager: ISpriteManager): void;
  89324. /**
  89325. * Add a particle system to the rendering manager in order to render it this frame.
  89326. * @param particleSystem Define the particle system to render
  89327. */
  89328. dispatchParticles(particleSystem: IParticleSystem): void;
  89329. /**
  89330. * Add a submesh to the manager in order to render it this frame
  89331. * @param subMesh The submesh to dispatch
  89332. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89333. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89334. */
  89335. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89336. /**
  89337. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89338. * This allowed control for front to back rendering or reversly depending of the special needs.
  89339. *
  89340. * @param renderingGroupId The rendering group id corresponding to its index
  89341. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89342. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89343. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89344. */
  89345. 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;
  89346. /**
  89347. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89348. *
  89349. * @param renderingGroupId The rendering group id corresponding to its index
  89350. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89351. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89352. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89353. */
  89354. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89355. /**
  89356. * Gets the current auto clear configuration for one rendering group of the rendering
  89357. * manager.
  89358. * @param index the rendering group index to get the information for
  89359. * @returns The auto clear setup for the requested rendering group
  89360. */
  89361. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89362. }
  89363. }
  89364. declare module BABYLON {
  89365. /**
  89366. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89367. */
  89368. export interface ICustomShaderOptions {
  89369. /**
  89370. * Gets or sets the custom shader name to use
  89371. */
  89372. shaderName: string;
  89373. /**
  89374. * The list of attribute names used in the shader
  89375. */
  89376. attributes?: string[];
  89377. /**
  89378. * The list of unifrom names used in the shader
  89379. */
  89380. uniforms?: string[];
  89381. /**
  89382. * The list of sampler names used in the shader
  89383. */
  89384. samplers?: string[];
  89385. /**
  89386. * The list of defines used in the shader
  89387. */
  89388. defines?: string[];
  89389. }
  89390. /**
  89391. * Interface to implement to create a shadow generator compatible with BJS.
  89392. */
  89393. export interface IShadowGenerator {
  89394. /**
  89395. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89396. * @returns The render target texture if present otherwise, null
  89397. */
  89398. getShadowMap(): Nullable<RenderTargetTexture>;
  89399. /**
  89400. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89401. * @param subMesh The submesh we want to render in the shadow map
  89402. * @param useInstances Defines wether will draw in the map using instances
  89403. * @returns true if ready otherwise, false
  89404. */
  89405. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89406. /**
  89407. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89408. * @param defines Defines of the material we want to update
  89409. * @param lightIndex Index of the light in the enabled light list of the material
  89410. */
  89411. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89412. /**
  89413. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89414. * defined in the generator but impacting the effect).
  89415. * It implies the unifroms available on the materials are the standard BJS ones.
  89416. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89417. * @param effect The effect we are binfing the information for
  89418. */
  89419. bindShadowLight(lightIndex: string, effect: Effect): void;
  89420. /**
  89421. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89422. * (eq to shadow prjection matrix * light transform matrix)
  89423. * @returns The transform matrix used to create the shadow map
  89424. */
  89425. getTransformMatrix(): Matrix;
  89426. /**
  89427. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89428. * Cube and 2D textures for instance.
  89429. */
  89430. recreateShadowMap(): void;
  89431. /**
  89432. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89433. * @param onCompiled Callback triggered at the and of the effects compilation
  89434. * @param options Sets of optional options forcing the compilation with different modes
  89435. */
  89436. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89437. useInstances: boolean;
  89438. }>): void;
  89439. /**
  89440. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89441. * @param options Sets of optional options forcing the compilation with different modes
  89442. * @returns A promise that resolves when the compilation completes
  89443. */
  89444. forceCompilationAsync(options?: Partial<{
  89445. useInstances: boolean;
  89446. }>): Promise<void>;
  89447. /**
  89448. * Serializes the shadow generator setup to a json object.
  89449. * @returns The serialized JSON object
  89450. */
  89451. serialize(): any;
  89452. /**
  89453. * Disposes the Shadow map and related Textures and effects.
  89454. */
  89455. dispose(): void;
  89456. }
  89457. /**
  89458. * Default implementation IShadowGenerator.
  89459. * This is the main object responsible of generating shadows in the framework.
  89460. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89461. */
  89462. export class ShadowGenerator implements IShadowGenerator {
  89463. /**
  89464. * Name of the shadow generator class
  89465. */
  89466. static CLASSNAME: string;
  89467. /**
  89468. * Shadow generator mode None: no filtering applied.
  89469. */
  89470. static readonly FILTER_NONE: number;
  89471. /**
  89472. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89474. */
  89475. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89476. /**
  89477. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89478. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89479. */
  89480. static readonly FILTER_POISSONSAMPLING: number;
  89481. /**
  89482. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89483. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89484. */
  89485. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89486. /**
  89487. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89488. * edge artifacts on steep falloff.
  89489. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89490. */
  89491. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89492. /**
  89493. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89494. * edge artifacts on steep falloff.
  89495. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89496. */
  89497. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89498. /**
  89499. * Shadow generator mode PCF: Percentage Closer Filtering
  89500. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89501. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89502. */
  89503. static readonly FILTER_PCF: number;
  89504. /**
  89505. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89506. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89507. * Contact Hardening
  89508. */
  89509. static readonly FILTER_PCSS: number;
  89510. /**
  89511. * Reserved for PCF and PCSS
  89512. * Highest Quality.
  89513. *
  89514. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89515. *
  89516. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89517. */
  89518. static readonly QUALITY_HIGH: number;
  89519. /**
  89520. * Reserved for PCF and PCSS
  89521. * Good tradeoff for quality/perf cross devices
  89522. *
  89523. * Execute PCF on a 3*3 kernel.
  89524. *
  89525. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89526. */
  89527. static readonly QUALITY_MEDIUM: number;
  89528. /**
  89529. * Reserved for PCF and PCSS
  89530. * The lowest quality but the fastest.
  89531. *
  89532. * Execute PCF on a 1*1 kernel.
  89533. *
  89534. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89535. */
  89536. static readonly QUALITY_LOW: number;
  89537. /** Gets or sets the custom shader name to use */
  89538. customShaderOptions: ICustomShaderOptions;
  89539. /**
  89540. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89541. */
  89542. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89543. /**
  89544. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89545. */
  89546. onAfterShadowMapRenderObservable: Observable<Effect>;
  89547. /**
  89548. * Observable triggered before a mesh is rendered in the shadow map.
  89549. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89550. */
  89551. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89552. /**
  89553. * Observable triggered after a mesh is rendered in the shadow map.
  89554. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89555. */
  89556. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89557. protected _bias: number;
  89558. /**
  89559. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89560. */
  89561. get bias(): number;
  89562. /**
  89563. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89564. */
  89565. set bias(bias: number);
  89566. protected _normalBias: number;
  89567. /**
  89568. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89569. */
  89570. get normalBias(): number;
  89571. /**
  89572. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89573. */
  89574. set normalBias(normalBias: number);
  89575. protected _blurBoxOffset: number;
  89576. /**
  89577. * Gets the blur box offset: offset applied during the blur pass.
  89578. * Only useful if useKernelBlur = false
  89579. */
  89580. get blurBoxOffset(): number;
  89581. /**
  89582. * Sets the blur box offset: offset applied during the blur pass.
  89583. * Only useful if useKernelBlur = false
  89584. */
  89585. set blurBoxOffset(value: number);
  89586. protected _blurScale: number;
  89587. /**
  89588. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89589. * 2 means half of the size.
  89590. */
  89591. get blurScale(): number;
  89592. /**
  89593. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89594. * 2 means half of the size.
  89595. */
  89596. set blurScale(value: number);
  89597. protected _blurKernel: number;
  89598. /**
  89599. * Gets the blur kernel: kernel size of the blur pass.
  89600. * Only useful if useKernelBlur = true
  89601. */
  89602. get blurKernel(): number;
  89603. /**
  89604. * Sets the blur kernel: kernel size of the blur pass.
  89605. * Only useful if useKernelBlur = true
  89606. */
  89607. set blurKernel(value: number);
  89608. protected _useKernelBlur: boolean;
  89609. /**
  89610. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89611. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89612. */
  89613. get useKernelBlur(): boolean;
  89614. /**
  89615. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89616. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89617. */
  89618. set useKernelBlur(value: boolean);
  89619. protected _depthScale: number;
  89620. /**
  89621. * Gets the depth scale used in ESM mode.
  89622. */
  89623. get depthScale(): number;
  89624. /**
  89625. * Sets the depth scale used in ESM mode.
  89626. * This can override the scale stored on the light.
  89627. */
  89628. set depthScale(value: number);
  89629. protected _validateFilter(filter: number): number;
  89630. protected _filter: number;
  89631. /**
  89632. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89633. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89634. */
  89635. get filter(): number;
  89636. /**
  89637. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89638. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89639. */
  89640. set filter(value: number);
  89641. /**
  89642. * Gets if the current filter is set to Poisson Sampling.
  89643. */
  89644. get usePoissonSampling(): boolean;
  89645. /**
  89646. * Sets the current filter to Poisson Sampling.
  89647. */
  89648. set usePoissonSampling(value: boolean);
  89649. /**
  89650. * Gets if the current filter is set to ESM.
  89651. */
  89652. get useExponentialShadowMap(): boolean;
  89653. /**
  89654. * Sets the current filter is to ESM.
  89655. */
  89656. set useExponentialShadowMap(value: boolean);
  89657. /**
  89658. * Gets if the current filter is set to filtered ESM.
  89659. */
  89660. get useBlurExponentialShadowMap(): boolean;
  89661. /**
  89662. * Gets if the current filter is set to filtered ESM.
  89663. */
  89664. set useBlurExponentialShadowMap(value: boolean);
  89665. /**
  89666. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89667. * exponential to prevent steep falloff artifacts).
  89668. */
  89669. get useCloseExponentialShadowMap(): boolean;
  89670. /**
  89671. * Sets the current filter to "close ESM" (using the inverse of the
  89672. * exponential to prevent steep falloff artifacts).
  89673. */
  89674. set useCloseExponentialShadowMap(value: boolean);
  89675. /**
  89676. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89677. * exponential to prevent steep falloff artifacts).
  89678. */
  89679. get useBlurCloseExponentialShadowMap(): boolean;
  89680. /**
  89681. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89682. * exponential to prevent steep falloff artifacts).
  89683. */
  89684. set useBlurCloseExponentialShadowMap(value: boolean);
  89685. /**
  89686. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89687. */
  89688. get usePercentageCloserFiltering(): boolean;
  89689. /**
  89690. * Sets the current filter to "PCF" (percentage closer filtering).
  89691. */
  89692. set usePercentageCloserFiltering(value: boolean);
  89693. protected _filteringQuality: number;
  89694. /**
  89695. * Gets the PCF or PCSS Quality.
  89696. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89697. */
  89698. get filteringQuality(): number;
  89699. /**
  89700. * Sets the PCF or PCSS Quality.
  89701. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89702. */
  89703. set filteringQuality(filteringQuality: number);
  89704. /**
  89705. * Gets if the current filter is set to "PCSS" (contact hardening).
  89706. */
  89707. get useContactHardeningShadow(): boolean;
  89708. /**
  89709. * Sets the current filter to "PCSS" (contact hardening).
  89710. */
  89711. set useContactHardeningShadow(value: boolean);
  89712. protected _contactHardeningLightSizeUVRatio: number;
  89713. /**
  89714. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89715. * Using a ratio helps keeping shape stability independently of the map size.
  89716. *
  89717. * It does not account for the light projection as it was having too much
  89718. * instability during the light setup or during light position changes.
  89719. *
  89720. * Only valid if useContactHardeningShadow is true.
  89721. */
  89722. get contactHardeningLightSizeUVRatio(): number;
  89723. /**
  89724. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89725. * Using a ratio helps keeping shape stability independently of the map size.
  89726. *
  89727. * It does not account for the light projection as it was having too much
  89728. * instability during the light setup or during light position changes.
  89729. *
  89730. * Only valid if useContactHardeningShadow is true.
  89731. */
  89732. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89733. protected _darkness: number;
  89734. /** Gets or sets the actual darkness of a shadow */
  89735. get darkness(): number;
  89736. set darkness(value: number);
  89737. /**
  89738. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89739. * 0 means strongest and 1 would means no shadow.
  89740. * @returns the darkness.
  89741. */
  89742. getDarkness(): number;
  89743. /**
  89744. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89745. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89746. * @returns the shadow generator allowing fluent coding.
  89747. */
  89748. setDarkness(darkness: number): ShadowGenerator;
  89749. protected _transparencyShadow: boolean;
  89750. /** Gets or sets the ability to have transparent shadow */
  89751. get transparencyShadow(): boolean;
  89752. set transparencyShadow(value: boolean);
  89753. /**
  89754. * Sets the ability to have transparent shadow (boolean).
  89755. * @param transparent True if transparent else False
  89756. * @returns the shadow generator allowing fluent coding
  89757. */
  89758. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89759. protected _shadowMap: Nullable<RenderTargetTexture>;
  89760. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89761. /**
  89762. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89763. * @returns The render target texture if present otherwise, null
  89764. */
  89765. getShadowMap(): Nullable<RenderTargetTexture>;
  89766. /**
  89767. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89768. * @returns The render target texture if the shadow map is present otherwise, null
  89769. */
  89770. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89771. /**
  89772. * Gets the class name of that object
  89773. * @returns "ShadowGenerator"
  89774. */
  89775. getClassName(): string;
  89776. /**
  89777. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89778. * @param mesh Mesh to add
  89779. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89780. * @returns the Shadow Generator itself
  89781. */
  89782. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89783. /**
  89784. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89785. * @param mesh Mesh to remove
  89786. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89787. * @returns the Shadow Generator itself
  89788. */
  89789. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89790. /**
  89791. * Controls the extent to which the shadows fade out at the edge of the frustum
  89792. */
  89793. frustumEdgeFalloff: number;
  89794. protected _light: IShadowLight;
  89795. /**
  89796. * Returns the associated light object.
  89797. * @returns the light generating the shadow
  89798. */
  89799. getLight(): IShadowLight;
  89800. /**
  89801. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89802. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89803. * It might on the other hand introduce peter panning.
  89804. */
  89805. forceBackFacesOnly: boolean;
  89806. protected _scene: Scene;
  89807. protected _lightDirection: Vector3;
  89808. protected _effect: Effect;
  89809. protected _viewMatrix: Matrix;
  89810. protected _projectionMatrix: Matrix;
  89811. protected _transformMatrix: Matrix;
  89812. protected _cachedPosition: Vector3;
  89813. protected _cachedDirection: Vector3;
  89814. protected _cachedDefines: string;
  89815. protected _currentRenderID: number;
  89816. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89817. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89818. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89819. protected _blurPostProcesses: PostProcess[];
  89820. protected _mapSize: number;
  89821. protected _currentFaceIndex: number;
  89822. protected _currentFaceIndexCache: number;
  89823. protected _textureType: number;
  89824. protected _defaultTextureMatrix: Matrix;
  89825. protected _storedUniqueId: Nullable<number>;
  89826. /** @hidden */
  89827. static _SceneComponentInitialization: (scene: Scene) => void;
  89828. /**
  89829. * Creates a ShadowGenerator object.
  89830. * A ShadowGenerator is the required tool to use the shadows.
  89831. * Each light casting shadows needs to use its own ShadowGenerator.
  89832. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89833. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89834. * @param light The light object generating the shadows.
  89835. * @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.
  89836. */
  89837. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89838. protected _initializeGenerator(): void;
  89839. protected _createTargetRenderTexture(): void;
  89840. protected _initializeShadowMap(): void;
  89841. protected _initializeBlurRTTAndPostProcesses(): void;
  89842. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89843. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89844. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89845. protected _applyFilterValues(): void;
  89846. /**
  89847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89848. * @param onCompiled Callback triggered at the and of the effects compilation
  89849. * @param options Sets of optional options forcing the compilation with different modes
  89850. */
  89851. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89852. useInstances: boolean;
  89853. }>): void;
  89854. /**
  89855. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89856. * @param options Sets of optional options forcing the compilation with different modes
  89857. * @returns A promise that resolves when the compilation completes
  89858. */
  89859. forceCompilationAsync(options?: Partial<{
  89860. useInstances: boolean;
  89861. }>): Promise<void>;
  89862. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89863. /**
  89864. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89865. * @param subMesh The submesh we want to render in the shadow map
  89866. * @param useInstances Defines wether will draw in the map using instances
  89867. * @returns true if ready otherwise, false
  89868. */
  89869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89870. /**
  89871. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89872. * @param defines Defines of the material we want to update
  89873. * @param lightIndex Index of the light in the enabled light list of the material
  89874. */
  89875. prepareDefines(defines: any, lightIndex: number): void;
  89876. /**
  89877. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89878. * defined in the generator but impacting the effect).
  89879. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89880. * @param effect The effect we are binfing the information for
  89881. */
  89882. bindShadowLight(lightIndex: string, effect: Effect): void;
  89883. /**
  89884. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89885. * (eq to shadow prjection matrix * light transform matrix)
  89886. * @returns The transform matrix used to create the shadow map
  89887. */
  89888. getTransformMatrix(): Matrix;
  89889. /**
  89890. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89891. * Cube and 2D textures for instance.
  89892. */
  89893. recreateShadowMap(): void;
  89894. protected _disposeBlurPostProcesses(): void;
  89895. protected _disposeRTTandPostProcesses(): void;
  89896. /**
  89897. * Disposes the ShadowGenerator.
  89898. * Returns nothing.
  89899. */
  89900. dispose(): void;
  89901. /**
  89902. * Serializes the shadow generator setup to a json object.
  89903. * @returns The serialized JSON object
  89904. */
  89905. serialize(): any;
  89906. /**
  89907. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89908. * @param parsedShadowGenerator The JSON object to parse
  89909. * @param scene The scene to create the shadow map for
  89910. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89911. * @returns The parsed shadow generator
  89912. */
  89913. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89914. }
  89915. }
  89916. declare module BABYLON {
  89917. /**
  89918. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89919. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89920. * 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.
  89921. */
  89922. export abstract class Light extends Node {
  89923. /**
  89924. * Falloff Default: light is falling off following the material specification:
  89925. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89926. */
  89927. static readonly FALLOFF_DEFAULT: number;
  89928. /**
  89929. * Falloff Physical: light is falling off following the inverse squared distance law.
  89930. */
  89931. static readonly FALLOFF_PHYSICAL: number;
  89932. /**
  89933. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89934. * to enhance interoperability with other engines.
  89935. */
  89936. static readonly FALLOFF_GLTF: number;
  89937. /**
  89938. * Falloff Standard: light is falling off like in the standard material
  89939. * to enhance interoperability with other materials.
  89940. */
  89941. static readonly FALLOFF_STANDARD: number;
  89942. /**
  89943. * If every light affecting the material is in this lightmapMode,
  89944. * material.lightmapTexture adds or multiplies
  89945. * (depends on material.useLightmapAsShadowmap)
  89946. * after every other light calculations.
  89947. */
  89948. static readonly LIGHTMAP_DEFAULT: number;
  89949. /**
  89950. * material.lightmapTexture as only diffuse lighting from this light
  89951. * adds only specular lighting from this light
  89952. * adds dynamic shadows
  89953. */
  89954. static readonly LIGHTMAP_SPECULAR: number;
  89955. /**
  89956. * material.lightmapTexture as only lighting
  89957. * no light calculation from this light
  89958. * only adds dynamic shadows from this light
  89959. */
  89960. static readonly LIGHTMAP_SHADOWSONLY: number;
  89961. /**
  89962. * Each light type uses the default quantity according to its type:
  89963. * point/spot lights use luminous intensity
  89964. * directional lights use illuminance
  89965. */
  89966. static readonly INTENSITYMODE_AUTOMATIC: number;
  89967. /**
  89968. * lumen (lm)
  89969. */
  89970. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89971. /**
  89972. * candela (lm/sr)
  89973. */
  89974. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89975. /**
  89976. * lux (lm/m^2)
  89977. */
  89978. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89979. /**
  89980. * nit (cd/m^2)
  89981. */
  89982. static readonly INTENSITYMODE_LUMINANCE: number;
  89983. /**
  89984. * Light type const id of the point light.
  89985. */
  89986. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89987. /**
  89988. * Light type const id of the directional light.
  89989. */
  89990. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89991. /**
  89992. * Light type const id of the spot light.
  89993. */
  89994. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89995. /**
  89996. * Light type const id of the hemispheric light.
  89997. */
  89998. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89999. /**
  90000. * Diffuse gives the basic color to an object.
  90001. */
  90002. diffuse: Color3;
  90003. /**
  90004. * Specular produces a highlight color on an object.
  90005. * Note: This is note affecting PBR materials.
  90006. */
  90007. specular: Color3;
  90008. /**
  90009. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90010. * falling off base on range or angle.
  90011. * This can be set to any values in Light.FALLOFF_x.
  90012. *
  90013. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90014. * other types of materials.
  90015. */
  90016. falloffType: number;
  90017. /**
  90018. * Strength of the light.
  90019. * Note: By default it is define in the framework own unit.
  90020. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90021. */
  90022. intensity: number;
  90023. private _range;
  90024. protected _inverseSquaredRange: number;
  90025. /**
  90026. * Defines how far from the source the light is impacting in scene units.
  90027. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90028. */
  90029. get range(): number;
  90030. /**
  90031. * Defines how far from the source the light is impacting in scene units.
  90032. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90033. */
  90034. set range(value: number);
  90035. /**
  90036. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90037. * of light.
  90038. */
  90039. private _photometricScale;
  90040. private _intensityMode;
  90041. /**
  90042. * Gets the photometric scale used to interpret the intensity.
  90043. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90044. */
  90045. get intensityMode(): number;
  90046. /**
  90047. * Sets the photometric scale used to interpret the intensity.
  90048. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90049. */
  90050. set intensityMode(value: number);
  90051. private _radius;
  90052. /**
  90053. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90054. */
  90055. get radius(): number;
  90056. /**
  90057. * sets the light radius used by PBR Materials to simulate soft area lights.
  90058. */
  90059. set radius(value: number);
  90060. private _renderPriority;
  90061. /**
  90062. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90063. * exceeding the number allowed of the materials.
  90064. */
  90065. renderPriority: number;
  90066. private _shadowEnabled;
  90067. /**
  90068. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90069. * the current shadow generator.
  90070. */
  90071. get shadowEnabled(): boolean;
  90072. /**
  90073. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90074. * the current shadow generator.
  90075. */
  90076. set shadowEnabled(value: boolean);
  90077. private _includedOnlyMeshes;
  90078. /**
  90079. * Gets the only meshes impacted by this light.
  90080. */
  90081. get includedOnlyMeshes(): AbstractMesh[];
  90082. /**
  90083. * Sets the only meshes impacted by this light.
  90084. */
  90085. set includedOnlyMeshes(value: AbstractMesh[]);
  90086. private _excludedMeshes;
  90087. /**
  90088. * Gets the meshes not impacted by this light.
  90089. */
  90090. get excludedMeshes(): AbstractMesh[];
  90091. /**
  90092. * Sets the meshes not impacted by this light.
  90093. */
  90094. set excludedMeshes(value: AbstractMesh[]);
  90095. private _excludeWithLayerMask;
  90096. /**
  90097. * Gets the layer id use to find what meshes are not impacted by the light.
  90098. * Inactive if 0
  90099. */
  90100. get excludeWithLayerMask(): number;
  90101. /**
  90102. * Sets the layer id use to find what meshes are not impacted by the light.
  90103. * Inactive if 0
  90104. */
  90105. set excludeWithLayerMask(value: number);
  90106. private _includeOnlyWithLayerMask;
  90107. /**
  90108. * Gets the layer id use to find what meshes are impacted by the light.
  90109. * Inactive if 0
  90110. */
  90111. get includeOnlyWithLayerMask(): number;
  90112. /**
  90113. * Sets the layer id use to find what meshes are impacted by the light.
  90114. * Inactive if 0
  90115. */
  90116. set includeOnlyWithLayerMask(value: number);
  90117. private _lightmapMode;
  90118. /**
  90119. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90120. */
  90121. get lightmapMode(): number;
  90122. /**
  90123. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90124. */
  90125. set lightmapMode(value: number);
  90126. /**
  90127. * Shadow generator associted to the light.
  90128. * @hidden Internal use only.
  90129. */
  90130. _shadowGenerator: Nullable<IShadowGenerator>;
  90131. /**
  90132. * @hidden Internal use only.
  90133. */
  90134. _excludedMeshesIds: string[];
  90135. /**
  90136. * @hidden Internal use only.
  90137. */
  90138. _includedOnlyMeshesIds: string[];
  90139. /**
  90140. * The current light unifom buffer.
  90141. * @hidden Internal use only.
  90142. */
  90143. _uniformBuffer: UniformBuffer;
  90144. /** @hidden */
  90145. _renderId: number;
  90146. /**
  90147. * Creates a Light object in the scene.
  90148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90149. * @param name The firendly name of the light
  90150. * @param scene The scene the light belongs too
  90151. */
  90152. constructor(name: string, scene: Scene);
  90153. protected abstract _buildUniformLayout(): void;
  90154. /**
  90155. * Sets the passed Effect "effect" with the Light information.
  90156. * @param effect The effect to update
  90157. * @param lightIndex The index of the light in the effect to update
  90158. * @returns The light
  90159. */
  90160. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90161. /**
  90162. * Sets the passed Effect "effect" with the Light textures.
  90163. * @param effect The effect to update
  90164. * @param lightIndex The index of the light in the effect to update
  90165. * @returns The light
  90166. */
  90167. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90168. /**
  90169. * Binds the lights information from the scene to the effect for the given mesh.
  90170. * @param lightIndex Light index
  90171. * @param scene The scene where the light belongs to
  90172. * @param effect The effect we are binding the data to
  90173. * @param useSpecular Defines if specular is supported
  90174. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90175. */
  90176. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90177. /**
  90178. * Sets the passed Effect "effect" with the Light information.
  90179. * @param effect The effect to update
  90180. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90181. * @returns The light
  90182. */
  90183. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90184. /**
  90185. * Returns the string "Light".
  90186. * @returns the class name
  90187. */
  90188. getClassName(): string;
  90189. /** @hidden */
  90190. readonly _isLight: boolean;
  90191. /**
  90192. * Converts the light information to a readable string for debug purpose.
  90193. * @param fullDetails Supports for multiple levels of logging within scene loading
  90194. * @returns the human readable light info
  90195. */
  90196. toString(fullDetails?: boolean): string;
  90197. /** @hidden */
  90198. protected _syncParentEnabledState(): void;
  90199. /**
  90200. * Set the enabled state of this node.
  90201. * @param value - the new enabled state
  90202. */
  90203. setEnabled(value: boolean): void;
  90204. /**
  90205. * Returns the Light associated shadow generator if any.
  90206. * @return the associated shadow generator.
  90207. */
  90208. getShadowGenerator(): Nullable<IShadowGenerator>;
  90209. /**
  90210. * Returns a Vector3, the absolute light position in the World.
  90211. * @returns the world space position of the light
  90212. */
  90213. getAbsolutePosition(): Vector3;
  90214. /**
  90215. * Specifies if the light will affect the passed mesh.
  90216. * @param mesh The mesh to test against the light
  90217. * @return true the mesh is affected otherwise, false.
  90218. */
  90219. canAffectMesh(mesh: AbstractMesh): boolean;
  90220. /**
  90221. * Sort function to order lights for rendering.
  90222. * @param a First Light object to compare to second.
  90223. * @param b Second Light object to compare first.
  90224. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90225. */
  90226. static CompareLightsPriority(a: Light, b: Light): number;
  90227. /**
  90228. * Releases resources associated with this node.
  90229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90231. */
  90232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90233. /**
  90234. * Returns the light type ID (integer).
  90235. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90236. */
  90237. getTypeID(): number;
  90238. /**
  90239. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90240. * @returns the scaled intensity in intensity mode unit
  90241. */
  90242. getScaledIntensity(): number;
  90243. /**
  90244. * Returns a new Light object, named "name", from the current one.
  90245. * @param name The name of the cloned light
  90246. * @returns the new created light
  90247. */
  90248. clone(name: string): Nullable<Light>;
  90249. /**
  90250. * Serializes the current light into a Serialization object.
  90251. * @returns the serialized object.
  90252. */
  90253. serialize(): any;
  90254. /**
  90255. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90256. * This new light is named "name" and added to the passed scene.
  90257. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90258. * @param name The friendly name of the light
  90259. * @param scene The scene the new light will belong to
  90260. * @returns the constructor function
  90261. */
  90262. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90263. /**
  90264. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90265. * @param parsedLight The JSON representation of the light
  90266. * @param scene The scene to create the parsed light in
  90267. * @returns the created light after parsing
  90268. */
  90269. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90270. private _hookArrayForExcluded;
  90271. private _hookArrayForIncludedOnly;
  90272. private _resyncMeshes;
  90273. /**
  90274. * Forces the meshes to update their light related information in their rendering used effects
  90275. * @hidden Internal Use Only
  90276. */
  90277. _markMeshesAsLightDirty(): void;
  90278. /**
  90279. * Recomputes the cached photometric scale if needed.
  90280. */
  90281. private _computePhotometricScale;
  90282. /**
  90283. * Returns the Photometric Scale according to the light type and intensity mode.
  90284. */
  90285. private _getPhotometricScale;
  90286. /**
  90287. * Reorder the light in the scene according to their defined priority.
  90288. * @hidden Internal Use Only
  90289. */
  90290. _reorderLightsInScene(): void;
  90291. /**
  90292. * Prepares the list of defines specific to the light type.
  90293. * @param defines the list of defines
  90294. * @param lightIndex defines the index of the light for the effect
  90295. */
  90296. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90297. }
  90298. }
  90299. declare module BABYLON {
  90300. /**
  90301. * Interface used to define Action
  90302. */
  90303. export interface IAction {
  90304. /**
  90305. * Trigger for the action
  90306. */
  90307. trigger: number;
  90308. /** Options of the trigger */
  90309. triggerOptions: any;
  90310. /**
  90311. * Gets the trigger parameters
  90312. * @returns the trigger parameters
  90313. */
  90314. getTriggerParameter(): any;
  90315. /**
  90316. * Internal only - executes current action event
  90317. * @hidden
  90318. */
  90319. _executeCurrent(evt?: ActionEvent): void;
  90320. /**
  90321. * Serialize placeholder for child classes
  90322. * @param parent of child
  90323. * @returns the serialized object
  90324. */
  90325. serialize(parent: any): any;
  90326. /**
  90327. * Internal only
  90328. * @hidden
  90329. */
  90330. _prepare(): void;
  90331. /**
  90332. * Internal only - manager for action
  90333. * @hidden
  90334. */
  90335. _actionManager: AbstractActionManager;
  90336. /**
  90337. * Adds action to chain of actions, may be a DoNothingAction
  90338. * @param action defines the next action to execute
  90339. * @returns The action passed in
  90340. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90341. */
  90342. then(action: IAction): IAction;
  90343. }
  90344. /**
  90345. * The action to be carried out following a trigger
  90346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90347. */
  90348. export class Action implements IAction {
  90349. /** the trigger, with or without parameters, for the action */
  90350. triggerOptions: any;
  90351. /**
  90352. * Trigger for the action
  90353. */
  90354. trigger: number;
  90355. /**
  90356. * Internal only - manager for action
  90357. * @hidden
  90358. */
  90359. _actionManager: ActionManager;
  90360. private _nextActiveAction;
  90361. private _child;
  90362. private _condition?;
  90363. private _triggerParameter;
  90364. /**
  90365. * An event triggered prior to action being executed.
  90366. */
  90367. onBeforeExecuteObservable: Observable<Action>;
  90368. /**
  90369. * Creates a new Action
  90370. * @param triggerOptions the trigger, with or without parameters, for the action
  90371. * @param condition an optional determinant of action
  90372. */
  90373. constructor(
  90374. /** the trigger, with or without parameters, for the action */
  90375. triggerOptions: any, condition?: Condition);
  90376. /**
  90377. * Internal only
  90378. * @hidden
  90379. */
  90380. _prepare(): void;
  90381. /**
  90382. * Gets the trigger parameters
  90383. * @returns the trigger parameters
  90384. */
  90385. getTriggerParameter(): any;
  90386. /**
  90387. * Internal only - executes current action event
  90388. * @hidden
  90389. */
  90390. _executeCurrent(evt?: ActionEvent): void;
  90391. /**
  90392. * Execute placeholder for child classes
  90393. * @param evt optional action event
  90394. */
  90395. execute(evt?: ActionEvent): void;
  90396. /**
  90397. * Skips to next active action
  90398. */
  90399. skipToNextActiveAction(): void;
  90400. /**
  90401. * Adds action to chain of actions, may be a DoNothingAction
  90402. * @param action defines the next action to execute
  90403. * @returns The action passed in
  90404. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90405. */
  90406. then(action: Action): Action;
  90407. /**
  90408. * Internal only
  90409. * @hidden
  90410. */
  90411. _getProperty(propertyPath: string): string;
  90412. /**
  90413. * Internal only
  90414. * @hidden
  90415. */
  90416. _getEffectiveTarget(target: any, propertyPath: string): any;
  90417. /**
  90418. * Serialize placeholder for child classes
  90419. * @param parent of child
  90420. * @returns the serialized object
  90421. */
  90422. serialize(parent: any): any;
  90423. /**
  90424. * Internal only called by serialize
  90425. * @hidden
  90426. */
  90427. protected _serialize(serializedAction: any, parent?: any): any;
  90428. /**
  90429. * Internal only
  90430. * @hidden
  90431. */
  90432. static _SerializeValueAsString: (value: any) => string;
  90433. /**
  90434. * Internal only
  90435. * @hidden
  90436. */
  90437. static _GetTargetProperty: (target: Node | Scene) => {
  90438. name: string;
  90439. targetType: string;
  90440. value: string;
  90441. };
  90442. }
  90443. }
  90444. declare module BABYLON {
  90445. /**
  90446. * A Condition applied to an Action
  90447. */
  90448. export class Condition {
  90449. /**
  90450. * Internal only - manager for action
  90451. * @hidden
  90452. */
  90453. _actionManager: ActionManager;
  90454. /**
  90455. * Internal only
  90456. * @hidden
  90457. */
  90458. _evaluationId: number;
  90459. /**
  90460. * Internal only
  90461. * @hidden
  90462. */
  90463. _currentResult: boolean;
  90464. /**
  90465. * Creates a new Condition
  90466. * @param actionManager the manager of the action the condition is applied to
  90467. */
  90468. constructor(actionManager: ActionManager);
  90469. /**
  90470. * Check if the current condition is valid
  90471. * @returns a boolean
  90472. */
  90473. isValid(): boolean;
  90474. /**
  90475. * Internal only
  90476. * @hidden
  90477. */
  90478. _getProperty(propertyPath: string): string;
  90479. /**
  90480. * Internal only
  90481. * @hidden
  90482. */
  90483. _getEffectiveTarget(target: any, propertyPath: string): any;
  90484. /**
  90485. * Serialize placeholder for child classes
  90486. * @returns the serialized object
  90487. */
  90488. serialize(): any;
  90489. /**
  90490. * Internal only
  90491. * @hidden
  90492. */
  90493. protected _serialize(serializedCondition: any): any;
  90494. }
  90495. /**
  90496. * Defines specific conditional operators as extensions of Condition
  90497. */
  90498. export class ValueCondition extends Condition {
  90499. /** path to specify the property of the target the conditional operator uses */
  90500. propertyPath: string;
  90501. /** the value compared by the conditional operator against the current value of the property */
  90502. value: any;
  90503. /** the conditional operator, default ValueCondition.IsEqual */
  90504. operator: number;
  90505. /**
  90506. * Internal only
  90507. * @hidden
  90508. */
  90509. private static _IsEqual;
  90510. /**
  90511. * Internal only
  90512. * @hidden
  90513. */
  90514. private static _IsDifferent;
  90515. /**
  90516. * Internal only
  90517. * @hidden
  90518. */
  90519. private static _IsGreater;
  90520. /**
  90521. * Internal only
  90522. * @hidden
  90523. */
  90524. private static _IsLesser;
  90525. /**
  90526. * returns the number for IsEqual
  90527. */
  90528. static get IsEqual(): number;
  90529. /**
  90530. * Returns the number for IsDifferent
  90531. */
  90532. static get IsDifferent(): number;
  90533. /**
  90534. * Returns the number for IsGreater
  90535. */
  90536. static get IsGreater(): number;
  90537. /**
  90538. * Returns the number for IsLesser
  90539. */
  90540. static get IsLesser(): number;
  90541. /**
  90542. * Internal only The action manager for the condition
  90543. * @hidden
  90544. */
  90545. _actionManager: ActionManager;
  90546. /**
  90547. * Internal only
  90548. * @hidden
  90549. */
  90550. private _target;
  90551. /**
  90552. * Internal only
  90553. * @hidden
  90554. */
  90555. private _effectiveTarget;
  90556. /**
  90557. * Internal only
  90558. * @hidden
  90559. */
  90560. private _property;
  90561. /**
  90562. * Creates a new ValueCondition
  90563. * @param actionManager manager for the action the condition applies to
  90564. * @param target for the action
  90565. * @param propertyPath path to specify the property of the target the conditional operator uses
  90566. * @param value the value compared by the conditional operator against the current value of the property
  90567. * @param operator the conditional operator, default ValueCondition.IsEqual
  90568. */
  90569. constructor(actionManager: ActionManager, target: any,
  90570. /** path to specify the property of the target the conditional operator uses */
  90571. propertyPath: string,
  90572. /** the value compared by the conditional operator against the current value of the property */
  90573. value: any,
  90574. /** the conditional operator, default ValueCondition.IsEqual */
  90575. operator?: number);
  90576. /**
  90577. * Compares the given value with the property value for the specified conditional operator
  90578. * @returns the result of the comparison
  90579. */
  90580. isValid(): boolean;
  90581. /**
  90582. * Serialize the ValueCondition into a JSON compatible object
  90583. * @returns serialization object
  90584. */
  90585. serialize(): any;
  90586. /**
  90587. * Gets the name of the conditional operator for the ValueCondition
  90588. * @param operator the conditional operator
  90589. * @returns the name
  90590. */
  90591. static GetOperatorName(operator: number): string;
  90592. }
  90593. /**
  90594. * Defines a predicate condition as an extension of Condition
  90595. */
  90596. export class PredicateCondition extends Condition {
  90597. /** defines the predicate function used to validate the condition */
  90598. predicate: () => boolean;
  90599. /**
  90600. * Internal only - manager for action
  90601. * @hidden
  90602. */
  90603. _actionManager: ActionManager;
  90604. /**
  90605. * Creates a new PredicateCondition
  90606. * @param actionManager manager for the action the condition applies to
  90607. * @param predicate defines the predicate function used to validate the condition
  90608. */
  90609. constructor(actionManager: ActionManager,
  90610. /** defines the predicate function used to validate the condition */
  90611. predicate: () => boolean);
  90612. /**
  90613. * @returns the validity of the predicate condition
  90614. */
  90615. isValid(): boolean;
  90616. }
  90617. /**
  90618. * Defines a state condition as an extension of Condition
  90619. */
  90620. export class StateCondition extends Condition {
  90621. /** Value to compare with target state */
  90622. value: string;
  90623. /**
  90624. * Internal only - manager for action
  90625. * @hidden
  90626. */
  90627. _actionManager: ActionManager;
  90628. /**
  90629. * Internal only
  90630. * @hidden
  90631. */
  90632. private _target;
  90633. /**
  90634. * Creates a new StateCondition
  90635. * @param actionManager manager for the action the condition applies to
  90636. * @param target of the condition
  90637. * @param value to compare with target state
  90638. */
  90639. constructor(actionManager: ActionManager, target: any,
  90640. /** Value to compare with target state */
  90641. value: string);
  90642. /**
  90643. * Gets a boolean indicating if the current condition is met
  90644. * @returns the validity of the state
  90645. */
  90646. isValid(): boolean;
  90647. /**
  90648. * Serialize the StateCondition into a JSON compatible object
  90649. * @returns serialization object
  90650. */
  90651. serialize(): any;
  90652. }
  90653. }
  90654. declare module BABYLON {
  90655. /**
  90656. * This defines an action responsible to toggle a boolean once triggered.
  90657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90658. */
  90659. export class SwitchBooleanAction extends Action {
  90660. /**
  90661. * The path to the boolean property in the target object
  90662. */
  90663. propertyPath: string;
  90664. private _target;
  90665. private _effectiveTarget;
  90666. private _property;
  90667. /**
  90668. * Instantiate the action
  90669. * @param triggerOptions defines the trigger options
  90670. * @param target defines the object containing the boolean
  90671. * @param propertyPath defines the path to the boolean property in the target object
  90672. * @param condition defines the trigger related conditions
  90673. */
  90674. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90675. /** @hidden */
  90676. _prepare(): void;
  90677. /**
  90678. * Execute the action toggle the boolean value.
  90679. */
  90680. execute(): void;
  90681. /**
  90682. * Serializes the actions and its related information.
  90683. * @param parent defines the object to serialize in
  90684. * @returns the serialized object
  90685. */
  90686. serialize(parent: any): any;
  90687. }
  90688. /**
  90689. * This defines an action responsible to set a the state field of the target
  90690. * to a desired value once triggered.
  90691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90692. */
  90693. export class SetStateAction extends Action {
  90694. /**
  90695. * The value to store in the state field.
  90696. */
  90697. value: string;
  90698. private _target;
  90699. /**
  90700. * Instantiate the action
  90701. * @param triggerOptions defines the trigger options
  90702. * @param target defines the object containing the state property
  90703. * @param value defines the value to store in the state field
  90704. * @param condition defines the trigger related conditions
  90705. */
  90706. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90707. /**
  90708. * Execute the action and store the value on the target state property.
  90709. */
  90710. execute(): void;
  90711. /**
  90712. * Serializes the actions and its related information.
  90713. * @param parent defines the object to serialize in
  90714. * @returns the serialized object
  90715. */
  90716. serialize(parent: any): any;
  90717. }
  90718. /**
  90719. * This defines an action responsible to set a property of the target
  90720. * to a desired value once triggered.
  90721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90722. */
  90723. export class SetValueAction extends Action {
  90724. /**
  90725. * The path of the property to set in the target.
  90726. */
  90727. propertyPath: string;
  90728. /**
  90729. * The value to set in the property
  90730. */
  90731. value: any;
  90732. private _target;
  90733. private _effectiveTarget;
  90734. private _property;
  90735. /**
  90736. * Instantiate the action
  90737. * @param triggerOptions defines the trigger options
  90738. * @param target defines the object containing the property
  90739. * @param propertyPath defines the path of the property to set in the target
  90740. * @param value defines the value to set in the property
  90741. * @param condition defines the trigger related conditions
  90742. */
  90743. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90744. /** @hidden */
  90745. _prepare(): void;
  90746. /**
  90747. * Execute the action and set the targetted property to the desired value.
  90748. */
  90749. execute(): void;
  90750. /**
  90751. * Serializes the actions and its related information.
  90752. * @param parent defines the object to serialize in
  90753. * @returns the serialized object
  90754. */
  90755. serialize(parent: any): any;
  90756. }
  90757. /**
  90758. * This defines an action responsible to increment the target value
  90759. * to a desired value once triggered.
  90760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90761. */
  90762. export class IncrementValueAction extends Action {
  90763. /**
  90764. * The path of the property to increment in the target.
  90765. */
  90766. propertyPath: string;
  90767. /**
  90768. * The value we should increment the property by.
  90769. */
  90770. value: any;
  90771. private _target;
  90772. private _effectiveTarget;
  90773. private _property;
  90774. /**
  90775. * Instantiate the action
  90776. * @param triggerOptions defines the trigger options
  90777. * @param target defines the object containing the property
  90778. * @param propertyPath defines the path of the property to increment in the target
  90779. * @param value defines the value value we should increment the property by
  90780. * @param condition defines the trigger related conditions
  90781. */
  90782. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90783. /** @hidden */
  90784. _prepare(): void;
  90785. /**
  90786. * Execute the action and increment the target of the value amount.
  90787. */
  90788. execute(): void;
  90789. /**
  90790. * Serializes the actions and its related information.
  90791. * @param parent defines the object to serialize in
  90792. * @returns the serialized object
  90793. */
  90794. serialize(parent: any): any;
  90795. }
  90796. /**
  90797. * This defines an action responsible to start an animation once triggered.
  90798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90799. */
  90800. export class PlayAnimationAction extends Action {
  90801. /**
  90802. * Where the animation should start (animation frame)
  90803. */
  90804. from: number;
  90805. /**
  90806. * Where the animation should stop (animation frame)
  90807. */
  90808. to: number;
  90809. /**
  90810. * Define if the animation should loop or stop after the first play.
  90811. */
  90812. loop?: boolean;
  90813. private _target;
  90814. /**
  90815. * Instantiate the action
  90816. * @param triggerOptions defines the trigger options
  90817. * @param target defines the target animation or animation name
  90818. * @param from defines from where the animation should start (animation frame)
  90819. * @param end defines where the animation should stop (animation frame)
  90820. * @param loop defines if the animation should loop or stop after the first play
  90821. * @param condition defines the trigger related conditions
  90822. */
  90823. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90824. /** @hidden */
  90825. _prepare(): void;
  90826. /**
  90827. * Execute the action and play the animation.
  90828. */
  90829. execute(): void;
  90830. /**
  90831. * Serializes the actions and its related information.
  90832. * @param parent defines the object to serialize in
  90833. * @returns the serialized object
  90834. */
  90835. serialize(parent: any): any;
  90836. }
  90837. /**
  90838. * This defines an action responsible to stop an animation once triggered.
  90839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90840. */
  90841. export class StopAnimationAction extends Action {
  90842. private _target;
  90843. /**
  90844. * Instantiate the action
  90845. * @param triggerOptions defines the trigger options
  90846. * @param target defines the target animation or animation name
  90847. * @param condition defines the trigger related conditions
  90848. */
  90849. constructor(triggerOptions: any, target: any, condition?: Condition);
  90850. /** @hidden */
  90851. _prepare(): void;
  90852. /**
  90853. * Execute the action and stop the animation.
  90854. */
  90855. execute(): void;
  90856. /**
  90857. * Serializes the actions and its related information.
  90858. * @param parent defines the object to serialize in
  90859. * @returns the serialized object
  90860. */
  90861. serialize(parent: any): any;
  90862. }
  90863. /**
  90864. * This defines an action responsible that does nothing once triggered.
  90865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90866. */
  90867. export class DoNothingAction extends Action {
  90868. /**
  90869. * Instantiate the action
  90870. * @param triggerOptions defines the trigger options
  90871. * @param condition defines the trigger related conditions
  90872. */
  90873. constructor(triggerOptions?: any, condition?: Condition);
  90874. /**
  90875. * Execute the action and do nothing.
  90876. */
  90877. execute(): void;
  90878. /**
  90879. * Serializes the actions and its related information.
  90880. * @param parent defines the object to serialize in
  90881. * @returns the serialized object
  90882. */
  90883. serialize(parent: any): any;
  90884. }
  90885. /**
  90886. * This defines an action responsible to trigger several actions once triggered.
  90887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90888. */
  90889. export class CombineAction extends Action {
  90890. /**
  90891. * The list of aggregated animations to run.
  90892. */
  90893. children: Action[];
  90894. /**
  90895. * Instantiate the action
  90896. * @param triggerOptions defines the trigger options
  90897. * @param children defines the list of aggregated animations to run
  90898. * @param condition defines the trigger related conditions
  90899. */
  90900. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90901. /** @hidden */
  90902. _prepare(): void;
  90903. /**
  90904. * Execute the action and executes all the aggregated actions.
  90905. */
  90906. execute(evt: ActionEvent): void;
  90907. /**
  90908. * Serializes the actions and its related information.
  90909. * @param parent defines the object to serialize in
  90910. * @returns the serialized object
  90911. */
  90912. serialize(parent: any): any;
  90913. }
  90914. /**
  90915. * This defines an action responsible to run code (external event) once triggered.
  90916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90917. */
  90918. export class ExecuteCodeAction extends Action {
  90919. /**
  90920. * The callback function to run.
  90921. */
  90922. func: (evt: ActionEvent) => void;
  90923. /**
  90924. * Instantiate the action
  90925. * @param triggerOptions defines the trigger options
  90926. * @param func defines the callback function to run
  90927. * @param condition defines the trigger related conditions
  90928. */
  90929. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90930. /**
  90931. * Execute the action and run the attached code.
  90932. */
  90933. execute(evt: ActionEvent): void;
  90934. }
  90935. /**
  90936. * This defines an action responsible to set the parent property of the target once triggered.
  90937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90938. */
  90939. export class SetParentAction extends Action {
  90940. private _parent;
  90941. private _target;
  90942. /**
  90943. * Instantiate the action
  90944. * @param triggerOptions defines the trigger options
  90945. * @param target defines the target containing the parent property
  90946. * @param parent defines from where the animation should start (animation frame)
  90947. * @param condition defines the trigger related conditions
  90948. */
  90949. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90950. /** @hidden */
  90951. _prepare(): void;
  90952. /**
  90953. * Execute the action and set the parent property.
  90954. */
  90955. execute(): void;
  90956. /**
  90957. * Serializes the actions and its related information.
  90958. * @param parent defines the object to serialize in
  90959. * @returns the serialized object
  90960. */
  90961. serialize(parent: any): any;
  90962. }
  90963. }
  90964. declare module BABYLON {
  90965. /**
  90966. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90967. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90969. */
  90970. export class ActionManager extends AbstractActionManager {
  90971. /**
  90972. * Nothing
  90973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90974. */
  90975. static readonly NothingTrigger: number;
  90976. /**
  90977. * On pick
  90978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90979. */
  90980. static readonly OnPickTrigger: number;
  90981. /**
  90982. * On left pick
  90983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90984. */
  90985. static readonly OnLeftPickTrigger: number;
  90986. /**
  90987. * On right pick
  90988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90989. */
  90990. static readonly OnRightPickTrigger: number;
  90991. /**
  90992. * On center pick
  90993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90994. */
  90995. static readonly OnCenterPickTrigger: number;
  90996. /**
  90997. * On pick down
  90998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90999. */
  91000. static readonly OnPickDownTrigger: number;
  91001. /**
  91002. * On double pick
  91003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91004. */
  91005. static readonly OnDoublePickTrigger: number;
  91006. /**
  91007. * On pick up
  91008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91009. */
  91010. static readonly OnPickUpTrigger: number;
  91011. /**
  91012. * On pick out.
  91013. * This trigger will only be raised if you also declared a OnPickDown
  91014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91015. */
  91016. static readonly OnPickOutTrigger: number;
  91017. /**
  91018. * On long press
  91019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91020. */
  91021. static readonly OnLongPressTrigger: number;
  91022. /**
  91023. * On pointer over
  91024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91025. */
  91026. static readonly OnPointerOverTrigger: number;
  91027. /**
  91028. * On pointer out
  91029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91030. */
  91031. static readonly OnPointerOutTrigger: number;
  91032. /**
  91033. * On every frame
  91034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91035. */
  91036. static readonly OnEveryFrameTrigger: number;
  91037. /**
  91038. * On intersection enter
  91039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91040. */
  91041. static readonly OnIntersectionEnterTrigger: number;
  91042. /**
  91043. * On intersection exit
  91044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91045. */
  91046. static readonly OnIntersectionExitTrigger: number;
  91047. /**
  91048. * On key down
  91049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91050. */
  91051. static readonly OnKeyDownTrigger: number;
  91052. /**
  91053. * On key up
  91054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91055. */
  91056. static readonly OnKeyUpTrigger: number;
  91057. private _scene;
  91058. /**
  91059. * Creates a new action manager
  91060. * @param scene defines the hosting scene
  91061. */
  91062. constructor(scene: Scene);
  91063. /**
  91064. * Releases all associated resources
  91065. */
  91066. dispose(): void;
  91067. /**
  91068. * Gets hosting scene
  91069. * @returns the hosting scene
  91070. */
  91071. getScene(): Scene;
  91072. /**
  91073. * Does this action manager handles actions of any of the given triggers
  91074. * @param triggers defines the triggers to be tested
  91075. * @return a boolean indicating whether one (or more) of the triggers is handled
  91076. */
  91077. hasSpecificTriggers(triggers: number[]): boolean;
  91078. /**
  91079. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91080. * speed.
  91081. * @param triggerA defines the trigger to be tested
  91082. * @param triggerB defines the trigger to be tested
  91083. * @return a boolean indicating whether one (or more) of the triggers is handled
  91084. */
  91085. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91086. /**
  91087. * Does this action manager handles actions of a given trigger
  91088. * @param trigger defines the trigger to be tested
  91089. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91090. * @return whether the trigger is handled
  91091. */
  91092. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91093. /**
  91094. * Does this action manager has pointer triggers
  91095. */
  91096. get hasPointerTriggers(): boolean;
  91097. /**
  91098. * Does this action manager has pick triggers
  91099. */
  91100. get hasPickTriggers(): boolean;
  91101. /**
  91102. * Registers an action to this action manager
  91103. * @param action defines the action to be registered
  91104. * @return the action amended (prepared) after registration
  91105. */
  91106. registerAction(action: IAction): Nullable<IAction>;
  91107. /**
  91108. * Unregisters an action to this action manager
  91109. * @param action defines the action to be unregistered
  91110. * @return a boolean indicating whether the action has been unregistered
  91111. */
  91112. unregisterAction(action: IAction): Boolean;
  91113. /**
  91114. * Process a specific trigger
  91115. * @param trigger defines the trigger to process
  91116. * @param evt defines the event details to be processed
  91117. */
  91118. processTrigger(trigger: number, evt?: IActionEvent): void;
  91119. /** @hidden */
  91120. _getEffectiveTarget(target: any, propertyPath: string): any;
  91121. /** @hidden */
  91122. _getProperty(propertyPath: string): string;
  91123. /**
  91124. * Serialize this manager to a JSON object
  91125. * @param name defines the property name to store this manager
  91126. * @returns a JSON representation of this manager
  91127. */
  91128. serialize(name: string): any;
  91129. /**
  91130. * Creates a new ActionManager from a JSON data
  91131. * @param parsedActions defines the JSON data to read from
  91132. * @param object defines the hosting mesh
  91133. * @param scene defines the hosting scene
  91134. */
  91135. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91136. /**
  91137. * Get a trigger name by index
  91138. * @param trigger defines the trigger index
  91139. * @returns a trigger name
  91140. */
  91141. static GetTriggerName(trigger: number): string;
  91142. }
  91143. }
  91144. declare module BABYLON {
  91145. /**
  91146. * Class used to represent a sprite
  91147. * @see http://doc.babylonjs.com/babylon101/sprites
  91148. */
  91149. export class Sprite {
  91150. /** defines the name */
  91151. name: string;
  91152. /** Gets or sets the current world position */
  91153. position: Vector3;
  91154. /** Gets or sets the main color */
  91155. color: Color4;
  91156. /** Gets or sets the width */
  91157. width: number;
  91158. /** Gets or sets the height */
  91159. height: number;
  91160. /** Gets or sets rotation angle */
  91161. angle: number;
  91162. /** Gets or sets the cell index in the sprite sheet */
  91163. cellIndex: number;
  91164. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91165. cellRef: string;
  91166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91167. invertU: number;
  91168. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91169. invertV: number;
  91170. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91171. disposeWhenFinishedAnimating: boolean;
  91172. /** Gets the list of attached animations */
  91173. animations: Animation[];
  91174. /** Gets or sets a boolean indicating if the sprite can be picked */
  91175. isPickable: boolean;
  91176. /**
  91177. * Gets or sets the associated action manager
  91178. */
  91179. actionManager: Nullable<ActionManager>;
  91180. private _animationStarted;
  91181. private _loopAnimation;
  91182. private _fromIndex;
  91183. private _toIndex;
  91184. private _delay;
  91185. private _direction;
  91186. private _manager;
  91187. private _time;
  91188. private _onAnimationEnd;
  91189. /**
  91190. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91191. */
  91192. isVisible: boolean;
  91193. /**
  91194. * Gets or sets the sprite size
  91195. */
  91196. get size(): number;
  91197. set size(value: number);
  91198. /**
  91199. * Creates a new Sprite
  91200. * @param name defines the name
  91201. * @param manager defines the manager
  91202. */
  91203. constructor(
  91204. /** defines the name */
  91205. name: string, manager: ISpriteManager);
  91206. /**
  91207. * Starts an animation
  91208. * @param from defines the initial key
  91209. * @param to defines the end key
  91210. * @param loop defines if the animation must loop
  91211. * @param delay defines the start delay (in ms)
  91212. * @param onAnimationEnd defines a callback to call when animation ends
  91213. */
  91214. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91215. /** Stops current animation (if any) */
  91216. stopAnimation(): void;
  91217. /** @hidden */
  91218. _animate(deltaTime: number): void;
  91219. /** Release associated resources */
  91220. dispose(): void;
  91221. }
  91222. }
  91223. declare module BABYLON {
  91224. /**
  91225. * Information about the result of picking within a scene
  91226. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91227. */
  91228. export class PickingInfo {
  91229. /** @hidden */
  91230. _pickingUnavailable: boolean;
  91231. /**
  91232. * If the pick collided with an object
  91233. */
  91234. hit: boolean;
  91235. /**
  91236. * Distance away where the pick collided
  91237. */
  91238. distance: number;
  91239. /**
  91240. * The location of pick collision
  91241. */
  91242. pickedPoint: Nullable<Vector3>;
  91243. /**
  91244. * The mesh corresponding the the pick collision
  91245. */
  91246. pickedMesh: Nullable<AbstractMesh>;
  91247. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91248. bu: number;
  91249. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91250. bv: number;
  91251. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91252. faceId: number;
  91253. /** Id of the the submesh that was picked */
  91254. subMeshId: number;
  91255. /** If a sprite was picked, this will be the sprite the pick collided with */
  91256. pickedSprite: Nullable<Sprite>;
  91257. /**
  91258. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91259. */
  91260. originMesh: Nullable<AbstractMesh>;
  91261. /**
  91262. * The ray that was used to perform the picking.
  91263. */
  91264. ray: Nullable<Ray>;
  91265. /**
  91266. * Gets the normal correspodning to the face the pick collided with
  91267. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91268. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91269. * @returns The normal correspodning to the face the pick collided with
  91270. */
  91271. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91272. /**
  91273. * Gets the texture coordinates of where the pick occured
  91274. * @returns the vector containing the coordnates of the texture
  91275. */
  91276. getTextureCoordinates(): Nullable<Vector2>;
  91277. }
  91278. }
  91279. declare module BABYLON {
  91280. /**
  91281. * Gather the list of pointer event types as constants.
  91282. */
  91283. export class PointerEventTypes {
  91284. /**
  91285. * 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.
  91286. */
  91287. static readonly POINTERDOWN: number;
  91288. /**
  91289. * The pointerup event is fired when a pointer is no longer active.
  91290. */
  91291. static readonly POINTERUP: number;
  91292. /**
  91293. * The pointermove event is fired when a pointer changes coordinates.
  91294. */
  91295. static readonly POINTERMOVE: number;
  91296. /**
  91297. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91298. */
  91299. static readonly POINTERWHEEL: number;
  91300. /**
  91301. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91302. */
  91303. static readonly POINTERPICK: number;
  91304. /**
  91305. * The pointertap event is fired when a the object has been touched and released without drag.
  91306. */
  91307. static readonly POINTERTAP: number;
  91308. /**
  91309. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91310. */
  91311. static readonly POINTERDOUBLETAP: number;
  91312. }
  91313. /**
  91314. * Base class of pointer info types.
  91315. */
  91316. export class PointerInfoBase {
  91317. /**
  91318. * Defines the type of event (PointerEventTypes)
  91319. */
  91320. type: number;
  91321. /**
  91322. * Defines the related dom event
  91323. */
  91324. event: PointerEvent | MouseWheelEvent;
  91325. /**
  91326. * Instantiates the base class of pointers info.
  91327. * @param type Defines the type of event (PointerEventTypes)
  91328. * @param event Defines the related dom event
  91329. */
  91330. constructor(
  91331. /**
  91332. * Defines the type of event (PointerEventTypes)
  91333. */
  91334. type: number,
  91335. /**
  91336. * Defines the related dom event
  91337. */
  91338. event: PointerEvent | MouseWheelEvent);
  91339. }
  91340. /**
  91341. * This class is used to store pointer related info for the onPrePointerObservable event.
  91342. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91343. */
  91344. export class PointerInfoPre extends PointerInfoBase {
  91345. /**
  91346. * Ray from a pointer if availible (eg. 6dof controller)
  91347. */
  91348. ray: Nullable<Ray>;
  91349. /**
  91350. * Defines the local position of the pointer on the canvas.
  91351. */
  91352. localPosition: Vector2;
  91353. /**
  91354. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91355. */
  91356. skipOnPointerObservable: boolean;
  91357. /**
  91358. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91359. * @param type Defines the type of event (PointerEventTypes)
  91360. * @param event Defines the related dom event
  91361. * @param localX Defines the local x coordinates of the pointer when the event occured
  91362. * @param localY Defines the local y coordinates of the pointer when the event occured
  91363. */
  91364. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91365. }
  91366. /**
  91367. * This type contains all the data related to a pointer event in Babylon.js.
  91368. * 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.
  91369. */
  91370. export class PointerInfo extends PointerInfoBase {
  91371. /**
  91372. * Defines the picking info associated to the info (if any)\
  91373. */
  91374. pickInfo: Nullable<PickingInfo>;
  91375. /**
  91376. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91377. * @param type Defines the type of event (PointerEventTypes)
  91378. * @param event Defines the related dom event
  91379. * @param pickInfo Defines the picking info associated to the info (if any)\
  91380. */
  91381. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91382. /**
  91383. * Defines the picking info associated to the info (if any)\
  91384. */
  91385. pickInfo: Nullable<PickingInfo>);
  91386. }
  91387. /**
  91388. * Data relating to a touch event on the screen.
  91389. */
  91390. export interface PointerTouch {
  91391. /**
  91392. * X coordinate of touch.
  91393. */
  91394. x: number;
  91395. /**
  91396. * Y coordinate of touch.
  91397. */
  91398. y: number;
  91399. /**
  91400. * Id of touch. Unique for each finger.
  91401. */
  91402. pointerId: number;
  91403. /**
  91404. * Event type passed from DOM.
  91405. */
  91406. type: any;
  91407. }
  91408. }
  91409. declare module BABYLON {
  91410. /**
  91411. * Manage the mouse inputs to control the movement of a free camera.
  91412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91413. */
  91414. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91415. /**
  91416. * Define if touch is enabled in the mouse input
  91417. */
  91418. touchEnabled: boolean;
  91419. /**
  91420. * Defines the camera the input is attached to.
  91421. */
  91422. camera: FreeCamera;
  91423. /**
  91424. * Defines the buttons associated with the input to handle camera move.
  91425. */
  91426. buttons: number[];
  91427. /**
  91428. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91429. */
  91430. angularSensibility: number;
  91431. private _pointerInput;
  91432. private _onMouseMove;
  91433. private _observer;
  91434. private previousPosition;
  91435. /**
  91436. * Observable for when a pointer move event occurs containing the move offset
  91437. */
  91438. onPointerMovedObservable: Observable<{
  91439. offsetX: number;
  91440. offsetY: number;
  91441. }>;
  91442. /**
  91443. * @hidden
  91444. * If the camera should be rotated automatically based on pointer movement
  91445. */
  91446. _allowCameraRotation: boolean;
  91447. /**
  91448. * Manage the mouse inputs to control the movement of a free camera.
  91449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91450. * @param touchEnabled Defines if touch is enabled or not
  91451. */
  91452. constructor(
  91453. /**
  91454. * Define if touch is enabled in the mouse input
  91455. */
  91456. touchEnabled?: boolean);
  91457. /**
  91458. * Attach the input controls to a specific dom element to get the input from.
  91459. * @param element Defines the element the controls should be listened from
  91460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91461. */
  91462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91463. /**
  91464. * Called on JS contextmenu event.
  91465. * Override this method to provide functionality.
  91466. */
  91467. protected onContextMenu(evt: PointerEvent): void;
  91468. /**
  91469. * Detach the current controls from the specified dom element.
  91470. * @param element Defines the element to stop listening the inputs from
  91471. */
  91472. detachControl(element: Nullable<HTMLElement>): void;
  91473. /**
  91474. * Gets the class name of the current intput.
  91475. * @returns the class name
  91476. */
  91477. getClassName(): string;
  91478. /**
  91479. * Get the friendly name associated with the input class.
  91480. * @returns the input friendly name
  91481. */
  91482. getSimpleName(): string;
  91483. }
  91484. }
  91485. declare module BABYLON {
  91486. /**
  91487. * Manage the touch inputs to control the movement of a free camera.
  91488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91489. */
  91490. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91491. /**
  91492. * Defines the camera the input is attached to.
  91493. */
  91494. camera: FreeCamera;
  91495. /**
  91496. * Defines the touch sensibility for rotation.
  91497. * The higher the faster.
  91498. */
  91499. touchAngularSensibility: number;
  91500. /**
  91501. * Defines the touch sensibility for move.
  91502. * The higher the faster.
  91503. */
  91504. touchMoveSensibility: number;
  91505. private _offsetX;
  91506. private _offsetY;
  91507. private _pointerPressed;
  91508. private _pointerInput;
  91509. private _observer;
  91510. private _onLostFocus;
  91511. /**
  91512. * Attach the input controls to a specific dom element to get the input from.
  91513. * @param element Defines the element the controls should be listened from
  91514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91515. */
  91516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91517. /**
  91518. * Detach the current controls from the specified dom element.
  91519. * @param element Defines the element to stop listening the inputs from
  91520. */
  91521. detachControl(element: Nullable<HTMLElement>): void;
  91522. /**
  91523. * Update the current camera state depending on the inputs that have been used this frame.
  91524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91525. */
  91526. checkInputs(): void;
  91527. /**
  91528. * Gets the class name of the current intput.
  91529. * @returns the class name
  91530. */
  91531. getClassName(): string;
  91532. /**
  91533. * Get the friendly name associated with the input class.
  91534. * @returns the input friendly name
  91535. */
  91536. getSimpleName(): string;
  91537. }
  91538. }
  91539. declare module BABYLON {
  91540. /**
  91541. * Default Inputs manager for the FreeCamera.
  91542. * It groups all the default supported inputs for ease of use.
  91543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91544. */
  91545. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91546. /**
  91547. * @hidden
  91548. */
  91549. _mouseInput: Nullable<FreeCameraMouseInput>;
  91550. /**
  91551. * Instantiates a new FreeCameraInputsManager.
  91552. * @param camera Defines the camera the inputs belong to
  91553. */
  91554. constructor(camera: FreeCamera);
  91555. /**
  91556. * Add keyboard input support to the input manager.
  91557. * @returns the current input manager
  91558. */
  91559. addKeyboard(): FreeCameraInputsManager;
  91560. /**
  91561. * Add mouse input support to the input manager.
  91562. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91563. * @returns the current input manager
  91564. */
  91565. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91566. /**
  91567. * Removes the mouse input support from the manager
  91568. * @returns the current input manager
  91569. */
  91570. removeMouse(): FreeCameraInputsManager;
  91571. /**
  91572. * Add touch input support to the input manager.
  91573. * @returns the current input manager
  91574. */
  91575. addTouch(): FreeCameraInputsManager;
  91576. /**
  91577. * Remove all attached input methods from a camera
  91578. */
  91579. clear(): void;
  91580. }
  91581. }
  91582. declare module BABYLON {
  91583. /**
  91584. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91585. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91586. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91587. */
  91588. export class FreeCamera extends TargetCamera {
  91589. /**
  91590. * Define the collision ellipsoid of the camera.
  91591. * This is helpful to simulate a camera body like the player body around the camera
  91592. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91593. */
  91594. ellipsoid: Vector3;
  91595. /**
  91596. * Define an offset for the position of the ellipsoid around the camera.
  91597. * This can be helpful to determine the center of the body near the gravity center of the body
  91598. * instead of its head.
  91599. */
  91600. ellipsoidOffset: Vector3;
  91601. /**
  91602. * Enable or disable collisions of the camera with the rest of the scene objects.
  91603. */
  91604. checkCollisions: boolean;
  91605. /**
  91606. * Enable or disable gravity on the camera.
  91607. */
  91608. applyGravity: boolean;
  91609. /**
  91610. * Define the input manager associated to the camera.
  91611. */
  91612. inputs: FreeCameraInputsManager;
  91613. /**
  91614. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91615. * Higher values reduce sensitivity.
  91616. */
  91617. get angularSensibility(): number;
  91618. /**
  91619. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91620. * Higher values reduce sensitivity.
  91621. */
  91622. set angularSensibility(value: number);
  91623. /**
  91624. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91625. */
  91626. get keysUp(): number[];
  91627. set keysUp(value: number[]);
  91628. /**
  91629. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91630. */
  91631. get keysDown(): number[];
  91632. set keysDown(value: number[]);
  91633. /**
  91634. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91635. */
  91636. get keysLeft(): number[];
  91637. set keysLeft(value: number[]);
  91638. /**
  91639. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91640. */
  91641. get keysRight(): number[];
  91642. set keysRight(value: number[]);
  91643. /**
  91644. * Event raised when the camera collide with a mesh in the scene.
  91645. */
  91646. onCollide: (collidedMesh: AbstractMesh) => void;
  91647. private _collider;
  91648. private _needMoveForGravity;
  91649. private _oldPosition;
  91650. private _diffPosition;
  91651. private _newPosition;
  91652. /** @hidden */
  91653. _localDirection: Vector3;
  91654. /** @hidden */
  91655. _transformedDirection: Vector3;
  91656. /**
  91657. * Instantiates a Free Camera.
  91658. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91659. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91660. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91661. * @param name Define the name of the camera in the scene
  91662. * @param position Define the start position of the camera in the scene
  91663. * @param scene Define the scene the camera belongs to
  91664. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91665. */
  91666. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91667. /**
  91668. * Attached controls to the current camera.
  91669. * @param element Defines the element the controls should be listened from
  91670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91671. */
  91672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91673. /**
  91674. * Detach the current controls from the camera.
  91675. * The camera will stop reacting to inputs.
  91676. * @param element Defines the element to stop listening the inputs from
  91677. */
  91678. detachControl(element: HTMLElement): void;
  91679. private _collisionMask;
  91680. /**
  91681. * Define a collision mask to limit the list of object the camera can collide with
  91682. */
  91683. get collisionMask(): number;
  91684. set collisionMask(mask: number);
  91685. /** @hidden */
  91686. _collideWithWorld(displacement: Vector3): void;
  91687. private _onCollisionPositionChange;
  91688. /** @hidden */
  91689. _checkInputs(): void;
  91690. /** @hidden */
  91691. _decideIfNeedsToMove(): boolean;
  91692. /** @hidden */
  91693. _updatePosition(): void;
  91694. /**
  91695. * Destroy the camera and release the current resources hold by it.
  91696. */
  91697. dispose(): void;
  91698. /**
  91699. * Gets the current object class name.
  91700. * @return the class name
  91701. */
  91702. getClassName(): string;
  91703. }
  91704. }
  91705. declare module BABYLON {
  91706. /**
  91707. * Represents a gamepad control stick position
  91708. */
  91709. export class StickValues {
  91710. /**
  91711. * The x component of the control stick
  91712. */
  91713. x: number;
  91714. /**
  91715. * The y component of the control stick
  91716. */
  91717. y: number;
  91718. /**
  91719. * Initializes the gamepad x and y control stick values
  91720. * @param x The x component of the gamepad control stick value
  91721. * @param y The y component of the gamepad control stick value
  91722. */
  91723. constructor(
  91724. /**
  91725. * The x component of the control stick
  91726. */
  91727. x: number,
  91728. /**
  91729. * The y component of the control stick
  91730. */
  91731. y: number);
  91732. }
  91733. /**
  91734. * An interface which manages callbacks for gamepad button changes
  91735. */
  91736. export interface GamepadButtonChanges {
  91737. /**
  91738. * Called when a gamepad has been changed
  91739. */
  91740. changed: boolean;
  91741. /**
  91742. * Called when a gamepad press event has been triggered
  91743. */
  91744. pressChanged: boolean;
  91745. /**
  91746. * Called when a touch event has been triggered
  91747. */
  91748. touchChanged: boolean;
  91749. /**
  91750. * Called when a value has changed
  91751. */
  91752. valueChanged: boolean;
  91753. }
  91754. /**
  91755. * Represents a gamepad
  91756. */
  91757. export class Gamepad {
  91758. /**
  91759. * The id of the gamepad
  91760. */
  91761. id: string;
  91762. /**
  91763. * The index of the gamepad
  91764. */
  91765. index: number;
  91766. /**
  91767. * The browser gamepad
  91768. */
  91769. browserGamepad: any;
  91770. /**
  91771. * Specifies what type of gamepad this represents
  91772. */
  91773. type: number;
  91774. private _leftStick;
  91775. private _rightStick;
  91776. /** @hidden */
  91777. _isConnected: boolean;
  91778. private _leftStickAxisX;
  91779. private _leftStickAxisY;
  91780. private _rightStickAxisX;
  91781. private _rightStickAxisY;
  91782. /**
  91783. * Triggered when the left control stick has been changed
  91784. */
  91785. private _onleftstickchanged;
  91786. /**
  91787. * Triggered when the right control stick has been changed
  91788. */
  91789. private _onrightstickchanged;
  91790. /**
  91791. * Represents a gamepad controller
  91792. */
  91793. static GAMEPAD: number;
  91794. /**
  91795. * Represents a generic controller
  91796. */
  91797. static GENERIC: number;
  91798. /**
  91799. * Represents an XBox controller
  91800. */
  91801. static XBOX: number;
  91802. /**
  91803. * Represents a pose-enabled controller
  91804. */
  91805. static POSE_ENABLED: number;
  91806. /**
  91807. * Represents an Dual Shock controller
  91808. */
  91809. static DUALSHOCK: number;
  91810. /**
  91811. * Specifies whether the left control stick should be Y-inverted
  91812. */
  91813. protected _invertLeftStickY: boolean;
  91814. /**
  91815. * Specifies if the gamepad has been connected
  91816. */
  91817. get isConnected(): boolean;
  91818. /**
  91819. * Initializes the gamepad
  91820. * @param id The id of the gamepad
  91821. * @param index The index of the gamepad
  91822. * @param browserGamepad The browser gamepad
  91823. * @param leftStickX The x component of the left joystick
  91824. * @param leftStickY The y component of the left joystick
  91825. * @param rightStickX The x component of the right joystick
  91826. * @param rightStickY The y component of the right joystick
  91827. */
  91828. constructor(
  91829. /**
  91830. * The id of the gamepad
  91831. */
  91832. id: string,
  91833. /**
  91834. * The index of the gamepad
  91835. */
  91836. index: number,
  91837. /**
  91838. * The browser gamepad
  91839. */
  91840. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91841. /**
  91842. * Callback triggered when the left joystick has changed
  91843. * @param callback
  91844. */
  91845. onleftstickchanged(callback: (values: StickValues) => void): void;
  91846. /**
  91847. * Callback triggered when the right joystick has changed
  91848. * @param callback
  91849. */
  91850. onrightstickchanged(callback: (values: StickValues) => void): void;
  91851. /**
  91852. * Gets the left joystick
  91853. */
  91854. get leftStick(): StickValues;
  91855. /**
  91856. * Sets the left joystick values
  91857. */
  91858. set leftStick(newValues: StickValues);
  91859. /**
  91860. * Gets the right joystick
  91861. */
  91862. get rightStick(): StickValues;
  91863. /**
  91864. * Sets the right joystick value
  91865. */
  91866. set rightStick(newValues: StickValues);
  91867. /**
  91868. * Updates the gamepad joystick positions
  91869. */
  91870. update(): void;
  91871. /**
  91872. * Disposes the gamepad
  91873. */
  91874. dispose(): void;
  91875. }
  91876. /**
  91877. * Represents a generic gamepad
  91878. */
  91879. export class GenericPad extends Gamepad {
  91880. private _buttons;
  91881. private _onbuttondown;
  91882. private _onbuttonup;
  91883. /**
  91884. * Observable triggered when a button has been pressed
  91885. */
  91886. onButtonDownObservable: Observable<number>;
  91887. /**
  91888. * Observable triggered when a button has been released
  91889. */
  91890. onButtonUpObservable: Observable<number>;
  91891. /**
  91892. * Callback triggered when a button has been pressed
  91893. * @param callback Called when a button has been pressed
  91894. */
  91895. onbuttondown(callback: (buttonPressed: number) => void): void;
  91896. /**
  91897. * Callback triggered when a button has been released
  91898. * @param callback Called when a button has been released
  91899. */
  91900. onbuttonup(callback: (buttonReleased: number) => void): void;
  91901. /**
  91902. * Initializes the generic gamepad
  91903. * @param id The id of the generic gamepad
  91904. * @param index The index of the generic gamepad
  91905. * @param browserGamepad The browser gamepad
  91906. */
  91907. constructor(id: string, index: number, browserGamepad: any);
  91908. private _setButtonValue;
  91909. /**
  91910. * Updates the generic gamepad
  91911. */
  91912. update(): void;
  91913. /**
  91914. * Disposes the generic gamepad
  91915. */
  91916. dispose(): void;
  91917. }
  91918. }
  91919. declare module BABYLON {
  91920. /**
  91921. * Defines the types of pose enabled controllers that are supported
  91922. */
  91923. export enum PoseEnabledControllerType {
  91924. /**
  91925. * HTC Vive
  91926. */
  91927. VIVE = 0,
  91928. /**
  91929. * Oculus Rift
  91930. */
  91931. OCULUS = 1,
  91932. /**
  91933. * Windows mixed reality
  91934. */
  91935. WINDOWS = 2,
  91936. /**
  91937. * Samsung gear VR
  91938. */
  91939. GEAR_VR = 3,
  91940. /**
  91941. * Google Daydream
  91942. */
  91943. DAYDREAM = 4,
  91944. /**
  91945. * Generic
  91946. */
  91947. GENERIC = 5
  91948. }
  91949. /**
  91950. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91951. */
  91952. export interface MutableGamepadButton {
  91953. /**
  91954. * Value of the button/trigger
  91955. */
  91956. value: number;
  91957. /**
  91958. * If the button/trigger is currently touched
  91959. */
  91960. touched: boolean;
  91961. /**
  91962. * If the button/trigger is currently pressed
  91963. */
  91964. pressed: boolean;
  91965. }
  91966. /**
  91967. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91968. * @hidden
  91969. */
  91970. export interface ExtendedGamepadButton extends GamepadButton {
  91971. /**
  91972. * If the button/trigger is currently pressed
  91973. */
  91974. readonly pressed: boolean;
  91975. /**
  91976. * If the button/trigger is currently touched
  91977. */
  91978. readonly touched: boolean;
  91979. /**
  91980. * Value of the button/trigger
  91981. */
  91982. readonly value: number;
  91983. }
  91984. /** @hidden */
  91985. export interface _GamePadFactory {
  91986. /**
  91987. * Returns whether or not the current gamepad can be created for this type of controller.
  91988. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91989. * @returns true if it can be created, otherwise false
  91990. */
  91991. canCreate(gamepadInfo: any): boolean;
  91992. /**
  91993. * Creates a new instance of the Gamepad.
  91994. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91995. * @returns the new gamepad instance
  91996. */
  91997. create(gamepadInfo: any): Gamepad;
  91998. }
  91999. /**
  92000. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92001. */
  92002. export class PoseEnabledControllerHelper {
  92003. /** @hidden */
  92004. static _ControllerFactories: _GamePadFactory[];
  92005. /** @hidden */
  92006. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92007. /**
  92008. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92009. * @param vrGamepad the gamepad to initialized
  92010. * @returns a vr controller of the type the gamepad identified as
  92011. */
  92012. static InitiateController(vrGamepad: any): Gamepad;
  92013. }
  92014. /**
  92015. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92016. */
  92017. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92018. /**
  92019. * If the controller is used in a webXR session
  92020. */
  92021. isXR: boolean;
  92022. private _deviceRoomPosition;
  92023. private _deviceRoomRotationQuaternion;
  92024. /**
  92025. * The device position in babylon space
  92026. */
  92027. devicePosition: Vector3;
  92028. /**
  92029. * The device rotation in babylon space
  92030. */
  92031. deviceRotationQuaternion: Quaternion;
  92032. /**
  92033. * The scale factor of the device in babylon space
  92034. */
  92035. deviceScaleFactor: number;
  92036. /**
  92037. * (Likely devicePosition should be used instead) The device position in its room space
  92038. */
  92039. position: Vector3;
  92040. /**
  92041. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92042. */
  92043. rotationQuaternion: Quaternion;
  92044. /**
  92045. * The type of controller (Eg. Windows mixed reality)
  92046. */
  92047. controllerType: PoseEnabledControllerType;
  92048. protected _calculatedPosition: Vector3;
  92049. private _calculatedRotation;
  92050. /**
  92051. * The raw pose from the device
  92052. */
  92053. rawPose: DevicePose;
  92054. private _trackPosition;
  92055. private _maxRotationDistFromHeadset;
  92056. private _draggedRoomRotation;
  92057. /**
  92058. * @hidden
  92059. */
  92060. _disableTrackPosition(fixedPosition: Vector3): void;
  92061. /**
  92062. * Internal, the mesh attached to the controller
  92063. * @hidden
  92064. */
  92065. _mesh: Nullable<AbstractMesh>;
  92066. private _poseControlledCamera;
  92067. private _leftHandSystemQuaternion;
  92068. /**
  92069. * Internal, matrix used to convert room space to babylon space
  92070. * @hidden
  92071. */
  92072. _deviceToWorld: Matrix;
  92073. /**
  92074. * Node to be used when casting a ray from the controller
  92075. * @hidden
  92076. */
  92077. _pointingPoseNode: Nullable<TransformNode>;
  92078. /**
  92079. * Name of the child mesh that can be used to cast a ray from the controller
  92080. */
  92081. static readonly POINTING_POSE: string;
  92082. /**
  92083. * Creates a new PoseEnabledController from a gamepad
  92084. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92085. */
  92086. constructor(browserGamepad: any);
  92087. private _workingMatrix;
  92088. /**
  92089. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92090. */
  92091. update(): void;
  92092. /**
  92093. * Updates only the pose device and mesh without doing any button event checking
  92094. */
  92095. protected _updatePoseAndMesh(): void;
  92096. /**
  92097. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92098. * @param poseData raw pose fromthe device
  92099. */
  92100. updateFromDevice(poseData: DevicePose): void;
  92101. /**
  92102. * @hidden
  92103. */
  92104. _meshAttachedObservable: Observable<AbstractMesh>;
  92105. /**
  92106. * Attaches a mesh to the controller
  92107. * @param mesh the mesh to be attached
  92108. */
  92109. attachToMesh(mesh: AbstractMesh): void;
  92110. /**
  92111. * Attaches the controllers mesh to a camera
  92112. * @param camera the camera the mesh should be attached to
  92113. */
  92114. attachToPoseControlledCamera(camera: TargetCamera): void;
  92115. /**
  92116. * Disposes of the controller
  92117. */
  92118. dispose(): void;
  92119. /**
  92120. * The mesh that is attached to the controller
  92121. */
  92122. get mesh(): Nullable<AbstractMesh>;
  92123. /**
  92124. * Gets the ray of the controller in the direction the controller is pointing
  92125. * @param length the length the resulting ray should be
  92126. * @returns a ray in the direction the controller is pointing
  92127. */
  92128. getForwardRay(length?: number): Ray;
  92129. }
  92130. }
  92131. declare module BABYLON {
  92132. /**
  92133. * Defines the WebVRController object that represents controllers tracked in 3D space
  92134. */
  92135. export abstract class WebVRController extends PoseEnabledController {
  92136. /**
  92137. * Internal, the default controller model for the controller
  92138. */
  92139. protected _defaultModel: Nullable<AbstractMesh>;
  92140. /**
  92141. * Fired when the trigger state has changed
  92142. */
  92143. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92144. /**
  92145. * Fired when the main button state has changed
  92146. */
  92147. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92148. /**
  92149. * Fired when the secondary button state has changed
  92150. */
  92151. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92152. /**
  92153. * Fired when the pad state has changed
  92154. */
  92155. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92156. /**
  92157. * Fired when controllers stick values have changed
  92158. */
  92159. onPadValuesChangedObservable: Observable<StickValues>;
  92160. /**
  92161. * Array of button availible on the controller
  92162. */
  92163. protected _buttons: Array<MutableGamepadButton>;
  92164. private _onButtonStateChange;
  92165. /**
  92166. * Fired when a controller button's state has changed
  92167. * @param callback the callback containing the button that was modified
  92168. */
  92169. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92170. /**
  92171. * X and Y axis corresponding to the controllers joystick
  92172. */
  92173. pad: StickValues;
  92174. /**
  92175. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92176. */
  92177. hand: string;
  92178. /**
  92179. * The default controller model for the controller
  92180. */
  92181. get defaultModel(): Nullable<AbstractMesh>;
  92182. /**
  92183. * Creates a new WebVRController from a gamepad
  92184. * @param vrGamepad the gamepad that the WebVRController should be created from
  92185. */
  92186. constructor(vrGamepad: any);
  92187. /**
  92188. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92189. */
  92190. update(): void;
  92191. /**
  92192. * Function to be called when a button is modified
  92193. */
  92194. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92195. /**
  92196. * Loads a mesh and attaches it to the controller
  92197. * @param scene the scene the mesh should be added to
  92198. * @param meshLoaded callback for when the mesh has been loaded
  92199. */
  92200. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92201. private _setButtonValue;
  92202. private _changes;
  92203. private _checkChanges;
  92204. /**
  92205. * Disposes of th webVRCOntroller
  92206. */
  92207. dispose(): void;
  92208. }
  92209. }
  92210. declare module BABYLON {
  92211. /**
  92212. * The HemisphericLight simulates the ambient environment light,
  92213. * so the passed direction is the light reflection direction, not the incoming direction.
  92214. */
  92215. export class HemisphericLight extends Light {
  92216. /**
  92217. * The groundColor is the light in the opposite direction to the one specified during creation.
  92218. * 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.
  92219. */
  92220. groundColor: Color3;
  92221. /**
  92222. * The light reflection direction, not the incoming direction.
  92223. */
  92224. direction: Vector3;
  92225. /**
  92226. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92227. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92228. * The HemisphericLight can't cast shadows.
  92229. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92230. * @param name The friendly name of the light
  92231. * @param direction The direction of the light reflection
  92232. * @param scene The scene the light belongs to
  92233. */
  92234. constructor(name: string, direction: Vector3, scene: Scene);
  92235. protected _buildUniformLayout(): void;
  92236. /**
  92237. * Returns the string "HemisphericLight".
  92238. * @return The class name
  92239. */
  92240. getClassName(): string;
  92241. /**
  92242. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92243. * Returns the updated direction.
  92244. * @param target The target the direction should point to
  92245. * @return The computed direction
  92246. */
  92247. setDirectionToTarget(target: Vector3): Vector3;
  92248. /**
  92249. * Returns the shadow generator associated to the light.
  92250. * @returns Always null for hemispheric lights because it does not support shadows.
  92251. */
  92252. getShadowGenerator(): Nullable<IShadowGenerator>;
  92253. /**
  92254. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92255. * @param effect The effect to update
  92256. * @param lightIndex The index of the light in the effect to update
  92257. * @returns The hemispheric light
  92258. */
  92259. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92260. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92261. /**
  92262. * Computes the world matrix of the node
  92263. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92264. * @param useWasUpdatedFlag defines a reserved property
  92265. * @returns the world matrix
  92266. */
  92267. computeWorldMatrix(): Matrix;
  92268. /**
  92269. * Returns the integer 3.
  92270. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92271. */
  92272. getTypeID(): number;
  92273. /**
  92274. * Prepares the list of defines specific to the light type.
  92275. * @param defines the list of defines
  92276. * @param lightIndex defines the index of the light for the effect
  92277. */
  92278. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92279. }
  92280. }
  92281. declare module BABYLON {
  92282. /** @hidden */
  92283. export var vrMultiviewToSingleviewPixelShader: {
  92284. name: string;
  92285. shader: string;
  92286. };
  92287. }
  92288. declare module BABYLON {
  92289. /**
  92290. * Renders to multiple views with a single draw call
  92291. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92292. */
  92293. export class MultiviewRenderTarget extends RenderTargetTexture {
  92294. /**
  92295. * Creates a multiview render target
  92296. * @param scene scene used with the render target
  92297. * @param size the size of the render target (used for each view)
  92298. */
  92299. constructor(scene: Scene, size?: number | {
  92300. width: number;
  92301. height: number;
  92302. } | {
  92303. ratio: number;
  92304. });
  92305. /**
  92306. * @hidden
  92307. * @param faceIndex the face index, if its a cube texture
  92308. */
  92309. _bindFrameBuffer(faceIndex?: number): void;
  92310. /**
  92311. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92312. * @returns the view count
  92313. */
  92314. getViewCount(): number;
  92315. }
  92316. }
  92317. declare module BABYLON {
  92318. /**
  92319. * Represents a camera frustum
  92320. */
  92321. export class Frustum {
  92322. /**
  92323. * Gets the planes representing the frustum
  92324. * @param transform matrix to be applied to the returned planes
  92325. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92326. */
  92327. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92328. /**
  92329. * Gets the near frustum plane transformed by the transform matrix
  92330. * @param transform transformation matrix to be applied to the resulting frustum plane
  92331. * @param frustumPlane the resuling frustum plane
  92332. */
  92333. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92334. /**
  92335. * Gets the far frustum plane transformed by the transform matrix
  92336. * @param transform transformation matrix to be applied to the resulting frustum plane
  92337. * @param frustumPlane the resuling frustum plane
  92338. */
  92339. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92340. /**
  92341. * Gets the left frustum plane transformed by the transform matrix
  92342. * @param transform transformation matrix to be applied to the resulting frustum plane
  92343. * @param frustumPlane the resuling frustum plane
  92344. */
  92345. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92346. /**
  92347. * Gets the right frustum plane transformed by the transform matrix
  92348. * @param transform transformation matrix to be applied to the resulting frustum plane
  92349. * @param frustumPlane the resuling frustum plane
  92350. */
  92351. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92352. /**
  92353. * Gets the top frustum plane transformed by the transform matrix
  92354. * @param transform transformation matrix to be applied to the resulting frustum plane
  92355. * @param frustumPlane the resuling frustum plane
  92356. */
  92357. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92358. /**
  92359. * Gets the bottom frustum plane transformed by the transform matrix
  92360. * @param transform transformation matrix to be applied to the resulting frustum plane
  92361. * @param frustumPlane the resuling frustum plane
  92362. */
  92363. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92364. /**
  92365. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92366. * @param transform transformation matrix to be applied to the resulting frustum planes
  92367. * @param frustumPlanes the resuling frustum planes
  92368. */
  92369. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92370. }
  92371. }
  92372. declare module BABYLON {
  92373. interface Engine {
  92374. /**
  92375. * Creates a new multiview render target
  92376. * @param width defines the width of the texture
  92377. * @param height defines the height of the texture
  92378. * @returns the created multiview texture
  92379. */
  92380. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92381. /**
  92382. * Binds a multiview framebuffer to be drawn to
  92383. * @param multiviewTexture texture to bind
  92384. */
  92385. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92386. }
  92387. interface Camera {
  92388. /**
  92389. * @hidden
  92390. * 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)
  92391. */
  92392. _useMultiviewToSingleView: boolean;
  92393. /**
  92394. * @hidden
  92395. * 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)
  92396. */
  92397. _multiviewTexture: Nullable<RenderTargetTexture>;
  92398. /**
  92399. * @hidden
  92400. * ensures the multiview texture of the camera exists and has the specified width/height
  92401. * @param width height to set on the multiview texture
  92402. * @param height width to set on the multiview texture
  92403. */
  92404. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92405. }
  92406. interface Scene {
  92407. /** @hidden */
  92408. _transformMatrixR: Matrix;
  92409. /** @hidden */
  92410. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92411. /** @hidden */
  92412. _createMultiviewUbo(): void;
  92413. /** @hidden */
  92414. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92415. /** @hidden */
  92416. _renderMultiviewToSingleView(camera: Camera): void;
  92417. }
  92418. }
  92419. declare module BABYLON {
  92420. /**
  92421. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92422. * This will not be used for webXR as it supports displaying texture arrays directly
  92423. */
  92424. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92425. /**
  92426. * Initializes a VRMultiviewToSingleview
  92427. * @param name name of the post process
  92428. * @param camera camera to be applied to
  92429. * @param scaleFactor scaling factor to the size of the output texture
  92430. */
  92431. constructor(name: string, camera: Camera, scaleFactor: number);
  92432. }
  92433. }
  92434. declare module BABYLON {
  92435. /**
  92436. * Interface used to define additional presentation attributes
  92437. */
  92438. export interface IVRPresentationAttributes {
  92439. /**
  92440. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92441. */
  92442. highRefreshRate: boolean;
  92443. /**
  92444. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92445. */
  92446. foveationLevel: number;
  92447. }
  92448. interface Engine {
  92449. /** @hidden */
  92450. _vrDisplay: any;
  92451. /** @hidden */
  92452. _vrSupported: boolean;
  92453. /** @hidden */
  92454. _oldSize: Size;
  92455. /** @hidden */
  92456. _oldHardwareScaleFactor: number;
  92457. /** @hidden */
  92458. _vrExclusivePointerMode: boolean;
  92459. /** @hidden */
  92460. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92461. /** @hidden */
  92462. _onVRDisplayPointerRestricted: () => void;
  92463. /** @hidden */
  92464. _onVRDisplayPointerUnrestricted: () => void;
  92465. /** @hidden */
  92466. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92467. /** @hidden */
  92468. _onVrDisplayDisconnect: Nullable<() => void>;
  92469. /** @hidden */
  92470. _onVrDisplayPresentChange: Nullable<() => void>;
  92471. /**
  92472. * Observable signaled when VR display mode changes
  92473. */
  92474. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92475. /**
  92476. * Observable signaled when VR request present is complete
  92477. */
  92478. onVRRequestPresentComplete: Observable<boolean>;
  92479. /**
  92480. * Observable signaled when VR request present starts
  92481. */
  92482. onVRRequestPresentStart: Observable<Engine>;
  92483. /**
  92484. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92485. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92486. */
  92487. isInVRExclusivePointerMode: boolean;
  92488. /**
  92489. * Gets a boolean indicating if a webVR device was detected
  92490. * @returns true if a webVR device was detected
  92491. */
  92492. isVRDevicePresent(): boolean;
  92493. /**
  92494. * Gets the current webVR device
  92495. * @returns the current webVR device (or null)
  92496. */
  92497. getVRDevice(): any;
  92498. /**
  92499. * Initializes a webVR display and starts listening to display change events
  92500. * The onVRDisplayChangedObservable will be notified upon these changes
  92501. * @returns A promise containing a VRDisplay and if vr is supported
  92502. */
  92503. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92504. /** @hidden */
  92505. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92506. /**
  92507. * Gets or sets the presentation attributes used to configure VR rendering
  92508. */
  92509. vrPresentationAttributes?: IVRPresentationAttributes;
  92510. /**
  92511. * Call this function to switch to webVR mode
  92512. * Will do nothing if webVR is not supported or if there is no webVR device
  92513. * @param options the webvr options provided to the camera. mainly used for multiview
  92514. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92515. */
  92516. enableVR(options: WebVROptions): void;
  92517. /** @hidden */
  92518. _onVRFullScreenTriggered(): void;
  92519. }
  92520. }
  92521. declare module BABYLON {
  92522. /**
  92523. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92524. * IMPORTANT!! The data is right-hand data.
  92525. * @export
  92526. * @interface DevicePose
  92527. */
  92528. export interface DevicePose {
  92529. /**
  92530. * The position of the device, values in array are [x,y,z].
  92531. */
  92532. readonly position: Nullable<Float32Array>;
  92533. /**
  92534. * The linearVelocity of the device, values in array are [x,y,z].
  92535. */
  92536. readonly linearVelocity: Nullable<Float32Array>;
  92537. /**
  92538. * The linearAcceleration of the device, values in array are [x,y,z].
  92539. */
  92540. readonly linearAcceleration: Nullable<Float32Array>;
  92541. /**
  92542. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92543. */
  92544. readonly orientation: Nullable<Float32Array>;
  92545. /**
  92546. * The angularVelocity of the device, values in array are [x,y,z].
  92547. */
  92548. readonly angularVelocity: Nullable<Float32Array>;
  92549. /**
  92550. * The angularAcceleration of the device, values in array are [x,y,z].
  92551. */
  92552. readonly angularAcceleration: Nullable<Float32Array>;
  92553. }
  92554. /**
  92555. * Interface representing a pose controlled object in Babylon.
  92556. * A pose controlled object has both regular pose values as well as pose values
  92557. * from an external device such as a VR head mounted display
  92558. */
  92559. export interface PoseControlled {
  92560. /**
  92561. * The position of the object in babylon space.
  92562. */
  92563. position: Vector3;
  92564. /**
  92565. * The rotation quaternion of the object in babylon space.
  92566. */
  92567. rotationQuaternion: Quaternion;
  92568. /**
  92569. * The position of the device in babylon space.
  92570. */
  92571. devicePosition?: Vector3;
  92572. /**
  92573. * The rotation quaternion of the device in babylon space.
  92574. */
  92575. deviceRotationQuaternion: Quaternion;
  92576. /**
  92577. * The raw pose coming from the device.
  92578. */
  92579. rawPose: Nullable<DevicePose>;
  92580. /**
  92581. * The scale of the device to be used when translating from device space to babylon space.
  92582. */
  92583. deviceScaleFactor: number;
  92584. /**
  92585. * Updates the poseControlled values based on the input device pose.
  92586. * @param poseData the pose data to update the object with
  92587. */
  92588. updateFromDevice(poseData: DevicePose): void;
  92589. }
  92590. /**
  92591. * Set of options to customize the webVRCamera
  92592. */
  92593. export interface WebVROptions {
  92594. /**
  92595. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92596. */
  92597. trackPosition?: boolean;
  92598. /**
  92599. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92600. */
  92601. positionScale?: number;
  92602. /**
  92603. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92604. */
  92605. displayName?: string;
  92606. /**
  92607. * Should the native controller meshes be initialized. (default: true)
  92608. */
  92609. controllerMeshes?: boolean;
  92610. /**
  92611. * Creating a default HemiLight only on controllers. (default: true)
  92612. */
  92613. defaultLightingOnControllers?: boolean;
  92614. /**
  92615. * If you don't want to use the default VR button of the helper. (default: false)
  92616. */
  92617. useCustomVRButton?: boolean;
  92618. /**
  92619. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92620. */
  92621. customVRButton?: HTMLButtonElement;
  92622. /**
  92623. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92624. */
  92625. rayLength?: number;
  92626. /**
  92627. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92628. */
  92629. defaultHeight?: number;
  92630. /**
  92631. * If multiview should be used if availible (default: false)
  92632. */
  92633. useMultiview?: boolean;
  92634. }
  92635. /**
  92636. * This represents a WebVR camera.
  92637. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92638. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92639. */
  92640. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92641. private webVROptions;
  92642. /**
  92643. * @hidden
  92644. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92645. */
  92646. _vrDevice: any;
  92647. /**
  92648. * The rawPose of the vrDevice.
  92649. */
  92650. rawPose: Nullable<DevicePose>;
  92651. private _onVREnabled;
  92652. private _specsVersion;
  92653. private _attached;
  92654. private _frameData;
  92655. protected _descendants: Array<Node>;
  92656. private _deviceRoomPosition;
  92657. /** @hidden */
  92658. _deviceRoomRotationQuaternion: Quaternion;
  92659. private _standingMatrix;
  92660. /**
  92661. * Represents device position in babylon space.
  92662. */
  92663. devicePosition: Vector3;
  92664. /**
  92665. * Represents device rotation in babylon space.
  92666. */
  92667. deviceRotationQuaternion: Quaternion;
  92668. /**
  92669. * The scale of the device to be used when translating from device space to babylon space.
  92670. */
  92671. deviceScaleFactor: number;
  92672. private _deviceToWorld;
  92673. private _worldToDevice;
  92674. /**
  92675. * References to the webVR controllers for the vrDevice.
  92676. */
  92677. controllers: Array<WebVRController>;
  92678. /**
  92679. * Emits an event when a controller is attached.
  92680. */
  92681. onControllersAttachedObservable: Observable<WebVRController[]>;
  92682. /**
  92683. * Emits an event when a controller's mesh has been loaded;
  92684. */
  92685. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92686. /**
  92687. * Emits an event when the HMD's pose has been updated.
  92688. */
  92689. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92690. private _poseSet;
  92691. /**
  92692. * If the rig cameras be used as parent instead of this camera.
  92693. */
  92694. rigParenting: boolean;
  92695. private _lightOnControllers;
  92696. private _defaultHeight?;
  92697. /**
  92698. * Instantiates a WebVRFreeCamera.
  92699. * @param name The name of the WebVRFreeCamera
  92700. * @param position The starting anchor position for the camera
  92701. * @param scene The scene the camera belongs to
  92702. * @param webVROptions a set of customizable options for the webVRCamera
  92703. */
  92704. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92705. /**
  92706. * Gets the device distance from the ground in meters.
  92707. * @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.
  92708. */
  92709. deviceDistanceToRoomGround(): number;
  92710. /**
  92711. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92712. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92713. */
  92714. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92715. /**
  92716. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92717. * @returns A promise with a boolean set to if the standing matrix is supported.
  92718. */
  92719. useStandingMatrixAsync(): Promise<boolean>;
  92720. /**
  92721. * Disposes the camera
  92722. */
  92723. dispose(): void;
  92724. /**
  92725. * Gets a vrController by name.
  92726. * @param name The name of the controller to retreive
  92727. * @returns the controller matching the name specified or null if not found
  92728. */
  92729. getControllerByName(name: string): Nullable<WebVRController>;
  92730. private _leftController;
  92731. /**
  92732. * The controller corresponding to the users left hand.
  92733. */
  92734. get leftController(): Nullable<WebVRController>;
  92735. private _rightController;
  92736. /**
  92737. * The controller corresponding to the users right hand.
  92738. */
  92739. get rightController(): Nullable<WebVRController>;
  92740. /**
  92741. * Casts a ray forward from the vrCamera's gaze.
  92742. * @param length Length of the ray (default: 100)
  92743. * @returns the ray corresponding to the gaze
  92744. */
  92745. getForwardRay(length?: number): Ray;
  92746. /**
  92747. * @hidden
  92748. * Updates the camera based on device's frame data
  92749. */
  92750. _checkInputs(): void;
  92751. /**
  92752. * Updates the poseControlled values based on the input device pose.
  92753. * @param poseData Pose coming from the device
  92754. */
  92755. updateFromDevice(poseData: DevicePose): void;
  92756. private _htmlElementAttached;
  92757. private _detachIfAttached;
  92758. /**
  92759. * WebVR's attach control will start broadcasting frames to the device.
  92760. * Note that in certain browsers (chrome for example) this function must be called
  92761. * within a user-interaction callback. Example:
  92762. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92763. *
  92764. * @param element html element to attach the vrDevice to
  92765. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92766. */
  92767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92768. /**
  92769. * Detaches the camera from the html element and disables VR
  92770. *
  92771. * @param element html element to detach from
  92772. */
  92773. detachControl(element: HTMLElement): void;
  92774. /**
  92775. * @returns the name of this class
  92776. */
  92777. getClassName(): string;
  92778. /**
  92779. * Calls resetPose on the vrDisplay
  92780. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92781. */
  92782. resetToCurrentRotation(): void;
  92783. /**
  92784. * @hidden
  92785. * Updates the rig cameras (left and right eye)
  92786. */
  92787. _updateRigCameras(): void;
  92788. private _workingVector;
  92789. private _oneVector;
  92790. private _workingMatrix;
  92791. private updateCacheCalled;
  92792. private _correctPositionIfNotTrackPosition;
  92793. /**
  92794. * @hidden
  92795. * Updates the cached values of the camera
  92796. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92797. */
  92798. _updateCache(ignoreParentClass?: boolean): void;
  92799. /**
  92800. * @hidden
  92801. * Get current device position in babylon world
  92802. */
  92803. _computeDevicePosition(): void;
  92804. /**
  92805. * Updates the current device position and rotation in the babylon world
  92806. */
  92807. update(): void;
  92808. /**
  92809. * @hidden
  92810. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92811. * @returns an identity matrix
  92812. */
  92813. _getViewMatrix(): Matrix;
  92814. private _tmpMatrix;
  92815. /**
  92816. * This function is called by the two RIG cameras.
  92817. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92818. * @hidden
  92819. */
  92820. _getWebVRViewMatrix(): Matrix;
  92821. /** @hidden */
  92822. _getWebVRProjectionMatrix(): Matrix;
  92823. private _onGamepadConnectedObserver;
  92824. private _onGamepadDisconnectedObserver;
  92825. private _updateCacheWhenTrackingDisabledObserver;
  92826. /**
  92827. * Initializes the controllers and their meshes
  92828. */
  92829. initControllers(): void;
  92830. }
  92831. }
  92832. declare module BABYLON {
  92833. /**
  92834. * Size options for a post process
  92835. */
  92836. export type PostProcessOptions = {
  92837. width: number;
  92838. height: number;
  92839. };
  92840. /**
  92841. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92842. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92843. */
  92844. export class PostProcess {
  92845. /** Name of the PostProcess. */
  92846. name: string;
  92847. /**
  92848. * Gets or sets the unique id of the post process
  92849. */
  92850. uniqueId: number;
  92851. /**
  92852. * Width of the texture to apply the post process on
  92853. */
  92854. width: number;
  92855. /**
  92856. * Height of the texture to apply the post process on
  92857. */
  92858. height: number;
  92859. /**
  92860. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92861. * @hidden
  92862. */
  92863. _outputTexture: Nullable<InternalTexture>;
  92864. /**
  92865. * Sampling mode used by the shader
  92866. * See https://doc.babylonjs.com/classes/3.1/texture
  92867. */
  92868. renderTargetSamplingMode: number;
  92869. /**
  92870. * Clear color to use when screen clearing
  92871. */
  92872. clearColor: Color4;
  92873. /**
  92874. * If the buffer needs to be cleared before applying the post process. (default: true)
  92875. * Should be set to false if shader will overwrite all previous pixels.
  92876. */
  92877. autoClear: boolean;
  92878. /**
  92879. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92880. */
  92881. alphaMode: number;
  92882. /**
  92883. * Sets the setAlphaBlendConstants of the babylon engine
  92884. */
  92885. alphaConstants: Color4;
  92886. /**
  92887. * Animations to be used for the post processing
  92888. */
  92889. animations: Animation[];
  92890. /**
  92891. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92892. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92893. */
  92894. enablePixelPerfectMode: boolean;
  92895. /**
  92896. * Force the postprocess to be applied without taking in account viewport
  92897. */
  92898. forceFullscreenViewport: boolean;
  92899. /**
  92900. * List of inspectable custom properties (used by the Inspector)
  92901. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92902. */
  92903. inspectableCustomProperties: IInspectable[];
  92904. /**
  92905. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92906. *
  92907. * | Value | Type | Description |
  92908. * | ----- | ----------------------------------- | ----------- |
  92909. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92910. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92911. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92912. *
  92913. */
  92914. scaleMode: number;
  92915. /**
  92916. * Force textures to be a power of two (default: false)
  92917. */
  92918. alwaysForcePOT: boolean;
  92919. private _samples;
  92920. /**
  92921. * Number of sample textures (default: 1)
  92922. */
  92923. get samples(): number;
  92924. set samples(n: number);
  92925. /**
  92926. * Modify the scale of the post process to be the same as the viewport (default: false)
  92927. */
  92928. adaptScaleToCurrentViewport: boolean;
  92929. private _camera;
  92930. private _scene;
  92931. private _engine;
  92932. private _options;
  92933. private _reusable;
  92934. private _textureType;
  92935. private _textureFormat;
  92936. /**
  92937. * Smart array of input and output textures for the post process.
  92938. * @hidden
  92939. */
  92940. _textures: SmartArray<InternalTexture>;
  92941. /**
  92942. * The index in _textures that corresponds to the output texture.
  92943. * @hidden
  92944. */
  92945. _currentRenderTextureInd: number;
  92946. private _effect;
  92947. private _samplers;
  92948. private _fragmentUrl;
  92949. private _vertexUrl;
  92950. private _parameters;
  92951. private _scaleRatio;
  92952. protected _indexParameters: any;
  92953. private _shareOutputWithPostProcess;
  92954. private _texelSize;
  92955. private _forcedOutputTexture;
  92956. /**
  92957. * Returns the fragment url or shader name used in the post process.
  92958. * @returns the fragment url or name in the shader store.
  92959. */
  92960. getEffectName(): string;
  92961. /**
  92962. * An event triggered when the postprocess is activated.
  92963. */
  92964. onActivateObservable: Observable<Camera>;
  92965. private _onActivateObserver;
  92966. /**
  92967. * A function that is added to the onActivateObservable
  92968. */
  92969. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92970. /**
  92971. * An event triggered when the postprocess changes its size.
  92972. */
  92973. onSizeChangedObservable: Observable<PostProcess>;
  92974. private _onSizeChangedObserver;
  92975. /**
  92976. * A function that is added to the onSizeChangedObservable
  92977. */
  92978. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92979. /**
  92980. * An event triggered when the postprocess applies its effect.
  92981. */
  92982. onApplyObservable: Observable<Effect>;
  92983. private _onApplyObserver;
  92984. /**
  92985. * A function that is added to the onApplyObservable
  92986. */
  92987. set onApply(callback: (effect: Effect) => void);
  92988. /**
  92989. * An event triggered before rendering the postprocess
  92990. */
  92991. onBeforeRenderObservable: Observable<Effect>;
  92992. private _onBeforeRenderObserver;
  92993. /**
  92994. * A function that is added to the onBeforeRenderObservable
  92995. */
  92996. set onBeforeRender(callback: (effect: Effect) => void);
  92997. /**
  92998. * An event triggered after rendering the postprocess
  92999. */
  93000. onAfterRenderObservable: Observable<Effect>;
  93001. private _onAfterRenderObserver;
  93002. /**
  93003. * A function that is added to the onAfterRenderObservable
  93004. */
  93005. set onAfterRender(callback: (efect: Effect) => void);
  93006. /**
  93007. * 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
  93008. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93009. */
  93010. get inputTexture(): InternalTexture;
  93011. set inputTexture(value: InternalTexture);
  93012. /**
  93013. * Gets the camera which post process is applied to.
  93014. * @returns The camera the post process is applied to.
  93015. */
  93016. getCamera(): Camera;
  93017. /**
  93018. * Gets the texel size of the postprocess.
  93019. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93020. */
  93021. get texelSize(): Vector2;
  93022. /**
  93023. * Creates a new instance PostProcess
  93024. * @param name The name of the PostProcess.
  93025. * @param fragmentUrl The url of the fragment shader to be used.
  93026. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93027. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93028. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93029. * @param camera The camera to apply the render pass to.
  93030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93031. * @param engine The engine which the post process will be applied. (default: current engine)
  93032. * @param reusable If the post process can be reused on the same frame. (default: false)
  93033. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93034. * @param textureType Type of textures used when performing the post process. (default: 0)
  93035. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93036. * @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
  93037. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93038. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93039. */
  93040. constructor(
  93041. /** Name of the PostProcess. */
  93042. 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);
  93043. /**
  93044. * Gets a string idenfifying the name of the class
  93045. * @returns "PostProcess" string
  93046. */
  93047. getClassName(): string;
  93048. /**
  93049. * Gets the engine which this post process belongs to.
  93050. * @returns The engine the post process was enabled with.
  93051. */
  93052. getEngine(): Engine;
  93053. /**
  93054. * The effect that is created when initializing the post process.
  93055. * @returns The created effect corresponding the the postprocess.
  93056. */
  93057. getEffect(): Effect;
  93058. /**
  93059. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93060. * @param postProcess The post process to share the output with.
  93061. * @returns This post process.
  93062. */
  93063. shareOutputWith(postProcess: PostProcess): PostProcess;
  93064. /**
  93065. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93066. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93067. */
  93068. useOwnOutput(): void;
  93069. /**
  93070. * Updates the effect with the current post process compile time values and recompiles the shader.
  93071. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93072. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93073. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93074. * @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
  93075. * @param onCompiled Called when the shader has been compiled.
  93076. * @param onError Called if there is an error when compiling a shader.
  93077. */
  93078. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93079. /**
  93080. * The post process is reusable if it can be used multiple times within one frame.
  93081. * @returns If the post process is reusable
  93082. */
  93083. isReusable(): boolean;
  93084. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93085. markTextureDirty(): void;
  93086. /**
  93087. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93088. * 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.
  93089. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93090. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93091. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93092. * @returns The target texture that was bound to be written to.
  93093. */
  93094. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93095. /**
  93096. * If the post process is supported.
  93097. */
  93098. get isSupported(): boolean;
  93099. /**
  93100. * The aspect ratio of the output texture.
  93101. */
  93102. get aspectRatio(): number;
  93103. /**
  93104. * Get a value indicating if the post-process is ready to be used
  93105. * @returns true if the post-process is ready (shader is compiled)
  93106. */
  93107. isReady(): boolean;
  93108. /**
  93109. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93110. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93111. */
  93112. apply(): Nullable<Effect>;
  93113. private _disposeTextures;
  93114. /**
  93115. * Disposes the post process.
  93116. * @param camera The camera to dispose the post process on.
  93117. */
  93118. dispose(camera?: Camera): void;
  93119. }
  93120. }
  93121. declare module BABYLON {
  93122. /** @hidden */
  93123. export var kernelBlurVaryingDeclaration: {
  93124. name: string;
  93125. shader: string;
  93126. };
  93127. }
  93128. declare module BABYLON {
  93129. /** @hidden */
  93130. export var kernelBlurFragment: {
  93131. name: string;
  93132. shader: string;
  93133. };
  93134. }
  93135. declare module BABYLON {
  93136. /** @hidden */
  93137. export var kernelBlurFragment2: {
  93138. name: string;
  93139. shader: string;
  93140. };
  93141. }
  93142. declare module BABYLON {
  93143. /** @hidden */
  93144. export var kernelBlurPixelShader: {
  93145. name: string;
  93146. shader: string;
  93147. };
  93148. }
  93149. declare module BABYLON {
  93150. /** @hidden */
  93151. export var kernelBlurVertex: {
  93152. name: string;
  93153. shader: string;
  93154. };
  93155. }
  93156. declare module BABYLON {
  93157. /** @hidden */
  93158. export var kernelBlurVertexShader: {
  93159. name: string;
  93160. shader: string;
  93161. };
  93162. }
  93163. declare module BABYLON {
  93164. /**
  93165. * The Blur Post Process which blurs an image based on a kernel and direction.
  93166. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93167. */
  93168. export class BlurPostProcess extends PostProcess {
  93169. /** The direction in which to blur the image. */
  93170. direction: Vector2;
  93171. private blockCompilation;
  93172. protected _kernel: number;
  93173. protected _idealKernel: number;
  93174. protected _packedFloat: boolean;
  93175. private _staticDefines;
  93176. /**
  93177. * Sets the length in pixels of the blur sample region
  93178. */
  93179. set kernel(v: number);
  93180. /**
  93181. * Gets the length in pixels of the blur sample region
  93182. */
  93183. get kernel(): number;
  93184. /**
  93185. * Sets wether or not the blur needs to unpack/repack floats
  93186. */
  93187. set packedFloat(v: boolean);
  93188. /**
  93189. * Gets wether or not the blur is unpacking/repacking floats
  93190. */
  93191. get packedFloat(): boolean;
  93192. /**
  93193. * Creates a new instance BlurPostProcess
  93194. * @param name The name of the effect.
  93195. * @param direction The direction in which to blur the image.
  93196. * @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.
  93197. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93198. * @param camera The camera to apply the render pass to.
  93199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93200. * @param engine The engine which the post process will be applied. (default: current engine)
  93201. * @param reusable If the post process can be reused on the same frame. (default: false)
  93202. * @param textureType Type of textures used when performing the post process. (default: 0)
  93203. * @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)
  93204. */
  93205. constructor(name: string,
  93206. /** The direction in which to blur the image. */
  93207. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93208. /**
  93209. * Updates the effect with the current post process compile time values and recompiles the shader.
  93210. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93211. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93212. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93213. * @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
  93214. * @param onCompiled Called when the shader has been compiled.
  93215. * @param onError Called if there is an error when compiling a shader.
  93216. */
  93217. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93218. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93219. /**
  93220. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93221. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93222. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93223. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93224. * The gaps between physical kernels are compensated for in the weighting of the samples
  93225. * @param idealKernel Ideal blur kernel.
  93226. * @return Nearest best kernel.
  93227. */
  93228. protected _nearestBestKernel(idealKernel: number): number;
  93229. /**
  93230. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93231. * @param x The point on the Gaussian distribution to sample.
  93232. * @return the value of the Gaussian function at x.
  93233. */
  93234. protected _gaussianWeight(x: number): number;
  93235. /**
  93236. * Generates a string that can be used as a floating point number in GLSL.
  93237. * @param x Value to print.
  93238. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93239. * @return GLSL float string.
  93240. */
  93241. protected _glslFloat(x: number, decimalFigures?: number): string;
  93242. }
  93243. }
  93244. declare module BABYLON {
  93245. /**
  93246. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93247. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93248. * You can then easily use it as a reflectionTexture on a flat surface.
  93249. * In case the surface is not a plane, please consider relying on reflection probes.
  93250. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93251. */
  93252. export class MirrorTexture extends RenderTargetTexture {
  93253. private scene;
  93254. /**
  93255. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93256. * 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.
  93257. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93258. */
  93259. mirrorPlane: Plane;
  93260. /**
  93261. * Define the blur ratio used to blur the reflection if needed.
  93262. */
  93263. set blurRatio(value: number);
  93264. get blurRatio(): number;
  93265. /**
  93266. * Define the adaptive blur kernel used to blur the reflection if needed.
  93267. * This will autocompute the closest best match for the `blurKernel`
  93268. */
  93269. set adaptiveBlurKernel(value: number);
  93270. /**
  93271. * Define the blur kernel used to blur the reflection if needed.
  93272. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93273. */
  93274. set blurKernel(value: number);
  93275. /**
  93276. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93277. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93278. */
  93279. set blurKernelX(value: number);
  93280. get blurKernelX(): number;
  93281. /**
  93282. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93283. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93284. */
  93285. set blurKernelY(value: number);
  93286. get blurKernelY(): number;
  93287. private _autoComputeBlurKernel;
  93288. protected _onRatioRescale(): void;
  93289. private _updateGammaSpace;
  93290. private _imageProcessingConfigChangeObserver;
  93291. private _transformMatrix;
  93292. private _mirrorMatrix;
  93293. private _savedViewMatrix;
  93294. private _blurX;
  93295. private _blurY;
  93296. private _adaptiveBlurKernel;
  93297. private _blurKernelX;
  93298. private _blurKernelY;
  93299. private _blurRatio;
  93300. /**
  93301. * Instantiates a Mirror Texture.
  93302. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93303. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93304. * You can then easily use it as a reflectionTexture on a flat surface.
  93305. * In case the surface is not a plane, please consider relying on reflection probes.
  93306. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93307. * @param name
  93308. * @param size
  93309. * @param scene
  93310. * @param generateMipMaps
  93311. * @param type
  93312. * @param samplingMode
  93313. * @param generateDepthBuffer
  93314. */
  93315. constructor(name: string, size: number | {
  93316. width: number;
  93317. height: number;
  93318. } | {
  93319. ratio: number;
  93320. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93321. private _preparePostProcesses;
  93322. /**
  93323. * Clone the mirror texture.
  93324. * @returns the cloned texture
  93325. */
  93326. clone(): MirrorTexture;
  93327. /**
  93328. * Serialize the texture to a JSON representation you could use in Parse later on
  93329. * @returns the serialized JSON representation
  93330. */
  93331. serialize(): any;
  93332. /**
  93333. * Dispose the texture and release its associated resources.
  93334. */
  93335. dispose(): void;
  93336. }
  93337. }
  93338. declare module BABYLON {
  93339. /**
  93340. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93341. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93342. */
  93343. export class Texture extends BaseTexture {
  93344. /**
  93345. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93346. */
  93347. static SerializeBuffers: boolean;
  93348. /** @hidden */
  93349. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93350. /** @hidden */
  93351. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93352. /** @hidden */
  93353. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93354. /** nearest is mag = nearest and min = nearest and mip = linear */
  93355. static readonly NEAREST_SAMPLINGMODE: number;
  93356. /** nearest is mag = nearest and min = nearest and mip = linear */
  93357. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93358. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93359. static readonly BILINEAR_SAMPLINGMODE: number;
  93360. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93361. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93362. /** Trilinear is mag = linear and min = linear and mip = linear */
  93363. static readonly TRILINEAR_SAMPLINGMODE: number;
  93364. /** Trilinear is mag = linear and min = linear and mip = linear */
  93365. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93366. /** mag = nearest and min = nearest and mip = nearest */
  93367. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93368. /** mag = nearest and min = linear and mip = nearest */
  93369. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93370. /** mag = nearest and min = linear and mip = linear */
  93371. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93372. /** mag = nearest and min = linear and mip = none */
  93373. static readonly NEAREST_LINEAR: number;
  93374. /** mag = nearest and min = nearest and mip = none */
  93375. static readonly NEAREST_NEAREST: number;
  93376. /** mag = linear and min = nearest and mip = nearest */
  93377. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93378. /** mag = linear and min = nearest and mip = linear */
  93379. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93380. /** mag = linear and min = linear and mip = none */
  93381. static readonly LINEAR_LINEAR: number;
  93382. /** mag = linear and min = nearest and mip = none */
  93383. static readonly LINEAR_NEAREST: number;
  93384. /** Explicit coordinates mode */
  93385. static readonly EXPLICIT_MODE: number;
  93386. /** Spherical coordinates mode */
  93387. static readonly SPHERICAL_MODE: number;
  93388. /** Planar coordinates mode */
  93389. static readonly PLANAR_MODE: number;
  93390. /** Cubic coordinates mode */
  93391. static readonly CUBIC_MODE: number;
  93392. /** Projection coordinates mode */
  93393. static readonly PROJECTION_MODE: number;
  93394. /** Inverse Cubic coordinates mode */
  93395. static readonly SKYBOX_MODE: number;
  93396. /** Inverse Cubic coordinates mode */
  93397. static readonly INVCUBIC_MODE: number;
  93398. /** Equirectangular coordinates mode */
  93399. static readonly EQUIRECTANGULAR_MODE: number;
  93400. /** Equirectangular Fixed coordinates mode */
  93401. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93402. /** Equirectangular Fixed Mirrored coordinates mode */
  93403. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93404. /** Texture is not repeating outside of 0..1 UVs */
  93405. static readonly CLAMP_ADDRESSMODE: number;
  93406. /** Texture is repeating outside of 0..1 UVs */
  93407. static readonly WRAP_ADDRESSMODE: number;
  93408. /** Texture is repeating and mirrored */
  93409. static readonly MIRROR_ADDRESSMODE: number;
  93410. /**
  93411. * 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
  93412. */
  93413. static UseSerializedUrlIfAny: boolean;
  93414. /**
  93415. * Define the url of the texture.
  93416. */
  93417. url: Nullable<string>;
  93418. /**
  93419. * Define an offset on the texture to offset the u coordinates of the UVs
  93420. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93421. */
  93422. uOffset: number;
  93423. /**
  93424. * Define an offset on the texture to offset the v coordinates of the UVs
  93425. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93426. */
  93427. vOffset: number;
  93428. /**
  93429. * Define an offset on the texture to scale the u coordinates of the UVs
  93430. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93431. */
  93432. uScale: number;
  93433. /**
  93434. * Define an offset on the texture to scale the v coordinates of the UVs
  93435. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93436. */
  93437. vScale: number;
  93438. /**
  93439. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93440. * @see http://doc.babylonjs.com/how_to/more_materials
  93441. */
  93442. uAng: number;
  93443. /**
  93444. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93445. * @see http://doc.babylonjs.com/how_to/more_materials
  93446. */
  93447. vAng: number;
  93448. /**
  93449. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93450. * @see http://doc.babylonjs.com/how_to/more_materials
  93451. */
  93452. wAng: number;
  93453. /**
  93454. * Defines the center of rotation (U)
  93455. */
  93456. uRotationCenter: number;
  93457. /**
  93458. * Defines the center of rotation (V)
  93459. */
  93460. vRotationCenter: number;
  93461. /**
  93462. * Defines the center of rotation (W)
  93463. */
  93464. wRotationCenter: number;
  93465. /**
  93466. * Are mip maps generated for this texture or not.
  93467. */
  93468. get noMipmap(): boolean;
  93469. /**
  93470. * List of inspectable custom properties (used by the Inspector)
  93471. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93472. */
  93473. inspectableCustomProperties: Nullable<IInspectable[]>;
  93474. private _noMipmap;
  93475. /** @hidden */
  93476. _invertY: boolean;
  93477. private _rowGenerationMatrix;
  93478. private _cachedTextureMatrix;
  93479. private _projectionModeMatrix;
  93480. private _t0;
  93481. private _t1;
  93482. private _t2;
  93483. private _cachedUOffset;
  93484. private _cachedVOffset;
  93485. private _cachedUScale;
  93486. private _cachedVScale;
  93487. private _cachedUAng;
  93488. private _cachedVAng;
  93489. private _cachedWAng;
  93490. private _cachedProjectionMatrixId;
  93491. private _cachedCoordinatesMode;
  93492. /** @hidden */
  93493. protected _initialSamplingMode: number;
  93494. /** @hidden */
  93495. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93496. private _deleteBuffer;
  93497. protected _format: Nullable<number>;
  93498. private _delayedOnLoad;
  93499. private _delayedOnError;
  93500. private _mimeType?;
  93501. /**
  93502. * Observable triggered once the texture has been loaded.
  93503. */
  93504. onLoadObservable: Observable<Texture>;
  93505. protected _isBlocking: boolean;
  93506. /**
  93507. * Is the texture preventing material to render while loading.
  93508. * If false, a default texture will be used instead of the loading one during the preparation step.
  93509. */
  93510. set isBlocking(value: boolean);
  93511. get isBlocking(): boolean;
  93512. /**
  93513. * Get the current sampling mode associated with the texture.
  93514. */
  93515. get samplingMode(): number;
  93516. /**
  93517. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93518. */
  93519. get invertY(): boolean;
  93520. /**
  93521. * Instantiates a new texture.
  93522. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93523. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93524. * @param url defines the url of the picture to load as a texture
  93525. * @param scene defines the scene or engine the texture will belong to
  93526. * @param noMipmap defines if the texture will require mip maps or not
  93527. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93528. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93529. * @param onLoad defines a callback triggered when the texture has been loaded
  93530. * @param onError defines a callback triggered when an error occurred during the loading session
  93531. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93532. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93533. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93534. * @param mimeType defines an optional mime type information
  93535. */
  93536. 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);
  93537. /**
  93538. * Update the url (and optional buffer) of this texture if url was null during construction.
  93539. * @param url the url of the texture
  93540. * @param buffer the buffer of the texture (defaults to null)
  93541. * @param onLoad callback called when the texture is loaded (defaults to null)
  93542. */
  93543. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93544. /**
  93545. * Finish the loading sequence of a texture flagged as delayed load.
  93546. * @hidden
  93547. */
  93548. delayLoad(): void;
  93549. private _prepareRowForTextureGeneration;
  93550. /**
  93551. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93552. * @returns the transform matrix of the texture.
  93553. */
  93554. getTextureMatrix(uBase?: number): Matrix;
  93555. /**
  93556. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93557. * @returns The reflection texture transform
  93558. */
  93559. getReflectionTextureMatrix(): Matrix;
  93560. /**
  93561. * Clones the texture.
  93562. * @returns the cloned texture
  93563. */
  93564. clone(): Texture;
  93565. /**
  93566. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93567. * @returns The JSON representation of the texture
  93568. */
  93569. serialize(): any;
  93570. /**
  93571. * Get the current class name of the texture useful for serialization or dynamic coding.
  93572. * @returns "Texture"
  93573. */
  93574. getClassName(): string;
  93575. /**
  93576. * Dispose the texture and release its associated resources.
  93577. */
  93578. dispose(): void;
  93579. /**
  93580. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93581. * @param parsedTexture Define the JSON representation of the texture
  93582. * @param scene Define the scene the parsed texture should be instantiated in
  93583. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93584. * @returns The parsed texture if successful
  93585. */
  93586. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93587. /**
  93588. * Creates a texture from its base 64 representation.
  93589. * @param data Define the base64 payload without the data: prefix
  93590. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93591. * @param scene Define the scene the texture should belong to
  93592. * @param noMipmap Forces the texture to not create mip map information if true
  93593. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93594. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93595. * @param onLoad define a callback triggered when the texture has been loaded
  93596. * @param onError define a callback triggered when an error occurred during the loading session
  93597. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93598. * @returns the created texture
  93599. */
  93600. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93601. /**
  93602. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93603. * @param data Define the base64 payload without the data: prefix
  93604. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93605. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93606. * @param scene Define the scene the texture should belong to
  93607. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93608. * @param noMipmap Forces the texture to not create mip map information if true
  93609. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93610. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93611. * @param onLoad define a callback triggered when the texture has been loaded
  93612. * @param onError define a callback triggered when an error occurred during the loading session
  93613. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93614. * @returns the created texture
  93615. */
  93616. 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;
  93617. }
  93618. }
  93619. declare module BABYLON {
  93620. /**
  93621. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93622. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93623. */
  93624. export class PostProcessManager {
  93625. private _scene;
  93626. private _indexBuffer;
  93627. private _vertexBuffers;
  93628. /**
  93629. * Creates a new instance PostProcess
  93630. * @param scene The scene that the post process is associated with.
  93631. */
  93632. constructor(scene: Scene);
  93633. private _prepareBuffers;
  93634. private _buildIndexBuffer;
  93635. /**
  93636. * Rebuilds the vertex buffers of the manager.
  93637. * @hidden
  93638. */
  93639. _rebuild(): void;
  93640. /**
  93641. * Prepares a frame to be run through a post process.
  93642. * @param sourceTexture The input texture to the post procesess. (default: null)
  93643. * @param postProcesses An array of post processes to be run. (default: null)
  93644. * @returns True if the post processes were able to be run.
  93645. * @hidden
  93646. */
  93647. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93648. /**
  93649. * Manually render a set of post processes to a texture.
  93650. * @param postProcesses An array of post processes to be run.
  93651. * @param targetTexture The target texture to render to.
  93652. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93653. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93654. * @param lodLevel defines which lod of the texture to render to
  93655. */
  93656. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93657. /**
  93658. * Finalize the result of the output of the postprocesses.
  93659. * @param doNotPresent If true the result will not be displayed to the screen.
  93660. * @param targetTexture The target texture to render to.
  93661. * @param faceIndex The index of the face to bind the target texture to.
  93662. * @param postProcesses The array of post processes to render.
  93663. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93664. * @hidden
  93665. */
  93666. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93667. /**
  93668. * Disposes of the post process manager.
  93669. */
  93670. dispose(): void;
  93671. }
  93672. }
  93673. declare module BABYLON {
  93674. /**
  93675. * This Helps creating a texture that will be created from a camera in your scene.
  93676. * It is basically a dynamic texture that could be used to create special effects for instance.
  93677. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93678. */
  93679. export class RenderTargetTexture extends Texture {
  93680. isCube: boolean;
  93681. /**
  93682. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93683. */
  93684. static readonly REFRESHRATE_RENDER_ONCE: number;
  93685. /**
  93686. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93687. */
  93688. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93689. /**
  93690. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93691. * the central point of your effect and can save a lot of performances.
  93692. */
  93693. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93694. /**
  93695. * Use this predicate to dynamically define the list of mesh you want to render.
  93696. * If set, the renderList property will be overwritten.
  93697. */
  93698. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93699. private _renderList;
  93700. /**
  93701. * Use this list to define the list of mesh you want to render.
  93702. */
  93703. get renderList(): Nullable<Array<AbstractMesh>>;
  93704. set renderList(value: Nullable<Array<AbstractMesh>>);
  93705. /**
  93706. * Use this function to overload the renderList array at rendering time.
  93707. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93708. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93709. * the cube (if the RTT is a cube, else layerOrFace=0).
  93710. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93711. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93712. * hold dummy elements!
  93713. */
  93714. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93715. private _hookArray;
  93716. /**
  93717. * Define if particles should be rendered in your texture.
  93718. */
  93719. renderParticles: boolean;
  93720. /**
  93721. * Define if sprites should be rendered in your texture.
  93722. */
  93723. renderSprites: boolean;
  93724. /**
  93725. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93726. */
  93727. coordinatesMode: number;
  93728. /**
  93729. * Define the camera used to render the texture.
  93730. */
  93731. activeCamera: Nullable<Camera>;
  93732. /**
  93733. * Override the render function of the texture with your own one.
  93734. */
  93735. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93736. /**
  93737. * Define if camera post processes should be use while rendering the texture.
  93738. */
  93739. useCameraPostProcesses: boolean;
  93740. /**
  93741. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93742. */
  93743. ignoreCameraViewport: boolean;
  93744. private _postProcessManager;
  93745. private _postProcesses;
  93746. private _resizeObserver;
  93747. /**
  93748. * An event triggered when the texture is unbind.
  93749. */
  93750. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93751. /**
  93752. * An event triggered when the texture is unbind.
  93753. */
  93754. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93755. private _onAfterUnbindObserver;
  93756. /**
  93757. * Set a after unbind callback in the texture.
  93758. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93759. */
  93760. set onAfterUnbind(callback: () => void);
  93761. /**
  93762. * An event triggered before rendering the texture
  93763. */
  93764. onBeforeRenderObservable: Observable<number>;
  93765. private _onBeforeRenderObserver;
  93766. /**
  93767. * Set a before render callback in the texture.
  93768. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93769. */
  93770. set onBeforeRender(callback: (faceIndex: number) => void);
  93771. /**
  93772. * An event triggered after rendering the texture
  93773. */
  93774. onAfterRenderObservable: Observable<number>;
  93775. private _onAfterRenderObserver;
  93776. /**
  93777. * Set a after render callback in the texture.
  93778. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93779. */
  93780. set onAfterRender(callback: (faceIndex: number) => void);
  93781. /**
  93782. * An event triggered after the texture clear
  93783. */
  93784. onClearObservable: Observable<Engine>;
  93785. private _onClearObserver;
  93786. /**
  93787. * Set a clear callback in the texture.
  93788. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93789. */
  93790. set onClear(callback: (Engine: Engine) => void);
  93791. /**
  93792. * An event triggered when the texture is resized.
  93793. */
  93794. onResizeObservable: Observable<RenderTargetTexture>;
  93795. /**
  93796. * Define the clear color of the Render Target if it should be different from the scene.
  93797. */
  93798. clearColor: Color4;
  93799. protected _size: number | {
  93800. width: number;
  93801. height: number;
  93802. layers?: number;
  93803. };
  93804. protected _initialSizeParameter: number | {
  93805. width: number;
  93806. height: number;
  93807. } | {
  93808. ratio: number;
  93809. };
  93810. protected _sizeRatio: Nullable<number>;
  93811. /** @hidden */
  93812. _generateMipMaps: boolean;
  93813. protected _renderingManager: RenderingManager;
  93814. /** @hidden */
  93815. _waitingRenderList: string[];
  93816. protected _doNotChangeAspectRatio: boolean;
  93817. protected _currentRefreshId: number;
  93818. protected _refreshRate: number;
  93819. protected _textureMatrix: Matrix;
  93820. protected _samples: number;
  93821. protected _renderTargetOptions: RenderTargetCreationOptions;
  93822. /**
  93823. * Gets render target creation options that were used.
  93824. */
  93825. get renderTargetOptions(): RenderTargetCreationOptions;
  93826. protected _engine: Engine;
  93827. protected _onRatioRescale(): void;
  93828. /**
  93829. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93830. * It must define where the camera used to render the texture is set
  93831. */
  93832. boundingBoxPosition: Vector3;
  93833. private _boundingBoxSize;
  93834. /**
  93835. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93836. * When defined, the cubemap will switch to local mode
  93837. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93838. * @example https://www.babylonjs-playground.com/#RNASML
  93839. */
  93840. set boundingBoxSize(value: Vector3);
  93841. get boundingBoxSize(): Vector3;
  93842. /**
  93843. * In case the RTT has been created with a depth texture, get the associated
  93844. * depth texture.
  93845. * Otherwise, return null.
  93846. */
  93847. get depthStencilTexture(): Nullable<InternalTexture>;
  93848. /**
  93849. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93850. * or used a shadow, depth texture...
  93851. * @param name The friendly name of the texture
  93852. * @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)
  93853. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93854. * @param generateMipMaps True if mip maps need to be generated after render.
  93855. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93856. * @param type The type of the buffer in the RTT (int, half float, float...)
  93857. * @param isCube True if a cube texture needs to be created
  93858. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93859. * @param generateDepthBuffer True to generate a depth buffer
  93860. * @param generateStencilBuffer True to generate a stencil buffer
  93861. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93862. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93863. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93864. */
  93865. constructor(name: string, size: number | {
  93866. width: number;
  93867. height: number;
  93868. layers?: number;
  93869. } | {
  93870. ratio: number;
  93871. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93872. /**
  93873. * Creates a depth stencil texture.
  93874. * This is only available in WebGL 2 or with the depth texture extension available.
  93875. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93876. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93877. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93878. */
  93879. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93880. private _processSizeParameter;
  93881. /**
  93882. * Define the number of samples to use in case of MSAA.
  93883. * It defaults to one meaning no MSAA has been enabled.
  93884. */
  93885. get samples(): number;
  93886. set samples(value: number);
  93887. /**
  93888. * Resets the refresh counter of the texture and start bak from scratch.
  93889. * Could be useful to regenerate the texture if it is setup to render only once.
  93890. */
  93891. resetRefreshCounter(): void;
  93892. /**
  93893. * Define the refresh rate of the texture or the rendering frequency.
  93894. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93895. */
  93896. get refreshRate(): number;
  93897. set refreshRate(value: number);
  93898. /**
  93899. * Adds a post process to the render target rendering passes.
  93900. * @param postProcess define the post process to add
  93901. */
  93902. addPostProcess(postProcess: PostProcess): void;
  93903. /**
  93904. * Clear all the post processes attached to the render target
  93905. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93906. */
  93907. clearPostProcesses(dispose?: boolean): void;
  93908. /**
  93909. * Remove one of the post process from the list of attached post processes to the texture
  93910. * @param postProcess define the post process to remove from the list
  93911. */
  93912. removePostProcess(postProcess: PostProcess): void;
  93913. /** @hidden */
  93914. _shouldRender(): boolean;
  93915. /**
  93916. * Gets the actual render size of the texture.
  93917. * @returns the width of the render size
  93918. */
  93919. getRenderSize(): number;
  93920. /**
  93921. * Gets the actual render width of the texture.
  93922. * @returns the width of the render size
  93923. */
  93924. getRenderWidth(): number;
  93925. /**
  93926. * Gets the actual render height of the texture.
  93927. * @returns the height of the render size
  93928. */
  93929. getRenderHeight(): number;
  93930. /**
  93931. * Gets the actual number of layers of the texture.
  93932. * @returns the number of layers
  93933. */
  93934. getRenderLayers(): number;
  93935. /**
  93936. * Get if the texture can be rescaled or not.
  93937. */
  93938. get canRescale(): boolean;
  93939. /**
  93940. * Resize the texture using a ratio.
  93941. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93942. */
  93943. scale(ratio: number): void;
  93944. /**
  93945. * Get the texture reflection matrix used to rotate/transform the reflection.
  93946. * @returns the reflection matrix
  93947. */
  93948. getReflectionTextureMatrix(): Matrix;
  93949. /**
  93950. * Resize the texture to a new desired size.
  93951. * Be carrefull as it will recreate all the data in the new texture.
  93952. * @param size Define the new size. It can be:
  93953. * - a number for squared texture,
  93954. * - an object containing { width: number, height: number }
  93955. * - or an object containing a ratio { ratio: number }
  93956. */
  93957. resize(size: number | {
  93958. width: number;
  93959. height: number;
  93960. } | {
  93961. ratio: number;
  93962. }): void;
  93963. private _defaultRenderListPrepared;
  93964. /**
  93965. * Renders all the objects from the render list into the texture.
  93966. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93967. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93968. */
  93969. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93970. private _bestReflectionRenderTargetDimension;
  93971. private _prepareRenderingManager;
  93972. /**
  93973. * @hidden
  93974. * @param faceIndex face index to bind to if this is a cubetexture
  93975. * @param layer defines the index of the texture to bind in the array
  93976. */
  93977. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93978. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93979. private renderToTarget;
  93980. /**
  93981. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93982. * This allowed control for front to back rendering or reversly depending of the special needs.
  93983. *
  93984. * @param renderingGroupId The rendering group id corresponding to its index
  93985. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93986. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93987. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93988. */
  93989. 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;
  93990. /**
  93991. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93992. *
  93993. * @param renderingGroupId The rendering group id corresponding to its index
  93994. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93995. */
  93996. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93997. /**
  93998. * Clones the texture.
  93999. * @returns the cloned texture
  94000. */
  94001. clone(): RenderTargetTexture;
  94002. /**
  94003. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94004. * @returns The JSON representation of the texture
  94005. */
  94006. serialize(): any;
  94007. /**
  94008. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94009. */
  94010. disposeFramebufferObjects(): void;
  94011. /**
  94012. * Dispose the texture and release its associated resources.
  94013. */
  94014. dispose(): void;
  94015. /** @hidden */
  94016. _rebuild(): void;
  94017. /**
  94018. * Clear the info related to rendering groups preventing retention point in material dispose.
  94019. */
  94020. freeRenderingGroups(): void;
  94021. /**
  94022. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94023. * @returns the view count
  94024. */
  94025. getViewCount(): number;
  94026. }
  94027. }
  94028. declare module BABYLON {
  94029. /**
  94030. * Options for compiling materials.
  94031. */
  94032. export interface IMaterialCompilationOptions {
  94033. /**
  94034. * Defines whether clip planes are enabled.
  94035. */
  94036. clipPlane: boolean;
  94037. /**
  94038. * Defines whether instances are enabled.
  94039. */
  94040. useInstances: boolean;
  94041. }
  94042. /**
  94043. * Base class for the main features of a material in Babylon.js
  94044. */
  94045. export class Material implements IAnimatable {
  94046. /**
  94047. * Returns the triangle fill mode
  94048. */
  94049. static readonly TriangleFillMode: number;
  94050. /**
  94051. * Returns the wireframe mode
  94052. */
  94053. static readonly WireFrameFillMode: number;
  94054. /**
  94055. * Returns the point fill mode
  94056. */
  94057. static readonly PointFillMode: number;
  94058. /**
  94059. * Returns the point list draw mode
  94060. */
  94061. static readonly PointListDrawMode: number;
  94062. /**
  94063. * Returns the line list draw mode
  94064. */
  94065. static readonly LineListDrawMode: number;
  94066. /**
  94067. * Returns the line loop draw mode
  94068. */
  94069. static readonly LineLoopDrawMode: number;
  94070. /**
  94071. * Returns the line strip draw mode
  94072. */
  94073. static readonly LineStripDrawMode: number;
  94074. /**
  94075. * Returns the triangle strip draw mode
  94076. */
  94077. static readonly TriangleStripDrawMode: number;
  94078. /**
  94079. * Returns the triangle fan draw mode
  94080. */
  94081. static readonly TriangleFanDrawMode: number;
  94082. /**
  94083. * Stores the clock-wise side orientation
  94084. */
  94085. static readonly ClockWiseSideOrientation: number;
  94086. /**
  94087. * Stores the counter clock-wise side orientation
  94088. */
  94089. static readonly CounterClockWiseSideOrientation: number;
  94090. /**
  94091. * The dirty texture flag value
  94092. */
  94093. static readonly TextureDirtyFlag: number;
  94094. /**
  94095. * The dirty light flag value
  94096. */
  94097. static readonly LightDirtyFlag: number;
  94098. /**
  94099. * The dirty fresnel flag value
  94100. */
  94101. static readonly FresnelDirtyFlag: number;
  94102. /**
  94103. * The dirty attribute flag value
  94104. */
  94105. static readonly AttributesDirtyFlag: number;
  94106. /**
  94107. * The dirty misc flag value
  94108. */
  94109. static readonly MiscDirtyFlag: number;
  94110. /**
  94111. * The all dirty flag value
  94112. */
  94113. static readonly AllDirtyFlag: number;
  94114. /**
  94115. * The ID of the material
  94116. */
  94117. id: string;
  94118. /**
  94119. * Gets or sets the unique id of the material
  94120. */
  94121. uniqueId: number;
  94122. /**
  94123. * The name of the material
  94124. */
  94125. name: string;
  94126. /**
  94127. * Gets or sets user defined metadata
  94128. */
  94129. metadata: any;
  94130. /**
  94131. * For internal use only. Please do not use.
  94132. */
  94133. reservedDataStore: any;
  94134. /**
  94135. * Specifies if the ready state should be checked on each call
  94136. */
  94137. checkReadyOnEveryCall: boolean;
  94138. /**
  94139. * Specifies if the ready state should be checked once
  94140. */
  94141. checkReadyOnlyOnce: boolean;
  94142. /**
  94143. * The state of the material
  94144. */
  94145. state: string;
  94146. /**
  94147. * The alpha value of the material
  94148. */
  94149. protected _alpha: number;
  94150. /**
  94151. * List of inspectable custom properties (used by the Inspector)
  94152. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94153. */
  94154. inspectableCustomProperties: IInspectable[];
  94155. /**
  94156. * Sets the alpha value of the material
  94157. */
  94158. set alpha(value: number);
  94159. /**
  94160. * Gets the alpha value of the material
  94161. */
  94162. get alpha(): number;
  94163. /**
  94164. * Specifies if back face culling is enabled
  94165. */
  94166. protected _backFaceCulling: boolean;
  94167. /**
  94168. * Sets the back-face culling state
  94169. */
  94170. set backFaceCulling(value: boolean);
  94171. /**
  94172. * Gets the back-face culling state
  94173. */
  94174. get backFaceCulling(): boolean;
  94175. /**
  94176. * Stores the value for side orientation
  94177. */
  94178. sideOrientation: number;
  94179. /**
  94180. * Callback triggered when the material is compiled
  94181. */
  94182. onCompiled: Nullable<(effect: Effect) => void>;
  94183. /**
  94184. * Callback triggered when an error occurs
  94185. */
  94186. onError: Nullable<(effect: Effect, errors: string) => void>;
  94187. /**
  94188. * Callback triggered to get the render target textures
  94189. */
  94190. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94191. /**
  94192. * Gets a boolean indicating that current material needs to register RTT
  94193. */
  94194. get hasRenderTargetTextures(): boolean;
  94195. /**
  94196. * Specifies if the material should be serialized
  94197. */
  94198. doNotSerialize: boolean;
  94199. /**
  94200. * @hidden
  94201. */
  94202. _storeEffectOnSubMeshes: boolean;
  94203. /**
  94204. * Stores the animations for the material
  94205. */
  94206. animations: Nullable<Array<Animation>>;
  94207. /**
  94208. * An event triggered when the material is disposed
  94209. */
  94210. onDisposeObservable: Observable<Material>;
  94211. /**
  94212. * An observer which watches for dispose events
  94213. */
  94214. private _onDisposeObserver;
  94215. private _onUnBindObservable;
  94216. /**
  94217. * Called during a dispose event
  94218. */
  94219. set onDispose(callback: () => void);
  94220. private _onBindObservable;
  94221. /**
  94222. * An event triggered when the material is bound
  94223. */
  94224. get onBindObservable(): Observable<AbstractMesh>;
  94225. /**
  94226. * An observer which watches for bind events
  94227. */
  94228. private _onBindObserver;
  94229. /**
  94230. * Called during a bind event
  94231. */
  94232. set onBind(callback: (Mesh: AbstractMesh) => void);
  94233. /**
  94234. * An event triggered when the material is unbound
  94235. */
  94236. get onUnBindObservable(): Observable<Material>;
  94237. /**
  94238. * Stores the value of the alpha mode
  94239. */
  94240. private _alphaMode;
  94241. /**
  94242. * Sets the value of the alpha mode.
  94243. *
  94244. * | Value | Type | Description |
  94245. * | --- | --- | --- |
  94246. * | 0 | ALPHA_DISABLE | |
  94247. * | 1 | ALPHA_ADD | |
  94248. * | 2 | ALPHA_COMBINE | |
  94249. * | 3 | ALPHA_SUBTRACT | |
  94250. * | 4 | ALPHA_MULTIPLY | |
  94251. * | 5 | ALPHA_MAXIMIZED | |
  94252. * | 6 | ALPHA_ONEONE | |
  94253. * | 7 | ALPHA_PREMULTIPLIED | |
  94254. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94255. * | 9 | ALPHA_INTERPOLATE | |
  94256. * | 10 | ALPHA_SCREENMODE | |
  94257. *
  94258. */
  94259. set alphaMode(value: number);
  94260. /**
  94261. * Gets the value of the alpha mode
  94262. */
  94263. get alphaMode(): number;
  94264. /**
  94265. * Stores the state of the need depth pre-pass value
  94266. */
  94267. private _needDepthPrePass;
  94268. /**
  94269. * Sets the need depth pre-pass value
  94270. */
  94271. set needDepthPrePass(value: boolean);
  94272. /**
  94273. * Gets the depth pre-pass value
  94274. */
  94275. get needDepthPrePass(): boolean;
  94276. /**
  94277. * Specifies if depth writing should be disabled
  94278. */
  94279. disableDepthWrite: boolean;
  94280. /**
  94281. * Specifies if depth writing should be forced
  94282. */
  94283. forceDepthWrite: boolean;
  94284. /**
  94285. * Specifies the depth function that should be used. 0 means the default engine function
  94286. */
  94287. depthFunction: number;
  94288. /**
  94289. * Specifies if there should be a separate pass for culling
  94290. */
  94291. separateCullingPass: boolean;
  94292. /**
  94293. * Stores the state specifing if fog should be enabled
  94294. */
  94295. private _fogEnabled;
  94296. /**
  94297. * Sets the state for enabling fog
  94298. */
  94299. set fogEnabled(value: boolean);
  94300. /**
  94301. * Gets the value of the fog enabled state
  94302. */
  94303. get fogEnabled(): boolean;
  94304. /**
  94305. * Stores the size of points
  94306. */
  94307. pointSize: number;
  94308. /**
  94309. * Stores the z offset value
  94310. */
  94311. zOffset: number;
  94312. /**
  94313. * Gets a value specifying if wireframe mode is enabled
  94314. */
  94315. get wireframe(): boolean;
  94316. /**
  94317. * Sets the state of wireframe mode
  94318. */
  94319. set wireframe(value: boolean);
  94320. /**
  94321. * Gets the value specifying if point clouds are enabled
  94322. */
  94323. get pointsCloud(): boolean;
  94324. /**
  94325. * Sets the state of point cloud mode
  94326. */
  94327. set pointsCloud(value: boolean);
  94328. /**
  94329. * Gets the material fill mode
  94330. */
  94331. get fillMode(): number;
  94332. /**
  94333. * Sets the material fill mode
  94334. */
  94335. set fillMode(value: number);
  94336. /**
  94337. * @hidden
  94338. * Stores the effects for the material
  94339. */
  94340. _effect: Nullable<Effect>;
  94341. /**
  94342. * Specifies if uniform buffers should be used
  94343. */
  94344. private _useUBO;
  94345. /**
  94346. * Stores a reference to the scene
  94347. */
  94348. private _scene;
  94349. /**
  94350. * Stores the fill mode state
  94351. */
  94352. private _fillMode;
  94353. /**
  94354. * Specifies if the depth write state should be cached
  94355. */
  94356. private _cachedDepthWriteState;
  94357. /**
  94358. * Specifies if the depth function state should be cached
  94359. */
  94360. private _cachedDepthFunctionState;
  94361. /**
  94362. * Stores the uniform buffer
  94363. */
  94364. protected _uniformBuffer: UniformBuffer;
  94365. /** @hidden */
  94366. _indexInSceneMaterialArray: number;
  94367. /** @hidden */
  94368. meshMap: Nullable<{
  94369. [id: string]: AbstractMesh | undefined;
  94370. }>;
  94371. /**
  94372. * Creates a material instance
  94373. * @param name defines the name of the material
  94374. * @param scene defines the scene to reference
  94375. * @param doNotAdd specifies if the material should be added to the scene
  94376. */
  94377. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94378. /**
  94379. * Returns a string representation of the current material
  94380. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94381. * @returns a string with material information
  94382. */
  94383. toString(fullDetails?: boolean): string;
  94384. /**
  94385. * Gets the class name of the material
  94386. * @returns a string with the class name of the material
  94387. */
  94388. getClassName(): string;
  94389. /**
  94390. * Specifies if updates for the material been locked
  94391. */
  94392. get isFrozen(): boolean;
  94393. /**
  94394. * Locks updates for the material
  94395. */
  94396. freeze(): void;
  94397. /**
  94398. * Unlocks updates for the material
  94399. */
  94400. unfreeze(): void;
  94401. /**
  94402. * Specifies if the material is ready to be used
  94403. * @param mesh defines the mesh to check
  94404. * @param useInstances specifies if instances should be used
  94405. * @returns a boolean indicating if the material is ready to be used
  94406. */
  94407. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94408. /**
  94409. * Specifies that the submesh is ready to be used
  94410. * @param mesh defines the mesh to check
  94411. * @param subMesh defines which submesh to check
  94412. * @param useInstances specifies that instances should be used
  94413. * @returns a boolean indicating that the submesh is ready or not
  94414. */
  94415. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94416. /**
  94417. * Returns the material effect
  94418. * @returns the effect associated with the material
  94419. */
  94420. getEffect(): Nullable<Effect>;
  94421. /**
  94422. * Returns the current scene
  94423. * @returns a Scene
  94424. */
  94425. getScene(): Scene;
  94426. /**
  94427. * Specifies if the material will require alpha blending
  94428. * @returns a boolean specifying if alpha blending is needed
  94429. */
  94430. needAlphaBlending(): boolean;
  94431. /**
  94432. * Specifies if the mesh will require alpha blending
  94433. * @param mesh defines the mesh to check
  94434. * @returns a boolean specifying if alpha blending is needed for the mesh
  94435. */
  94436. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94437. /**
  94438. * Specifies if this material should be rendered in alpha test mode
  94439. * @returns a boolean specifying if an alpha test is needed.
  94440. */
  94441. needAlphaTesting(): boolean;
  94442. /**
  94443. * Gets the texture used for the alpha test
  94444. * @returns the texture to use for alpha testing
  94445. */
  94446. getAlphaTestTexture(): Nullable<BaseTexture>;
  94447. /**
  94448. * Marks the material to indicate that it needs to be re-calculated
  94449. */
  94450. markDirty(): void;
  94451. /** @hidden */
  94452. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94453. /**
  94454. * Binds the material to the mesh
  94455. * @param world defines the world transformation matrix
  94456. * @param mesh defines the mesh to bind the material to
  94457. */
  94458. bind(world: Matrix, mesh?: Mesh): void;
  94459. /**
  94460. * Binds the submesh to the material
  94461. * @param world defines the world transformation matrix
  94462. * @param mesh defines the mesh containing the submesh
  94463. * @param subMesh defines the submesh to bind the material to
  94464. */
  94465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94466. /**
  94467. * Binds the world matrix to the material
  94468. * @param world defines the world transformation matrix
  94469. */
  94470. bindOnlyWorldMatrix(world: Matrix): void;
  94471. /**
  94472. * Binds the scene's uniform buffer to the effect.
  94473. * @param effect defines the effect to bind to the scene uniform buffer
  94474. * @param sceneUbo defines the uniform buffer storing scene data
  94475. */
  94476. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94477. /**
  94478. * Binds the view matrix to the effect
  94479. * @param effect defines the effect to bind the view matrix to
  94480. */
  94481. bindView(effect: Effect): void;
  94482. /**
  94483. * Binds the view projection matrix to the effect
  94484. * @param effect defines the effect to bind the view projection matrix to
  94485. */
  94486. bindViewProjection(effect: Effect): void;
  94487. /**
  94488. * Specifies if material alpha testing should be turned on for the mesh
  94489. * @param mesh defines the mesh to check
  94490. */
  94491. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94492. /**
  94493. * Processes to execute after binding the material to a mesh
  94494. * @param mesh defines the rendered mesh
  94495. */
  94496. protected _afterBind(mesh?: Mesh): void;
  94497. /**
  94498. * Unbinds the material from the mesh
  94499. */
  94500. unbind(): void;
  94501. /**
  94502. * Gets the active textures from the material
  94503. * @returns an array of textures
  94504. */
  94505. getActiveTextures(): BaseTexture[];
  94506. /**
  94507. * Specifies if the material uses a texture
  94508. * @param texture defines the texture to check against the material
  94509. * @returns a boolean specifying if the material uses the texture
  94510. */
  94511. hasTexture(texture: BaseTexture): boolean;
  94512. /**
  94513. * Makes a duplicate of the material, and gives it a new name
  94514. * @param name defines the new name for the duplicated material
  94515. * @returns the cloned material
  94516. */
  94517. clone(name: string): Nullable<Material>;
  94518. /**
  94519. * Gets the meshes bound to the material
  94520. * @returns an array of meshes bound to the material
  94521. */
  94522. getBindedMeshes(): AbstractMesh[];
  94523. /**
  94524. * Force shader compilation
  94525. * @param mesh defines the mesh associated with this material
  94526. * @param onCompiled defines a function to execute once the material is compiled
  94527. * @param options defines the options to configure the compilation
  94528. * @param onError defines a function to execute if the material fails compiling
  94529. */
  94530. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94531. /**
  94532. * Force shader compilation
  94533. * @param mesh defines the mesh that will use this material
  94534. * @param options defines additional options for compiling the shaders
  94535. * @returns a promise that resolves when the compilation completes
  94536. */
  94537. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94538. private static readonly _AllDirtyCallBack;
  94539. private static readonly _ImageProcessingDirtyCallBack;
  94540. private static readonly _TextureDirtyCallBack;
  94541. private static readonly _FresnelDirtyCallBack;
  94542. private static readonly _MiscDirtyCallBack;
  94543. private static readonly _LightsDirtyCallBack;
  94544. private static readonly _AttributeDirtyCallBack;
  94545. private static _FresnelAndMiscDirtyCallBack;
  94546. private static _TextureAndMiscDirtyCallBack;
  94547. private static readonly _DirtyCallbackArray;
  94548. private static readonly _RunDirtyCallBacks;
  94549. /**
  94550. * Marks a define in the material to indicate that it needs to be re-computed
  94551. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94552. */
  94553. markAsDirty(flag: number): void;
  94554. /**
  94555. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94556. * @param func defines a function which checks material defines against the submeshes
  94557. */
  94558. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94559. /**
  94560. * Indicates that we need to re-calculated for all submeshes
  94561. */
  94562. protected _markAllSubMeshesAsAllDirty(): void;
  94563. /**
  94564. * Indicates that image processing needs to be re-calculated for all submeshes
  94565. */
  94566. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94567. /**
  94568. * Indicates that textures need to be re-calculated for all submeshes
  94569. */
  94570. protected _markAllSubMeshesAsTexturesDirty(): void;
  94571. /**
  94572. * Indicates that fresnel needs to be re-calculated for all submeshes
  94573. */
  94574. protected _markAllSubMeshesAsFresnelDirty(): void;
  94575. /**
  94576. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94577. */
  94578. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94579. /**
  94580. * Indicates that lights need to be re-calculated for all submeshes
  94581. */
  94582. protected _markAllSubMeshesAsLightsDirty(): void;
  94583. /**
  94584. * Indicates that attributes need to be re-calculated for all submeshes
  94585. */
  94586. protected _markAllSubMeshesAsAttributesDirty(): void;
  94587. /**
  94588. * Indicates that misc needs to be re-calculated for all submeshes
  94589. */
  94590. protected _markAllSubMeshesAsMiscDirty(): void;
  94591. /**
  94592. * Indicates that textures and misc need to be re-calculated for all submeshes
  94593. */
  94594. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94595. /**
  94596. * Disposes the material
  94597. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94598. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94599. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94600. */
  94601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94602. /** @hidden */
  94603. private releaseVertexArrayObject;
  94604. /**
  94605. * Serializes this material
  94606. * @returns the serialized material object
  94607. */
  94608. serialize(): any;
  94609. /**
  94610. * Creates a material from parsed material data
  94611. * @param parsedMaterial defines parsed material data
  94612. * @param scene defines the hosting scene
  94613. * @param rootUrl defines the root URL to use to load textures
  94614. * @returns a new material
  94615. */
  94616. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94617. }
  94618. }
  94619. declare module BABYLON {
  94620. /**
  94621. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94622. * separate meshes. This can be use to improve performances.
  94623. * @see http://doc.babylonjs.com/how_to/multi_materials
  94624. */
  94625. export class MultiMaterial extends Material {
  94626. private _subMaterials;
  94627. /**
  94628. * Gets or Sets the list of Materials used within the multi material.
  94629. * They need to be ordered according to the submeshes order in the associated mesh
  94630. */
  94631. get subMaterials(): Nullable<Material>[];
  94632. set subMaterials(value: Nullable<Material>[]);
  94633. /**
  94634. * Function used to align with Node.getChildren()
  94635. * @returns the list of Materials used within the multi material
  94636. */
  94637. getChildren(): Nullable<Material>[];
  94638. /**
  94639. * Instantiates a new Multi Material
  94640. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94641. * separate meshes. This can be use to improve performances.
  94642. * @see http://doc.babylonjs.com/how_to/multi_materials
  94643. * @param name Define the name in the scene
  94644. * @param scene Define the scene the material belongs to
  94645. */
  94646. constructor(name: string, scene: Scene);
  94647. private _hookArray;
  94648. /**
  94649. * Get one of the submaterial by its index in the submaterials array
  94650. * @param index The index to look the sub material at
  94651. * @returns The Material if the index has been defined
  94652. */
  94653. getSubMaterial(index: number): Nullable<Material>;
  94654. /**
  94655. * Get the list of active textures for the whole sub materials list.
  94656. * @returns All the textures that will be used during the rendering
  94657. */
  94658. getActiveTextures(): BaseTexture[];
  94659. /**
  94660. * Gets the current class name of the material e.g. "MultiMaterial"
  94661. * Mainly use in serialization.
  94662. * @returns the class name
  94663. */
  94664. getClassName(): string;
  94665. /**
  94666. * Checks if the material is ready to render the requested sub mesh
  94667. * @param mesh Define the mesh the submesh belongs to
  94668. * @param subMesh Define the sub mesh to look readyness for
  94669. * @param useInstances Define whether or not the material is used with instances
  94670. * @returns true if ready, otherwise false
  94671. */
  94672. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94673. /**
  94674. * Clones the current material and its related sub materials
  94675. * @param name Define the name of the newly cloned material
  94676. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94677. * @returns the cloned material
  94678. */
  94679. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94680. /**
  94681. * Serializes the materials into a JSON representation.
  94682. * @returns the JSON representation
  94683. */
  94684. serialize(): any;
  94685. /**
  94686. * Dispose the material and release its associated resources
  94687. * @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)
  94688. * @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)
  94689. * @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)
  94690. */
  94691. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94692. /**
  94693. * Creates a MultiMaterial from parsed MultiMaterial data.
  94694. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94695. * @param scene defines the hosting scene
  94696. * @returns a new MultiMaterial
  94697. */
  94698. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94699. }
  94700. }
  94701. declare module BABYLON {
  94702. /**
  94703. * Base class for submeshes
  94704. */
  94705. export class BaseSubMesh {
  94706. /** @hidden */
  94707. _materialDefines: Nullable<MaterialDefines>;
  94708. /** @hidden */
  94709. _materialEffect: Nullable<Effect>;
  94710. /**
  94711. * Gets material defines used by the effect associated to the sub mesh
  94712. */
  94713. get materialDefines(): Nullable<MaterialDefines>;
  94714. /**
  94715. * Sets material defines used by the effect associated to the sub mesh
  94716. */
  94717. set materialDefines(defines: Nullable<MaterialDefines>);
  94718. /**
  94719. * Gets associated effect
  94720. */
  94721. get effect(): Nullable<Effect>;
  94722. /**
  94723. * Sets associated effect (effect used to render this submesh)
  94724. * @param effect defines the effect to associate with
  94725. * @param defines defines the set of defines used to compile this effect
  94726. */
  94727. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94728. }
  94729. /**
  94730. * Defines a subdivision inside a mesh
  94731. */
  94732. export class SubMesh extends BaseSubMesh implements ICullable {
  94733. /** the material index to use */
  94734. materialIndex: number;
  94735. /** vertex index start */
  94736. verticesStart: number;
  94737. /** vertices count */
  94738. verticesCount: number;
  94739. /** index start */
  94740. indexStart: number;
  94741. /** indices count */
  94742. indexCount: number;
  94743. /** @hidden */
  94744. _linesIndexCount: number;
  94745. private _mesh;
  94746. private _renderingMesh;
  94747. private _boundingInfo;
  94748. private _linesIndexBuffer;
  94749. /** @hidden */
  94750. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94751. /** @hidden */
  94752. _trianglePlanes: Plane[];
  94753. /** @hidden */
  94754. _lastColliderTransformMatrix: Nullable<Matrix>;
  94755. /** @hidden */
  94756. _renderId: number;
  94757. /** @hidden */
  94758. _alphaIndex: number;
  94759. /** @hidden */
  94760. _distanceToCamera: number;
  94761. /** @hidden */
  94762. _id: number;
  94763. private _currentMaterial;
  94764. /**
  94765. * Add a new submesh to a mesh
  94766. * @param materialIndex defines the material index to use
  94767. * @param verticesStart defines vertex index start
  94768. * @param verticesCount defines vertices count
  94769. * @param indexStart defines index start
  94770. * @param indexCount defines indices count
  94771. * @param mesh defines the parent mesh
  94772. * @param renderingMesh defines an optional rendering mesh
  94773. * @param createBoundingBox defines if bounding box should be created for this submesh
  94774. * @returns the new submesh
  94775. */
  94776. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94777. /**
  94778. * Creates a new submesh
  94779. * @param materialIndex defines the material index to use
  94780. * @param verticesStart defines vertex index start
  94781. * @param verticesCount defines vertices count
  94782. * @param indexStart defines index start
  94783. * @param indexCount defines indices count
  94784. * @param mesh defines the parent mesh
  94785. * @param renderingMesh defines an optional rendering mesh
  94786. * @param createBoundingBox defines if bounding box should be created for this submesh
  94787. */
  94788. constructor(
  94789. /** the material index to use */
  94790. materialIndex: number,
  94791. /** vertex index start */
  94792. verticesStart: number,
  94793. /** vertices count */
  94794. verticesCount: number,
  94795. /** index start */
  94796. indexStart: number,
  94797. /** indices count */
  94798. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94799. /**
  94800. * Returns true if this submesh covers the entire parent mesh
  94801. * @ignorenaming
  94802. */
  94803. get IsGlobal(): boolean;
  94804. /**
  94805. * Returns the submesh BoudingInfo object
  94806. * @returns current bounding info (or mesh's one if the submesh is global)
  94807. */
  94808. getBoundingInfo(): BoundingInfo;
  94809. /**
  94810. * Sets the submesh BoundingInfo
  94811. * @param boundingInfo defines the new bounding info to use
  94812. * @returns the SubMesh
  94813. */
  94814. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94815. /**
  94816. * Returns the mesh of the current submesh
  94817. * @return the parent mesh
  94818. */
  94819. getMesh(): AbstractMesh;
  94820. /**
  94821. * Returns the rendering mesh of the submesh
  94822. * @returns the rendering mesh (could be different from parent mesh)
  94823. */
  94824. getRenderingMesh(): Mesh;
  94825. /**
  94826. * Returns the submesh material
  94827. * @returns null or the current material
  94828. */
  94829. getMaterial(): Nullable<Material>;
  94830. /**
  94831. * Sets a new updated BoundingInfo object to the submesh
  94832. * @param data defines an optional position array to use to determine the bounding info
  94833. * @returns the SubMesh
  94834. */
  94835. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94836. /** @hidden */
  94837. _checkCollision(collider: Collider): boolean;
  94838. /**
  94839. * Updates the submesh BoundingInfo
  94840. * @param world defines the world matrix to use to update the bounding info
  94841. * @returns the submesh
  94842. */
  94843. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94844. /**
  94845. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94846. * @param frustumPlanes defines the frustum planes
  94847. * @returns true if the submesh is intersecting with the frustum
  94848. */
  94849. isInFrustum(frustumPlanes: Plane[]): boolean;
  94850. /**
  94851. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94852. * @param frustumPlanes defines the frustum planes
  94853. * @returns true if the submesh is inside the frustum
  94854. */
  94855. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94856. /**
  94857. * Renders the submesh
  94858. * @param enableAlphaMode defines if alpha needs to be used
  94859. * @returns the submesh
  94860. */
  94861. render(enableAlphaMode: boolean): SubMesh;
  94862. /**
  94863. * @hidden
  94864. */
  94865. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94866. /**
  94867. * Checks if the submesh intersects with a ray
  94868. * @param ray defines the ray to test
  94869. * @returns true is the passed ray intersects the submesh bounding box
  94870. */
  94871. canIntersects(ray: Ray): boolean;
  94872. /**
  94873. * Intersects current submesh with a ray
  94874. * @param ray defines the ray to test
  94875. * @param positions defines mesh's positions array
  94876. * @param indices defines mesh's indices array
  94877. * @param fastCheck defines if only bounding info should be used
  94878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94879. * @returns intersection info or null if no intersection
  94880. */
  94881. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94882. /** @hidden */
  94883. private _intersectLines;
  94884. /** @hidden */
  94885. private _intersectUnIndexedLines;
  94886. /** @hidden */
  94887. private _intersectTriangles;
  94888. /** @hidden */
  94889. private _intersectUnIndexedTriangles;
  94890. /** @hidden */
  94891. _rebuild(): void;
  94892. /**
  94893. * Creates a new submesh from the passed mesh
  94894. * @param newMesh defines the new hosting mesh
  94895. * @param newRenderingMesh defines an optional rendering mesh
  94896. * @returns the new submesh
  94897. */
  94898. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94899. /**
  94900. * Release associated resources
  94901. */
  94902. dispose(): void;
  94903. /**
  94904. * Gets the class name
  94905. * @returns the string "SubMesh".
  94906. */
  94907. getClassName(): string;
  94908. /**
  94909. * Creates a new submesh from indices data
  94910. * @param materialIndex the index of the main mesh material
  94911. * @param startIndex the index where to start the copy in the mesh indices array
  94912. * @param indexCount the number of indices to copy then from the startIndex
  94913. * @param mesh the main mesh to create the submesh from
  94914. * @param renderingMesh the optional rendering mesh
  94915. * @returns a new submesh
  94916. */
  94917. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94918. }
  94919. }
  94920. declare module BABYLON {
  94921. /**
  94922. * Class used to represent data loading progression
  94923. */
  94924. export class SceneLoaderFlags {
  94925. private static _ForceFullSceneLoadingForIncremental;
  94926. private static _ShowLoadingScreen;
  94927. private static _CleanBoneMatrixWeights;
  94928. private static _loggingLevel;
  94929. /**
  94930. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94931. */
  94932. static get ForceFullSceneLoadingForIncremental(): boolean;
  94933. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94934. /**
  94935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94936. */
  94937. static get ShowLoadingScreen(): boolean;
  94938. static set ShowLoadingScreen(value: boolean);
  94939. /**
  94940. * Defines the current logging level (while loading the scene)
  94941. * @ignorenaming
  94942. */
  94943. static get loggingLevel(): number;
  94944. static set loggingLevel(value: number);
  94945. /**
  94946. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94947. */
  94948. static get CleanBoneMatrixWeights(): boolean;
  94949. static set CleanBoneMatrixWeights(value: boolean);
  94950. }
  94951. }
  94952. declare module BABYLON {
  94953. /**
  94954. * Class used to store geometry data (vertex buffers + index buffer)
  94955. */
  94956. export class Geometry implements IGetSetVerticesData {
  94957. /**
  94958. * Gets or sets the ID of the geometry
  94959. */
  94960. id: string;
  94961. /**
  94962. * Gets or sets the unique ID of the geometry
  94963. */
  94964. uniqueId: number;
  94965. /**
  94966. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94967. */
  94968. delayLoadState: number;
  94969. /**
  94970. * Gets the file containing the data to load when running in delay load state
  94971. */
  94972. delayLoadingFile: Nullable<string>;
  94973. /**
  94974. * Callback called when the geometry is updated
  94975. */
  94976. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94977. private _scene;
  94978. private _engine;
  94979. private _meshes;
  94980. private _totalVertices;
  94981. /** @hidden */
  94982. _indices: IndicesArray;
  94983. /** @hidden */
  94984. _vertexBuffers: {
  94985. [key: string]: VertexBuffer;
  94986. };
  94987. private _isDisposed;
  94988. private _extend;
  94989. private _boundingBias;
  94990. /** @hidden */
  94991. _delayInfo: Array<string>;
  94992. private _indexBuffer;
  94993. private _indexBufferIsUpdatable;
  94994. /** @hidden */
  94995. _boundingInfo: Nullable<BoundingInfo>;
  94996. /** @hidden */
  94997. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94998. /** @hidden */
  94999. _softwareSkinningFrameId: number;
  95000. private _vertexArrayObjects;
  95001. private _updatable;
  95002. /** @hidden */
  95003. _positions: Nullable<Vector3[]>;
  95004. /**
  95005. * 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
  95006. */
  95007. get boundingBias(): Vector2;
  95008. /**
  95009. * 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
  95010. */
  95011. set boundingBias(value: Vector2);
  95012. /**
  95013. * Static function used to attach a new empty geometry to a mesh
  95014. * @param mesh defines the mesh to attach the geometry to
  95015. * @returns the new Geometry
  95016. */
  95017. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95018. /**
  95019. * Creates a new geometry
  95020. * @param id defines the unique ID
  95021. * @param scene defines the hosting scene
  95022. * @param vertexData defines the VertexData used to get geometry data
  95023. * @param updatable defines if geometry must be updatable (false by default)
  95024. * @param mesh defines the mesh that will be associated with the geometry
  95025. */
  95026. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95027. /**
  95028. * Gets the current extend of the geometry
  95029. */
  95030. get extend(): {
  95031. minimum: Vector3;
  95032. maximum: Vector3;
  95033. };
  95034. /**
  95035. * Gets the hosting scene
  95036. * @returns the hosting Scene
  95037. */
  95038. getScene(): Scene;
  95039. /**
  95040. * Gets the hosting engine
  95041. * @returns the hosting Engine
  95042. */
  95043. getEngine(): Engine;
  95044. /**
  95045. * Defines if the geometry is ready to use
  95046. * @returns true if the geometry is ready to be used
  95047. */
  95048. isReady(): boolean;
  95049. /**
  95050. * Gets a value indicating that the geometry should not be serialized
  95051. */
  95052. get doNotSerialize(): boolean;
  95053. /** @hidden */
  95054. _rebuild(): void;
  95055. /**
  95056. * Affects all geometry data in one call
  95057. * @param vertexData defines the geometry data
  95058. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95059. */
  95060. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95061. /**
  95062. * Set specific vertex data
  95063. * @param kind defines the data kind (Position, normal, etc...)
  95064. * @param data defines the vertex data to use
  95065. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95066. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95067. */
  95068. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95069. /**
  95070. * Removes a specific vertex data
  95071. * @param kind defines the data kind (Position, normal, etc...)
  95072. */
  95073. removeVerticesData(kind: string): void;
  95074. /**
  95075. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95076. * @param buffer defines the vertex buffer to use
  95077. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95078. */
  95079. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95080. /**
  95081. * Update a specific vertex buffer
  95082. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95083. * It will do nothing if the buffer is not updatable
  95084. * @param kind defines the data kind (Position, normal, etc...)
  95085. * @param data defines the data to use
  95086. * @param offset defines the offset in the target buffer where to store the data
  95087. * @param useBytes set to true if the offset is in bytes
  95088. */
  95089. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95090. /**
  95091. * Update a specific vertex buffer
  95092. * This function will create a new buffer if the current one is not updatable
  95093. * @param kind defines the data kind (Position, normal, etc...)
  95094. * @param data defines the data to use
  95095. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95096. */
  95097. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95098. private _updateBoundingInfo;
  95099. /** @hidden */
  95100. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95101. /**
  95102. * Gets total number of vertices
  95103. * @returns the total number of vertices
  95104. */
  95105. getTotalVertices(): number;
  95106. /**
  95107. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95108. * @param kind defines the data kind (Position, normal, etc...)
  95109. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95110. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95111. * @returns a float array containing vertex data
  95112. */
  95113. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95114. /**
  95115. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95116. * @param kind defines the data kind (Position, normal, etc...)
  95117. * @returns true if the vertex buffer with the specified kind is updatable
  95118. */
  95119. isVertexBufferUpdatable(kind: string): boolean;
  95120. /**
  95121. * Gets a specific vertex buffer
  95122. * @param kind defines the data kind (Position, normal, etc...)
  95123. * @returns a VertexBuffer
  95124. */
  95125. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95126. /**
  95127. * Returns all vertex buffers
  95128. * @return an object holding all vertex buffers indexed by kind
  95129. */
  95130. getVertexBuffers(): Nullable<{
  95131. [key: string]: VertexBuffer;
  95132. }>;
  95133. /**
  95134. * Gets a boolean indicating if specific vertex buffer is present
  95135. * @param kind defines the data kind (Position, normal, etc...)
  95136. * @returns true if data is present
  95137. */
  95138. isVerticesDataPresent(kind: string): boolean;
  95139. /**
  95140. * Gets a list of all attached data kinds (Position, normal, etc...)
  95141. * @returns a list of string containing all kinds
  95142. */
  95143. getVerticesDataKinds(): string[];
  95144. /**
  95145. * Update index buffer
  95146. * @param indices defines the indices to store in the index buffer
  95147. * @param offset defines the offset in the target buffer where to store the data
  95148. * @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)
  95149. */
  95150. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95151. /**
  95152. * Creates a new index buffer
  95153. * @param indices defines the indices to store in the index buffer
  95154. * @param totalVertices defines the total number of vertices (could be null)
  95155. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95156. */
  95157. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95158. /**
  95159. * Return the total number of indices
  95160. * @returns the total number of indices
  95161. */
  95162. getTotalIndices(): number;
  95163. /**
  95164. * Gets the index buffer array
  95165. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95166. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95167. * @returns the index buffer array
  95168. */
  95169. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95170. /**
  95171. * Gets the index buffer
  95172. * @return the index buffer
  95173. */
  95174. getIndexBuffer(): Nullable<DataBuffer>;
  95175. /** @hidden */
  95176. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95177. /**
  95178. * Release the associated resources for a specific mesh
  95179. * @param mesh defines the source mesh
  95180. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95181. */
  95182. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95183. /**
  95184. * Apply current geometry to a given mesh
  95185. * @param mesh defines the mesh to apply geometry to
  95186. */
  95187. applyToMesh(mesh: Mesh): void;
  95188. private _updateExtend;
  95189. private _applyToMesh;
  95190. private notifyUpdate;
  95191. /**
  95192. * Load the geometry if it was flagged as delay loaded
  95193. * @param scene defines the hosting scene
  95194. * @param onLoaded defines a callback called when the geometry is loaded
  95195. */
  95196. load(scene: Scene, onLoaded?: () => void): void;
  95197. private _queueLoad;
  95198. /**
  95199. * Invert the geometry to move from a right handed system to a left handed one.
  95200. */
  95201. toLeftHanded(): void;
  95202. /** @hidden */
  95203. _resetPointsArrayCache(): void;
  95204. /** @hidden */
  95205. _generatePointsArray(): boolean;
  95206. /**
  95207. * Gets a value indicating if the geometry is disposed
  95208. * @returns true if the geometry was disposed
  95209. */
  95210. isDisposed(): boolean;
  95211. private _disposeVertexArrayObjects;
  95212. /**
  95213. * Free all associated resources
  95214. */
  95215. dispose(): void;
  95216. /**
  95217. * Clone the current geometry into a new geometry
  95218. * @param id defines the unique ID of the new geometry
  95219. * @returns a new geometry object
  95220. */
  95221. copy(id: string): Geometry;
  95222. /**
  95223. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95224. * @return a JSON representation of the current geometry data (without the vertices data)
  95225. */
  95226. serialize(): any;
  95227. private toNumberArray;
  95228. /**
  95229. * Serialize all vertices data into a JSON oject
  95230. * @returns a JSON representation of the current geometry data
  95231. */
  95232. serializeVerticeData(): any;
  95233. /**
  95234. * Extracts a clone of a mesh geometry
  95235. * @param mesh defines the source mesh
  95236. * @param id defines the unique ID of the new geometry object
  95237. * @returns the new geometry object
  95238. */
  95239. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95240. /**
  95241. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95242. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95243. * Be aware Math.random() could cause collisions, but:
  95244. * "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"
  95245. * @returns a string containing a new GUID
  95246. */
  95247. static RandomId(): string;
  95248. /** @hidden */
  95249. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95250. private static _CleanMatricesWeights;
  95251. /**
  95252. * Create a new geometry from persisted data (Using .babylon file format)
  95253. * @param parsedVertexData defines the persisted data
  95254. * @param scene defines the hosting scene
  95255. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95256. * @returns the new geometry object
  95257. */
  95258. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95259. }
  95260. }
  95261. declare module BABYLON {
  95262. /**
  95263. * Define an interface for all classes that will get and set the data on vertices
  95264. */
  95265. export interface IGetSetVerticesData {
  95266. /**
  95267. * Gets a boolean indicating if specific vertex data is present
  95268. * @param kind defines the vertex data kind to use
  95269. * @returns true is data kind is present
  95270. */
  95271. isVerticesDataPresent(kind: string): boolean;
  95272. /**
  95273. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95274. * @param kind defines the data kind (Position, normal, etc...)
  95275. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95276. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95277. * @returns a float array containing vertex data
  95278. */
  95279. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95280. /**
  95281. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95282. * @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.
  95283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95284. * @returns the indices array or an empty array if the mesh has no geometry
  95285. */
  95286. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95287. /**
  95288. * Set specific vertex data
  95289. * @param kind defines the data kind (Position, normal, etc...)
  95290. * @param data defines the vertex data to use
  95291. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95292. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95293. */
  95294. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95295. /**
  95296. * Update a specific associated vertex buffer
  95297. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95298. * - VertexBuffer.PositionKind
  95299. * - VertexBuffer.UVKind
  95300. * - VertexBuffer.UV2Kind
  95301. * - VertexBuffer.UV3Kind
  95302. * - VertexBuffer.UV4Kind
  95303. * - VertexBuffer.UV5Kind
  95304. * - VertexBuffer.UV6Kind
  95305. * - VertexBuffer.ColorKind
  95306. * - VertexBuffer.MatricesIndicesKind
  95307. * - VertexBuffer.MatricesIndicesExtraKind
  95308. * - VertexBuffer.MatricesWeightsKind
  95309. * - VertexBuffer.MatricesWeightsExtraKind
  95310. * @param data defines the data source
  95311. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95312. * @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)
  95313. */
  95314. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95315. /**
  95316. * Creates a new index buffer
  95317. * @param indices defines the indices to store in the index buffer
  95318. * @param totalVertices defines the total number of vertices (could be null)
  95319. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95320. */
  95321. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95322. }
  95323. /**
  95324. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95325. */
  95326. export class VertexData {
  95327. /**
  95328. * Mesh side orientation : usually the external or front surface
  95329. */
  95330. static readonly FRONTSIDE: number;
  95331. /**
  95332. * Mesh side orientation : usually the internal or back surface
  95333. */
  95334. static readonly BACKSIDE: number;
  95335. /**
  95336. * Mesh side orientation : both internal and external or front and back surfaces
  95337. */
  95338. static readonly DOUBLESIDE: number;
  95339. /**
  95340. * Mesh side orientation : by default, `FRONTSIDE`
  95341. */
  95342. static readonly DEFAULTSIDE: number;
  95343. /**
  95344. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95345. */
  95346. positions: Nullable<FloatArray>;
  95347. /**
  95348. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95349. */
  95350. normals: Nullable<FloatArray>;
  95351. /**
  95352. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95353. */
  95354. tangents: Nullable<FloatArray>;
  95355. /**
  95356. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95357. */
  95358. uvs: Nullable<FloatArray>;
  95359. /**
  95360. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95361. */
  95362. uvs2: Nullable<FloatArray>;
  95363. /**
  95364. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95365. */
  95366. uvs3: Nullable<FloatArray>;
  95367. /**
  95368. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95369. */
  95370. uvs4: Nullable<FloatArray>;
  95371. /**
  95372. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95373. */
  95374. uvs5: Nullable<FloatArray>;
  95375. /**
  95376. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95377. */
  95378. uvs6: Nullable<FloatArray>;
  95379. /**
  95380. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95381. */
  95382. colors: Nullable<FloatArray>;
  95383. /**
  95384. * 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).
  95385. */
  95386. matricesIndices: Nullable<FloatArray>;
  95387. /**
  95388. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95389. */
  95390. matricesWeights: Nullable<FloatArray>;
  95391. /**
  95392. * An array extending the number of possible indices
  95393. */
  95394. matricesIndicesExtra: Nullable<FloatArray>;
  95395. /**
  95396. * An array extending the number of possible weights when the number of indices is extended
  95397. */
  95398. matricesWeightsExtra: Nullable<FloatArray>;
  95399. /**
  95400. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95401. */
  95402. indices: Nullable<IndicesArray>;
  95403. /**
  95404. * Uses the passed data array to set the set the values for the specified kind of data
  95405. * @param data a linear array of floating numbers
  95406. * @param kind the type of data that is being set, eg positions, colors etc
  95407. */
  95408. set(data: FloatArray, kind: string): void;
  95409. /**
  95410. * Associates the vertexData to the passed Mesh.
  95411. * Sets it as updatable or not (default `false`)
  95412. * @param mesh the mesh the vertexData is applied to
  95413. * @param updatable when used and having the value true allows new data to update the vertexData
  95414. * @returns the VertexData
  95415. */
  95416. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95417. /**
  95418. * Associates the vertexData to the passed Geometry.
  95419. * Sets it as updatable or not (default `false`)
  95420. * @param geometry the geometry the vertexData is applied to
  95421. * @param updatable when used and having the value true allows new data to update the vertexData
  95422. * @returns VertexData
  95423. */
  95424. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95425. /**
  95426. * Updates the associated mesh
  95427. * @param mesh the mesh to be updated
  95428. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95429. * @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
  95430. * @returns VertexData
  95431. */
  95432. updateMesh(mesh: Mesh): VertexData;
  95433. /**
  95434. * Updates the associated geometry
  95435. * @param geometry the geometry to be updated
  95436. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95437. * @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
  95438. * @returns VertexData.
  95439. */
  95440. updateGeometry(geometry: Geometry): VertexData;
  95441. private _applyTo;
  95442. private _update;
  95443. /**
  95444. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95445. * @param matrix the transforming matrix
  95446. * @returns the VertexData
  95447. */
  95448. transform(matrix: Matrix): VertexData;
  95449. /**
  95450. * Merges the passed VertexData into the current one
  95451. * @param other the VertexData to be merged into the current one
  95452. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95453. * @returns the modified VertexData
  95454. */
  95455. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95456. private _mergeElement;
  95457. private _validate;
  95458. /**
  95459. * Serializes the VertexData
  95460. * @returns a serialized object
  95461. */
  95462. serialize(): any;
  95463. /**
  95464. * Extracts the vertexData from a mesh
  95465. * @param mesh the mesh from which to extract the VertexData
  95466. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95467. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95468. * @returns the object VertexData associated to the passed mesh
  95469. */
  95470. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95471. /**
  95472. * Extracts the vertexData from the geometry
  95473. * @param geometry the geometry from which to extract the VertexData
  95474. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95475. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95476. * @returns the object VertexData associated to the passed mesh
  95477. */
  95478. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95479. private static _ExtractFrom;
  95480. /**
  95481. * Creates the VertexData for a Ribbon
  95482. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95483. * * pathArray array of paths, each of which an array of successive Vector3
  95484. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95485. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95486. * * 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
  95487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95488. * * 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)
  95489. * * 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)
  95490. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95491. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95492. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95493. * @returns the VertexData of the ribbon
  95494. */
  95495. static CreateRibbon(options: {
  95496. pathArray: Vector3[][];
  95497. closeArray?: boolean;
  95498. closePath?: boolean;
  95499. offset?: number;
  95500. sideOrientation?: number;
  95501. frontUVs?: Vector4;
  95502. backUVs?: Vector4;
  95503. invertUV?: boolean;
  95504. uvs?: Vector2[];
  95505. colors?: Color4[];
  95506. }): VertexData;
  95507. /**
  95508. * Creates the VertexData for a box
  95509. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95510. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95511. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95512. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95513. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95514. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95515. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95517. * * 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)
  95518. * * 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)
  95519. * @returns the VertexData of the box
  95520. */
  95521. static CreateBox(options: {
  95522. size?: number;
  95523. width?: number;
  95524. height?: number;
  95525. depth?: number;
  95526. faceUV?: Vector4[];
  95527. faceColors?: Color4[];
  95528. sideOrientation?: number;
  95529. frontUVs?: Vector4;
  95530. backUVs?: Vector4;
  95531. }): VertexData;
  95532. /**
  95533. * Creates the VertexData for a tiled box
  95534. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95535. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95536. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95537. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95539. * @returns the VertexData of the box
  95540. */
  95541. static CreateTiledBox(options: {
  95542. pattern?: number;
  95543. width?: number;
  95544. height?: number;
  95545. depth?: number;
  95546. tileSize?: number;
  95547. tileWidth?: number;
  95548. tileHeight?: number;
  95549. alignHorizontal?: number;
  95550. alignVertical?: number;
  95551. faceUV?: Vector4[];
  95552. faceColors?: Color4[];
  95553. sideOrientation?: number;
  95554. }): VertexData;
  95555. /**
  95556. * Creates the VertexData for a tiled plane
  95557. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95558. * * pattern a limited pattern arrangement depending on the number
  95559. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95560. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95561. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95562. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95563. * * 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)
  95564. * * 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)
  95565. * @returns the VertexData of the tiled plane
  95566. */
  95567. static CreateTiledPlane(options: {
  95568. pattern?: number;
  95569. tileSize?: number;
  95570. tileWidth?: number;
  95571. tileHeight?: number;
  95572. size?: number;
  95573. width?: number;
  95574. height?: number;
  95575. alignHorizontal?: number;
  95576. alignVertical?: number;
  95577. sideOrientation?: number;
  95578. frontUVs?: Vector4;
  95579. backUVs?: Vector4;
  95580. }): VertexData;
  95581. /**
  95582. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95583. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95584. * * segments sets the number of horizontal strips optional, default 32
  95585. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95586. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95587. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95588. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95589. * * 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
  95590. * * 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
  95591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95592. * * 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)
  95593. * * 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)
  95594. * @returns the VertexData of the ellipsoid
  95595. */
  95596. static CreateSphere(options: {
  95597. segments?: number;
  95598. diameter?: number;
  95599. diameterX?: number;
  95600. diameterY?: number;
  95601. diameterZ?: number;
  95602. arc?: number;
  95603. slice?: number;
  95604. sideOrientation?: number;
  95605. frontUVs?: Vector4;
  95606. backUVs?: Vector4;
  95607. }): VertexData;
  95608. /**
  95609. * Creates the VertexData for a cylinder, cone or prism
  95610. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95611. * * height sets the height (y direction) of the cylinder, optional, default 2
  95612. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95613. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95614. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95615. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95616. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95617. * * 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
  95618. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95619. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95620. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95621. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95622. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95623. * * 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)
  95624. * * 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)
  95625. * @returns the VertexData of the cylinder, cone or prism
  95626. */
  95627. static CreateCylinder(options: {
  95628. height?: number;
  95629. diameterTop?: number;
  95630. diameterBottom?: number;
  95631. diameter?: number;
  95632. tessellation?: number;
  95633. subdivisions?: number;
  95634. arc?: number;
  95635. faceColors?: Color4[];
  95636. faceUV?: Vector4[];
  95637. hasRings?: boolean;
  95638. enclose?: boolean;
  95639. sideOrientation?: number;
  95640. frontUVs?: Vector4;
  95641. backUVs?: Vector4;
  95642. }): VertexData;
  95643. /**
  95644. * Creates the VertexData for a torus
  95645. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95646. * * diameter the diameter of the torus, optional default 1
  95647. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95648. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95650. * * 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)
  95651. * * 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)
  95652. * @returns the VertexData of the torus
  95653. */
  95654. static CreateTorus(options: {
  95655. diameter?: number;
  95656. thickness?: number;
  95657. tessellation?: number;
  95658. sideOrientation?: number;
  95659. frontUVs?: Vector4;
  95660. backUVs?: Vector4;
  95661. }): VertexData;
  95662. /**
  95663. * Creates the VertexData of the LineSystem
  95664. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95665. * - lines an array of lines, each line being an array of successive Vector3
  95666. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95667. * @returns the VertexData of the LineSystem
  95668. */
  95669. static CreateLineSystem(options: {
  95670. lines: Vector3[][];
  95671. colors?: Nullable<Color4[][]>;
  95672. }): VertexData;
  95673. /**
  95674. * Create the VertexData for a DashedLines
  95675. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95676. * - points an array successive Vector3
  95677. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95678. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95679. * - dashNb the intended total number of dashes, optional, default 200
  95680. * @returns the VertexData for the DashedLines
  95681. */
  95682. static CreateDashedLines(options: {
  95683. points: Vector3[];
  95684. dashSize?: number;
  95685. gapSize?: number;
  95686. dashNb?: number;
  95687. }): VertexData;
  95688. /**
  95689. * Creates the VertexData for a Ground
  95690. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95691. * - width the width (x direction) of the ground, optional, default 1
  95692. * - height the height (z direction) of the ground, optional, default 1
  95693. * - subdivisions the number of subdivisions per side, optional, default 1
  95694. * @returns the VertexData of the Ground
  95695. */
  95696. static CreateGround(options: {
  95697. width?: number;
  95698. height?: number;
  95699. subdivisions?: number;
  95700. subdivisionsX?: number;
  95701. subdivisionsY?: number;
  95702. }): VertexData;
  95703. /**
  95704. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95705. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95706. * * xmin the ground minimum X coordinate, optional, default -1
  95707. * * zmin the ground minimum Z coordinate, optional, default -1
  95708. * * xmax the ground maximum X coordinate, optional, default 1
  95709. * * zmax the ground maximum Z coordinate, optional, default 1
  95710. * * 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}
  95711. * * 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}
  95712. * @returns the VertexData of the TiledGround
  95713. */
  95714. static CreateTiledGround(options: {
  95715. xmin: number;
  95716. zmin: number;
  95717. xmax: number;
  95718. zmax: number;
  95719. subdivisions?: {
  95720. w: number;
  95721. h: number;
  95722. };
  95723. precision?: {
  95724. w: number;
  95725. h: number;
  95726. };
  95727. }): VertexData;
  95728. /**
  95729. * Creates the VertexData of the Ground designed from a heightmap
  95730. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95731. * * width the width (x direction) of the ground
  95732. * * height the height (z direction) of the ground
  95733. * * subdivisions the number of subdivisions per side
  95734. * * minHeight the minimum altitude on the ground, optional, default 0
  95735. * * maxHeight the maximum altitude on the ground, optional default 1
  95736. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95737. * * buffer the array holding the image color data
  95738. * * bufferWidth the width of image
  95739. * * bufferHeight the height of image
  95740. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95741. * @returns the VertexData of the Ground designed from a heightmap
  95742. */
  95743. static CreateGroundFromHeightMap(options: {
  95744. width: number;
  95745. height: number;
  95746. subdivisions: number;
  95747. minHeight: number;
  95748. maxHeight: number;
  95749. colorFilter: Color3;
  95750. buffer: Uint8Array;
  95751. bufferWidth: number;
  95752. bufferHeight: number;
  95753. alphaFilter: number;
  95754. }): VertexData;
  95755. /**
  95756. * Creates the VertexData for a Plane
  95757. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95758. * * size sets the width and height of the plane to the value of size, optional default 1
  95759. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95760. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95762. * * 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)
  95763. * * 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)
  95764. * @returns the VertexData of the box
  95765. */
  95766. static CreatePlane(options: {
  95767. size?: number;
  95768. width?: number;
  95769. height?: number;
  95770. sideOrientation?: number;
  95771. frontUVs?: Vector4;
  95772. backUVs?: Vector4;
  95773. }): VertexData;
  95774. /**
  95775. * Creates the VertexData of the Disc or regular Polygon
  95776. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95777. * * radius the radius of the disc, optional default 0.5
  95778. * * tessellation the number of polygon sides, optional, default 64
  95779. * * 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
  95780. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95781. * * 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)
  95782. * * 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)
  95783. * @returns the VertexData of the box
  95784. */
  95785. static CreateDisc(options: {
  95786. radius?: number;
  95787. tessellation?: number;
  95788. arc?: number;
  95789. sideOrientation?: number;
  95790. frontUVs?: Vector4;
  95791. backUVs?: Vector4;
  95792. }): VertexData;
  95793. /**
  95794. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95795. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95796. * @param polygon a mesh built from polygonTriangulation.build()
  95797. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95798. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95799. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95800. * @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)
  95801. * @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)
  95802. * @returns the VertexData of the Polygon
  95803. */
  95804. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95805. /**
  95806. * Creates the VertexData of the IcoSphere
  95807. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95808. * * radius the radius of the IcoSphere, optional default 1
  95809. * * radiusX allows stretching in the x direction, optional, default radius
  95810. * * radiusY allows stretching in the y direction, optional, default radius
  95811. * * radiusZ allows stretching in the z direction, optional, default radius
  95812. * * flat when true creates a flat shaded mesh, optional, default true
  95813. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95815. * * 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)
  95816. * * 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)
  95817. * @returns the VertexData of the IcoSphere
  95818. */
  95819. static CreateIcoSphere(options: {
  95820. radius?: number;
  95821. radiusX?: number;
  95822. radiusY?: number;
  95823. radiusZ?: number;
  95824. flat?: boolean;
  95825. subdivisions?: number;
  95826. sideOrientation?: number;
  95827. frontUVs?: Vector4;
  95828. backUVs?: Vector4;
  95829. }): VertexData;
  95830. /**
  95831. * Creates the VertexData for a Polyhedron
  95832. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95833. * * type provided types are:
  95834. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95835. * * 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)
  95836. * * size the size of the IcoSphere, optional default 1
  95837. * * sizeX allows stretching in the x direction, optional, default size
  95838. * * sizeY allows stretching in the y direction, optional, default size
  95839. * * sizeZ allows stretching in the z direction, optional, default size
  95840. * * 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
  95841. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95842. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95843. * * flat when true creates a flat shaded mesh, optional, default true
  95844. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95846. * * 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)
  95847. * * 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)
  95848. * @returns the VertexData of the Polyhedron
  95849. */
  95850. static CreatePolyhedron(options: {
  95851. type?: number;
  95852. size?: number;
  95853. sizeX?: number;
  95854. sizeY?: number;
  95855. sizeZ?: number;
  95856. custom?: any;
  95857. faceUV?: Vector4[];
  95858. faceColors?: Color4[];
  95859. flat?: boolean;
  95860. sideOrientation?: number;
  95861. frontUVs?: Vector4;
  95862. backUVs?: Vector4;
  95863. }): VertexData;
  95864. /**
  95865. * Creates the VertexData for a TorusKnot
  95866. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95867. * * radius the radius of the torus knot, optional, default 2
  95868. * * tube the thickness of the tube, optional, default 0.5
  95869. * * radialSegments the number of sides on each tube segments, optional, default 32
  95870. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95871. * * p the number of windings around the z axis, optional, default 2
  95872. * * q the number of windings around the x axis, optional, default 3
  95873. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95874. * * 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)
  95875. * * 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)
  95876. * @returns the VertexData of the Torus Knot
  95877. */
  95878. static CreateTorusKnot(options: {
  95879. radius?: number;
  95880. tube?: number;
  95881. radialSegments?: number;
  95882. tubularSegments?: number;
  95883. p?: number;
  95884. q?: number;
  95885. sideOrientation?: number;
  95886. frontUVs?: Vector4;
  95887. backUVs?: Vector4;
  95888. }): VertexData;
  95889. /**
  95890. * Compute normals for given positions and indices
  95891. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95892. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95893. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95894. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95895. * * facetNormals : optional array of facet normals (vector3)
  95896. * * facetPositions : optional array of facet positions (vector3)
  95897. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95898. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95899. * * bInfo : optional bounding info, required for facetPartitioning computation
  95900. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95901. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95902. * * useRightHandedSystem: optional boolean to for right handed system computation
  95903. * * depthSort : optional boolean to enable the facet depth sort computation
  95904. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95905. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95906. */
  95907. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95908. facetNormals?: any;
  95909. facetPositions?: any;
  95910. facetPartitioning?: any;
  95911. ratio?: number;
  95912. bInfo?: any;
  95913. bbSize?: Vector3;
  95914. subDiv?: any;
  95915. useRightHandedSystem?: boolean;
  95916. depthSort?: boolean;
  95917. distanceTo?: Vector3;
  95918. depthSortedFacets?: any;
  95919. }): void;
  95920. /** @hidden */
  95921. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95922. /**
  95923. * Applies VertexData created from the imported parameters to the geometry
  95924. * @param parsedVertexData the parsed data from an imported file
  95925. * @param geometry the geometry to apply the VertexData to
  95926. */
  95927. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95928. }
  95929. }
  95930. declare module BABYLON {
  95931. /**
  95932. * Defines a target to use with MorphTargetManager
  95933. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95934. */
  95935. export class MorphTarget implements IAnimatable {
  95936. /** defines the name of the target */
  95937. name: string;
  95938. /**
  95939. * Gets or sets the list of animations
  95940. */
  95941. animations: Animation[];
  95942. private _scene;
  95943. private _positions;
  95944. private _normals;
  95945. private _tangents;
  95946. private _uvs;
  95947. private _influence;
  95948. private _uniqueId;
  95949. /**
  95950. * Observable raised when the influence changes
  95951. */
  95952. onInfluenceChanged: Observable<boolean>;
  95953. /** @hidden */
  95954. _onDataLayoutChanged: Observable<void>;
  95955. /**
  95956. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95957. */
  95958. get influence(): number;
  95959. set influence(influence: number);
  95960. /**
  95961. * Gets or sets the id of the morph Target
  95962. */
  95963. id: string;
  95964. private _animationPropertiesOverride;
  95965. /**
  95966. * Gets or sets the animation properties override
  95967. */
  95968. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95969. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95970. /**
  95971. * Creates a new MorphTarget
  95972. * @param name defines the name of the target
  95973. * @param influence defines the influence to use
  95974. * @param scene defines the scene the morphtarget belongs to
  95975. */
  95976. constructor(
  95977. /** defines the name of the target */
  95978. name: string, influence?: number, scene?: Nullable<Scene>);
  95979. /**
  95980. * Gets the unique ID of this manager
  95981. */
  95982. get uniqueId(): number;
  95983. /**
  95984. * Gets a boolean defining if the target contains position data
  95985. */
  95986. get hasPositions(): boolean;
  95987. /**
  95988. * Gets a boolean defining if the target contains normal data
  95989. */
  95990. get hasNormals(): boolean;
  95991. /**
  95992. * Gets a boolean defining if the target contains tangent data
  95993. */
  95994. get hasTangents(): boolean;
  95995. /**
  95996. * Gets a boolean defining if the target contains texture coordinates data
  95997. */
  95998. get hasUVs(): boolean;
  95999. /**
  96000. * Affects position data to this target
  96001. * @param data defines the position data to use
  96002. */
  96003. setPositions(data: Nullable<FloatArray>): void;
  96004. /**
  96005. * Gets the position data stored in this target
  96006. * @returns a FloatArray containing the position data (or null if not present)
  96007. */
  96008. getPositions(): Nullable<FloatArray>;
  96009. /**
  96010. * Affects normal data to this target
  96011. * @param data defines the normal data to use
  96012. */
  96013. setNormals(data: Nullable<FloatArray>): void;
  96014. /**
  96015. * Gets the normal data stored in this target
  96016. * @returns a FloatArray containing the normal data (or null if not present)
  96017. */
  96018. getNormals(): Nullable<FloatArray>;
  96019. /**
  96020. * Affects tangent data to this target
  96021. * @param data defines the tangent data to use
  96022. */
  96023. setTangents(data: Nullable<FloatArray>): void;
  96024. /**
  96025. * Gets the tangent data stored in this target
  96026. * @returns a FloatArray containing the tangent data (or null if not present)
  96027. */
  96028. getTangents(): Nullable<FloatArray>;
  96029. /**
  96030. * Affects texture coordinates data to this target
  96031. * @param data defines the texture coordinates data to use
  96032. */
  96033. setUVs(data: Nullable<FloatArray>): void;
  96034. /**
  96035. * Gets the texture coordinates data stored in this target
  96036. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96037. */
  96038. getUVs(): Nullable<FloatArray>;
  96039. /**
  96040. * Clone the current target
  96041. * @returns a new MorphTarget
  96042. */
  96043. clone(): MorphTarget;
  96044. /**
  96045. * Serializes the current target into a Serialization object
  96046. * @returns the serialized object
  96047. */
  96048. serialize(): any;
  96049. /**
  96050. * Returns the string "MorphTarget"
  96051. * @returns "MorphTarget"
  96052. */
  96053. getClassName(): string;
  96054. /**
  96055. * Creates a new target from serialized data
  96056. * @param serializationObject defines the serialized data to use
  96057. * @returns a new MorphTarget
  96058. */
  96059. static Parse(serializationObject: any): MorphTarget;
  96060. /**
  96061. * Creates a MorphTarget from mesh data
  96062. * @param mesh defines the source mesh
  96063. * @param name defines the name to use for the new target
  96064. * @param influence defines the influence to attach to the target
  96065. * @returns a new MorphTarget
  96066. */
  96067. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96068. }
  96069. }
  96070. declare module BABYLON {
  96071. /**
  96072. * This class is used to deform meshes using morphing between different targets
  96073. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96074. */
  96075. export class MorphTargetManager {
  96076. private _targets;
  96077. private _targetInfluenceChangedObservers;
  96078. private _targetDataLayoutChangedObservers;
  96079. private _activeTargets;
  96080. private _scene;
  96081. private _influences;
  96082. private _supportsNormals;
  96083. private _supportsTangents;
  96084. private _supportsUVs;
  96085. private _vertexCount;
  96086. private _uniqueId;
  96087. private _tempInfluences;
  96088. /**
  96089. * Gets or sets a boolean indicating if normals must be morphed
  96090. */
  96091. enableNormalMorphing: boolean;
  96092. /**
  96093. * Gets or sets a boolean indicating if tangents must be morphed
  96094. */
  96095. enableTangentMorphing: boolean;
  96096. /**
  96097. * Gets or sets a boolean indicating if UV must be morphed
  96098. */
  96099. enableUVMorphing: boolean;
  96100. /**
  96101. * Creates a new MorphTargetManager
  96102. * @param scene defines the current scene
  96103. */
  96104. constructor(scene?: Nullable<Scene>);
  96105. /**
  96106. * Gets the unique ID of this manager
  96107. */
  96108. get uniqueId(): number;
  96109. /**
  96110. * Gets the number of vertices handled by this manager
  96111. */
  96112. get vertexCount(): number;
  96113. /**
  96114. * Gets a boolean indicating if this manager supports morphing of normals
  96115. */
  96116. get supportsNormals(): boolean;
  96117. /**
  96118. * Gets a boolean indicating if this manager supports morphing of tangents
  96119. */
  96120. get supportsTangents(): boolean;
  96121. /**
  96122. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96123. */
  96124. get supportsUVs(): boolean;
  96125. /**
  96126. * Gets the number of targets stored in this manager
  96127. */
  96128. get numTargets(): number;
  96129. /**
  96130. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96131. */
  96132. get numInfluencers(): number;
  96133. /**
  96134. * Gets the list of influences (one per target)
  96135. */
  96136. get influences(): Float32Array;
  96137. /**
  96138. * Gets the active target at specified index. An active target is a target with an influence > 0
  96139. * @param index defines the index to check
  96140. * @returns the requested target
  96141. */
  96142. getActiveTarget(index: number): MorphTarget;
  96143. /**
  96144. * Gets the target at specified index
  96145. * @param index defines the index to check
  96146. * @returns the requested target
  96147. */
  96148. getTarget(index: number): MorphTarget;
  96149. /**
  96150. * Add a new target to this manager
  96151. * @param target defines the target to add
  96152. */
  96153. addTarget(target: MorphTarget): void;
  96154. /**
  96155. * Removes a target from the manager
  96156. * @param target defines the target to remove
  96157. */
  96158. removeTarget(target: MorphTarget): void;
  96159. /**
  96160. * Clone the current manager
  96161. * @returns a new MorphTargetManager
  96162. */
  96163. clone(): MorphTargetManager;
  96164. /**
  96165. * Serializes the current manager into a Serialization object
  96166. * @returns the serialized object
  96167. */
  96168. serialize(): any;
  96169. private _syncActiveTargets;
  96170. /**
  96171. * Syncrhonize the targets with all the meshes using this morph target manager
  96172. */
  96173. synchronize(): void;
  96174. /**
  96175. * Creates a new MorphTargetManager from serialized data
  96176. * @param serializationObject defines the serialized data
  96177. * @param scene defines the hosting scene
  96178. * @returns the new MorphTargetManager
  96179. */
  96180. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96181. }
  96182. }
  96183. declare module BABYLON {
  96184. /**
  96185. * Class used to represent a specific level of detail of a mesh
  96186. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96187. */
  96188. export class MeshLODLevel {
  96189. /** Defines the distance where this level should start being displayed */
  96190. distance: number;
  96191. /** Defines the mesh to use to render this level */
  96192. mesh: Nullable<Mesh>;
  96193. /**
  96194. * Creates a new LOD level
  96195. * @param distance defines the distance where this level should star being displayed
  96196. * @param mesh defines the mesh to use to render this level
  96197. */
  96198. constructor(
  96199. /** Defines the distance where this level should start being displayed */
  96200. distance: number,
  96201. /** Defines the mesh to use to render this level */
  96202. mesh: Nullable<Mesh>);
  96203. }
  96204. }
  96205. declare module BABYLON {
  96206. /**
  96207. * Mesh representing the gorund
  96208. */
  96209. export class GroundMesh extends Mesh {
  96210. /** If octree should be generated */
  96211. generateOctree: boolean;
  96212. private _heightQuads;
  96213. /** @hidden */
  96214. _subdivisionsX: number;
  96215. /** @hidden */
  96216. _subdivisionsY: number;
  96217. /** @hidden */
  96218. _width: number;
  96219. /** @hidden */
  96220. _height: number;
  96221. /** @hidden */
  96222. _minX: number;
  96223. /** @hidden */
  96224. _maxX: number;
  96225. /** @hidden */
  96226. _minZ: number;
  96227. /** @hidden */
  96228. _maxZ: number;
  96229. constructor(name: string, scene: Scene);
  96230. /**
  96231. * "GroundMesh"
  96232. * @returns "GroundMesh"
  96233. */
  96234. getClassName(): string;
  96235. /**
  96236. * The minimum of x and y subdivisions
  96237. */
  96238. get subdivisions(): number;
  96239. /**
  96240. * X subdivisions
  96241. */
  96242. get subdivisionsX(): number;
  96243. /**
  96244. * Y subdivisions
  96245. */
  96246. get subdivisionsY(): number;
  96247. /**
  96248. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96249. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96250. * @param chunksCount the number of subdivisions for x and y
  96251. * @param octreeBlocksSize (Default: 32)
  96252. */
  96253. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96254. /**
  96255. * Returns a height (y) value in the Worl system :
  96256. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96257. * @param x x coordinate
  96258. * @param z z coordinate
  96259. * @returns the ground y position if (x, z) are outside the ground surface.
  96260. */
  96261. getHeightAtCoordinates(x: number, z: number): number;
  96262. /**
  96263. * Returns a normalized vector (Vector3) orthogonal to the ground
  96264. * at the ground coordinates (x, z) expressed in the World system.
  96265. * @param x x coordinate
  96266. * @param z z coordinate
  96267. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96268. */
  96269. getNormalAtCoordinates(x: number, z: number): Vector3;
  96270. /**
  96271. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96272. * at the ground coordinates (x, z) expressed in the World system.
  96273. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96274. * @param x x coordinate
  96275. * @param z z coordinate
  96276. * @param ref vector to store the result
  96277. * @returns the GroundMesh.
  96278. */
  96279. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96280. /**
  96281. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96282. * if the ground has been updated.
  96283. * This can be used in the render loop.
  96284. * @returns the GroundMesh.
  96285. */
  96286. updateCoordinateHeights(): GroundMesh;
  96287. private _getFacetAt;
  96288. private _initHeightQuads;
  96289. private _computeHeightQuads;
  96290. /**
  96291. * Serializes this ground mesh
  96292. * @param serializationObject object to write serialization to
  96293. */
  96294. serialize(serializationObject: any): void;
  96295. /**
  96296. * Parses a serialized ground mesh
  96297. * @param parsedMesh the serialized mesh
  96298. * @param scene the scene to create the ground mesh in
  96299. * @returns the created ground mesh
  96300. */
  96301. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96302. }
  96303. }
  96304. declare module BABYLON {
  96305. /**
  96306. * Interface for Physics-Joint data
  96307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96308. */
  96309. export interface PhysicsJointData {
  96310. /**
  96311. * The main pivot of the joint
  96312. */
  96313. mainPivot?: Vector3;
  96314. /**
  96315. * The connected pivot of the joint
  96316. */
  96317. connectedPivot?: Vector3;
  96318. /**
  96319. * The main axis of the joint
  96320. */
  96321. mainAxis?: Vector3;
  96322. /**
  96323. * The connected axis of the joint
  96324. */
  96325. connectedAxis?: Vector3;
  96326. /**
  96327. * The collision of the joint
  96328. */
  96329. collision?: boolean;
  96330. /**
  96331. * Native Oimo/Cannon/Energy data
  96332. */
  96333. nativeParams?: any;
  96334. }
  96335. /**
  96336. * This is a holder class for the physics joint created by the physics plugin
  96337. * It holds a set of functions to control the underlying joint
  96338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96339. */
  96340. export class PhysicsJoint {
  96341. /**
  96342. * The type of the physics joint
  96343. */
  96344. type: number;
  96345. /**
  96346. * The data for the physics joint
  96347. */
  96348. jointData: PhysicsJointData;
  96349. private _physicsJoint;
  96350. protected _physicsPlugin: IPhysicsEnginePlugin;
  96351. /**
  96352. * Initializes the physics joint
  96353. * @param type The type of the physics joint
  96354. * @param jointData The data for the physics joint
  96355. */
  96356. constructor(
  96357. /**
  96358. * The type of the physics joint
  96359. */
  96360. type: number,
  96361. /**
  96362. * The data for the physics joint
  96363. */
  96364. jointData: PhysicsJointData);
  96365. /**
  96366. * Gets the physics joint
  96367. */
  96368. get physicsJoint(): any;
  96369. /**
  96370. * Sets the physics joint
  96371. */
  96372. set physicsJoint(newJoint: any);
  96373. /**
  96374. * Sets the physics plugin
  96375. */
  96376. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96377. /**
  96378. * Execute a function that is physics-plugin specific.
  96379. * @param {Function} func the function that will be executed.
  96380. * It accepts two parameters: the physics world and the physics joint
  96381. */
  96382. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96383. /**
  96384. * Distance-Joint type
  96385. */
  96386. static DistanceJoint: number;
  96387. /**
  96388. * Hinge-Joint type
  96389. */
  96390. static HingeJoint: number;
  96391. /**
  96392. * Ball-and-Socket joint type
  96393. */
  96394. static BallAndSocketJoint: number;
  96395. /**
  96396. * Wheel-Joint type
  96397. */
  96398. static WheelJoint: number;
  96399. /**
  96400. * Slider-Joint type
  96401. */
  96402. static SliderJoint: number;
  96403. /**
  96404. * Prismatic-Joint type
  96405. */
  96406. static PrismaticJoint: number;
  96407. /**
  96408. * Universal-Joint type
  96409. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96410. */
  96411. static UniversalJoint: number;
  96412. /**
  96413. * Hinge-Joint 2 type
  96414. */
  96415. static Hinge2Joint: number;
  96416. /**
  96417. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96418. */
  96419. static PointToPointJoint: number;
  96420. /**
  96421. * Spring-Joint type
  96422. */
  96423. static SpringJoint: number;
  96424. /**
  96425. * Lock-Joint type
  96426. */
  96427. static LockJoint: number;
  96428. }
  96429. /**
  96430. * A class representing a physics distance joint
  96431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96432. */
  96433. export class DistanceJoint extends PhysicsJoint {
  96434. /**
  96435. *
  96436. * @param jointData The data for the Distance-Joint
  96437. */
  96438. constructor(jointData: DistanceJointData);
  96439. /**
  96440. * Update the predefined distance.
  96441. * @param maxDistance The maximum preferred distance
  96442. * @param minDistance The minimum preferred distance
  96443. */
  96444. updateDistance(maxDistance: number, minDistance?: number): void;
  96445. }
  96446. /**
  96447. * Represents a Motor-Enabled Joint
  96448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96449. */
  96450. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96451. /**
  96452. * Initializes the Motor-Enabled Joint
  96453. * @param type The type of the joint
  96454. * @param jointData The physica joint data for the joint
  96455. */
  96456. constructor(type: number, jointData: PhysicsJointData);
  96457. /**
  96458. * Set the motor values.
  96459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96460. * @param force the force to apply
  96461. * @param maxForce max force for this motor.
  96462. */
  96463. setMotor(force?: number, maxForce?: number): void;
  96464. /**
  96465. * Set the motor's limits.
  96466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96467. * @param upperLimit The upper limit of the motor
  96468. * @param lowerLimit The lower limit of the motor
  96469. */
  96470. setLimit(upperLimit: number, lowerLimit?: number): void;
  96471. }
  96472. /**
  96473. * This class represents a single physics Hinge-Joint
  96474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96475. */
  96476. export class HingeJoint extends MotorEnabledJoint {
  96477. /**
  96478. * Initializes the Hinge-Joint
  96479. * @param jointData The joint data for the Hinge-Joint
  96480. */
  96481. constructor(jointData: PhysicsJointData);
  96482. /**
  96483. * Set the motor values.
  96484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96485. * @param {number} force the force to apply
  96486. * @param {number} maxForce max force for this motor.
  96487. */
  96488. setMotor(force?: number, maxForce?: number): void;
  96489. /**
  96490. * Set the motor's limits.
  96491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96492. * @param upperLimit The upper limit of the motor
  96493. * @param lowerLimit The lower limit of the motor
  96494. */
  96495. setLimit(upperLimit: number, lowerLimit?: number): void;
  96496. }
  96497. /**
  96498. * This class represents a dual hinge physics joint (same as wheel joint)
  96499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96500. */
  96501. export class Hinge2Joint extends MotorEnabledJoint {
  96502. /**
  96503. * Initializes the Hinge2-Joint
  96504. * @param jointData The joint data for the Hinge2-Joint
  96505. */
  96506. constructor(jointData: PhysicsJointData);
  96507. /**
  96508. * Set the motor values.
  96509. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96510. * @param {number} targetSpeed the speed the motor is to reach
  96511. * @param {number} maxForce max force for this motor.
  96512. * @param {motorIndex} the motor's index, 0 or 1.
  96513. */
  96514. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96515. /**
  96516. * Set the motor limits.
  96517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96518. * @param {number} upperLimit the upper limit
  96519. * @param {number} lowerLimit lower limit
  96520. * @param {motorIndex} the motor's index, 0 or 1.
  96521. */
  96522. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96523. }
  96524. /**
  96525. * Interface for a motor enabled joint
  96526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96527. */
  96528. export interface IMotorEnabledJoint {
  96529. /**
  96530. * Physics joint
  96531. */
  96532. physicsJoint: any;
  96533. /**
  96534. * Sets the motor of the motor-enabled joint
  96535. * @param force The force of the motor
  96536. * @param maxForce The maximum force of the motor
  96537. * @param motorIndex The index of the motor
  96538. */
  96539. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96540. /**
  96541. * Sets the limit of the motor
  96542. * @param upperLimit The upper limit of the motor
  96543. * @param lowerLimit The lower limit of the motor
  96544. * @param motorIndex The index of the motor
  96545. */
  96546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96547. }
  96548. /**
  96549. * Joint data for a Distance-Joint
  96550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96551. */
  96552. export interface DistanceJointData extends PhysicsJointData {
  96553. /**
  96554. * Max distance the 2 joint objects can be apart
  96555. */
  96556. maxDistance: number;
  96557. }
  96558. /**
  96559. * Joint data from a spring joint
  96560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96561. */
  96562. export interface SpringJointData extends PhysicsJointData {
  96563. /**
  96564. * Length of the spring
  96565. */
  96566. length: number;
  96567. /**
  96568. * Stiffness of the spring
  96569. */
  96570. stiffness: number;
  96571. /**
  96572. * Damping of the spring
  96573. */
  96574. damping: number;
  96575. /** this callback will be called when applying the force to the impostors. */
  96576. forceApplicationCallback: () => void;
  96577. }
  96578. }
  96579. declare module BABYLON {
  96580. /**
  96581. * Holds the data for the raycast result
  96582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96583. */
  96584. export class PhysicsRaycastResult {
  96585. private _hasHit;
  96586. private _hitDistance;
  96587. private _hitNormalWorld;
  96588. private _hitPointWorld;
  96589. private _rayFromWorld;
  96590. private _rayToWorld;
  96591. /**
  96592. * Gets if there was a hit
  96593. */
  96594. get hasHit(): boolean;
  96595. /**
  96596. * Gets the distance from the hit
  96597. */
  96598. get hitDistance(): number;
  96599. /**
  96600. * Gets the hit normal/direction in the world
  96601. */
  96602. get hitNormalWorld(): Vector3;
  96603. /**
  96604. * Gets the hit point in the world
  96605. */
  96606. get hitPointWorld(): Vector3;
  96607. /**
  96608. * Gets the ray "start point" of the ray in the world
  96609. */
  96610. get rayFromWorld(): Vector3;
  96611. /**
  96612. * Gets the ray "end point" of the ray in the world
  96613. */
  96614. get rayToWorld(): Vector3;
  96615. /**
  96616. * Sets the hit data (normal & point in world space)
  96617. * @param hitNormalWorld defines the normal in world space
  96618. * @param hitPointWorld defines the point in world space
  96619. */
  96620. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96621. /**
  96622. * Sets the distance from the start point to the hit point
  96623. * @param distance
  96624. */
  96625. setHitDistance(distance: number): void;
  96626. /**
  96627. * Calculates the distance manually
  96628. */
  96629. calculateHitDistance(): void;
  96630. /**
  96631. * Resets all the values to default
  96632. * @param from The from point on world space
  96633. * @param to The to point on world space
  96634. */
  96635. reset(from?: Vector3, to?: Vector3): void;
  96636. }
  96637. /**
  96638. * Interface for the size containing width and height
  96639. */
  96640. interface IXYZ {
  96641. /**
  96642. * X
  96643. */
  96644. x: number;
  96645. /**
  96646. * Y
  96647. */
  96648. y: number;
  96649. /**
  96650. * Z
  96651. */
  96652. z: number;
  96653. }
  96654. }
  96655. declare module BABYLON {
  96656. /**
  96657. * Interface used to describe a physics joint
  96658. */
  96659. export interface PhysicsImpostorJoint {
  96660. /** Defines the main impostor to which the joint is linked */
  96661. mainImpostor: PhysicsImpostor;
  96662. /** Defines the impostor that is connected to the main impostor using this joint */
  96663. connectedImpostor: PhysicsImpostor;
  96664. /** Defines the joint itself */
  96665. joint: PhysicsJoint;
  96666. }
  96667. /** @hidden */
  96668. export interface IPhysicsEnginePlugin {
  96669. world: any;
  96670. name: string;
  96671. setGravity(gravity: Vector3): void;
  96672. setTimeStep(timeStep: number): void;
  96673. getTimeStep(): number;
  96674. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96675. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96676. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96677. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96678. removePhysicsBody(impostor: PhysicsImpostor): void;
  96679. generateJoint(joint: PhysicsImpostorJoint): void;
  96680. removeJoint(joint: PhysicsImpostorJoint): void;
  96681. isSupported(): boolean;
  96682. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96683. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96684. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96685. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96687. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96688. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96689. getBodyMass(impostor: PhysicsImpostor): number;
  96690. getBodyFriction(impostor: PhysicsImpostor): number;
  96691. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96692. getBodyRestitution(impostor: PhysicsImpostor): number;
  96693. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96694. getBodyPressure?(impostor: PhysicsImpostor): number;
  96695. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96696. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96697. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96698. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96699. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96700. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96701. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96702. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96703. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96704. sleepBody(impostor: PhysicsImpostor): void;
  96705. wakeUpBody(impostor: PhysicsImpostor): void;
  96706. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96707. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96708. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96709. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96710. getRadius(impostor: PhysicsImpostor): number;
  96711. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96712. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96713. dispose(): void;
  96714. }
  96715. /**
  96716. * Interface used to define a physics engine
  96717. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96718. */
  96719. export interface IPhysicsEngine {
  96720. /**
  96721. * Gets the gravity vector used by the simulation
  96722. */
  96723. gravity: Vector3;
  96724. /**
  96725. * Sets the gravity vector used by the simulation
  96726. * @param gravity defines the gravity vector to use
  96727. */
  96728. setGravity(gravity: Vector3): void;
  96729. /**
  96730. * Set the time step of the physics engine.
  96731. * Default is 1/60.
  96732. * To slow it down, enter 1/600 for example.
  96733. * To speed it up, 1/30
  96734. * @param newTimeStep the new timestep to apply to this world.
  96735. */
  96736. setTimeStep(newTimeStep: number): void;
  96737. /**
  96738. * Get the time step of the physics engine.
  96739. * @returns the current time step
  96740. */
  96741. getTimeStep(): number;
  96742. /**
  96743. * Set the sub time step of the physics engine.
  96744. * Default is 0 meaning there is no sub steps
  96745. * To increase physics resolution precision, set a small value (like 1 ms)
  96746. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96747. */
  96748. setSubTimeStep(subTimeStep: number): void;
  96749. /**
  96750. * Get the sub time step of the physics engine.
  96751. * @returns the current sub time step
  96752. */
  96753. getSubTimeStep(): number;
  96754. /**
  96755. * Release all resources
  96756. */
  96757. dispose(): void;
  96758. /**
  96759. * Gets the name of the current physics plugin
  96760. * @returns the name of the plugin
  96761. */
  96762. getPhysicsPluginName(): string;
  96763. /**
  96764. * Adding a new impostor for the impostor tracking.
  96765. * This will be done by the impostor itself.
  96766. * @param impostor the impostor to add
  96767. */
  96768. addImpostor(impostor: PhysicsImpostor): void;
  96769. /**
  96770. * Remove an impostor from the engine.
  96771. * This impostor and its mesh will not longer be updated by the physics engine.
  96772. * @param impostor the impostor to remove
  96773. */
  96774. removeImpostor(impostor: PhysicsImpostor): void;
  96775. /**
  96776. * Add a joint to the physics engine
  96777. * @param mainImpostor defines the main impostor to which the joint is added.
  96778. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96779. * @param joint defines the joint that will connect both impostors.
  96780. */
  96781. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96782. /**
  96783. * Removes a joint from the simulation
  96784. * @param mainImpostor defines the impostor used with the joint
  96785. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96786. * @param joint defines the joint to remove
  96787. */
  96788. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96789. /**
  96790. * Gets the current plugin used to run the simulation
  96791. * @returns current plugin
  96792. */
  96793. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96794. /**
  96795. * Gets the list of physic impostors
  96796. * @returns an array of PhysicsImpostor
  96797. */
  96798. getImpostors(): Array<PhysicsImpostor>;
  96799. /**
  96800. * Gets the impostor for a physics enabled object
  96801. * @param object defines the object impersonated by the impostor
  96802. * @returns the PhysicsImpostor or null if not found
  96803. */
  96804. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96805. /**
  96806. * Gets the impostor for a physics body object
  96807. * @param body defines physics body used by the impostor
  96808. * @returns the PhysicsImpostor or null if not found
  96809. */
  96810. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96811. /**
  96812. * Does a raycast in the physics world
  96813. * @param from when should the ray start?
  96814. * @param to when should the ray end?
  96815. * @returns PhysicsRaycastResult
  96816. */
  96817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96818. /**
  96819. * Called by the scene. No need to call it.
  96820. * @param delta defines the timespam between frames
  96821. */
  96822. _step(delta: number): void;
  96823. }
  96824. }
  96825. declare module BABYLON {
  96826. /**
  96827. * The interface for the physics imposter parameters
  96828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96829. */
  96830. export interface PhysicsImpostorParameters {
  96831. /**
  96832. * The mass of the physics imposter
  96833. */
  96834. mass: number;
  96835. /**
  96836. * The friction of the physics imposter
  96837. */
  96838. friction?: number;
  96839. /**
  96840. * The coefficient of restitution of the physics imposter
  96841. */
  96842. restitution?: number;
  96843. /**
  96844. * The native options of the physics imposter
  96845. */
  96846. nativeOptions?: any;
  96847. /**
  96848. * Specifies if the parent should be ignored
  96849. */
  96850. ignoreParent?: boolean;
  96851. /**
  96852. * Specifies if bi-directional transformations should be disabled
  96853. */
  96854. disableBidirectionalTransformation?: boolean;
  96855. /**
  96856. * The pressure inside the physics imposter, soft object only
  96857. */
  96858. pressure?: number;
  96859. /**
  96860. * The stiffness the physics imposter, soft object only
  96861. */
  96862. stiffness?: number;
  96863. /**
  96864. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96865. */
  96866. velocityIterations?: number;
  96867. /**
  96868. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96869. */
  96870. positionIterations?: number;
  96871. /**
  96872. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96873. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96874. * Add to fix multiple points
  96875. */
  96876. fixedPoints?: number;
  96877. /**
  96878. * The collision margin around a soft object
  96879. */
  96880. margin?: number;
  96881. /**
  96882. * The collision margin around a soft object
  96883. */
  96884. damping?: number;
  96885. /**
  96886. * The path for a rope based on an extrusion
  96887. */
  96888. path?: any;
  96889. /**
  96890. * The shape of an extrusion used for a rope based on an extrusion
  96891. */
  96892. shape?: any;
  96893. }
  96894. /**
  96895. * Interface for a physics-enabled object
  96896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96897. */
  96898. export interface IPhysicsEnabledObject {
  96899. /**
  96900. * The position of the physics-enabled object
  96901. */
  96902. position: Vector3;
  96903. /**
  96904. * The rotation of the physics-enabled object
  96905. */
  96906. rotationQuaternion: Nullable<Quaternion>;
  96907. /**
  96908. * The scale of the physics-enabled object
  96909. */
  96910. scaling: Vector3;
  96911. /**
  96912. * The rotation of the physics-enabled object
  96913. */
  96914. rotation?: Vector3;
  96915. /**
  96916. * The parent of the physics-enabled object
  96917. */
  96918. parent?: any;
  96919. /**
  96920. * The bounding info of the physics-enabled object
  96921. * @returns The bounding info of the physics-enabled object
  96922. */
  96923. getBoundingInfo(): BoundingInfo;
  96924. /**
  96925. * Computes the world matrix
  96926. * @param force Specifies if the world matrix should be computed by force
  96927. * @returns A world matrix
  96928. */
  96929. computeWorldMatrix(force: boolean): Matrix;
  96930. /**
  96931. * Gets the world matrix
  96932. * @returns A world matrix
  96933. */
  96934. getWorldMatrix?(): Matrix;
  96935. /**
  96936. * Gets the child meshes
  96937. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96938. * @returns An array of abstract meshes
  96939. */
  96940. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96941. /**
  96942. * Gets the vertex data
  96943. * @param kind The type of vertex data
  96944. * @returns A nullable array of numbers, or a float32 array
  96945. */
  96946. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96947. /**
  96948. * Gets the indices from the mesh
  96949. * @returns A nullable array of index arrays
  96950. */
  96951. getIndices?(): Nullable<IndicesArray>;
  96952. /**
  96953. * Gets the scene from the mesh
  96954. * @returns the indices array or null
  96955. */
  96956. getScene?(): Scene;
  96957. /**
  96958. * Gets the absolute position from the mesh
  96959. * @returns the absolute position
  96960. */
  96961. getAbsolutePosition(): Vector3;
  96962. /**
  96963. * Gets the absolute pivot point from the mesh
  96964. * @returns the absolute pivot point
  96965. */
  96966. getAbsolutePivotPoint(): Vector3;
  96967. /**
  96968. * Rotates the mesh
  96969. * @param axis The axis of rotation
  96970. * @param amount The amount of rotation
  96971. * @param space The space of the rotation
  96972. * @returns The rotation transform node
  96973. */
  96974. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96975. /**
  96976. * Translates the mesh
  96977. * @param axis The axis of translation
  96978. * @param distance The distance of translation
  96979. * @param space The space of the translation
  96980. * @returns The transform node
  96981. */
  96982. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96983. /**
  96984. * Sets the absolute position of the mesh
  96985. * @param absolutePosition The absolute position of the mesh
  96986. * @returns The transform node
  96987. */
  96988. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96989. /**
  96990. * Gets the class name of the mesh
  96991. * @returns The class name
  96992. */
  96993. getClassName(): string;
  96994. }
  96995. /**
  96996. * Represents a physics imposter
  96997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96998. */
  96999. export class PhysicsImpostor {
  97000. /**
  97001. * The physics-enabled object used as the physics imposter
  97002. */
  97003. object: IPhysicsEnabledObject;
  97004. /**
  97005. * The type of the physics imposter
  97006. */
  97007. type: number;
  97008. private _options;
  97009. private _scene?;
  97010. /**
  97011. * The default object size of the imposter
  97012. */
  97013. static DEFAULT_OBJECT_SIZE: Vector3;
  97014. /**
  97015. * The identity quaternion of the imposter
  97016. */
  97017. static IDENTITY_QUATERNION: Quaternion;
  97018. /** @hidden */
  97019. _pluginData: any;
  97020. private _physicsEngine;
  97021. private _physicsBody;
  97022. private _bodyUpdateRequired;
  97023. private _onBeforePhysicsStepCallbacks;
  97024. private _onAfterPhysicsStepCallbacks;
  97025. /** @hidden */
  97026. _onPhysicsCollideCallbacks: Array<{
  97027. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97028. otherImpostors: Array<PhysicsImpostor>;
  97029. }>;
  97030. private _deltaPosition;
  97031. private _deltaRotation;
  97032. private _deltaRotationConjugated;
  97033. /** @hidden */
  97034. _isFromLine: boolean;
  97035. private _parent;
  97036. private _isDisposed;
  97037. private static _tmpVecs;
  97038. private static _tmpQuat;
  97039. /**
  97040. * Specifies if the physics imposter is disposed
  97041. */
  97042. get isDisposed(): boolean;
  97043. /**
  97044. * Gets the mass of the physics imposter
  97045. */
  97046. get mass(): number;
  97047. set mass(value: number);
  97048. /**
  97049. * Gets the coefficient of friction
  97050. */
  97051. get friction(): number;
  97052. /**
  97053. * Sets the coefficient of friction
  97054. */
  97055. set friction(value: number);
  97056. /**
  97057. * Gets the coefficient of restitution
  97058. */
  97059. get restitution(): number;
  97060. /**
  97061. * Sets the coefficient of restitution
  97062. */
  97063. set restitution(value: number);
  97064. /**
  97065. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97066. */
  97067. get pressure(): number;
  97068. /**
  97069. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97070. */
  97071. set pressure(value: number);
  97072. /**
  97073. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97074. */
  97075. get stiffness(): number;
  97076. /**
  97077. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97078. */
  97079. set stiffness(value: number);
  97080. /**
  97081. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97082. */
  97083. get velocityIterations(): number;
  97084. /**
  97085. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97086. */
  97087. set velocityIterations(value: number);
  97088. /**
  97089. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97090. */
  97091. get positionIterations(): number;
  97092. /**
  97093. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97094. */
  97095. set positionIterations(value: number);
  97096. /**
  97097. * The unique id of the physics imposter
  97098. * set by the physics engine when adding this impostor to the array
  97099. */
  97100. uniqueId: number;
  97101. /**
  97102. * @hidden
  97103. */
  97104. soft: boolean;
  97105. /**
  97106. * @hidden
  97107. */
  97108. segments: number;
  97109. private _joints;
  97110. /**
  97111. * Initializes the physics imposter
  97112. * @param object The physics-enabled object used as the physics imposter
  97113. * @param type The type of the physics imposter
  97114. * @param _options The options for the physics imposter
  97115. * @param _scene The Babylon scene
  97116. */
  97117. constructor(
  97118. /**
  97119. * The physics-enabled object used as the physics imposter
  97120. */
  97121. object: IPhysicsEnabledObject,
  97122. /**
  97123. * The type of the physics imposter
  97124. */
  97125. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97126. /**
  97127. * This function will completly initialize this impostor.
  97128. * It will create a new body - but only if this mesh has no parent.
  97129. * If it has, this impostor will not be used other than to define the impostor
  97130. * of the child mesh.
  97131. * @hidden
  97132. */
  97133. _init(): void;
  97134. private _getPhysicsParent;
  97135. /**
  97136. * Should a new body be generated.
  97137. * @returns boolean specifying if body initialization is required
  97138. */
  97139. isBodyInitRequired(): boolean;
  97140. /**
  97141. * Sets the updated scaling
  97142. * @param updated Specifies if the scaling is updated
  97143. */
  97144. setScalingUpdated(): void;
  97145. /**
  97146. * Force a regeneration of this or the parent's impostor's body.
  97147. * Use under cautious - This will remove all joints already implemented.
  97148. */
  97149. forceUpdate(): void;
  97150. /**
  97151. * Gets the body that holds this impostor. Either its own, or its parent.
  97152. */
  97153. get physicsBody(): any;
  97154. /**
  97155. * Get the parent of the physics imposter
  97156. * @returns Physics imposter or null
  97157. */
  97158. get parent(): Nullable<PhysicsImpostor>;
  97159. /**
  97160. * Sets the parent of the physics imposter
  97161. */
  97162. set parent(value: Nullable<PhysicsImpostor>);
  97163. /**
  97164. * Set the physics body. Used mainly by the physics engine/plugin
  97165. */
  97166. set physicsBody(physicsBody: any);
  97167. /**
  97168. * Resets the update flags
  97169. */
  97170. resetUpdateFlags(): void;
  97171. /**
  97172. * Gets the object extend size
  97173. * @returns the object extend size
  97174. */
  97175. getObjectExtendSize(): Vector3;
  97176. /**
  97177. * Gets the object center
  97178. * @returns The object center
  97179. */
  97180. getObjectCenter(): Vector3;
  97181. /**
  97182. * Get a specific parameter from the options parameters
  97183. * @param paramName The object parameter name
  97184. * @returns The object parameter
  97185. */
  97186. getParam(paramName: string): any;
  97187. /**
  97188. * Sets a specific parameter in the options given to the physics plugin
  97189. * @param paramName The parameter name
  97190. * @param value The value of the parameter
  97191. */
  97192. setParam(paramName: string, value: number): void;
  97193. /**
  97194. * Specifically change the body's mass option. Won't recreate the physics body object
  97195. * @param mass The mass of the physics imposter
  97196. */
  97197. setMass(mass: number): void;
  97198. /**
  97199. * Gets the linear velocity
  97200. * @returns linear velocity or null
  97201. */
  97202. getLinearVelocity(): Nullable<Vector3>;
  97203. /**
  97204. * Sets the linear velocity
  97205. * @param velocity linear velocity or null
  97206. */
  97207. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97208. /**
  97209. * Gets the angular velocity
  97210. * @returns angular velocity or null
  97211. */
  97212. getAngularVelocity(): Nullable<Vector3>;
  97213. /**
  97214. * Sets the angular velocity
  97215. * @param velocity The velocity or null
  97216. */
  97217. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97218. /**
  97219. * Execute a function with the physics plugin native code
  97220. * Provide a function the will have two variables - the world object and the physics body object
  97221. * @param func The function to execute with the physics plugin native code
  97222. */
  97223. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97224. /**
  97225. * Register a function that will be executed before the physics world is stepping forward
  97226. * @param func The function to execute before the physics world is stepped forward
  97227. */
  97228. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97229. /**
  97230. * Unregister a function that will be executed before the physics world is stepping forward
  97231. * @param func The function to execute before the physics world is stepped forward
  97232. */
  97233. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97234. /**
  97235. * Register a function that will be executed after the physics step
  97236. * @param func The function to execute after physics step
  97237. */
  97238. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97239. /**
  97240. * Unregisters a function that will be executed after the physics step
  97241. * @param func The function to execute after physics step
  97242. */
  97243. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97244. /**
  97245. * register a function that will be executed when this impostor collides against a different body
  97246. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97247. * @param func Callback that is executed on collision
  97248. */
  97249. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97250. /**
  97251. * Unregisters the physics imposter on contact
  97252. * @param collideAgainst The physics object to collide against
  97253. * @param func Callback to execute on collision
  97254. */
  97255. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97256. private _tmpQuat;
  97257. private _tmpQuat2;
  97258. /**
  97259. * Get the parent rotation
  97260. * @returns The parent rotation
  97261. */
  97262. getParentsRotation(): Quaternion;
  97263. /**
  97264. * this function is executed by the physics engine.
  97265. */
  97266. beforeStep: () => void;
  97267. /**
  97268. * this function is executed by the physics engine
  97269. */
  97270. afterStep: () => void;
  97271. /**
  97272. * Legacy collision detection event support
  97273. */
  97274. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97275. /**
  97276. * event and body object due to cannon's event-based architecture.
  97277. */
  97278. onCollide: (e: {
  97279. body: any;
  97280. }) => void;
  97281. /**
  97282. * Apply a force
  97283. * @param force The force to apply
  97284. * @param contactPoint The contact point for the force
  97285. * @returns The physics imposter
  97286. */
  97287. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97288. /**
  97289. * Apply an impulse
  97290. * @param force The impulse force
  97291. * @param contactPoint The contact point for the impulse force
  97292. * @returns The physics imposter
  97293. */
  97294. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97295. /**
  97296. * A help function to create a joint
  97297. * @param otherImpostor A physics imposter used to create a joint
  97298. * @param jointType The type of joint
  97299. * @param jointData The data for the joint
  97300. * @returns The physics imposter
  97301. */
  97302. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97303. /**
  97304. * Add a joint to this impostor with a different impostor
  97305. * @param otherImpostor A physics imposter used to add a joint
  97306. * @param joint The joint to add
  97307. * @returns The physics imposter
  97308. */
  97309. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97310. /**
  97311. * Add an anchor to a cloth impostor
  97312. * @param otherImpostor rigid impostor to anchor to
  97313. * @param width ratio across width from 0 to 1
  97314. * @param height ratio up height from 0 to 1
  97315. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97316. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97317. * @returns impostor the soft imposter
  97318. */
  97319. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97320. /**
  97321. * Add a hook to a rope impostor
  97322. * @param otherImpostor rigid impostor to anchor to
  97323. * @param length ratio across rope from 0 to 1
  97324. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97325. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97326. * @returns impostor the rope imposter
  97327. */
  97328. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97329. /**
  97330. * Will keep this body still, in a sleep mode.
  97331. * @returns the physics imposter
  97332. */
  97333. sleep(): PhysicsImpostor;
  97334. /**
  97335. * Wake the body up.
  97336. * @returns The physics imposter
  97337. */
  97338. wakeUp(): PhysicsImpostor;
  97339. /**
  97340. * Clones the physics imposter
  97341. * @param newObject The physics imposter clones to this physics-enabled object
  97342. * @returns A nullable physics imposter
  97343. */
  97344. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97345. /**
  97346. * Disposes the physics imposter
  97347. */
  97348. dispose(): void;
  97349. /**
  97350. * Sets the delta position
  97351. * @param position The delta position amount
  97352. */
  97353. setDeltaPosition(position: Vector3): void;
  97354. /**
  97355. * Sets the delta rotation
  97356. * @param rotation The delta rotation amount
  97357. */
  97358. setDeltaRotation(rotation: Quaternion): void;
  97359. /**
  97360. * Gets the box size of the physics imposter and stores the result in the input parameter
  97361. * @param result Stores the box size
  97362. * @returns The physics imposter
  97363. */
  97364. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97365. /**
  97366. * Gets the radius of the physics imposter
  97367. * @returns Radius of the physics imposter
  97368. */
  97369. getRadius(): number;
  97370. /**
  97371. * Sync a bone with this impostor
  97372. * @param bone The bone to sync to the impostor.
  97373. * @param boneMesh The mesh that the bone is influencing.
  97374. * @param jointPivot The pivot of the joint / bone in local space.
  97375. * @param distToJoint Optional distance from the impostor to the joint.
  97376. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97377. */
  97378. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97379. /**
  97380. * Sync impostor to a bone
  97381. * @param bone The bone that the impostor will be synced to.
  97382. * @param boneMesh The mesh that the bone is influencing.
  97383. * @param jointPivot The pivot of the joint / bone in local space.
  97384. * @param distToJoint Optional distance from the impostor to the joint.
  97385. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97386. * @param boneAxis Optional vector3 axis the bone is aligned with
  97387. */
  97388. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97389. /**
  97390. * No-Imposter type
  97391. */
  97392. static NoImpostor: number;
  97393. /**
  97394. * Sphere-Imposter type
  97395. */
  97396. static SphereImpostor: number;
  97397. /**
  97398. * Box-Imposter type
  97399. */
  97400. static BoxImpostor: number;
  97401. /**
  97402. * Plane-Imposter type
  97403. */
  97404. static PlaneImpostor: number;
  97405. /**
  97406. * Mesh-imposter type
  97407. */
  97408. static MeshImpostor: number;
  97409. /**
  97410. * Capsule-Impostor type (Ammo.js plugin only)
  97411. */
  97412. static CapsuleImpostor: number;
  97413. /**
  97414. * Cylinder-Imposter type
  97415. */
  97416. static CylinderImpostor: number;
  97417. /**
  97418. * Particle-Imposter type
  97419. */
  97420. static ParticleImpostor: number;
  97421. /**
  97422. * Heightmap-Imposter type
  97423. */
  97424. static HeightmapImpostor: number;
  97425. /**
  97426. * ConvexHull-Impostor type (Ammo.js plugin only)
  97427. */
  97428. static ConvexHullImpostor: number;
  97429. /**
  97430. * Custom-Imposter type (Ammo.js plugin only)
  97431. */
  97432. static CustomImpostor: number;
  97433. /**
  97434. * Rope-Imposter type
  97435. */
  97436. static RopeImpostor: number;
  97437. /**
  97438. * Cloth-Imposter type
  97439. */
  97440. static ClothImpostor: number;
  97441. /**
  97442. * Softbody-Imposter type
  97443. */
  97444. static SoftbodyImpostor: number;
  97445. }
  97446. }
  97447. declare module BABYLON {
  97448. /**
  97449. * @hidden
  97450. **/
  97451. export class _CreationDataStorage {
  97452. closePath?: boolean;
  97453. closeArray?: boolean;
  97454. idx: number[];
  97455. dashSize: number;
  97456. gapSize: number;
  97457. path3D: Path3D;
  97458. pathArray: Vector3[][];
  97459. arc: number;
  97460. radius: number;
  97461. cap: number;
  97462. tessellation: number;
  97463. }
  97464. /**
  97465. * @hidden
  97466. **/
  97467. class _InstanceDataStorage {
  97468. visibleInstances: any;
  97469. batchCache: _InstancesBatch;
  97470. instancesBufferSize: number;
  97471. instancesBuffer: Nullable<Buffer>;
  97472. instancesData: Float32Array;
  97473. overridenInstanceCount: number;
  97474. isFrozen: boolean;
  97475. previousBatch: Nullable<_InstancesBatch>;
  97476. hardwareInstancedRendering: boolean;
  97477. sideOrientation: number;
  97478. manualUpdate: boolean;
  97479. }
  97480. /**
  97481. * @hidden
  97482. **/
  97483. export class _InstancesBatch {
  97484. mustReturn: boolean;
  97485. visibleInstances: Nullable<InstancedMesh[]>[];
  97486. renderSelf: boolean[];
  97487. hardwareInstancedRendering: boolean[];
  97488. }
  97489. /**
  97490. * Class used to represent renderable models
  97491. */
  97492. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97493. /**
  97494. * Mesh side orientation : usually the external or front surface
  97495. */
  97496. static readonly FRONTSIDE: number;
  97497. /**
  97498. * Mesh side orientation : usually the internal or back surface
  97499. */
  97500. static readonly BACKSIDE: number;
  97501. /**
  97502. * Mesh side orientation : both internal and external or front and back surfaces
  97503. */
  97504. static readonly DOUBLESIDE: number;
  97505. /**
  97506. * Mesh side orientation : by default, `FRONTSIDE`
  97507. */
  97508. static readonly DEFAULTSIDE: number;
  97509. /**
  97510. * Mesh cap setting : no cap
  97511. */
  97512. static readonly NO_CAP: number;
  97513. /**
  97514. * Mesh cap setting : one cap at the beginning of the mesh
  97515. */
  97516. static readonly CAP_START: number;
  97517. /**
  97518. * Mesh cap setting : one cap at the end of the mesh
  97519. */
  97520. static readonly CAP_END: number;
  97521. /**
  97522. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97523. */
  97524. static readonly CAP_ALL: number;
  97525. /**
  97526. * Mesh pattern setting : no flip or rotate
  97527. */
  97528. static readonly NO_FLIP: number;
  97529. /**
  97530. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97531. */
  97532. static readonly FLIP_TILE: number;
  97533. /**
  97534. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97535. */
  97536. static readonly ROTATE_TILE: number;
  97537. /**
  97538. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97539. */
  97540. static readonly FLIP_ROW: number;
  97541. /**
  97542. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97543. */
  97544. static readonly ROTATE_ROW: number;
  97545. /**
  97546. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97547. */
  97548. static readonly FLIP_N_ROTATE_TILE: number;
  97549. /**
  97550. * Mesh pattern setting : rotate pattern and rotate
  97551. */
  97552. static readonly FLIP_N_ROTATE_ROW: number;
  97553. /**
  97554. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97555. */
  97556. static readonly CENTER: number;
  97557. /**
  97558. * Mesh tile positioning : part tiles on left
  97559. */
  97560. static readonly LEFT: number;
  97561. /**
  97562. * Mesh tile positioning : part tiles on right
  97563. */
  97564. static readonly RIGHT: number;
  97565. /**
  97566. * Mesh tile positioning : part tiles on top
  97567. */
  97568. static readonly TOP: number;
  97569. /**
  97570. * Mesh tile positioning : part tiles on bottom
  97571. */
  97572. static readonly BOTTOM: number;
  97573. /**
  97574. * Gets the default side orientation.
  97575. * @param orientation the orientation to value to attempt to get
  97576. * @returns the default orientation
  97577. * @hidden
  97578. */
  97579. static _GetDefaultSideOrientation(orientation?: number): number;
  97580. private _internalMeshDataInfo;
  97581. /**
  97582. * An event triggered before rendering the mesh
  97583. */
  97584. get onBeforeRenderObservable(): Observable<Mesh>;
  97585. /**
  97586. * An event triggered before binding the mesh
  97587. */
  97588. get onBeforeBindObservable(): Observable<Mesh>;
  97589. /**
  97590. * An event triggered after rendering the mesh
  97591. */
  97592. get onAfterRenderObservable(): Observable<Mesh>;
  97593. /**
  97594. * An event triggered before drawing the mesh
  97595. */
  97596. get onBeforeDrawObservable(): Observable<Mesh>;
  97597. private _onBeforeDrawObserver;
  97598. /**
  97599. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97600. */
  97601. set onBeforeDraw(callback: () => void);
  97602. get hasInstances(): boolean;
  97603. /**
  97604. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97605. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97606. */
  97607. delayLoadState: number;
  97608. /**
  97609. * Gets the list of instances created from this mesh
  97610. * it is not supposed to be modified manually.
  97611. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97612. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97613. */
  97614. instances: InstancedMesh[];
  97615. /**
  97616. * Gets the file containing delay loading data for this mesh
  97617. */
  97618. delayLoadingFile: string;
  97619. /** @hidden */
  97620. _binaryInfo: any;
  97621. /**
  97622. * User defined function used to change how LOD level selection is done
  97623. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97624. */
  97625. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97626. /**
  97627. * Gets or sets the morph target manager
  97628. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97629. */
  97630. get morphTargetManager(): Nullable<MorphTargetManager>;
  97631. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97632. /** @hidden */
  97633. _creationDataStorage: Nullable<_CreationDataStorage>;
  97634. /** @hidden */
  97635. _geometry: Nullable<Geometry>;
  97636. /** @hidden */
  97637. _delayInfo: Array<string>;
  97638. /** @hidden */
  97639. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97640. /** @hidden */
  97641. _instanceDataStorage: _InstanceDataStorage;
  97642. private _effectiveMaterial;
  97643. /** @hidden */
  97644. _shouldGenerateFlatShading: boolean;
  97645. /** @hidden */
  97646. _originalBuilderSideOrientation: number;
  97647. /**
  97648. * Use this property to change the original side orientation defined at construction time
  97649. */
  97650. overrideMaterialSideOrientation: Nullable<number>;
  97651. /**
  97652. * Gets the source mesh (the one used to clone this one from)
  97653. */
  97654. get source(): Nullable<Mesh>;
  97655. /**
  97656. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97657. */
  97658. get isUnIndexed(): boolean;
  97659. set isUnIndexed(value: boolean);
  97660. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97661. get worldMatrixInstancedBuffer(): Float32Array;
  97662. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97663. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97664. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97665. /**
  97666. * @constructor
  97667. * @param name The value used by scene.getMeshByName() to do a lookup.
  97668. * @param scene The scene to add this mesh to.
  97669. * @param parent The parent of this mesh, if it has one
  97670. * @param source An optional Mesh from which geometry is shared, cloned.
  97671. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97672. * When false, achieved by calling a clone(), also passing False.
  97673. * This will make creation of children, recursive.
  97674. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97675. */
  97676. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97677. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97678. doNotInstantiate: boolean;
  97679. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97680. /**
  97681. * Gets the class name
  97682. * @returns the string "Mesh".
  97683. */
  97684. getClassName(): string;
  97685. /** @hidden */
  97686. get _isMesh(): boolean;
  97687. /**
  97688. * Returns a description of this mesh
  97689. * @param fullDetails define if full details about this mesh must be used
  97690. * @returns a descriptive string representing this mesh
  97691. */
  97692. toString(fullDetails?: boolean): string;
  97693. /** @hidden */
  97694. _unBindEffect(): void;
  97695. /**
  97696. * Gets a boolean indicating if this mesh has LOD
  97697. */
  97698. get hasLODLevels(): boolean;
  97699. /**
  97700. * Gets the list of MeshLODLevel associated with the current mesh
  97701. * @returns an array of MeshLODLevel
  97702. */
  97703. getLODLevels(): MeshLODLevel[];
  97704. private _sortLODLevels;
  97705. /**
  97706. * Add a mesh as LOD level triggered at the given distance.
  97707. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97708. * @param distance The distance from the center of the object to show this level
  97709. * @param mesh The mesh to be added as LOD level (can be null)
  97710. * @return This mesh (for chaining)
  97711. */
  97712. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97713. /**
  97714. * Returns the LOD level mesh at the passed distance or null if not found.
  97715. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97716. * @param distance The distance from the center of the object to show this level
  97717. * @returns a Mesh or `null`
  97718. */
  97719. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97720. /**
  97721. * Remove a mesh from the LOD array
  97722. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97723. * @param mesh defines the mesh to be removed
  97724. * @return This mesh (for chaining)
  97725. */
  97726. removeLODLevel(mesh: Mesh): Mesh;
  97727. /**
  97728. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97729. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97730. * @param camera defines the camera to use to compute distance
  97731. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97732. * @return This mesh (for chaining)
  97733. */
  97734. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97735. /**
  97736. * Gets the mesh internal Geometry object
  97737. */
  97738. get geometry(): Nullable<Geometry>;
  97739. /**
  97740. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97741. * @returns the total number of vertices
  97742. */
  97743. getTotalVertices(): number;
  97744. /**
  97745. * Returns the content of an associated vertex buffer
  97746. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97747. * - VertexBuffer.PositionKind
  97748. * - VertexBuffer.UVKind
  97749. * - VertexBuffer.UV2Kind
  97750. * - VertexBuffer.UV3Kind
  97751. * - VertexBuffer.UV4Kind
  97752. * - VertexBuffer.UV5Kind
  97753. * - VertexBuffer.UV6Kind
  97754. * - VertexBuffer.ColorKind
  97755. * - VertexBuffer.MatricesIndicesKind
  97756. * - VertexBuffer.MatricesIndicesExtraKind
  97757. * - VertexBuffer.MatricesWeightsKind
  97758. * - VertexBuffer.MatricesWeightsExtraKind
  97759. * @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
  97760. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97761. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97762. */
  97763. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97764. /**
  97765. * Returns the mesh VertexBuffer object from the requested `kind`
  97766. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97767. * - VertexBuffer.PositionKind
  97768. * - VertexBuffer.NormalKind
  97769. * - VertexBuffer.UVKind
  97770. * - VertexBuffer.UV2Kind
  97771. * - VertexBuffer.UV3Kind
  97772. * - VertexBuffer.UV4Kind
  97773. * - VertexBuffer.UV5Kind
  97774. * - VertexBuffer.UV6Kind
  97775. * - VertexBuffer.ColorKind
  97776. * - VertexBuffer.MatricesIndicesKind
  97777. * - VertexBuffer.MatricesIndicesExtraKind
  97778. * - VertexBuffer.MatricesWeightsKind
  97779. * - VertexBuffer.MatricesWeightsExtraKind
  97780. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97781. */
  97782. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97783. /**
  97784. * Tests if a specific vertex buffer is associated with this mesh
  97785. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97786. * - VertexBuffer.PositionKind
  97787. * - VertexBuffer.NormalKind
  97788. * - VertexBuffer.UVKind
  97789. * - VertexBuffer.UV2Kind
  97790. * - VertexBuffer.UV3Kind
  97791. * - VertexBuffer.UV4Kind
  97792. * - VertexBuffer.UV5Kind
  97793. * - VertexBuffer.UV6Kind
  97794. * - VertexBuffer.ColorKind
  97795. * - VertexBuffer.MatricesIndicesKind
  97796. * - VertexBuffer.MatricesIndicesExtraKind
  97797. * - VertexBuffer.MatricesWeightsKind
  97798. * - VertexBuffer.MatricesWeightsExtraKind
  97799. * @returns a boolean
  97800. */
  97801. isVerticesDataPresent(kind: string): boolean;
  97802. /**
  97803. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97804. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97805. * - VertexBuffer.PositionKind
  97806. * - VertexBuffer.UVKind
  97807. * - VertexBuffer.UV2Kind
  97808. * - VertexBuffer.UV3Kind
  97809. * - VertexBuffer.UV4Kind
  97810. * - VertexBuffer.UV5Kind
  97811. * - VertexBuffer.UV6Kind
  97812. * - VertexBuffer.ColorKind
  97813. * - VertexBuffer.MatricesIndicesKind
  97814. * - VertexBuffer.MatricesIndicesExtraKind
  97815. * - VertexBuffer.MatricesWeightsKind
  97816. * - VertexBuffer.MatricesWeightsExtraKind
  97817. * @returns a boolean
  97818. */
  97819. isVertexBufferUpdatable(kind: string): boolean;
  97820. /**
  97821. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97822. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97823. * - VertexBuffer.PositionKind
  97824. * - VertexBuffer.NormalKind
  97825. * - VertexBuffer.UVKind
  97826. * - VertexBuffer.UV2Kind
  97827. * - VertexBuffer.UV3Kind
  97828. * - VertexBuffer.UV4Kind
  97829. * - VertexBuffer.UV5Kind
  97830. * - VertexBuffer.UV6Kind
  97831. * - VertexBuffer.ColorKind
  97832. * - VertexBuffer.MatricesIndicesKind
  97833. * - VertexBuffer.MatricesIndicesExtraKind
  97834. * - VertexBuffer.MatricesWeightsKind
  97835. * - VertexBuffer.MatricesWeightsExtraKind
  97836. * @returns an array of strings
  97837. */
  97838. getVerticesDataKinds(): string[];
  97839. /**
  97840. * Returns a positive integer : the total number of indices in this mesh geometry.
  97841. * @returns the numner of indices or zero if the mesh has no geometry.
  97842. */
  97843. getTotalIndices(): number;
  97844. /**
  97845. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97846. * @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.
  97847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97848. * @returns the indices array or an empty array if the mesh has no geometry
  97849. */
  97850. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97851. get isBlocked(): boolean;
  97852. /**
  97853. * Determine if the current mesh is ready to be rendered
  97854. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97855. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97856. * @returns true if all associated assets are ready (material, textures, shaders)
  97857. */
  97858. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97859. /**
  97860. * 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.
  97861. */
  97862. get areNormalsFrozen(): boolean;
  97863. /**
  97864. * 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.
  97865. * @returns the current mesh
  97866. */
  97867. freezeNormals(): Mesh;
  97868. /**
  97869. * 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
  97870. * @returns the current mesh
  97871. */
  97872. unfreezeNormals(): Mesh;
  97873. /**
  97874. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97875. */
  97876. set overridenInstanceCount(count: number);
  97877. /** @hidden */
  97878. _preActivate(): Mesh;
  97879. /** @hidden */
  97880. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97881. /** @hidden */
  97882. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97883. /**
  97884. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97885. * This means the mesh underlying bounding box and sphere are recomputed.
  97886. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97887. * @returns the current mesh
  97888. */
  97889. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97890. /** @hidden */
  97891. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97892. /**
  97893. * This function will subdivide the mesh into multiple submeshes
  97894. * @param count defines the expected number of submeshes
  97895. */
  97896. subdivide(count: number): void;
  97897. /**
  97898. * Copy a FloatArray into a specific associated vertex buffer
  97899. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97900. * - VertexBuffer.PositionKind
  97901. * - VertexBuffer.UVKind
  97902. * - VertexBuffer.UV2Kind
  97903. * - VertexBuffer.UV3Kind
  97904. * - VertexBuffer.UV4Kind
  97905. * - VertexBuffer.UV5Kind
  97906. * - VertexBuffer.UV6Kind
  97907. * - VertexBuffer.ColorKind
  97908. * - VertexBuffer.MatricesIndicesKind
  97909. * - VertexBuffer.MatricesIndicesExtraKind
  97910. * - VertexBuffer.MatricesWeightsKind
  97911. * - VertexBuffer.MatricesWeightsExtraKind
  97912. * @param data defines the data source
  97913. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97914. * @param stride defines the data stride size (can be null)
  97915. * @returns the current mesh
  97916. */
  97917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97918. /**
  97919. * Delete a vertex buffer associated with this mesh
  97920. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97921. * - VertexBuffer.PositionKind
  97922. * - VertexBuffer.UVKind
  97923. * - VertexBuffer.UV2Kind
  97924. * - VertexBuffer.UV3Kind
  97925. * - VertexBuffer.UV4Kind
  97926. * - VertexBuffer.UV5Kind
  97927. * - VertexBuffer.UV6Kind
  97928. * - VertexBuffer.ColorKind
  97929. * - VertexBuffer.MatricesIndicesKind
  97930. * - VertexBuffer.MatricesIndicesExtraKind
  97931. * - VertexBuffer.MatricesWeightsKind
  97932. * - VertexBuffer.MatricesWeightsExtraKind
  97933. */
  97934. removeVerticesData(kind: string): void;
  97935. /**
  97936. * Flags an associated vertex buffer as updatable
  97937. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97938. * - VertexBuffer.PositionKind
  97939. * - VertexBuffer.UVKind
  97940. * - VertexBuffer.UV2Kind
  97941. * - VertexBuffer.UV3Kind
  97942. * - VertexBuffer.UV4Kind
  97943. * - VertexBuffer.UV5Kind
  97944. * - VertexBuffer.UV6Kind
  97945. * - VertexBuffer.ColorKind
  97946. * - VertexBuffer.MatricesIndicesKind
  97947. * - VertexBuffer.MatricesIndicesExtraKind
  97948. * - VertexBuffer.MatricesWeightsKind
  97949. * - VertexBuffer.MatricesWeightsExtraKind
  97950. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97951. */
  97952. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97953. /**
  97954. * Sets the mesh global Vertex Buffer
  97955. * @param buffer defines the buffer to use
  97956. * @returns the current mesh
  97957. */
  97958. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97959. /**
  97960. * Update a specific associated vertex buffer
  97961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97962. * - VertexBuffer.PositionKind
  97963. * - VertexBuffer.UVKind
  97964. * - VertexBuffer.UV2Kind
  97965. * - VertexBuffer.UV3Kind
  97966. * - VertexBuffer.UV4Kind
  97967. * - VertexBuffer.UV5Kind
  97968. * - VertexBuffer.UV6Kind
  97969. * - VertexBuffer.ColorKind
  97970. * - VertexBuffer.MatricesIndicesKind
  97971. * - VertexBuffer.MatricesIndicesExtraKind
  97972. * - VertexBuffer.MatricesWeightsKind
  97973. * - VertexBuffer.MatricesWeightsExtraKind
  97974. * @param data defines the data source
  97975. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97976. * @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)
  97977. * @returns the current mesh
  97978. */
  97979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97980. /**
  97981. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97982. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97983. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97984. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97985. * @returns the current mesh
  97986. */
  97987. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97988. /**
  97989. * Creates a un-shared specific occurence of the geometry for the mesh.
  97990. * @returns the current mesh
  97991. */
  97992. makeGeometryUnique(): Mesh;
  97993. /**
  97994. * Set the index buffer of this mesh
  97995. * @param indices defines the source data
  97996. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97997. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97998. * @returns the current mesh
  97999. */
  98000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98001. /**
  98002. * Update the current index buffer
  98003. * @param indices defines the source data
  98004. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98005. * @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)
  98006. * @returns the current mesh
  98007. */
  98008. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98009. /**
  98010. * Invert the geometry to move from a right handed system to a left handed one.
  98011. * @returns the current mesh
  98012. */
  98013. toLeftHanded(): Mesh;
  98014. /** @hidden */
  98015. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98016. /** @hidden */
  98017. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98018. /**
  98019. * Registers for this mesh a javascript function called just before the rendering process
  98020. * @param func defines the function to call before rendering this mesh
  98021. * @returns the current mesh
  98022. */
  98023. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98024. /**
  98025. * Disposes a previously registered javascript function called before the rendering
  98026. * @param func defines the function to remove
  98027. * @returns the current mesh
  98028. */
  98029. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98030. /**
  98031. * Registers for this mesh a javascript function called just after the rendering is complete
  98032. * @param func defines the function to call after rendering this mesh
  98033. * @returns the current mesh
  98034. */
  98035. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98036. /**
  98037. * Disposes a previously registered javascript function called after the rendering.
  98038. * @param func defines the function to remove
  98039. * @returns the current mesh
  98040. */
  98041. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98042. /** @hidden */
  98043. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98044. /** @hidden */
  98045. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98046. /** @hidden */
  98047. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98048. /** @hidden */
  98049. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98050. /** @hidden */
  98051. _rebuild(): void;
  98052. /** @hidden */
  98053. _freeze(): void;
  98054. /** @hidden */
  98055. _unFreeze(): void;
  98056. /**
  98057. * 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
  98058. * @param subMesh defines the subMesh to render
  98059. * @param enableAlphaMode defines if alpha mode can be changed
  98060. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98061. * @returns the current mesh
  98062. */
  98063. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98064. private _onBeforeDraw;
  98065. /**
  98066. * Renormalize the mesh and patch it up if there are no weights
  98067. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98068. * However in the case of zero weights then we set just a single influence to 1.
  98069. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98070. */
  98071. cleanMatrixWeights(): void;
  98072. private normalizeSkinFourWeights;
  98073. private normalizeSkinWeightsAndExtra;
  98074. /**
  98075. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98076. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98077. * the user know there was an issue with importing the mesh
  98078. * @returns a validation object with skinned, valid and report string
  98079. */
  98080. validateSkinning(): {
  98081. skinned: boolean;
  98082. valid: boolean;
  98083. report: string;
  98084. };
  98085. /** @hidden */
  98086. _checkDelayState(): Mesh;
  98087. private _queueLoad;
  98088. /**
  98089. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98090. * A mesh is in the frustum if its bounding box intersects the frustum
  98091. * @param frustumPlanes defines the frustum to test
  98092. * @returns true if the mesh is in the frustum planes
  98093. */
  98094. isInFrustum(frustumPlanes: Plane[]): boolean;
  98095. /**
  98096. * Sets the mesh material by the material or multiMaterial `id` property
  98097. * @param id is a string identifying the material or the multiMaterial
  98098. * @returns the current mesh
  98099. */
  98100. setMaterialByID(id: string): Mesh;
  98101. /**
  98102. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98103. * @returns an array of IAnimatable
  98104. */
  98105. getAnimatables(): IAnimatable[];
  98106. /**
  98107. * Modifies the mesh geometry according to the passed transformation matrix.
  98108. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98109. * The mesh normals are modified using the same transformation.
  98110. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98111. * @param transform defines the transform matrix to use
  98112. * @see http://doc.babylonjs.com/resources/baking_transformations
  98113. * @returns the current mesh
  98114. */
  98115. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98116. /**
  98117. * Modifies the mesh geometry according to its own current World Matrix.
  98118. * The mesh World Matrix is then reset.
  98119. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98120. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98121. * @see http://doc.babylonjs.com/resources/baking_transformations
  98122. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98123. * @returns the current mesh
  98124. */
  98125. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98126. /** @hidden */
  98127. get _positions(): Nullable<Vector3[]>;
  98128. /** @hidden */
  98129. _resetPointsArrayCache(): Mesh;
  98130. /** @hidden */
  98131. _generatePointsArray(): boolean;
  98132. /**
  98133. * Returns a new Mesh object generated from the current mesh properties.
  98134. * This method must not get confused with createInstance()
  98135. * @param name is a string, the name given to the new mesh
  98136. * @param newParent can be any Node object (default `null`)
  98137. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98138. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98139. * @returns a new mesh
  98140. */
  98141. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98142. /**
  98143. * Releases resources associated with this mesh.
  98144. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98145. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98146. */
  98147. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98148. /** @hidden */
  98149. _disposeInstanceSpecificData(): void;
  98150. /**
  98151. * Modifies the mesh geometry according to a displacement map.
  98152. * 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.
  98153. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98154. * @param url is a string, the URL from the image file is to be downloaded.
  98155. * @param minHeight is the lower limit of the displacement.
  98156. * @param maxHeight is the upper limit of the displacement.
  98157. * @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.
  98158. * @param uvOffset is an optional vector2 used to offset UV.
  98159. * @param uvScale is an optional vector2 used to scale UV.
  98160. * @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.
  98161. * @returns the Mesh.
  98162. */
  98163. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98164. /**
  98165. * Modifies the mesh geometry according to a displacementMap buffer.
  98166. * 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.
  98167. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98168. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98169. * @param heightMapWidth is the width of the buffer image.
  98170. * @param heightMapHeight is the height of the buffer image.
  98171. * @param minHeight is the lower limit of the displacement.
  98172. * @param maxHeight is the upper limit of the displacement.
  98173. * @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.
  98174. * @param uvOffset is an optional vector2 used to offset UV.
  98175. * @param uvScale is an optional vector2 used to scale UV.
  98176. * @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.
  98177. * @returns the Mesh.
  98178. */
  98179. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98180. /**
  98181. * Modify the mesh to get a flat shading rendering.
  98182. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98183. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98184. * @returns current mesh
  98185. */
  98186. convertToFlatShadedMesh(): Mesh;
  98187. /**
  98188. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98189. * In other words, more vertices, no more indices and a single bigger VBO.
  98190. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98191. * @returns current mesh
  98192. */
  98193. convertToUnIndexedMesh(): Mesh;
  98194. /**
  98195. * Inverses facet orientations.
  98196. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98197. * @param flipNormals will also inverts the normals
  98198. * @returns current mesh
  98199. */
  98200. flipFaces(flipNormals?: boolean): Mesh;
  98201. /**
  98202. * Increase the number of facets and hence vertices in a mesh
  98203. * Vertex normals are interpolated from existing vertex normals
  98204. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98205. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98206. */
  98207. increaseVertices(numberPerEdge: number): void;
  98208. /**
  98209. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98210. * This will undo any application of covertToFlatShadedMesh
  98211. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98212. */
  98213. forceSharedVertices(): void;
  98214. /** @hidden */
  98215. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98216. /** @hidden */
  98217. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98218. /**
  98219. * Creates a new InstancedMesh object from the mesh model.
  98220. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98221. * @param name defines the name of the new instance
  98222. * @returns a new InstancedMesh
  98223. */
  98224. createInstance(name: string): InstancedMesh;
  98225. /**
  98226. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98227. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98228. * @returns the current mesh
  98229. */
  98230. synchronizeInstances(): Mesh;
  98231. /**
  98232. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98233. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98234. * This should be used together with the simplification to avoid disappearing triangles.
  98235. * @param successCallback an optional success callback to be called after the optimization finished.
  98236. * @returns the current mesh
  98237. */
  98238. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98239. /**
  98240. * Serialize current mesh
  98241. * @param serializationObject defines the object which will receive the serialization data
  98242. */
  98243. serialize(serializationObject: any): void;
  98244. /** @hidden */
  98245. _syncGeometryWithMorphTargetManager(): void;
  98246. /** @hidden */
  98247. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98248. /**
  98249. * Returns a new Mesh object parsed from the source provided.
  98250. * @param parsedMesh is the source
  98251. * @param scene defines the hosting scene
  98252. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98253. * @returns a new Mesh
  98254. */
  98255. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98256. /**
  98257. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98258. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98259. * @param name defines the name of the mesh to create
  98260. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98261. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98262. * @param closePath creates a seam between the first and the last points of each path of the path array
  98263. * @param offset is taken in account only if the `pathArray` is containing a single path
  98264. * @param scene defines the hosting scene
  98265. * @param updatable defines if the mesh must be flagged as updatable
  98266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98267. * @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)
  98268. * @returns a new Mesh
  98269. */
  98270. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98271. /**
  98272. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98273. * @param name defines the name of the mesh to create
  98274. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98275. * @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
  98276. * @param scene defines the hosting scene
  98277. * @param updatable defines if the mesh must be flagged as updatable
  98278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98279. * @returns a new Mesh
  98280. */
  98281. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98282. /**
  98283. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98284. * @param name defines the name of the mesh to create
  98285. * @param size sets the size (float) of each box side (default 1)
  98286. * @param scene defines the hosting scene
  98287. * @param updatable defines if the mesh must be flagged as updatable
  98288. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98289. * @returns a new Mesh
  98290. */
  98291. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98292. /**
  98293. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98294. * @param name defines the name of the mesh to create
  98295. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98296. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98297. * @param scene defines the hosting scene
  98298. * @param updatable defines if the mesh must be flagged as updatable
  98299. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98300. * @returns a new Mesh
  98301. */
  98302. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98303. /**
  98304. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98305. * @param name defines the name of the mesh to create
  98306. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98307. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98308. * @param scene defines the hosting scene
  98309. * @returns a new Mesh
  98310. */
  98311. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98312. /**
  98313. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98314. * @param name defines the name of the mesh to create
  98315. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98316. * @param diameterTop set the top cap diameter (floats, default 1)
  98317. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98318. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98319. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98320. * @param scene defines the hosting scene
  98321. * @param updatable defines if the mesh must be flagged as updatable
  98322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98323. * @returns a new Mesh
  98324. */
  98325. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98326. /**
  98327. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98328. * @param name defines the name of the mesh to create
  98329. * @param diameter sets the diameter size (float) of the torus (default 1)
  98330. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98331. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98332. * @param scene defines the hosting scene
  98333. * @param updatable defines if the mesh must be flagged as updatable
  98334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98335. * @returns a new Mesh
  98336. */
  98337. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98338. /**
  98339. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98340. * @param name defines the name of the mesh to create
  98341. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98342. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98343. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98344. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98345. * @param p the number of windings on X axis (positive integers, default 2)
  98346. * @param q the number of windings on Y axis (positive integers, default 3)
  98347. * @param scene defines the hosting scene
  98348. * @param updatable defines if the mesh must be flagged as updatable
  98349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98350. * @returns a new Mesh
  98351. */
  98352. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98353. /**
  98354. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98355. * @param name defines the name of the mesh to create
  98356. * @param points is an array successive Vector3
  98357. * @param scene defines the hosting scene
  98358. * @param updatable defines if the mesh must be flagged as updatable
  98359. * @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).
  98360. * @returns a new Mesh
  98361. */
  98362. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98363. /**
  98364. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98365. * @param name defines the name of the mesh to create
  98366. * @param points is an array successive Vector3
  98367. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98368. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98369. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98370. * @param scene defines the hosting scene
  98371. * @param updatable defines if the mesh must be flagged as updatable
  98372. * @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)
  98373. * @returns a new Mesh
  98374. */
  98375. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98376. /**
  98377. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98378. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98379. * 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.
  98380. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98381. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98382. * Remember you can only change the shape positions, not their number when updating a polygon.
  98383. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98384. * @param name defines the name of the mesh to create
  98385. * @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
  98386. * @param scene defines the hosting scene
  98387. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98388. * @param updatable defines if the mesh must be flagged as updatable
  98389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98390. * @param earcutInjection can be used to inject your own earcut reference
  98391. * @returns a new Mesh
  98392. */
  98393. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98394. /**
  98395. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98396. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98397. * @param name defines the name of the mesh to create
  98398. * @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
  98399. * @param depth defines the height of extrusion
  98400. * @param scene defines the hosting scene
  98401. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98402. * @param updatable defines if the mesh must be flagged as updatable
  98403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98404. * @param earcutInjection can be used to inject your own earcut reference
  98405. * @returns a new Mesh
  98406. */
  98407. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98408. /**
  98409. * Creates an extruded shape mesh.
  98410. * 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
  98411. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98412. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98413. * @param name defines the name of the mesh to create
  98414. * @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
  98415. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98416. * @param scale is the value to scale the shape
  98417. * @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
  98418. * @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
  98419. * @param scene defines the hosting scene
  98420. * @param updatable defines if the mesh must be flagged as updatable
  98421. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98422. * @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)
  98423. * @returns a new Mesh
  98424. */
  98425. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98426. /**
  98427. * Creates an custom extruded shape mesh.
  98428. * The custom extrusion is a parametric shape.
  98429. * It has no predefined shape. Its final shape will depend on the input parameters.
  98430. * Please consider using the same method from the MeshBuilder class instead
  98431. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98432. * @param name defines the name of the mesh to create
  98433. * @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
  98434. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98435. * @param scaleFunction is a custom Javascript function called on each path point
  98436. * @param rotationFunction is a custom Javascript function called on each path point
  98437. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98438. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98439. * @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
  98440. * @param scene defines the hosting scene
  98441. * @param updatable defines if the mesh must be flagged as updatable
  98442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98443. * @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)
  98444. * @returns a new Mesh
  98445. */
  98446. 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;
  98447. /**
  98448. * Creates lathe mesh.
  98449. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98450. * Please consider using the same method from the MeshBuilder class instead
  98451. * @param name defines the name of the mesh to create
  98452. * @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
  98453. * @param radius is the radius value of the lathe
  98454. * @param tessellation is the side number of the lathe.
  98455. * @param scene defines the hosting scene
  98456. * @param updatable defines if the mesh must be flagged as updatable
  98457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98458. * @returns a new Mesh
  98459. */
  98460. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98461. /**
  98462. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98463. * @param name defines the name of the mesh to create
  98464. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98465. * @param scene defines the hosting scene
  98466. * @param updatable defines if the mesh must be flagged as updatable
  98467. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98468. * @returns a new Mesh
  98469. */
  98470. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98471. /**
  98472. * Creates a ground mesh.
  98473. * Please consider using the same method from the MeshBuilder class instead
  98474. * @param name defines the name of the mesh to create
  98475. * @param width set the width of the ground
  98476. * @param height set the height of the ground
  98477. * @param subdivisions sets the number of subdivisions per side
  98478. * @param scene defines the hosting scene
  98479. * @param updatable defines if the mesh must be flagged as updatable
  98480. * @returns a new Mesh
  98481. */
  98482. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98483. /**
  98484. * Creates a tiled ground mesh.
  98485. * Please consider using the same method from the MeshBuilder class instead
  98486. * @param name defines the name of the mesh to create
  98487. * @param xmin set the ground minimum X coordinate
  98488. * @param zmin set the ground minimum Y coordinate
  98489. * @param xmax set the ground maximum X coordinate
  98490. * @param zmax set the ground maximum Z coordinate
  98491. * @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
  98492. * @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
  98493. * @param scene defines the hosting scene
  98494. * @param updatable defines if the mesh must be flagged as updatable
  98495. * @returns a new Mesh
  98496. */
  98497. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98498. w: number;
  98499. h: number;
  98500. }, precision: {
  98501. w: number;
  98502. h: number;
  98503. }, scene: Scene, updatable?: boolean): Mesh;
  98504. /**
  98505. * Creates a ground mesh from a height map.
  98506. * Please consider using the same method from the MeshBuilder class instead
  98507. * @see http://doc.babylonjs.com/babylon101/height_map
  98508. * @param name defines the name of the mesh to create
  98509. * @param url sets the URL of the height map image resource
  98510. * @param width set the ground width size
  98511. * @param height set the ground height size
  98512. * @param subdivisions sets the number of subdivision per side
  98513. * @param minHeight is the minimum altitude on the ground
  98514. * @param maxHeight is the maximum altitude on the ground
  98515. * @param scene defines the hosting scene
  98516. * @param updatable defines if the mesh must be flagged as updatable
  98517. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98518. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98519. * @returns a new Mesh
  98520. */
  98521. 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;
  98522. /**
  98523. * Creates a tube mesh.
  98524. * The tube is a parametric shape.
  98525. * It has no predefined shape. Its final shape will depend on the input parameters.
  98526. * Please consider using the same method from the MeshBuilder class instead
  98527. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98528. * @param name defines the name of the mesh to create
  98529. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98530. * @param radius sets the tube radius size
  98531. * @param tessellation is the number of sides on the tubular surface
  98532. * @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
  98533. * @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
  98534. * @param scene defines the hosting scene
  98535. * @param updatable defines if the mesh must be flagged as updatable
  98536. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98537. * @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)
  98538. * @returns a new Mesh
  98539. */
  98540. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98541. (i: number, distance: number): number;
  98542. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98543. /**
  98544. * Creates a polyhedron mesh.
  98545. * Please consider using the same method from the MeshBuilder class instead.
  98546. * * 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
  98547. * * The parameter `size` (positive float, default 1) sets the polygon size
  98548. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98549. * * 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`
  98550. * * 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
  98551. * * 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)`)
  98552. * * 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
  98553. * * 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
  98554. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98555. * * If you create a double-sided mesh, you can choose what parts of 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
  98556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98557. * @param name defines the name of the mesh to create
  98558. * @param options defines the options used to create the mesh
  98559. * @param scene defines the hosting scene
  98560. * @returns a new Mesh
  98561. */
  98562. static CreatePolyhedron(name: string, options: {
  98563. type?: number;
  98564. size?: number;
  98565. sizeX?: number;
  98566. sizeY?: number;
  98567. sizeZ?: number;
  98568. custom?: any;
  98569. faceUV?: Vector4[];
  98570. faceColors?: Color4[];
  98571. updatable?: boolean;
  98572. sideOrientation?: number;
  98573. }, scene: Scene): Mesh;
  98574. /**
  98575. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98576. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98577. * * 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`)
  98578. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98579. * * 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
  98580. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98581. * * If you create a double-sided mesh, you can choose what parts of 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
  98582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98583. * @param name defines the name of the mesh
  98584. * @param options defines the options used to create the mesh
  98585. * @param scene defines the hosting scene
  98586. * @returns a new Mesh
  98587. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98588. */
  98589. static CreateIcoSphere(name: string, options: {
  98590. radius?: number;
  98591. flat?: boolean;
  98592. subdivisions?: number;
  98593. sideOrientation?: number;
  98594. updatable?: boolean;
  98595. }, scene: Scene): Mesh;
  98596. /**
  98597. * Creates a decal mesh.
  98598. * Please consider using the same method from the MeshBuilder class instead.
  98599. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98600. * @param name defines the name of the mesh
  98601. * @param sourceMesh defines the mesh receiving the decal
  98602. * @param position sets the position of the decal in world coordinates
  98603. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98604. * @param size sets the decal scaling
  98605. * @param angle sets the angle to rotate the decal
  98606. * @returns a new Mesh
  98607. */
  98608. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98609. /**
  98610. * Prepare internal position array for software CPU skinning
  98611. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98612. */
  98613. setPositionsForCPUSkinning(): Float32Array;
  98614. /**
  98615. * Prepare internal normal array for software CPU skinning
  98616. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98617. */
  98618. setNormalsForCPUSkinning(): Float32Array;
  98619. /**
  98620. * Updates the vertex buffer by applying transformation from the bones
  98621. * @param skeleton defines the skeleton to apply to current mesh
  98622. * @returns the current mesh
  98623. */
  98624. applySkeleton(skeleton: Skeleton): Mesh;
  98625. /**
  98626. * 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
  98627. * @param meshes defines the list of meshes to scan
  98628. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98629. */
  98630. static MinMax(meshes: AbstractMesh[]): {
  98631. min: Vector3;
  98632. max: Vector3;
  98633. };
  98634. /**
  98635. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98636. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98637. * @returns a vector3
  98638. */
  98639. static Center(meshesOrMinMaxVector: {
  98640. min: Vector3;
  98641. max: Vector3;
  98642. } | AbstractMesh[]): Vector3;
  98643. /**
  98644. * Merge the array of meshes into a single mesh for performance reasons.
  98645. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98646. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98647. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98648. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98649. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98650. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98651. * @returns a new mesh
  98652. */
  98653. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98654. /** @hidden */
  98655. addInstance(instance: InstancedMesh): void;
  98656. /** @hidden */
  98657. removeInstance(instance: InstancedMesh): void;
  98658. }
  98659. }
  98660. declare module BABYLON {
  98661. /**
  98662. * This is the base class of all the camera used in the application.
  98663. * @see http://doc.babylonjs.com/features/cameras
  98664. */
  98665. export class Camera extends Node {
  98666. /** @hidden */
  98667. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98668. /**
  98669. * This is the default projection mode used by the cameras.
  98670. * It helps recreating a feeling of perspective and better appreciate depth.
  98671. * This is the best way to simulate real life cameras.
  98672. */
  98673. static readonly PERSPECTIVE_CAMERA: number;
  98674. /**
  98675. * This helps creating camera with an orthographic mode.
  98676. * 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.
  98677. */
  98678. static readonly ORTHOGRAPHIC_CAMERA: number;
  98679. /**
  98680. * This is the default FOV mode for perspective cameras.
  98681. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98682. */
  98683. static readonly FOVMODE_VERTICAL_FIXED: number;
  98684. /**
  98685. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98686. */
  98687. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98688. /**
  98689. * This specifies ther is no need for a camera rig.
  98690. * Basically only one eye is rendered corresponding to the camera.
  98691. */
  98692. static readonly RIG_MODE_NONE: number;
  98693. /**
  98694. * Simulates a camera Rig with one blue eye and one red eye.
  98695. * This can be use with 3d blue and red glasses.
  98696. */
  98697. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98698. /**
  98699. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98700. */
  98701. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98702. /**
  98703. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98704. */
  98705. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98706. /**
  98707. * Defines that both eyes of the camera will be rendered over under each other.
  98708. */
  98709. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98710. /**
  98711. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98712. */
  98713. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98714. /**
  98715. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98716. */
  98717. static readonly RIG_MODE_VR: number;
  98718. /**
  98719. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98720. */
  98721. static readonly RIG_MODE_WEBVR: number;
  98722. /**
  98723. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98724. */
  98725. static readonly RIG_MODE_CUSTOM: number;
  98726. /**
  98727. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98728. */
  98729. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98730. /**
  98731. * Define the input manager associated with the camera.
  98732. */
  98733. inputs: CameraInputsManager<Camera>;
  98734. /** @hidden */
  98735. _position: Vector3;
  98736. /**
  98737. * Define the current local position of the camera in the scene
  98738. */
  98739. get position(): Vector3;
  98740. set position(newPosition: Vector3);
  98741. /**
  98742. * The vector the camera should consider as up.
  98743. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98744. */
  98745. upVector: Vector3;
  98746. /**
  98747. * Define the current limit on the left side for an orthographic camera
  98748. * In scene unit
  98749. */
  98750. orthoLeft: Nullable<number>;
  98751. /**
  98752. * Define the current limit on the right side for an orthographic camera
  98753. * In scene unit
  98754. */
  98755. orthoRight: Nullable<number>;
  98756. /**
  98757. * Define the current limit on the bottom side for an orthographic camera
  98758. * In scene unit
  98759. */
  98760. orthoBottom: Nullable<number>;
  98761. /**
  98762. * Define the current limit on the top side for an orthographic camera
  98763. * In scene unit
  98764. */
  98765. orthoTop: Nullable<number>;
  98766. /**
  98767. * Field Of View is set in Radians. (default is 0.8)
  98768. */
  98769. fov: number;
  98770. /**
  98771. * Define the minimum distance the camera can see from.
  98772. * This is important to note that the depth buffer are not infinite and the closer it starts
  98773. * the more your scene might encounter depth fighting issue.
  98774. */
  98775. minZ: number;
  98776. /**
  98777. * Define the maximum distance the camera can see to.
  98778. * This is important to note that the depth buffer are not infinite and the further it end
  98779. * the more your scene might encounter depth fighting issue.
  98780. */
  98781. maxZ: number;
  98782. /**
  98783. * Define the default inertia of the camera.
  98784. * This helps giving a smooth feeling to the camera movement.
  98785. */
  98786. inertia: number;
  98787. /**
  98788. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98789. */
  98790. mode: number;
  98791. /**
  98792. * Define whether the camera is intermediate.
  98793. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98794. */
  98795. isIntermediate: boolean;
  98796. /**
  98797. * Define the viewport of the camera.
  98798. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98799. */
  98800. viewport: Viewport;
  98801. /**
  98802. * Restricts the camera to viewing objects with the same layerMask.
  98803. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98804. */
  98805. layerMask: number;
  98806. /**
  98807. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98808. */
  98809. fovMode: number;
  98810. /**
  98811. * Rig mode of the camera.
  98812. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98813. * This is normally controlled byt the camera themselves as internal use.
  98814. */
  98815. cameraRigMode: number;
  98816. /**
  98817. * Defines the distance between both "eyes" in case of a RIG
  98818. */
  98819. interaxialDistance: number;
  98820. /**
  98821. * Defines if stereoscopic rendering is done side by side or over under.
  98822. */
  98823. isStereoscopicSideBySide: boolean;
  98824. /**
  98825. * 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
  98826. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98827. * else in the scene. (Eg. security camera)
  98828. *
  98829. * 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)
  98830. */
  98831. customRenderTargets: RenderTargetTexture[];
  98832. /**
  98833. * When set, the camera will render to this render target instead of the default canvas
  98834. *
  98835. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98836. */
  98837. outputRenderTarget: Nullable<RenderTargetTexture>;
  98838. /**
  98839. * Observable triggered when the camera view matrix has changed.
  98840. */
  98841. onViewMatrixChangedObservable: Observable<Camera>;
  98842. /**
  98843. * Observable triggered when the camera Projection matrix has changed.
  98844. */
  98845. onProjectionMatrixChangedObservable: Observable<Camera>;
  98846. /**
  98847. * Observable triggered when the inputs have been processed.
  98848. */
  98849. onAfterCheckInputsObservable: Observable<Camera>;
  98850. /**
  98851. * Observable triggered when reset has been called and applied to the camera.
  98852. */
  98853. onRestoreStateObservable: Observable<Camera>;
  98854. /**
  98855. * Is this camera a part of a rig system?
  98856. */
  98857. isRigCamera: boolean;
  98858. /**
  98859. * If isRigCamera set to true this will be set with the parent camera.
  98860. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98861. */
  98862. rigParent?: Camera;
  98863. /** @hidden */
  98864. _cameraRigParams: any;
  98865. /** @hidden */
  98866. _rigCameras: Camera[];
  98867. /** @hidden */
  98868. _rigPostProcess: Nullable<PostProcess>;
  98869. protected _webvrViewMatrix: Matrix;
  98870. /** @hidden */
  98871. _skipRendering: boolean;
  98872. /** @hidden */
  98873. _projectionMatrix: Matrix;
  98874. /** @hidden */
  98875. _postProcesses: Nullable<PostProcess>[];
  98876. /** @hidden */
  98877. _activeMeshes: SmartArray<AbstractMesh>;
  98878. protected _globalPosition: Vector3;
  98879. /** @hidden */
  98880. _computedViewMatrix: Matrix;
  98881. private _doNotComputeProjectionMatrix;
  98882. private _transformMatrix;
  98883. private _frustumPlanes;
  98884. private _refreshFrustumPlanes;
  98885. private _storedFov;
  98886. private _stateStored;
  98887. /**
  98888. * Instantiates a new camera object.
  98889. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98890. * @see http://doc.babylonjs.com/features/cameras
  98891. * @param name Defines the name of the camera in the scene
  98892. * @param position Defines the position of the camera
  98893. * @param scene Defines the scene the camera belongs too
  98894. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98895. */
  98896. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98897. /**
  98898. * Store current camera state (fov, position, etc..)
  98899. * @returns the camera
  98900. */
  98901. storeState(): Camera;
  98902. /**
  98903. * Restores the camera state values if it has been stored. You must call storeState() first
  98904. */
  98905. protected _restoreStateValues(): boolean;
  98906. /**
  98907. * Restored camera state. You must call storeState() first.
  98908. * @returns true if restored and false otherwise
  98909. */
  98910. restoreState(): boolean;
  98911. /**
  98912. * Gets the class name of the camera.
  98913. * @returns the class name
  98914. */
  98915. getClassName(): string;
  98916. /** @hidden */
  98917. readonly _isCamera: boolean;
  98918. /**
  98919. * Gets a string representation of the camera useful for debug purpose.
  98920. * @param fullDetails Defines that a more verboe level of logging is required
  98921. * @returns the string representation
  98922. */
  98923. toString(fullDetails?: boolean): string;
  98924. /**
  98925. * Gets the current world space position of the camera.
  98926. */
  98927. get globalPosition(): Vector3;
  98928. /**
  98929. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98930. * @returns the active meshe list
  98931. */
  98932. getActiveMeshes(): SmartArray<AbstractMesh>;
  98933. /**
  98934. * Check whether a mesh is part of the current active mesh list of the camera
  98935. * @param mesh Defines the mesh to check
  98936. * @returns true if active, false otherwise
  98937. */
  98938. isActiveMesh(mesh: Mesh): boolean;
  98939. /**
  98940. * Is this camera ready to be used/rendered
  98941. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98942. * @return true if the camera is ready
  98943. */
  98944. isReady(completeCheck?: boolean): boolean;
  98945. /** @hidden */
  98946. _initCache(): void;
  98947. /** @hidden */
  98948. _updateCache(ignoreParentClass?: boolean): void;
  98949. /** @hidden */
  98950. _isSynchronized(): boolean;
  98951. /** @hidden */
  98952. _isSynchronizedViewMatrix(): boolean;
  98953. /** @hidden */
  98954. _isSynchronizedProjectionMatrix(): boolean;
  98955. /**
  98956. * Attach the input controls to a specific dom element to get the input from.
  98957. * @param element Defines the element the controls should be listened from
  98958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98959. */
  98960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98961. /**
  98962. * Detach the current controls from the specified dom element.
  98963. * @param element Defines the element to stop listening the inputs from
  98964. */
  98965. detachControl(element: HTMLElement): void;
  98966. /**
  98967. * Update the camera state according to the different inputs gathered during the frame.
  98968. */
  98969. update(): void;
  98970. /** @hidden */
  98971. _checkInputs(): void;
  98972. /** @hidden */
  98973. get rigCameras(): Camera[];
  98974. /**
  98975. * Gets the post process used by the rig cameras
  98976. */
  98977. get rigPostProcess(): Nullable<PostProcess>;
  98978. /**
  98979. * Internal, gets the first post proces.
  98980. * @returns the first post process to be run on this camera.
  98981. */
  98982. _getFirstPostProcess(): Nullable<PostProcess>;
  98983. private _cascadePostProcessesToRigCams;
  98984. /**
  98985. * Attach a post process to the camera.
  98986. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98987. * @param postProcess The post process to attach to the camera
  98988. * @param insertAt The position of the post process in case several of them are in use in the scene
  98989. * @returns the position the post process has been inserted at
  98990. */
  98991. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98992. /**
  98993. * Detach a post process to the camera.
  98994. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98995. * @param postProcess The post process to detach from the camera
  98996. */
  98997. detachPostProcess(postProcess: PostProcess): void;
  98998. /**
  98999. * Gets the current world matrix of the camera
  99000. */
  99001. getWorldMatrix(): Matrix;
  99002. /** @hidden */
  99003. _getViewMatrix(): Matrix;
  99004. /**
  99005. * Gets the current view matrix of the camera.
  99006. * @param force forces the camera to recompute the matrix without looking at the cached state
  99007. * @returns the view matrix
  99008. */
  99009. getViewMatrix(force?: boolean): Matrix;
  99010. /**
  99011. * Freeze the projection matrix.
  99012. * It will prevent the cache check of the camera projection compute and can speed up perf
  99013. * if no parameter of the camera are meant to change
  99014. * @param projection Defines manually a projection if necessary
  99015. */
  99016. freezeProjectionMatrix(projection?: Matrix): void;
  99017. /**
  99018. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99019. */
  99020. unfreezeProjectionMatrix(): void;
  99021. /**
  99022. * Gets the current projection matrix of the camera.
  99023. * @param force forces the camera to recompute the matrix without looking at the cached state
  99024. * @returns the projection matrix
  99025. */
  99026. getProjectionMatrix(force?: boolean): Matrix;
  99027. /**
  99028. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99029. * @returns a Matrix
  99030. */
  99031. getTransformationMatrix(): Matrix;
  99032. private _updateFrustumPlanes;
  99033. /**
  99034. * Checks if a cullable object (mesh...) is in the camera frustum
  99035. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99036. * @param target The object to check
  99037. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99038. * @returns true if the object is in frustum otherwise false
  99039. */
  99040. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99041. /**
  99042. * Checks if a cullable object (mesh...) is in the camera frustum
  99043. * Unlike isInFrustum this cheks the full bounding box
  99044. * @param target The object to check
  99045. * @returns true if the object is in frustum otherwise false
  99046. */
  99047. isCompletelyInFrustum(target: ICullable): boolean;
  99048. /**
  99049. * Gets a ray in the forward direction from the camera.
  99050. * @param length Defines the length of the ray to create
  99051. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99052. * @param origin Defines the start point of the ray which defaults to the camera position
  99053. * @returns the forward ray
  99054. */
  99055. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99056. /**
  99057. * Releases resources associated with this node.
  99058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99060. */
  99061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99062. /** @hidden */
  99063. _isLeftCamera: boolean;
  99064. /**
  99065. * Gets the left camera of a rig setup in case of Rigged Camera
  99066. */
  99067. get isLeftCamera(): boolean;
  99068. /** @hidden */
  99069. _isRightCamera: boolean;
  99070. /**
  99071. * Gets the right camera of a rig setup in case of Rigged Camera
  99072. */
  99073. get isRightCamera(): boolean;
  99074. /**
  99075. * Gets the left camera of a rig setup in case of Rigged Camera
  99076. */
  99077. get leftCamera(): Nullable<FreeCamera>;
  99078. /**
  99079. * Gets the right camera of a rig setup in case of Rigged Camera
  99080. */
  99081. get rightCamera(): Nullable<FreeCamera>;
  99082. /**
  99083. * Gets the left camera target of a rig setup in case of Rigged Camera
  99084. * @returns the target position
  99085. */
  99086. getLeftTarget(): Nullable<Vector3>;
  99087. /**
  99088. * Gets the right camera target of a rig setup in case of Rigged Camera
  99089. * @returns the target position
  99090. */
  99091. getRightTarget(): Nullable<Vector3>;
  99092. /**
  99093. * @hidden
  99094. */
  99095. setCameraRigMode(mode: number, rigParams: any): void;
  99096. /** @hidden */
  99097. static _setStereoscopicRigMode(camera: Camera): void;
  99098. /** @hidden */
  99099. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99100. /** @hidden */
  99101. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99102. /** @hidden */
  99103. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99104. /** @hidden */
  99105. _getVRProjectionMatrix(): Matrix;
  99106. protected _updateCameraRotationMatrix(): void;
  99107. protected _updateWebVRCameraRotationMatrix(): void;
  99108. /**
  99109. * This function MUST be overwritten by the different WebVR cameras available.
  99110. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99111. * @hidden
  99112. */
  99113. _getWebVRProjectionMatrix(): Matrix;
  99114. /**
  99115. * This function MUST be overwritten by the different WebVR cameras available.
  99116. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99117. * @hidden
  99118. */
  99119. _getWebVRViewMatrix(): Matrix;
  99120. /** @hidden */
  99121. setCameraRigParameter(name: string, value: any): void;
  99122. /**
  99123. * needs to be overridden by children so sub has required properties to be copied
  99124. * @hidden
  99125. */
  99126. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99127. /**
  99128. * May need to be overridden by children
  99129. * @hidden
  99130. */
  99131. _updateRigCameras(): void;
  99132. /** @hidden */
  99133. _setupInputs(): void;
  99134. /**
  99135. * Serialiaze the camera setup to a json represention
  99136. * @returns the JSON representation
  99137. */
  99138. serialize(): any;
  99139. /**
  99140. * Clones the current camera.
  99141. * @param name The cloned camera name
  99142. * @returns the cloned camera
  99143. */
  99144. clone(name: string): Camera;
  99145. /**
  99146. * Gets the direction of the camera relative to a given local axis.
  99147. * @param localAxis Defines the reference axis to provide a relative direction.
  99148. * @return the direction
  99149. */
  99150. getDirection(localAxis: Vector3): Vector3;
  99151. /**
  99152. * Returns the current camera absolute rotation
  99153. */
  99154. get absoluteRotation(): Quaternion;
  99155. /**
  99156. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99157. * @param localAxis Defines the reference axis to provide a relative direction.
  99158. * @param result Defines the vector to store the result in
  99159. */
  99160. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99161. /**
  99162. * Gets a camera constructor for a given camera type
  99163. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99164. * @param name The name of the camera the result will be able to instantiate
  99165. * @param scene The scene the result will construct the camera in
  99166. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99167. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99168. * @returns a factory method to construc the camera
  99169. */
  99170. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99171. /**
  99172. * Compute the world matrix of the camera.
  99173. * @returns the camera world matrix
  99174. */
  99175. computeWorldMatrix(): Matrix;
  99176. /**
  99177. * Parse a JSON and creates the camera from the parsed information
  99178. * @param parsedCamera The JSON to parse
  99179. * @param scene The scene to instantiate the camera in
  99180. * @returns the newly constructed camera
  99181. */
  99182. static Parse(parsedCamera: any, scene: Scene): Camera;
  99183. }
  99184. }
  99185. declare module BABYLON {
  99186. /**
  99187. * Class containing static functions to help procedurally build meshes
  99188. */
  99189. export class DiscBuilder {
  99190. /**
  99191. * Creates a plane polygonal mesh. By default, this is a disc
  99192. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99193. * * 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
  99194. * * 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
  99195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99198. * @param name defines the name of the mesh
  99199. * @param options defines the options used to create the mesh
  99200. * @param scene defines the hosting scene
  99201. * @returns the plane polygonal mesh
  99202. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99203. */
  99204. static CreateDisc(name: string, options: {
  99205. radius?: number;
  99206. tessellation?: number;
  99207. arc?: number;
  99208. updatable?: boolean;
  99209. sideOrientation?: number;
  99210. frontUVs?: Vector4;
  99211. backUVs?: Vector4;
  99212. }, scene?: Nullable<Scene>): Mesh;
  99213. }
  99214. }
  99215. declare module BABYLON {
  99216. /**
  99217. * This represents all the required information to add a fresnel effect on a material:
  99218. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99219. */
  99220. export class FresnelParameters {
  99221. private _isEnabled;
  99222. /**
  99223. * Define if the fresnel effect is enable or not.
  99224. */
  99225. get isEnabled(): boolean;
  99226. set isEnabled(value: boolean);
  99227. /**
  99228. * Define the color used on edges (grazing angle)
  99229. */
  99230. leftColor: Color3;
  99231. /**
  99232. * Define the color used on center
  99233. */
  99234. rightColor: Color3;
  99235. /**
  99236. * Define bias applied to computed fresnel term
  99237. */
  99238. bias: number;
  99239. /**
  99240. * Defined the power exponent applied to fresnel term
  99241. */
  99242. power: number;
  99243. /**
  99244. * Clones the current fresnel and its valuues
  99245. * @returns a clone fresnel configuration
  99246. */
  99247. clone(): FresnelParameters;
  99248. /**
  99249. * Serializes the current fresnel parameters to a JSON representation.
  99250. * @return the JSON serialization
  99251. */
  99252. serialize(): any;
  99253. /**
  99254. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99255. * @param parsedFresnelParameters Define the JSON representation
  99256. * @returns the parsed parameters
  99257. */
  99258. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99259. }
  99260. }
  99261. declare module BABYLON {
  99262. /**
  99263. * Base class of materials working in push mode in babylon JS
  99264. * @hidden
  99265. */
  99266. export class PushMaterial extends Material {
  99267. protected _activeEffect: Effect;
  99268. protected _normalMatrix: Matrix;
  99269. /**
  99270. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99271. * This means that the material can keep using a previous shader while a new one is being compiled.
  99272. * This is mostly used when shader parallel compilation is supported (true by default)
  99273. */
  99274. allowShaderHotSwapping: boolean;
  99275. constructor(name: string, scene: Scene);
  99276. getEffect(): Effect;
  99277. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99278. /**
  99279. * Binds the given world matrix to the active effect
  99280. *
  99281. * @param world the matrix to bind
  99282. */
  99283. bindOnlyWorldMatrix(world: Matrix): void;
  99284. /**
  99285. * Binds the given normal matrix to the active effect
  99286. *
  99287. * @param normalMatrix the matrix to bind
  99288. */
  99289. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99290. bind(world: Matrix, mesh?: Mesh): void;
  99291. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99292. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99293. }
  99294. }
  99295. declare module BABYLON {
  99296. /**
  99297. * This groups all the flags used to control the materials channel.
  99298. */
  99299. export class MaterialFlags {
  99300. private static _DiffuseTextureEnabled;
  99301. /**
  99302. * Are diffuse textures enabled in the application.
  99303. */
  99304. static get DiffuseTextureEnabled(): boolean;
  99305. static set DiffuseTextureEnabled(value: boolean);
  99306. private static _AmbientTextureEnabled;
  99307. /**
  99308. * Are ambient textures enabled in the application.
  99309. */
  99310. static get AmbientTextureEnabled(): boolean;
  99311. static set AmbientTextureEnabled(value: boolean);
  99312. private static _OpacityTextureEnabled;
  99313. /**
  99314. * Are opacity textures enabled in the application.
  99315. */
  99316. static get OpacityTextureEnabled(): boolean;
  99317. static set OpacityTextureEnabled(value: boolean);
  99318. private static _ReflectionTextureEnabled;
  99319. /**
  99320. * Are reflection textures enabled in the application.
  99321. */
  99322. static get ReflectionTextureEnabled(): boolean;
  99323. static set ReflectionTextureEnabled(value: boolean);
  99324. private static _EmissiveTextureEnabled;
  99325. /**
  99326. * Are emissive textures enabled in the application.
  99327. */
  99328. static get EmissiveTextureEnabled(): boolean;
  99329. static set EmissiveTextureEnabled(value: boolean);
  99330. private static _SpecularTextureEnabled;
  99331. /**
  99332. * Are specular textures enabled in the application.
  99333. */
  99334. static get SpecularTextureEnabled(): boolean;
  99335. static set SpecularTextureEnabled(value: boolean);
  99336. private static _BumpTextureEnabled;
  99337. /**
  99338. * Are bump textures enabled in the application.
  99339. */
  99340. static get BumpTextureEnabled(): boolean;
  99341. static set BumpTextureEnabled(value: boolean);
  99342. private static _LightmapTextureEnabled;
  99343. /**
  99344. * Are lightmap textures enabled in the application.
  99345. */
  99346. static get LightmapTextureEnabled(): boolean;
  99347. static set LightmapTextureEnabled(value: boolean);
  99348. private static _RefractionTextureEnabled;
  99349. /**
  99350. * Are refraction textures enabled in the application.
  99351. */
  99352. static get RefractionTextureEnabled(): boolean;
  99353. static set RefractionTextureEnabled(value: boolean);
  99354. private static _ColorGradingTextureEnabled;
  99355. /**
  99356. * Are color grading textures enabled in the application.
  99357. */
  99358. static get ColorGradingTextureEnabled(): boolean;
  99359. static set ColorGradingTextureEnabled(value: boolean);
  99360. private static _FresnelEnabled;
  99361. /**
  99362. * Are fresnels enabled in the application.
  99363. */
  99364. static get FresnelEnabled(): boolean;
  99365. static set FresnelEnabled(value: boolean);
  99366. private static _ClearCoatTextureEnabled;
  99367. /**
  99368. * Are clear coat textures enabled in the application.
  99369. */
  99370. static get ClearCoatTextureEnabled(): boolean;
  99371. static set ClearCoatTextureEnabled(value: boolean);
  99372. private static _ClearCoatBumpTextureEnabled;
  99373. /**
  99374. * Are clear coat bump textures enabled in the application.
  99375. */
  99376. static get ClearCoatBumpTextureEnabled(): boolean;
  99377. static set ClearCoatBumpTextureEnabled(value: boolean);
  99378. private static _ClearCoatTintTextureEnabled;
  99379. /**
  99380. * Are clear coat tint textures enabled in the application.
  99381. */
  99382. static get ClearCoatTintTextureEnabled(): boolean;
  99383. static set ClearCoatTintTextureEnabled(value: boolean);
  99384. private static _SheenTextureEnabled;
  99385. /**
  99386. * Are sheen textures enabled in the application.
  99387. */
  99388. static get SheenTextureEnabled(): boolean;
  99389. static set SheenTextureEnabled(value: boolean);
  99390. private static _AnisotropicTextureEnabled;
  99391. /**
  99392. * Are anisotropic textures enabled in the application.
  99393. */
  99394. static get AnisotropicTextureEnabled(): boolean;
  99395. static set AnisotropicTextureEnabled(value: boolean);
  99396. private static _ThicknessTextureEnabled;
  99397. /**
  99398. * Are thickness textures enabled in the application.
  99399. */
  99400. static get ThicknessTextureEnabled(): boolean;
  99401. static set ThicknessTextureEnabled(value: boolean);
  99402. }
  99403. }
  99404. declare module BABYLON {
  99405. /** @hidden */
  99406. export var defaultFragmentDeclaration: {
  99407. name: string;
  99408. shader: string;
  99409. };
  99410. }
  99411. declare module BABYLON {
  99412. /** @hidden */
  99413. export var defaultUboDeclaration: {
  99414. name: string;
  99415. shader: string;
  99416. };
  99417. }
  99418. declare module BABYLON {
  99419. /** @hidden */
  99420. export var lightFragmentDeclaration: {
  99421. name: string;
  99422. shader: string;
  99423. };
  99424. }
  99425. declare module BABYLON {
  99426. /** @hidden */
  99427. export var lightUboDeclaration: {
  99428. name: string;
  99429. shader: string;
  99430. };
  99431. }
  99432. declare module BABYLON {
  99433. /** @hidden */
  99434. export var lightsFragmentFunctions: {
  99435. name: string;
  99436. shader: string;
  99437. };
  99438. }
  99439. declare module BABYLON {
  99440. /** @hidden */
  99441. export var shadowsFragmentFunctions: {
  99442. name: string;
  99443. shader: string;
  99444. };
  99445. }
  99446. declare module BABYLON {
  99447. /** @hidden */
  99448. export var fresnelFunction: {
  99449. name: string;
  99450. shader: string;
  99451. };
  99452. }
  99453. declare module BABYLON {
  99454. /** @hidden */
  99455. export var reflectionFunction: {
  99456. name: string;
  99457. shader: string;
  99458. };
  99459. }
  99460. declare module BABYLON {
  99461. /** @hidden */
  99462. export var bumpFragmentFunctions: {
  99463. name: string;
  99464. shader: string;
  99465. };
  99466. }
  99467. declare module BABYLON {
  99468. /** @hidden */
  99469. export var logDepthDeclaration: {
  99470. name: string;
  99471. shader: string;
  99472. };
  99473. }
  99474. declare module BABYLON {
  99475. /** @hidden */
  99476. export var bumpFragment: {
  99477. name: string;
  99478. shader: string;
  99479. };
  99480. }
  99481. declare module BABYLON {
  99482. /** @hidden */
  99483. export var depthPrePass: {
  99484. name: string;
  99485. shader: string;
  99486. };
  99487. }
  99488. declare module BABYLON {
  99489. /** @hidden */
  99490. export var lightFragment: {
  99491. name: string;
  99492. shader: string;
  99493. };
  99494. }
  99495. declare module BABYLON {
  99496. /** @hidden */
  99497. export var logDepthFragment: {
  99498. name: string;
  99499. shader: string;
  99500. };
  99501. }
  99502. declare module BABYLON {
  99503. /** @hidden */
  99504. export var defaultPixelShader: {
  99505. name: string;
  99506. shader: string;
  99507. };
  99508. }
  99509. declare module BABYLON {
  99510. /** @hidden */
  99511. export var defaultVertexDeclaration: {
  99512. name: string;
  99513. shader: string;
  99514. };
  99515. }
  99516. declare module BABYLON {
  99517. /** @hidden */
  99518. export var bumpVertexDeclaration: {
  99519. name: string;
  99520. shader: string;
  99521. };
  99522. }
  99523. declare module BABYLON {
  99524. /** @hidden */
  99525. export var bumpVertex: {
  99526. name: string;
  99527. shader: string;
  99528. };
  99529. }
  99530. declare module BABYLON {
  99531. /** @hidden */
  99532. export var fogVertex: {
  99533. name: string;
  99534. shader: string;
  99535. };
  99536. }
  99537. declare module BABYLON {
  99538. /** @hidden */
  99539. export var shadowsVertex: {
  99540. name: string;
  99541. shader: string;
  99542. };
  99543. }
  99544. declare module BABYLON {
  99545. /** @hidden */
  99546. export var pointCloudVertex: {
  99547. name: string;
  99548. shader: string;
  99549. };
  99550. }
  99551. declare module BABYLON {
  99552. /** @hidden */
  99553. export var logDepthVertex: {
  99554. name: string;
  99555. shader: string;
  99556. };
  99557. }
  99558. declare module BABYLON {
  99559. /** @hidden */
  99560. export var defaultVertexShader: {
  99561. name: string;
  99562. shader: string;
  99563. };
  99564. }
  99565. declare module BABYLON {
  99566. /** @hidden */
  99567. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99568. MAINUV1: boolean;
  99569. MAINUV2: boolean;
  99570. DIFFUSE: boolean;
  99571. DIFFUSEDIRECTUV: number;
  99572. AMBIENT: boolean;
  99573. AMBIENTDIRECTUV: number;
  99574. OPACITY: boolean;
  99575. OPACITYDIRECTUV: number;
  99576. OPACITYRGB: boolean;
  99577. REFLECTION: boolean;
  99578. EMISSIVE: boolean;
  99579. EMISSIVEDIRECTUV: number;
  99580. SPECULAR: boolean;
  99581. SPECULARDIRECTUV: number;
  99582. BUMP: boolean;
  99583. BUMPDIRECTUV: number;
  99584. PARALLAX: boolean;
  99585. PARALLAXOCCLUSION: boolean;
  99586. SPECULAROVERALPHA: boolean;
  99587. CLIPPLANE: boolean;
  99588. CLIPPLANE2: boolean;
  99589. CLIPPLANE3: boolean;
  99590. CLIPPLANE4: boolean;
  99591. CLIPPLANE5: boolean;
  99592. CLIPPLANE6: boolean;
  99593. ALPHATEST: boolean;
  99594. DEPTHPREPASS: boolean;
  99595. ALPHAFROMDIFFUSE: boolean;
  99596. POINTSIZE: boolean;
  99597. FOG: boolean;
  99598. SPECULARTERM: boolean;
  99599. DIFFUSEFRESNEL: boolean;
  99600. OPACITYFRESNEL: boolean;
  99601. REFLECTIONFRESNEL: boolean;
  99602. REFRACTIONFRESNEL: boolean;
  99603. EMISSIVEFRESNEL: boolean;
  99604. FRESNEL: boolean;
  99605. NORMAL: boolean;
  99606. UV1: boolean;
  99607. UV2: boolean;
  99608. VERTEXCOLOR: boolean;
  99609. VERTEXALPHA: boolean;
  99610. NUM_BONE_INFLUENCERS: number;
  99611. BonesPerMesh: number;
  99612. BONETEXTURE: boolean;
  99613. INSTANCES: boolean;
  99614. GLOSSINESS: boolean;
  99615. ROUGHNESS: boolean;
  99616. EMISSIVEASILLUMINATION: boolean;
  99617. LINKEMISSIVEWITHDIFFUSE: boolean;
  99618. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99619. LIGHTMAP: boolean;
  99620. LIGHTMAPDIRECTUV: number;
  99621. OBJECTSPACE_NORMALMAP: boolean;
  99622. USELIGHTMAPASSHADOWMAP: boolean;
  99623. REFLECTIONMAP_3D: boolean;
  99624. REFLECTIONMAP_SPHERICAL: boolean;
  99625. REFLECTIONMAP_PLANAR: boolean;
  99626. REFLECTIONMAP_CUBIC: boolean;
  99627. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99628. REFLECTIONMAP_PROJECTION: boolean;
  99629. REFLECTIONMAP_SKYBOX: boolean;
  99630. REFLECTIONMAP_EXPLICIT: boolean;
  99631. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99632. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99633. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99634. INVERTCUBICMAP: boolean;
  99635. LOGARITHMICDEPTH: boolean;
  99636. REFRACTION: boolean;
  99637. REFRACTIONMAP_3D: boolean;
  99638. REFLECTIONOVERALPHA: boolean;
  99639. TWOSIDEDLIGHTING: boolean;
  99640. SHADOWFLOAT: boolean;
  99641. MORPHTARGETS: boolean;
  99642. MORPHTARGETS_NORMAL: boolean;
  99643. MORPHTARGETS_TANGENT: boolean;
  99644. MORPHTARGETS_UV: boolean;
  99645. NUM_MORPH_INFLUENCERS: number;
  99646. NONUNIFORMSCALING: boolean;
  99647. PREMULTIPLYALPHA: boolean;
  99648. IMAGEPROCESSING: boolean;
  99649. VIGNETTE: boolean;
  99650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99651. VIGNETTEBLENDMODEOPAQUE: boolean;
  99652. TONEMAPPING: boolean;
  99653. TONEMAPPING_ACES: boolean;
  99654. CONTRAST: boolean;
  99655. COLORCURVES: boolean;
  99656. COLORGRADING: boolean;
  99657. COLORGRADING3D: boolean;
  99658. SAMPLER3DGREENDEPTH: boolean;
  99659. SAMPLER3DBGRMAP: boolean;
  99660. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99661. MULTIVIEW: boolean;
  99662. /**
  99663. * If the reflection texture on this material is in linear color space
  99664. * @hidden
  99665. */
  99666. IS_REFLECTION_LINEAR: boolean;
  99667. /**
  99668. * If the refraction texture on this material is in linear color space
  99669. * @hidden
  99670. */
  99671. IS_REFRACTION_LINEAR: boolean;
  99672. EXPOSURE: boolean;
  99673. constructor();
  99674. setReflectionMode(modeToEnable: string): void;
  99675. }
  99676. /**
  99677. * This is the default material used in Babylon. It is the best trade off between quality
  99678. * and performances.
  99679. * @see http://doc.babylonjs.com/babylon101/materials
  99680. */
  99681. export class StandardMaterial extends PushMaterial {
  99682. private _diffuseTexture;
  99683. /**
  99684. * The basic texture of the material as viewed under a light.
  99685. */
  99686. diffuseTexture: Nullable<BaseTexture>;
  99687. private _ambientTexture;
  99688. /**
  99689. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99690. */
  99691. ambientTexture: Nullable<BaseTexture>;
  99692. private _opacityTexture;
  99693. /**
  99694. * Define the transparency of the material from a texture.
  99695. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99696. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99697. */
  99698. opacityTexture: Nullable<BaseTexture>;
  99699. private _reflectionTexture;
  99700. /**
  99701. * Define the texture used to display the reflection.
  99702. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99703. */
  99704. reflectionTexture: Nullable<BaseTexture>;
  99705. private _emissiveTexture;
  99706. /**
  99707. * Define texture of the material as if self lit.
  99708. * This will be mixed in the final result even in the absence of light.
  99709. */
  99710. emissiveTexture: Nullable<BaseTexture>;
  99711. private _specularTexture;
  99712. /**
  99713. * Define how the color and intensity of the highlight given by the light in the material.
  99714. */
  99715. specularTexture: Nullable<BaseTexture>;
  99716. private _bumpTexture;
  99717. /**
  99718. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99719. * 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.
  99720. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99721. */
  99722. bumpTexture: Nullable<BaseTexture>;
  99723. private _lightmapTexture;
  99724. /**
  99725. * Complex lighting can be computationally expensive to compute at runtime.
  99726. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99727. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99728. */
  99729. lightmapTexture: Nullable<BaseTexture>;
  99730. private _refractionTexture;
  99731. /**
  99732. * Define the texture used to display the refraction.
  99733. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99734. */
  99735. refractionTexture: Nullable<BaseTexture>;
  99736. /**
  99737. * The color of the material lit by the environmental background lighting.
  99738. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99739. */
  99740. ambientColor: Color3;
  99741. /**
  99742. * The basic color of the material as viewed under a light.
  99743. */
  99744. diffuseColor: Color3;
  99745. /**
  99746. * Define how the color and intensity of the highlight given by the light in the material.
  99747. */
  99748. specularColor: Color3;
  99749. /**
  99750. * Define the color of the material as if self lit.
  99751. * This will be mixed in the final result even in the absence of light.
  99752. */
  99753. emissiveColor: Color3;
  99754. /**
  99755. * Defines how sharp are the highlights in the material.
  99756. * The bigger the value the sharper giving a more glossy feeling to the result.
  99757. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99758. */
  99759. specularPower: number;
  99760. private _useAlphaFromDiffuseTexture;
  99761. /**
  99762. * Does the transparency come from the diffuse texture alpha channel.
  99763. */
  99764. useAlphaFromDiffuseTexture: boolean;
  99765. private _useEmissiveAsIllumination;
  99766. /**
  99767. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99768. */
  99769. useEmissiveAsIllumination: boolean;
  99770. private _linkEmissiveWithDiffuse;
  99771. /**
  99772. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99773. * the emissive level when the final color is close to one.
  99774. */
  99775. linkEmissiveWithDiffuse: boolean;
  99776. private _useSpecularOverAlpha;
  99777. /**
  99778. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99779. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99780. */
  99781. useSpecularOverAlpha: boolean;
  99782. private _useReflectionOverAlpha;
  99783. /**
  99784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99786. */
  99787. useReflectionOverAlpha: boolean;
  99788. private _disableLighting;
  99789. /**
  99790. * Does lights from the scene impacts this material.
  99791. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99792. */
  99793. disableLighting: boolean;
  99794. private _useObjectSpaceNormalMap;
  99795. /**
  99796. * Allows using an object space normal map (instead of tangent space).
  99797. */
  99798. useObjectSpaceNormalMap: boolean;
  99799. private _useParallax;
  99800. /**
  99801. * Is parallax enabled or not.
  99802. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99803. */
  99804. useParallax: boolean;
  99805. private _useParallaxOcclusion;
  99806. /**
  99807. * Is parallax occlusion enabled or not.
  99808. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99809. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99810. */
  99811. useParallaxOcclusion: boolean;
  99812. /**
  99813. * 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.
  99814. */
  99815. parallaxScaleBias: number;
  99816. private _roughness;
  99817. /**
  99818. * Helps to define how blurry the reflections should appears in the material.
  99819. */
  99820. roughness: number;
  99821. /**
  99822. * In case of refraction, define the value of the index of refraction.
  99823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99824. */
  99825. indexOfRefraction: number;
  99826. /**
  99827. * Invert the refraction texture alongside the y axis.
  99828. * It can be useful with procedural textures or probe for instance.
  99829. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99830. */
  99831. invertRefractionY: boolean;
  99832. /**
  99833. * Defines the alpha limits in alpha test mode.
  99834. */
  99835. alphaCutOff: number;
  99836. private _useLightmapAsShadowmap;
  99837. /**
  99838. * In case of light mapping, define whether the map contains light or shadow informations.
  99839. */
  99840. useLightmapAsShadowmap: boolean;
  99841. private _diffuseFresnelParameters;
  99842. /**
  99843. * Define the diffuse fresnel parameters of the material.
  99844. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99845. */
  99846. diffuseFresnelParameters: FresnelParameters;
  99847. private _opacityFresnelParameters;
  99848. /**
  99849. * Define the opacity fresnel parameters of the material.
  99850. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99851. */
  99852. opacityFresnelParameters: FresnelParameters;
  99853. private _reflectionFresnelParameters;
  99854. /**
  99855. * Define the reflection fresnel parameters of the material.
  99856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99857. */
  99858. reflectionFresnelParameters: FresnelParameters;
  99859. private _refractionFresnelParameters;
  99860. /**
  99861. * Define the refraction fresnel parameters of the material.
  99862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99863. */
  99864. refractionFresnelParameters: FresnelParameters;
  99865. private _emissiveFresnelParameters;
  99866. /**
  99867. * Define the emissive fresnel parameters of the material.
  99868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99869. */
  99870. emissiveFresnelParameters: FresnelParameters;
  99871. private _useReflectionFresnelFromSpecular;
  99872. /**
  99873. * If true automatically deducts the fresnels values from the material specularity.
  99874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99875. */
  99876. useReflectionFresnelFromSpecular: boolean;
  99877. private _useGlossinessFromSpecularMapAlpha;
  99878. /**
  99879. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99880. */
  99881. useGlossinessFromSpecularMapAlpha: boolean;
  99882. private _maxSimultaneousLights;
  99883. /**
  99884. * Defines the maximum number of lights that can be used in the material
  99885. */
  99886. maxSimultaneousLights: number;
  99887. private _invertNormalMapX;
  99888. /**
  99889. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99890. */
  99891. invertNormalMapX: boolean;
  99892. private _invertNormalMapY;
  99893. /**
  99894. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99895. */
  99896. invertNormalMapY: boolean;
  99897. private _twoSidedLighting;
  99898. /**
  99899. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99900. */
  99901. twoSidedLighting: boolean;
  99902. /**
  99903. * Default configuration related to image processing available in the standard Material.
  99904. */
  99905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99906. /**
  99907. * Gets the image processing configuration used either in this material.
  99908. */
  99909. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99910. /**
  99911. * Sets the Default image processing configuration used either in the this material.
  99912. *
  99913. * If sets to null, the scene one is in use.
  99914. */
  99915. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99916. /**
  99917. * Keep track of the image processing observer to allow dispose and replace.
  99918. */
  99919. private _imageProcessingObserver;
  99920. /**
  99921. * Attaches a new image processing configuration to the Standard Material.
  99922. * @param configuration
  99923. */
  99924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99925. /**
  99926. * Gets wether the color curves effect is enabled.
  99927. */
  99928. get cameraColorCurvesEnabled(): boolean;
  99929. /**
  99930. * Sets wether the color curves effect is enabled.
  99931. */
  99932. set cameraColorCurvesEnabled(value: boolean);
  99933. /**
  99934. * Gets wether the color grading effect is enabled.
  99935. */
  99936. get cameraColorGradingEnabled(): boolean;
  99937. /**
  99938. * Gets wether the color grading effect is enabled.
  99939. */
  99940. set cameraColorGradingEnabled(value: boolean);
  99941. /**
  99942. * Gets wether tonemapping is enabled or not.
  99943. */
  99944. get cameraToneMappingEnabled(): boolean;
  99945. /**
  99946. * Sets wether tonemapping is enabled or not
  99947. */
  99948. set cameraToneMappingEnabled(value: boolean);
  99949. /**
  99950. * The camera exposure used on this material.
  99951. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99952. * This corresponds to a photographic exposure.
  99953. */
  99954. get cameraExposure(): number;
  99955. /**
  99956. * The camera exposure used on this material.
  99957. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99958. * This corresponds to a photographic exposure.
  99959. */
  99960. set cameraExposure(value: number);
  99961. /**
  99962. * Gets The camera contrast used on this material.
  99963. */
  99964. get cameraContrast(): number;
  99965. /**
  99966. * Sets The camera contrast used on this material.
  99967. */
  99968. set cameraContrast(value: number);
  99969. /**
  99970. * Gets the Color Grading 2D Lookup Texture.
  99971. */
  99972. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99973. /**
  99974. * Sets the Color Grading 2D Lookup Texture.
  99975. */
  99976. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99977. /**
  99978. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99979. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99980. * 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;
  99981. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99982. */
  99983. get cameraColorCurves(): Nullable<ColorCurves>;
  99984. /**
  99985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99987. * 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;
  99988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99989. */
  99990. set cameraColorCurves(value: Nullable<ColorCurves>);
  99991. /**
  99992. * Custom callback helping to override the default shader used in the material.
  99993. */
  99994. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99995. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99996. protected _worldViewProjectionMatrix: Matrix;
  99997. protected _globalAmbientColor: Color3;
  99998. protected _useLogarithmicDepth: boolean;
  99999. protected _rebuildInParallel: boolean;
  100000. /**
  100001. * Instantiates a new standard material.
  100002. * This is the default material used in Babylon. It is the best trade off between quality
  100003. * and performances.
  100004. * @see http://doc.babylonjs.com/babylon101/materials
  100005. * @param name Define the name of the material in the scene
  100006. * @param scene Define the scene the material belong to
  100007. */
  100008. constructor(name: string, scene: Scene);
  100009. /**
  100010. * Gets a boolean indicating that current material needs to register RTT
  100011. */
  100012. get hasRenderTargetTextures(): boolean;
  100013. /**
  100014. * Gets the current class name of the material e.g. "StandardMaterial"
  100015. * Mainly use in serialization.
  100016. * @returns the class name
  100017. */
  100018. getClassName(): string;
  100019. /**
  100020. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100021. * You can try switching to logarithmic depth.
  100022. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100023. */
  100024. get useLogarithmicDepth(): boolean;
  100025. set useLogarithmicDepth(value: boolean);
  100026. /**
  100027. * Specifies if the material will require alpha blending
  100028. * @returns a boolean specifying if alpha blending is needed
  100029. */
  100030. needAlphaBlending(): boolean;
  100031. /**
  100032. * Specifies if this material should be rendered in alpha test mode
  100033. * @returns a boolean specifying if an alpha test is needed.
  100034. */
  100035. needAlphaTesting(): boolean;
  100036. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100037. /**
  100038. * Get the texture used for alpha test purpose.
  100039. * @returns the diffuse texture in case of the standard material.
  100040. */
  100041. getAlphaTestTexture(): Nullable<BaseTexture>;
  100042. /**
  100043. * Get if the submesh is ready to be used and all its information available.
  100044. * Child classes can use it to update shaders
  100045. * @param mesh defines the mesh to check
  100046. * @param subMesh defines which submesh to check
  100047. * @param useInstances specifies that instances should be used
  100048. * @returns a boolean indicating that the submesh is ready or not
  100049. */
  100050. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100051. /**
  100052. * Builds the material UBO layouts.
  100053. * Used internally during the effect preparation.
  100054. */
  100055. buildUniformLayout(): void;
  100056. /**
  100057. * Unbinds the material from the mesh
  100058. */
  100059. unbind(): void;
  100060. /**
  100061. * Binds the submesh to this material by preparing the effect and shader to draw
  100062. * @param world defines the world transformation matrix
  100063. * @param mesh defines the mesh containing the submesh
  100064. * @param subMesh defines the submesh to bind the material to
  100065. */
  100066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100067. /**
  100068. * Get the list of animatables in the material.
  100069. * @returns the list of animatables object used in the material
  100070. */
  100071. getAnimatables(): IAnimatable[];
  100072. /**
  100073. * Gets the active textures from the material
  100074. * @returns an array of textures
  100075. */
  100076. getActiveTextures(): BaseTexture[];
  100077. /**
  100078. * Specifies if the material uses a texture
  100079. * @param texture defines the texture to check against the material
  100080. * @returns a boolean specifying if the material uses the texture
  100081. */
  100082. hasTexture(texture: BaseTexture): boolean;
  100083. /**
  100084. * Disposes the material
  100085. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100086. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100087. */
  100088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100089. /**
  100090. * Makes a duplicate of the material, and gives it a new name
  100091. * @param name defines the new name for the duplicated material
  100092. * @returns the cloned material
  100093. */
  100094. clone(name: string): StandardMaterial;
  100095. /**
  100096. * Serializes this material in a JSON representation
  100097. * @returns the serialized material object
  100098. */
  100099. serialize(): any;
  100100. /**
  100101. * Creates a standard material from parsed material data
  100102. * @param source defines the JSON representation of the material
  100103. * @param scene defines the hosting scene
  100104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100105. * @returns a new standard material
  100106. */
  100107. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100108. /**
  100109. * Are diffuse textures enabled in the application.
  100110. */
  100111. static get DiffuseTextureEnabled(): boolean;
  100112. static set DiffuseTextureEnabled(value: boolean);
  100113. /**
  100114. * Are ambient textures enabled in the application.
  100115. */
  100116. static get AmbientTextureEnabled(): boolean;
  100117. static set AmbientTextureEnabled(value: boolean);
  100118. /**
  100119. * Are opacity textures enabled in the application.
  100120. */
  100121. static get OpacityTextureEnabled(): boolean;
  100122. static set OpacityTextureEnabled(value: boolean);
  100123. /**
  100124. * Are reflection textures enabled in the application.
  100125. */
  100126. static get ReflectionTextureEnabled(): boolean;
  100127. static set ReflectionTextureEnabled(value: boolean);
  100128. /**
  100129. * Are emissive textures enabled in the application.
  100130. */
  100131. static get EmissiveTextureEnabled(): boolean;
  100132. static set EmissiveTextureEnabled(value: boolean);
  100133. /**
  100134. * Are specular textures enabled in the application.
  100135. */
  100136. static get SpecularTextureEnabled(): boolean;
  100137. static set SpecularTextureEnabled(value: boolean);
  100138. /**
  100139. * Are bump textures enabled in the application.
  100140. */
  100141. static get BumpTextureEnabled(): boolean;
  100142. static set BumpTextureEnabled(value: boolean);
  100143. /**
  100144. * Are lightmap textures enabled in the application.
  100145. */
  100146. static get LightmapTextureEnabled(): boolean;
  100147. static set LightmapTextureEnabled(value: boolean);
  100148. /**
  100149. * Are refraction textures enabled in the application.
  100150. */
  100151. static get RefractionTextureEnabled(): boolean;
  100152. static set RefractionTextureEnabled(value: boolean);
  100153. /**
  100154. * Are color grading textures enabled in the application.
  100155. */
  100156. static get ColorGradingTextureEnabled(): boolean;
  100157. static set ColorGradingTextureEnabled(value: boolean);
  100158. /**
  100159. * Are fresnels enabled in the application.
  100160. */
  100161. static get FresnelEnabled(): boolean;
  100162. static set FresnelEnabled(value: boolean);
  100163. }
  100164. }
  100165. declare module BABYLON {
  100166. /**
  100167. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100168. *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.
  100169. * The SPS is also a particle system. It provides some methods to manage the particles.
  100170. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100171. *
  100172. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100173. */
  100174. export class SolidParticleSystem implements IDisposable {
  100175. /**
  100176. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100177. * Example : var p = SPS.particles[i];
  100178. */
  100179. particles: SolidParticle[];
  100180. /**
  100181. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100182. */
  100183. nbParticles: number;
  100184. /**
  100185. * If the particles must ever face the camera (default false). Useful for planar particles.
  100186. */
  100187. billboard: boolean;
  100188. /**
  100189. * Recompute normals when adding a shape
  100190. */
  100191. recomputeNormals: boolean;
  100192. /**
  100193. * This a counter ofr your own usage. It's not set by any SPS functions.
  100194. */
  100195. counter: number;
  100196. /**
  100197. * The SPS name. This name is also given to the underlying mesh.
  100198. */
  100199. name: string;
  100200. /**
  100201. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100202. */
  100203. mesh: Mesh;
  100204. /**
  100205. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100206. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100207. */
  100208. vars: any;
  100209. /**
  100210. * This array is populated when the SPS is set as 'pickable'.
  100211. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100212. * Each element of this array is an object `{idx: int, faceId: int}`.
  100213. * `idx` is the picked particle index in the `SPS.particles` array
  100214. * `faceId` is the picked face index counted within this particle.
  100215. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100216. */
  100217. pickedParticles: {
  100218. idx: number;
  100219. faceId: number;
  100220. }[];
  100221. /**
  100222. * This array is populated when `enableDepthSort` is set to true.
  100223. * Each element of this array is an instance of the class DepthSortedParticle.
  100224. */
  100225. depthSortedParticles: DepthSortedParticle[];
  100226. /**
  100227. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100228. * @hidden
  100229. */
  100230. _bSphereOnly: boolean;
  100231. /**
  100232. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100233. * @hidden
  100234. */
  100235. _bSphereRadiusFactor: number;
  100236. private _scene;
  100237. private _positions;
  100238. private _indices;
  100239. private _normals;
  100240. private _colors;
  100241. private _uvs;
  100242. private _indices32;
  100243. private _positions32;
  100244. private _normals32;
  100245. private _fixedNormal32;
  100246. private _colors32;
  100247. private _uvs32;
  100248. private _index;
  100249. private _updatable;
  100250. private _pickable;
  100251. private _isVisibilityBoxLocked;
  100252. private _alwaysVisible;
  100253. private _depthSort;
  100254. private _expandable;
  100255. private _shapeCounter;
  100256. private _copy;
  100257. private _color;
  100258. private _computeParticleColor;
  100259. private _computeParticleTexture;
  100260. private _computeParticleRotation;
  100261. private _computeParticleVertex;
  100262. private _computeBoundingBox;
  100263. private _depthSortParticles;
  100264. private _camera;
  100265. private _mustUnrotateFixedNormals;
  100266. private _particlesIntersect;
  100267. private _needs32Bits;
  100268. private _isNotBuilt;
  100269. private _lastParticleId;
  100270. private _idxOfId;
  100271. private _multimaterialEnabled;
  100272. private _useModelMaterial;
  100273. private _indicesByMaterial;
  100274. private _materialIndexes;
  100275. private _depthSortFunction;
  100276. private _materialSortFunction;
  100277. private _materials;
  100278. private _multimaterial;
  100279. private _materialIndexesById;
  100280. private _defaultMaterial;
  100281. private _autoUpdateSubMeshes;
  100282. /**
  100283. * Creates a SPS (Solid Particle System) object.
  100284. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100285. * @param scene (Scene) is the scene in which the SPS is added.
  100286. * @param options defines the options of the sps e.g.
  100287. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100288. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100289. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100290. * * 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.
  100291. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100292. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100293. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100294. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100295. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100296. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100297. */
  100298. constructor(name: string, scene: Scene, options?: {
  100299. updatable?: boolean;
  100300. isPickable?: boolean;
  100301. enableDepthSort?: boolean;
  100302. particleIntersection?: boolean;
  100303. boundingSphereOnly?: boolean;
  100304. bSphereRadiusFactor?: number;
  100305. expandable?: boolean;
  100306. useModelMaterial?: boolean;
  100307. enableMultiMaterial?: boolean;
  100308. });
  100309. /**
  100310. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100311. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100312. * @returns the created mesh
  100313. */
  100314. buildMesh(): Mesh;
  100315. /**
  100316. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100317. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100318. * Thus the particles generated from `digest()` have their property `position` set yet.
  100319. * @param mesh ( Mesh ) is the mesh to be digested
  100320. * @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
  100321. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100322. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100323. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100324. * @returns the current SPS
  100325. */
  100326. digest(mesh: Mesh, options?: {
  100327. facetNb?: number;
  100328. number?: number;
  100329. delta?: number;
  100330. storage?: [];
  100331. }): SolidParticleSystem;
  100332. /**
  100333. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100334. * @hidden
  100335. */
  100336. private _unrotateFixedNormals;
  100337. /**
  100338. * Resets the temporary working copy particle
  100339. * @hidden
  100340. */
  100341. private _resetCopy;
  100342. /**
  100343. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100344. * @param p the current index in the positions array to be updated
  100345. * @param ind the current index in the indices array
  100346. * @param shape a Vector3 array, the shape geometry
  100347. * @param positions the positions array to be updated
  100348. * @param meshInd the shape indices array
  100349. * @param indices the indices array to be updated
  100350. * @param meshUV the shape uv array
  100351. * @param uvs the uv array to be updated
  100352. * @param meshCol the shape color array
  100353. * @param colors the color array to be updated
  100354. * @param meshNor the shape normals array
  100355. * @param normals the normals array to be updated
  100356. * @param idx the particle index
  100357. * @param idxInShape the particle index in its shape
  100358. * @param options the addShape() method passed options
  100359. * @model the particle model
  100360. * @hidden
  100361. */
  100362. private _meshBuilder;
  100363. /**
  100364. * Returns a shape Vector3 array from positions float array
  100365. * @param positions float array
  100366. * @returns a vector3 array
  100367. * @hidden
  100368. */
  100369. private _posToShape;
  100370. /**
  100371. * Returns a shapeUV array from a float uvs (array deep copy)
  100372. * @param uvs as a float array
  100373. * @returns a shapeUV array
  100374. * @hidden
  100375. */
  100376. private _uvsToShapeUV;
  100377. /**
  100378. * Adds a new particle object in the particles array
  100379. * @param idx particle index in particles array
  100380. * @param id particle id
  100381. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100382. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100383. * @param model particle ModelShape object
  100384. * @param shapeId model shape identifier
  100385. * @param idxInShape index of the particle in the current model
  100386. * @param bInfo model bounding info object
  100387. * @param storage target storage array, if any
  100388. * @hidden
  100389. */
  100390. private _addParticle;
  100391. /**
  100392. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100393. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100394. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100395. * @param nb (positive integer) the number of particles to be created from this model
  100396. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100397. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100398. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100399. * @returns the number of shapes in the system
  100400. */
  100401. addShape(mesh: Mesh, nb: number, options?: {
  100402. positionFunction?: any;
  100403. vertexFunction?: any;
  100404. storage?: [];
  100405. }): number;
  100406. /**
  100407. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100408. * @hidden
  100409. */
  100410. private _rebuildParticle;
  100411. /**
  100412. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100413. * @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.
  100414. * @returns the SPS.
  100415. */
  100416. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100417. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100418. * Returns an array with the removed particles.
  100419. * 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.
  100420. * The SPS can't be empty so at least one particle needs to remain in place.
  100421. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100422. * @param start index of the first particle to remove
  100423. * @param end index of the last particle to remove (included)
  100424. * @returns an array populated with the removed particles
  100425. */
  100426. removeParticles(start: number, end: number): SolidParticle[];
  100427. /**
  100428. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100429. * @param solidParticleArray an array populated with Solid Particles objects
  100430. * @returns the SPS
  100431. */
  100432. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100433. /**
  100434. * Creates a new particle and modifies the SPS mesh geometry :
  100435. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100436. * - calls _addParticle() to populate the particle array
  100437. * factorized code from addShape() and insertParticlesFromArray()
  100438. * @param idx particle index in the particles array
  100439. * @param i particle index in its shape
  100440. * @param modelShape particle ModelShape object
  100441. * @param shape shape vertex array
  100442. * @param meshInd shape indices array
  100443. * @param meshUV shape uv array
  100444. * @param meshCol shape color array
  100445. * @param meshNor shape normals array
  100446. * @param bbInfo shape bounding info
  100447. * @param storage target particle storage
  100448. * @options addShape() passed options
  100449. * @hidden
  100450. */
  100451. private _insertNewParticle;
  100452. /**
  100453. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100454. * This method calls `updateParticle()` for each particle of the SPS.
  100455. * For an animated SPS, it is usually called within the render loop.
  100456. * 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.
  100457. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100458. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100459. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100460. * @returns the SPS.
  100461. */
  100462. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100463. /**
  100464. * Disposes the SPS.
  100465. */
  100466. dispose(): void;
  100467. /**
  100468. * Returns a SolidParticle object from its identifier : particle.id
  100469. * @param id (integer) the particle Id
  100470. * @returns the searched particle or null if not found in the SPS.
  100471. */
  100472. getParticleById(id: number): Nullable<SolidParticle>;
  100473. /**
  100474. * Returns a new array populated with the particles having the passed shapeId.
  100475. * @param shapeId (integer) the shape identifier
  100476. * @returns a new solid particle array
  100477. */
  100478. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100479. /**
  100480. * Populates the passed array "ref" with the particles having the passed shapeId.
  100481. * @param shapeId the shape identifier
  100482. * @returns the SPS
  100483. * @param ref
  100484. */
  100485. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100486. /**
  100487. * Computes the required SubMeshes according the materials assigned to the particles.
  100488. * @returns the solid particle system.
  100489. * Does nothing if called before the SPS mesh is built.
  100490. */
  100491. computeSubMeshes(): SolidParticleSystem;
  100492. /**
  100493. * Sorts the solid particles by material when MultiMaterial is enabled.
  100494. * Updates the indices32 array.
  100495. * Updates the indicesByMaterial array.
  100496. * Updates the mesh indices array.
  100497. * @returns the SPS
  100498. * @hidden
  100499. */
  100500. private _sortParticlesByMaterial;
  100501. /**
  100502. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100503. * @hidden
  100504. */
  100505. private _setMaterialIndexesById;
  100506. /**
  100507. * Returns an array with unique values of Materials from the passed array
  100508. * @param array the material array to be checked and filtered
  100509. * @hidden
  100510. */
  100511. private _filterUniqueMaterialId;
  100512. /**
  100513. * Sets a new Standard Material as _defaultMaterial if not already set.
  100514. * @hidden
  100515. */
  100516. private _setDefaultMaterial;
  100517. /**
  100518. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100519. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100520. * @returns the SPS.
  100521. */
  100522. refreshVisibleSize(): SolidParticleSystem;
  100523. /**
  100524. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100525. * @param size the size (float) of the visibility box
  100526. * note : this doesn't lock the SPS mesh bounding box.
  100527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100528. */
  100529. setVisibilityBox(size: number): void;
  100530. /**
  100531. * Gets whether the SPS as always visible or not
  100532. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100533. */
  100534. get isAlwaysVisible(): boolean;
  100535. /**
  100536. * Sets the SPS as always visible or not
  100537. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100538. */
  100539. set isAlwaysVisible(val: boolean);
  100540. /**
  100541. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100543. */
  100544. set isVisibilityBoxLocked(val: boolean);
  100545. /**
  100546. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100548. */
  100549. get isVisibilityBoxLocked(): boolean;
  100550. /**
  100551. * Tells to `setParticles()` to compute the particle rotations or not.
  100552. * Default value : true. The SPS is faster when it's set to false.
  100553. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100554. */
  100555. set computeParticleRotation(val: boolean);
  100556. /**
  100557. * Tells to `setParticles()` to compute the particle colors or not.
  100558. * Default value : true. The SPS is faster when it's set to false.
  100559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100560. */
  100561. set computeParticleColor(val: boolean);
  100562. set computeParticleTexture(val: boolean);
  100563. /**
  100564. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100565. * Default value : false. The SPS is faster when it's set to false.
  100566. * Note : the particle custom vertex positions aren't stored values.
  100567. */
  100568. set computeParticleVertex(val: boolean);
  100569. /**
  100570. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100571. */
  100572. set computeBoundingBox(val: boolean);
  100573. /**
  100574. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100576. * Default : `true`
  100577. */
  100578. set depthSortParticles(val: boolean);
  100579. /**
  100580. * Gets if `setParticles()` computes the particle rotations or not.
  100581. * Default value : true. The SPS is faster when it's set to false.
  100582. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100583. */
  100584. get computeParticleRotation(): boolean;
  100585. /**
  100586. * Gets if `setParticles()` computes the particle colors or not.
  100587. * Default value : true. The SPS is faster when it's set to false.
  100588. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100589. */
  100590. get computeParticleColor(): boolean;
  100591. /**
  100592. * Gets if `setParticles()` computes the particle textures or not.
  100593. * Default value : true. The SPS is faster when it's set to false.
  100594. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100595. */
  100596. get computeParticleTexture(): boolean;
  100597. /**
  100598. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100599. * Default value : false. The SPS is faster when it's set to false.
  100600. * Note : the particle custom vertex positions aren't stored values.
  100601. */
  100602. get computeParticleVertex(): boolean;
  100603. /**
  100604. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100605. */
  100606. get computeBoundingBox(): boolean;
  100607. /**
  100608. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100609. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100610. * Default : `true`
  100611. */
  100612. get depthSortParticles(): boolean;
  100613. /**
  100614. * Gets if the SPS is created as expandable at construction time.
  100615. * Default : `false`
  100616. */
  100617. get expandable(): boolean;
  100618. /**
  100619. * Gets if the SPS supports the Multi Materials
  100620. */
  100621. get multimaterialEnabled(): boolean;
  100622. /**
  100623. * Gets if the SPS uses the model materials for its own multimaterial.
  100624. */
  100625. get useModelMaterial(): boolean;
  100626. /**
  100627. * The SPS used material array.
  100628. */
  100629. get materials(): Material[];
  100630. /**
  100631. * Sets the SPS MultiMaterial from the passed materials.
  100632. * Note : the passed array is internally copied and not used then by reference.
  100633. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100634. */
  100635. setMultiMaterial(materials: Material[]): void;
  100636. /**
  100637. * The SPS computed multimaterial object
  100638. */
  100639. get multimaterial(): MultiMaterial;
  100640. set multimaterial(mm: MultiMaterial);
  100641. /**
  100642. * If the subMeshes must be updated on the next call to setParticles()
  100643. */
  100644. get autoUpdateSubMeshes(): boolean;
  100645. set autoUpdateSubMeshes(val: boolean);
  100646. /**
  100647. * This function does nothing. It may be overwritten to set all the particle first values.
  100648. * The SPS doesn't call this function, you may have to call it by your own.
  100649. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100650. */
  100651. initParticles(): void;
  100652. /**
  100653. * This function does nothing. It may be overwritten to recycle a particle.
  100654. * The SPS doesn't call this function, you may have to call it by your own.
  100655. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100656. * @param particle The particle to recycle
  100657. * @returns the recycled particle
  100658. */
  100659. recycleParticle(particle: SolidParticle): SolidParticle;
  100660. /**
  100661. * Updates a particle : this function should be overwritten by the user.
  100662. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100663. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100664. * @example : just set a particle position or velocity and recycle conditions
  100665. * @param particle The particle to update
  100666. * @returns the updated particle
  100667. */
  100668. updateParticle(particle: SolidParticle): SolidParticle;
  100669. /**
  100670. * Updates a vertex of a particle : it can be overwritten by the user.
  100671. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100672. * @param particle the current particle
  100673. * @param vertex the current index of the current particle
  100674. * @param pt the index of the current vertex in the particle shape
  100675. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100676. * @example : just set a vertex particle position
  100677. * @returns the updated vertex
  100678. */
  100679. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100680. /**
  100681. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100682. * This does nothing and may be overwritten by the user.
  100683. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100684. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100685. * @param update the boolean update value actually passed to setParticles()
  100686. */
  100687. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100688. /**
  100689. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100690. * This will be passed three parameters.
  100691. * This does nothing and may be overwritten by the user.
  100692. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100693. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100694. * @param update the boolean update value actually passed to setParticles()
  100695. */
  100696. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100697. }
  100698. }
  100699. declare module BABYLON {
  100700. /**
  100701. * Represents one particle of a solid particle system.
  100702. */
  100703. export class SolidParticle {
  100704. /**
  100705. * particle global index
  100706. */
  100707. idx: number;
  100708. /**
  100709. * particle identifier
  100710. */
  100711. id: number;
  100712. /**
  100713. * The color of the particle
  100714. */
  100715. color: Nullable<Color4>;
  100716. /**
  100717. * The world space position of the particle.
  100718. */
  100719. position: Vector3;
  100720. /**
  100721. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100722. */
  100723. rotation: Vector3;
  100724. /**
  100725. * The world space rotation quaternion of the particle.
  100726. */
  100727. rotationQuaternion: Nullable<Quaternion>;
  100728. /**
  100729. * The scaling of the particle.
  100730. */
  100731. scaling: Vector3;
  100732. /**
  100733. * The uvs of the particle.
  100734. */
  100735. uvs: Vector4;
  100736. /**
  100737. * The current speed of the particle.
  100738. */
  100739. velocity: Vector3;
  100740. /**
  100741. * The pivot point in the particle local space.
  100742. */
  100743. pivot: Vector3;
  100744. /**
  100745. * Must the particle be translated from its pivot point in its local space ?
  100746. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100747. * Default : false
  100748. */
  100749. translateFromPivot: boolean;
  100750. /**
  100751. * Is the particle active or not ?
  100752. */
  100753. alive: boolean;
  100754. /**
  100755. * Is the particle visible or not ?
  100756. */
  100757. isVisible: boolean;
  100758. /**
  100759. * Index of this particle in the global "positions" array (Internal use)
  100760. * @hidden
  100761. */
  100762. _pos: number;
  100763. /**
  100764. * @hidden Index of this particle in the global "indices" array (Internal use)
  100765. */
  100766. _ind: number;
  100767. /**
  100768. * @hidden ModelShape of this particle (Internal use)
  100769. */
  100770. _model: ModelShape;
  100771. /**
  100772. * ModelShape id of this particle
  100773. */
  100774. shapeId: number;
  100775. /**
  100776. * Index of the particle in its shape id
  100777. */
  100778. idxInShape: number;
  100779. /**
  100780. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100781. */
  100782. _modelBoundingInfo: BoundingInfo;
  100783. /**
  100784. * @hidden Particle BoundingInfo object (Internal use)
  100785. */
  100786. _boundingInfo: BoundingInfo;
  100787. /**
  100788. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100789. */
  100790. _sps: SolidParticleSystem;
  100791. /**
  100792. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100793. */
  100794. _stillInvisible: boolean;
  100795. /**
  100796. * @hidden Last computed particle rotation matrix
  100797. */
  100798. _rotationMatrix: number[];
  100799. /**
  100800. * Parent particle Id, if any.
  100801. * Default null.
  100802. */
  100803. parentId: Nullable<number>;
  100804. /**
  100805. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100806. */
  100807. materialIndex: Nullable<number>;
  100808. /**
  100809. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100810. * The possible values are :
  100811. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100812. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100813. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100815. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100816. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100817. * */
  100818. cullingStrategy: number;
  100819. /**
  100820. * @hidden Internal global position in the SPS.
  100821. */
  100822. _globalPosition: Vector3;
  100823. /**
  100824. * Creates a Solid Particle object.
  100825. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100826. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100827. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100828. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100829. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100830. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100831. * @param shapeId (integer) is the model shape identifier in the SPS.
  100832. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100833. * @param sps defines the sps it is associated to
  100834. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100835. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100836. */
  100837. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100838. /**
  100839. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100840. * @param target the particle target
  100841. * @returns the current particle
  100842. */
  100843. copyToRef(target: SolidParticle): SolidParticle;
  100844. /**
  100845. * Legacy support, changed scale to scaling
  100846. */
  100847. get scale(): Vector3;
  100848. /**
  100849. * Legacy support, changed scale to scaling
  100850. */
  100851. set scale(scale: Vector3);
  100852. /**
  100853. * Legacy support, changed quaternion to rotationQuaternion
  100854. */
  100855. get quaternion(): Nullable<Quaternion>;
  100856. /**
  100857. * Legacy support, changed quaternion to rotationQuaternion
  100858. */
  100859. set quaternion(q: Nullable<Quaternion>);
  100860. /**
  100861. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100862. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100863. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100864. * @returns true if it intersects
  100865. */
  100866. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100867. /**
  100868. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100869. * A particle is in the frustum if its bounding box intersects the frustum
  100870. * @param frustumPlanes defines the frustum to test
  100871. * @returns true if the particle is in the frustum planes
  100872. */
  100873. isInFrustum(frustumPlanes: Plane[]): boolean;
  100874. /**
  100875. * get the rotation matrix of the particle
  100876. * @hidden
  100877. */
  100878. getRotationMatrix(m: Matrix): void;
  100879. }
  100880. /**
  100881. * Represents the shape of the model used by one particle of a solid particle system.
  100882. * SPS internal tool, don't use it manually.
  100883. */
  100884. export class ModelShape {
  100885. /**
  100886. * The shape id
  100887. * @hidden
  100888. */
  100889. shapeID: number;
  100890. /**
  100891. * flat array of model positions (internal use)
  100892. * @hidden
  100893. */
  100894. _shape: Vector3[];
  100895. /**
  100896. * flat array of model UVs (internal use)
  100897. * @hidden
  100898. */
  100899. _shapeUV: number[];
  100900. /**
  100901. * color array of the model
  100902. * @hidden
  100903. */
  100904. _shapeColors: number[];
  100905. /**
  100906. * indices array of the model
  100907. * @hidden
  100908. */
  100909. _indices: number[];
  100910. /**
  100911. * normals array of the model
  100912. * @hidden
  100913. */
  100914. _normals: number[];
  100915. /**
  100916. * length of the shape in the model indices array (internal use)
  100917. * @hidden
  100918. */
  100919. _indicesLength: number;
  100920. /**
  100921. * Custom position function (internal use)
  100922. * @hidden
  100923. */
  100924. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100925. /**
  100926. * Custom vertex function (internal use)
  100927. * @hidden
  100928. */
  100929. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100930. /**
  100931. * Model material (internal use)
  100932. * @hidden
  100933. */
  100934. _material: Nullable<Material>;
  100935. /**
  100936. * 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.
  100937. * SPS internal tool, don't use it manually.
  100938. * @hidden
  100939. */
  100940. 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>);
  100941. }
  100942. /**
  100943. * Represents a Depth Sorted Particle in the solid particle system.
  100944. * @hidden
  100945. */
  100946. export class DepthSortedParticle {
  100947. /**
  100948. * Index of the particle in the "indices" array
  100949. */
  100950. ind: number;
  100951. /**
  100952. * Length of the particle shape in the "indices" array
  100953. */
  100954. indicesLength: number;
  100955. /**
  100956. * Squared distance from the particle to the camera
  100957. */
  100958. sqDistance: number;
  100959. /**
  100960. * Material index when used with MultiMaterials
  100961. */
  100962. materialIndex: number;
  100963. /**
  100964. * Creates a new sorted particle
  100965. * @param materialIndex
  100966. */
  100967. constructor(ind: number, indLength: number, materialIndex: number);
  100968. }
  100969. }
  100970. declare module BABYLON {
  100971. /**
  100972. * @hidden
  100973. */
  100974. export class _MeshCollisionData {
  100975. _checkCollisions: boolean;
  100976. _collisionMask: number;
  100977. _collisionGroup: number;
  100978. _collider: Nullable<Collider>;
  100979. _oldPositionForCollisions: Vector3;
  100980. _diffPositionForCollisions: Vector3;
  100981. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100982. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100983. }
  100984. }
  100985. declare module BABYLON {
  100986. /** @hidden */
  100987. class _FacetDataStorage {
  100988. facetPositions: Vector3[];
  100989. facetNormals: Vector3[];
  100990. facetPartitioning: number[][];
  100991. facetNb: number;
  100992. partitioningSubdivisions: number;
  100993. partitioningBBoxRatio: number;
  100994. facetDataEnabled: boolean;
  100995. facetParameters: any;
  100996. bbSize: Vector3;
  100997. subDiv: {
  100998. max: number;
  100999. X: number;
  101000. Y: number;
  101001. Z: number;
  101002. };
  101003. facetDepthSort: boolean;
  101004. facetDepthSortEnabled: boolean;
  101005. depthSortedIndices: IndicesArray;
  101006. depthSortedFacets: {
  101007. ind: number;
  101008. sqDistance: number;
  101009. }[];
  101010. facetDepthSortFunction: (f1: {
  101011. ind: number;
  101012. sqDistance: number;
  101013. }, f2: {
  101014. ind: number;
  101015. sqDistance: number;
  101016. }) => number;
  101017. facetDepthSortFrom: Vector3;
  101018. facetDepthSortOrigin: Vector3;
  101019. invertedMatrix: Matrix;
  101020. }
  101021. /**
  101022. * @hidden
  101023. **/
  101024. class _InternalAbstractMeshDataInfo {
  101025. _hasVertexAlpha: boolean;
  101026. _useVertexColors: boolean;
  101027. _numBoneInfluencers: number;
  101028. _applyFog: boolean;
  101029. _receiveShadows: boolean;
  101030. _facetData: _FacetDataStorage;
  101031. _visibility: number;
  101032. _skeleton: Nullable<Skeleton>;
  101033. _layerMask: number;
  101034. _computeBonesUsingShaders: boolean;
  101035. _isActive: boolean;
  101036. _onlyForInstances: boolean;
  101037. _isActiveIntermediate: boolean;
  101038. _onlyForInstancesIntermediate: boolean;
  101039. _actAsRegularMesh: boolean;
  101040. }
  101041. /**
  101042. * Class used to store all common mesh properties
  101043. */
  101044. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101045. /** No occlusion */
  101046. static OCCLUSION_TYPE_NONE: number;
  101047. /** Occlusion set to optimisitic */
  101048. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101049. /** Occlusion set to strict */
  101050. static OCCLUSION_TYPE_STRICT: number;
  101051. /** Use an accurante occlusion algorithm */
  101052. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101053. /** Use a conservative occlusion algorithm */
  101054. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101055. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101056. * Test order :
  101057. * Is the bounding sphere outside the frustum ?
  101058. * If not, are the bounding box vertices outside the frustum ?
  101059. * It not, then the cullable object is in the frustum.
  101060. */
  101061. static readonly CULLINGSTRATEGY_STANDARD: number;
  101062. /** Culling strategy : Bounding Sphere Only.
  101063. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101064. * It's also less accurate than the standard because some not visible objects can still be selected.
  101065. * Test : is the bounding sphere outside the frustum ?
  101066. * If not, then the cullable object is in the frustum.
  101067. */
  101068. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101069. /** Culling strategy : Optimistic Inclusion.
  101070. * This in an inclusion test first, then the standard exclusion test.
  101071. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101072. * 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.
  101073. * Anyway, it's as accurate as the standard strategy.
  101074. * Test :
  101075. * Is the cullable object bounding sphere center in the frustum ?
  101076. * If not, apply the default culling strategy.
  101077. */
  101078. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101079. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101080. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101081. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101082. * 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.
  101083. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101084. * Test :
  101085. * Is the cullable object bounding sphere center in the frustum ?
  101086. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101087. */
  101088. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101089. /**
  101090. * No billboard
  101091. */
  101092. static get BILLBOARDMODE_NONE(): number;
  101093. /** Billboard on X axis */
  101094. static get BILLBOARDMODE_X(): number;
  101095. /** Billboard on Y axis */
  101096. static get BILLBOARDMODE_Y(): number;
  101097. /** Billboard on Z axis */
  101098. static get BILLBOARDMODE_Z(): number;
  101099. /** Billboard on all axes */
  101100. static get BILLBOARDMODE_ALL(): number;
  101101. /** Billboard on using position instead of orientation */
  101102. static get BILLBOARDMODE_USE_POSITION(): number;
  101103. /** @hidden */
  101104. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101105. /**
  101106. * The culling strategy to use to check whether the mesh must be rendered or not.
  101107. * This value can be changed at any time and will be used on the next render mesh selection.
  101108. * The possible values are :
  101109. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101110. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101111. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101113. * Please read each static variable documentation to get details about the culling process.
  101114. * */
  101115. cullingStrategy: number;
  101116. /**
  101117. * Gets the number of facets in the mesh
  101118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101119. */
  101120. get facetNb(): number;
  101121. /**
  101122. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101124. */
  101125. get partitioningSubdivisions(): number;
  101126. set partitioningSubdivisions(nb: number);
  101127. /**
  101128. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101129. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101131. */
  101132. get partitioningBBoxRatio(): number;
  101133. set partitioningBBoxRatio(ratio: number);
  101134. /**
  101135. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101136. * Works only for updatable meshes.
  101137. * Doesn't work with multi-materials
  101138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101139. */
  101140. get mustDepthSortFacets(): boolean;
  101141. set mustDepthSortFacets(sort: boolean);
  101142. /**
  101143. * The location (Vector3) where the facet depth sort must be computed from.
  101144. * By default, the active camera position.
  101145. * Used only when facet depth sort is enabled
  101146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101147. */
  101148. get facetDepthSortFrom(): Vector3;
  101149. set facetDepthSortFrom(location: Vector3);
  101150. /**
  101151. * gets a boolean indicating if facetData is enabled
  101152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101153. */
  101154. get isFacetDataEnabled(): boolean;
  101155. /** @hidden */
  101156. _updateNonUniformScalingState(value: boolean): boolean;
  101157. /**
  101158. * An event triggered when this mesh collides with another one
  101159. */
  101160. onCollideObservable: Observable<AbstractMesh>;
  101161. /** Set a function to call when this mesh collides with another one */
  101162. set onCollide(callback: () => void);
  101163. /**
  101164. * An event triggered when the collision's position changes
  101165. */
  101166. onCollisionPositionChangeObservable: Observable<Vector3>;
  101167. /** Set a function to call when the collision's position changes */
  101168. set onCollisionPositionChange(callback: () => void);
  101169. /**
  101170. * An event triggered when material is changed
  101171. */
  101172. onMaterialChangedObservable: Observable<AbstractMesh>;
  101173. /**
  101174. * Gets or sets the orientation for POV movement & rotation
  101175. */
  101176. definedFacingForward: boolean;
  101177. /** @hidden */
  101178. _occlusionQuery: Nullable<WebGLQuery>;
  101179. /** @hidden */
  101180. _renderingGroup: Nullable<RenderingGroup>;
  101181. /**
  101182. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101183. */
  101184. get visibility(): number;
  101185. /**
  101186. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101187. */
  101188. set visibility(value: number);
  101189. /** Gets or sets the alpha index used to sort transparent meshes
  101190. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101191. */
  101192. alphaIndex: number;
  101193. /**
  101194. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101195. */
  101196. isVisible: boolean;
  101197. /**
  101198. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101199. */
  101200. isPickable: boolean;
  101201. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101202. showSubMeshesBoundingBox: boolean;
  101203. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101204. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101205. */
  101206. isBlocker: boolean;
  101207. /**
  101208. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101209. */
  101210. enablePointerMoveEvents: boolean;
  101211. /**
  101212. * Specifies the rendering group id for this mesh (0 by default)
  101213. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101214. */
  101215. renderingGroupId: number;
  101216. private _material;
  101217. /** Gets or sets current material */
  101218. get material(): Nullable<Material>;
  101219. set material(value: Nullable<Material>);
  101220. /**
  101221. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101222. * @see http://doc.babylonjs.com/babylon101/shadows
  101223. */
  101224. get receiveShadows(): boolean;
  101225. set receiveShadows(value: boolean);
  101226. /** Defines color to use when rendering outline */
  101227. outlineColor: Color3;
  101228. /** Define width to use when rendering outline */
  101229. outlineWidth: number;
  101230. /** Defines color to use when rendering overlay */
  101231. overlayColor: Color3;
  101232. /** Defines alpha to use when rendering overlay */
  101233. overlayAlpha: number;
  101234. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101235. get hasVertexAlpha(): boolean;
  101236. set hasVertexAlpha(value: boolean);
  101237. /** 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) */
  101238. get useVertexColors(): boolean;
  101239. set useVertexColors(value: boolean);
  101240. /**
  101241. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101242. */
  101243. get computeBonesUsingShaders(): boolean;
  101244. set computeBonesUsingShaders(value: boolean);
  101245. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101246. get numBoneInfluencers(): number;
  101247. set numBoneInfluencers(value: number);
  101248. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101249. get applyFog(): boolean;
  101250. set applyFog(value: boolean);
  101251. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101252. useOctreeForRenderingSelection: boolean;
  101253. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101254. useOctreeForPicking: boolean;
  101255. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101256. useOctreeForCollisions: boolean;
  101257. /**
  101258. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101259. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101260. */
  101261. get layerMask(): number;
  101262. set layerMask(value: number);
  101263. /**
  101264. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101265. */
  101266. alwaysSelectAsActiveMesh: boolean;
  101267. /**
  101268. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101269. */
  101270. doNotSyncBoundingInfo: boolean;
  101271. /**
  101272. * Gets or sets the current action manager
  101273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101274. */
  101275. actionManager: Nullable<AbstractActionManager>;
  101276. private _meshCollisionData;
  101277. /**
  101278. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101279. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101280. */
  101281. ellipsoid: Vector3;
  101282. /**
  101283. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101285. */
  101286. ellipsoidOffset: Vector3;
  101287. /**
  101288. * Gets or sets a collision mask used to mask collisions (default is -1).
  101289. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101290. */
  101291. get collisionMask(): number;
  101292. set collisionMask(mask: number);
  101293. /**
  101294. * Gets or sets the current collision group mask (-1 by default).
  101295. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101296. */
  101297. get collisionGroup(): number;
  101298. set collisionGroup(mask: number);
  101299. /**
  101300. * Defines edge width used when edgesRenderer is enabled
  101301. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101302. */
  101303. edgesWidth: number;
  101304. /**
  101305. * Defines edge color used when edgesRenderer is enabled
  101306. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101307. */
  101308. edgesColor: Color4;
  101309. /** @hidden */
  101310. _edgesRenderer: Nullable<IEdgesRenderer>;
  101311. /** @hidden */
  101312. _masterMesh: Nullable<AbstractMesh>;
  101313. /** @hidden */
  101314. _boundingInfo: Nullable<BoundingInfo>;
  101315. /** @hidden */
  101316. _renderId: number;
  101317. /**
  101318. * Gets or sets the list of subMeshes
  101319. * @see http://doc.babylonjs.com/how_to/multi_materials
  101320. */
  101321. subMeshes: SubMesh[];
  101322. /** @hidden */
  101323. _intersectionsInProgress: AbstractMesh[];
  101324. /** @hidden */
  101325. _unIndexed: boolean;
  101326. /** @hidden */
  101327. _lightSources: Light[];
  101328. /** Gets the list of lights affecting that mesh */
  101329. get lightSources(): Light[];
  101330. /** @hidden */
  101331. get _positions(): Nullable<Vector3[]>;
  101332. /** @hidden */
  101333. _waitingData: {
  101334. lods: Nullable<any>;
  101335. actions: Nullable<any>;
  101336. freezeWorldMatrix: Nullable<boolean>;
  101337. };
  101338. /** @hidden */
  101339. _bonesTransformMatrices: Nullable<Float32Array>;
  101340. /** @hidden */
  101341. _transformMatrixTexture: Nullable<RawTexture>;
  101342. /**
  101343. * Gets or sets a skeleton to apply skining transformations
  101344. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101345. */
  101346. set skeleton(value: Nullable<Skeleton>);
  101347. get skeleton(): Nullable<Skeleton>;
  101348. /**
  101349. * An event triggered when the mesh is rebuilt.
  101350. */
  101351. onRebuildObservable: Observable<AbstractMesh>;
  101352. /**
  101353. * Creates a new AbstractMesh
  101354. * @param name defines the name of the mesh
  101355. * @param scene defines the hosting scene
  101356. */
  101357. constructor(name: string, scene?: Nullable<Scene>);
  101358. /**
  101359. * Returns the string "AbstractMesh"
  101360. * @returns "AbstractMesh"
  101361. */
  101362. getClassName(): string;
  101363. /**
  101364. * Gets a string representation of the current mesh
  101365. * @param fullDetails defines a boolean indicating if full details must be included
  101366. * @returns a string representation of the current mesh
  101367. */
  101368. toString(fullDetails?: boolean): string;
  101369. /**
  101370. * @hidden
  101371. */
  101372. protected _getEffectiveParent(): Nullable<Node>;
  101373. /** @hidden */
  101374. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101375. /** @hidden */
  101376. _rebuild(): void;
  101377. /** @hidden */
  101378. _resyncLightSources(): void;
  101379. /** @hidden */
  101380. _resyncLightSource(light: Light): void;
  101381. /** @hidden */
  101382. _unBindEffect(): void;
  101383. /** @hidden */
  101384. _removeLightSource(light: Light, dispose: boolean): void;
  101385. private _markSubMeshesAsDirty;
  101386. /** @hidden */
  101387. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101388. /** @hidden */
  101389. _markSubMeshesAsAttributesDirty(): void;
  101390. /** @hidden */
  101391. _markSubMeshesAsMiscDirty(): void;
  101392. /**
  101393. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101394. */
  101395. get scaling(): Vector3;
  101396. set scaling(newScaling: Vector3);
  101397. /**
  101398. * Returns true if the mesh is blocked. Implemented by child classes
  101399. */
  101400. get isBlocked(): boolean;
  101401. /**
  101402. * Returns the mesh itself by default. Implemented by child classes
  101403. * @param camera defines the camera to use to pick the right LOD level
  101404. * @returns the currentAbstractMesh
  101405. */
  101406. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101407. /**
  101408. * Returns 0 by default. Implemented by child classes
  101409. * @returns an integer
  101410. */
  101411. getTotalVertices(): number;
  101412. /**
  101413. * Returns a positive integer : the total number of indices in this mesh geometry.
  101414. * @returns the numner of indices or zero if the mesh has no geometry.
  101415. */
  101416. getTotalIndices(): number;
  101417. /**
  101418. * Returns null by default. Implemented by child classes
  101419. * @returns null
  101420. */
  101421. getIndices(): Nullable<IndicesArray>;
  101422. /**
  101423. * Returns the array of the requested vertex data kind. Implemented by child classes
  101424. * @param kind defines the vertex data kind to use
  101425. * @returns null
  101426. */
  101427. getVerticesData(kind: string): Nullable<FloatArray>;
  101428. /**
  101429. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101430. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101431. * Note that a new underlying VertexBuffer object is created each call.
  101432. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101433. * @param kind defines vertex data kind:
  101434. * * VertexBuffer.PositionKind
  101435. * * VertexBuffer.UVKind
  101436. * * VertexBuffer.UV2Kind
  101437. * * VertexBuffer.UV3Kind
  101438. * * VertexBuffer.UV4Kind
  101439. * * VertexBuffer.UV5Kind
  101440. * * VertexBuffer.UV6Kind
  101441. * * VertexBuffer.ColorKind
  101442. * * VertexBuffer.MatricesIndicesKind
  101443. * * VertexBuffer.MatricesIndicesExtraKind
  101444. * * VertexBuffer.MatricesWeightsKind
  101445. * * VertexBuffer.MatricesWeightsExtraKind
  101446. * @param data defines the data source
  101447. * @param updatable defines if the data must be flagged as updatable (or static)
  101448. * @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
  101449. * @returns the current mesh
  101450. */
  101451. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101452. /**
  101453. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101454. * If the mesh has no geometry, it is simply returned as it is.
  101455. * @param kind defines vertex data kind:
  101456. * * VertexBuffer.PositionKind
  101457. * * VertexBuffer.UVKind
  101458. * * VertexBuffer.UV2Kind
  101459. * * VertexBuffer.UV3Kind
  101460. * * VertexBuffer.UV4Kind
  101461. * * VertexBuffer.UV5Kind
  101462. * * VertexBuffer.UV6Kind
  101463. * * VertexBuffer.ColorKind
  101464. * * VertexBuffer.MatricesIndicesKind
  101465. * * VertexBuffer.MatricesIndicesExtraKind
  101466. * * VertexBuffer.MatricesWeightsKind
  101467. * * VertexBuffer.MatricesWeightsExtraKind
  101468. * @param data defines the data source
  101469. * @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
  101470. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101471. * @returns the current mesh
  101472. */
  101473. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101474. /**
  101475. * Sets the mesh indices,
  101476. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101477. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101478. * @param totalVertices Defines the total number of vertices
  101479. * @returns the current mesh
  101480. */
  101481. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101482. /**
  101483. * Gets a boolean indicating if specific vertex data is present
  101484. * @param kind defines the vertex data kind to use
  101485. * @returns true is data kind is present
  101486. */
  101487. isVerticesDataPresent(kind: string): boolean;
  101488. /**
  101489. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101490. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101491. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101492. * @returns a BoundingInfo
  101493. */
  101494. getBoundingInfo(): BoundingInfo;
  101495. /**
  101496. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101497. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101498. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101499. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101500. * @returns the current mesh
  101501. */
  101502. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101503. /**
  101504. * Overwrite the current bounding info
  101505. * @param boundingInfo defines the new bounding info
  101506. * @returns the current mesh
  101507. */
  101508. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101509. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101510. get useBones(): boolean;
  101511. /** @hidden */
  101512. _preActivate(): void;
  101513. /** @hidden */
  101514. _preActivateForIntermediateRendering(renderId: number): void;
  101515. /** @hidden */
  101516. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101517. /** @hidden */
  101518. _postActivate(): void;
  101519. /** @hidden */
  101520. _freeze(): void;
  101521. /** @hidden */
  101522. _unFreeze(): void;
  101523. /**
  101524. * Gets the current world matrix
  101525. * @returns a Matrix
  101526. */
  101527. getWorldMatrix(): Matrix;
  101528. /** @hidden */
  101529. _getWorldMatrixDeterminant(): number;
  101530. /**
  101531. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101532. */
  101533. get isAnInstance(): boolean;
  101534. /**
  101535. * Gets a boolean indicating if this mesh has instances
  101536. */
  101537. get hasInstances(): boolean;
  101538. /**
  101539. * Perform relative position change from the point of view of behind the front of the mesh.
  101540. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101541. * Supports definition of mesh facing forward or backward
  101542. * @param amountRight defines the distance on the right axis
  101543. * @param amountUp defines the distance on the up axis
  101544. * @param amountForward defines the distance on the forward axis
  101545. * @returns the current mesh
  101546. */
  101547. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101548. /**
  101549. * Calculate relative position change from the point of view of behind the front of the mesh.
  101550. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101551. * Supports definition of mesh facing forward or backward
  101552. * @param amountRight defines the distance on the right axis
  101553. * @param amountUp defines the distance on the up axis
  101554. * @param amountForward defines the distance on the forward axis
  101555. * @returns the new displacement vector
  101556. */
  101557. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101558. /**
  101559. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101560. * Supports definition of mesh facing forward or backward
  101561. * @param flipBack defines the flip
  101562. * @param twirlClockwise defines the twirl
  101563. * @param tiltRight defines the tilt
  101564. * @returns the current mesh
  101565. */
  101566. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101567. /**
  101568. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101569. * Supports definition of mesh facing forward or backward.
  101570. * @param flipBack defines the flip
  101571. * @param twirlClockwise defines the twirl
  101572. * @param tiltRight defines the tilt
  101573. * @returns the new rotation vector
  101574. */
  101575. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101576. /**
  101577. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101578. * This means the mesh underlying bounding box and sphere are recomputed.
  101579. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101580. * @returns the current mesh
  101581. */
  101582. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101583. /** @hidden */
  101584. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101585. /** @hidden */
  101586. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101587. /** @hidden */
  101588. _updateBoundingInfo(): AbstractMesh;
  101589. /** @hidden */
  101590. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101591. /** @hidden */
  101592. protected _afterComputeWorldMatrix(): void;
  101593. /** @hidden */
  101594. get _effectiveMesh(): AbstractMesh;
  101595. /**
  101596. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101597. * A mesh is in the frustum if its bounding box intersects the frustum
  101598. * @param frustumPlanes defines the frustum to test
  101599. * @returns true if the mesh is in the frustum planes
  101600. */
  101601. isInFrustum(frustumPlanes: Plane[]): boolean;
  101602. /**
  101603. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101604. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101605. * @param frustumPlanes defines the frustum to test
  101606. * @returns true if the mesh is completely in the frustum planes
  101607. */
  101608. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101609. /**
  101610. * True if the mesh intersects another mesh or a SolidParticle object
  101611. * @param mesh defines a target mesh or SolidParticle to test
  101612. * @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)
  101613. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101614. * @returns true if there is an intersection
  101615. */
  101616. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101617. /**
  101618. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101619. * @param point defines the point to test
  101620. * @returns true if there is an intersection
  101621. */
  101622. intersectsPoint(point: Vector3): boolean;
  101623. /**
  101624. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101626. */
  101627. get checkCollisions(): boolean;
  101628. set checkCollisions(collisionEnabled: boolean);
  101629. /**
  101630. * Gets Collider object used to compute collisions (not physics)
  101631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101632. */
  101633. get collider(): Nullable<Collider>;
  101634. /**
  101635. * Move the mesh using collision engine
  101636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101637. * @param displacement defines the requested displacement vector
  101638. * @returns the current mesh
  101639. */
  101640. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101641. private _onCollisionPositionChange;
  101642. /** @hidden */
  101643. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101644. /** @hidden */
  101645. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101646. /** @hidden */
  101647. _checkCollision(collider: Collider): AbstractMesh;
  101648. /** @hidden */
  101649. _generatePointsArray(): boolean;
  101650. /**
  101651. * Checks if the passed Ray intersects with the mesh
  101652. * @param ray defines the ray to use
  101653. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101654. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101655. * @returns the picking info
  101656. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101657. */
  101658. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101659. /**
  101660. * Clones the current mesh
  101661. * @param name defines the mesh name
  101662. * @param newParent defines the new mesh parent
  101663. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101664. * @returns the new mesh
  101665. */
  101666. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101667. /**
  101668. * Disposes all the submeshes of the current meshnp
  101669. * @returns the current mesh
  101670. */
  101671. releaseSubMeshes(): AbstractMesh;
  101672. /**
  101673. * Releases resources associated with this abstract mesh.
  101674. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101675. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101676. */
  101677. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101678. /**
  101679. * Adds the passed mesh as a child to the current mesh
  101680. * @param mesh defines the child mesh
  101681. * @returns the current mesh
  101682. */
  101683. addChild(mesh: AbstractMesh): AbstractMesh;
  101684. /**
  101685. * Removes the passed mesh from the current mesh children list
  101686. * @param mesh defines the child mesh
  101687. * @returns the current mesh
  101688. */
  101689. removeChild(mesh: AbstractMesh): AbstractMesh;
  101690. /** @hidden */
  101691. private _initFacetData;
  101692. /**
  101693. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101694. * This method can be called within the render loop.
  101695. * 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
  101696. * @returns the current mesh
  101697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101698. */
  101699. updateFacetData(): AbstractMesh;
  101700. /**
  101701. * Returns the facetLocalNormals array.
  101702. * The normals are expressed in the mesh local spac
  101703. * @returns an array of Vector3
  101704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101705. */
  101706. getFacetLocalNormals(): Vector3[];
  101707. /**
  101708. * Returns the facetLocalPositions array.
  101709. * The facet positions are expressed in the mesh local space
  101710. * @returns an array of Vector3
  101711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101712. */
  101713. getFacetLocalPositions(): Vector3[];
  101714. /**
  101715. * Returns the facetLocalPartioning array
  101716. * @returns an array of array of numbers
  101717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101718. */
  101719. getFacetLocalPartitioning(): number[][];
  101720. /**
  101721. * Returns the i-th facet position in the world system.
  101722. * This method allocates a new Vector3 per call
  101723. * @param i defines the facet index
  101724. * @returns a new Vector3
  101725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101726. */
  101727. getFacetPosition(i: number): Vector3;
  101728. /**
  101729. * Sets the reference Vector3 with the i-th facet position in the world system
  101730. * @param i defines the facet index
  101731. * @param ref defines the target vector
  101732. * @returns the current mesh
  101733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101734. */
  101735. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101736. /**
  101737. * Returns the i-th facet normal in the world system.
  101738. * This method allocates a new Vector3 per call
  101739. * @param i defines the facet index
  101740. * @returns a new Vector3
  101741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101742. */
  101743. getFacetNormal(i: number): Vector3;
  101744. /**
  101745. * Sets the reference Vector3 with the i-th facet normal in the world system
  101746. * @param i defines the facet index
  101747. * @param ref defines the target vector
  101748. * @returns the current mesh
  101749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101750. */
  101751. getFacetNormalToRef(i: number, ref: Vector3): this;
  101752. /**
  101753. * 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)
  101754. * @param x defines x coordinate
  101755. * @param y defines y coordinate
  101756. * @param z defines z coordinate
  101757. * @returns the array of facet indexes
  101758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101759. */
  101760. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101761. /**
  101762. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101763. * @param projected sets as the (x,y,z) world projection on the facet
  101764. * @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
  101765. * @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
  101766. * @param x defines x coordinate
  101767. * @param y defines y coordinate
  101768. * @param z defines z coordinate
  101769. * @returns the face index if found (or null instead)
  101770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101771. */
  101772. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101773. /**
  101774. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101775. * @param projected sets as the (x,y,z) local projection on the facet
  101776. * @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
  101777. * @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
  101778. * @param x defines x coordinate
  101779. * @param y defines y coordinate
  101780. * @param z defines z coordinate
  101781. * @returns the face index if found (or null instead)
  101782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101783. */
  101784. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101785. /**
  101786. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101787. * @returns the parameters
  101788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101789. */
  101790. getFacetDataParameters(): any;
  101791. /**
  101792. * Disables the feature FacetData and frees the related memory
  101793. * @returns the current mesh
  101794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101795. */
  101796. disableFacetData(): AbstractMesh;
  101797. /**
  101798. * Updates the AbstractMesh indices array
  101799. * @param indices defines the data source
  101800. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101801. * @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)
  101802. * @returns the current mesh
  101803. */
  101804. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101805. /**
  101806. * Creates new normals data for the mesh
  101807. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101808. * @returns the current mesh
  101809. */
  101810. createNormals(updatable: boolean): AbstractMesh;
  101811. /**
  101812. * Align the mesh with a normal
  101813. * @param normal defines the normal to use
  101814. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101815. * @returns the current mesh
  101816. */
  101817. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101818. /** @hidden */
  101819. _checkOcclusionQuery(): boolean;
  101820. /**
  101821. * Disables the mesh edge rendering mode
  101822. * @returns the currentAbstractMesh
  101823. */
  101824. disableEdgesRendering(): AbstractMesh;
  101825. /**
  101826. * Enables the edge rendering mode on the mesh.
  101827. * This mode makes the mesh edges visible
  101828. * @param epsilon defines the maximal distance between two angles to detect a face
  101829. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101830. * @returns the currentAbstractMesh
  101831. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101832. */
  101833. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101834. }
  101835. }
  101836. declare module BABYLON {
  101837. /**
  101838. * Interface used to define ActionEvent
  101839. */
  101840. export interface IActionEvent {
  101841. /** The mesh or sprite that triggered the action */
  101842. source: any;
  101843. /** The X mouse cursor position at the time of the event */
  101844. pointerX: number;
  101845. /** The Y mouse cursor position at the time of the event */
  101846. pointerY: number;
  101847. /** The mesh that is currently pointed at (can be null) */
  101848. meshUnderPointer: Nullable<AbstractMesh>;
  101849. /** the original (browser) event that triggered the ActionEvent */
  101850. sourceEvent?: any;
  101851. /** additional data for the event */
  101852. additionalData?: any;
  101853. }
  101854. /**
  101855. * ActionEvent is the event being sent when an action is triggered.
  101856. */
  101857. export class ActionEvent implements IActionEvent {
  101858. /** The mesh or sprite that triggered the action */
  101859. source: any;
  101860. /** The X mouse cursor position at the time of the event */
  101861. pointerX: number;
  101862. /** The Y mouse cursor position at the time of the event */
  101863. pointerY: number;
  101864. /** The mesh that is currently pointed at (can be null) */
  101865. meshUnderPointer: Nullable<AbstractMesh>;
  101866. /** the original (browser) event that triggered the ActionEvent */
  101867. sourceEvent?: any;
  101868. /** additional data for the event */
  101869. additionalData?: any;
  101870. /**
  101871. * Creates a new ActionEvent
  101872. * @param source The mesh or sprite that triggered the action
  101873. * @param pointerX The X mouse cursor position at the time of the event
  101874. * @param pointerY The Y mouse cursor position at the time of the event
  101875. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101876. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101877. * @param additionalData additional data for the event
  101878. */
  101879. constructor(
  101880. /** The mesh or sprite that triggered the action */
  101881. source: any,
  101882. /** The X mouse cursor position at the time of the event */
  101883. pointerX: number,
  101884. /** The Y mouse cursor position at the time of the event */
  101885. pointerY: number,
  101886. /** The mesh that is currently pointed at (can be null) */
  101887. meshUnderPointer: Nullable<AbstractMesh>,
  101888. /** the original (browser) event that triggered the ActionEvent */
  101889. sourceEvent?: any,
  101890. /** additional data for the event */
  101891. additionalData?: any);
  101892. /**
  101893. * Helper function to auto-create an ActionEvent from a source mesh.
  101894. * @param source The source mesh that triggered the event
  101895. * @param evt The original (browser) event
  101896. * @param additionalData additional data for the event
  101897. * @returns the new ActionEvent
  101898. */
  101899. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101900. /**
  101901. * Helper function to auto-create an ActionEvent from a source sprite
  101902. * @param source The source sprite that triggered the event
  101903. * @param scene Scene associated with the sprite
  101904. * @param evt The original (browser) event
  101905. * @param additionalData additional data for the event
  101906. * @returns the new ActionEvent
  101907. */
  101908. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101909. /**
  101910. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101911. * @param scene the scene where the event occurred
  101912. * @param evt The original (browser) event
  101913. * @returns the new ActionEvent
  101914. */
  101915. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101916. /**
  101917. * Helper function to auto-create an ActionEvent from a primitive
  101918. * @param prim defines the target primitive
  101919. * @param pointerPos defines the pointer position
  101920. * @param evt The original (browser) event
  101921. * @param additionalData additional data for the event
  101922. * @returns the new ActionEvent
  101923. */
  101924. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101925. }
  101926. }
  101927. declare module BABYLON {
  101928. /**
  101929. * Abstract class used to decouple action Manager from scene and meshes.
  101930. * Do not instantiate.
  101931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101932. */
  101933. export abstract class AbstractActionManager implements IDisposable {
  101934. /** Gets the list of active triggers */
  101935. static Triggers: {
  101936. [key: string]: number;
  101937. };
  101938. /** Gets the cursor to use when hovering items */
  101939. hoverCursor: string;
  101940. /** Gets the list of actions */
  101941. actions: IAction[];
  101942. /**
  101943. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101944. */
  101945. isRecursive: boolean;
  101946. /**
  101947. * Releases all associated resources
  101948. */
  101949. abstract dispose(): void;
  101950. /**
  101951. * Does this action manager has pointer triggers
  101952. */
  101953. abstract get hasPointerTriggers(): boolean;
  101954. /**
  101955. * Does this action manager has pick triggers
  101956. */
  101957. abstract get hasPickTriggers(): boolean;
  101958. /**
  101959. * Process a specific trigger
  101960. * @param trigger defines the trigger to process
  101961. * @param evt defines the event details to be processed
  101962. */
  101963. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101964. /**
  101965. * Does this action manager handles actions of any of the given triggers
  101966. * @param triggers defines the triggers to be tested
  101967. * @return a boolean indicating whether one (or more) of the triggers is handled
  101968. */
  101969. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101970. /**
  101971. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101972. * speed.
  101973. * @param triggerA defines the trigger to be tested
  101974. * @param triggerB defines the trigger to be tested
  101975. * @return a boolean indicating whether one (or more) of the triggers is handled
  101976. */
  101977. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101978. /**
  101979. * Does this action manager handles actions of a given trigger
  101980. * @param trigger defines the trigger to be tested
  101981. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101982. * @return whether the trigger is handled
  101983. */
  101984. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101985. /**
  101986. * Serialize this manager to a JSON object
  101987. * @param name defines the property name to store this manager
  101988. * @returns a JSON representation of this manager
  101989. */
  101990. abstract serialize(name: string): any;
  101991. /**
  101992. * Registers an action to this action manager
  101993. * @param action defines the action to be registered
  101994. * @return the action amended (prepared) after registration
  101995. */
  101996. abstract registerAction(action: IAction): Nullable<IAction>;
  101997. /**
  101998. * Unregisters an action to this action manager
  101999. * @param action defines the action to be unregistered
  102000. * @return a boolean indicating whether the action has been unregistered
  102001. */
  102002. abstract unregisterAction(action: IAction): Boolean;
  102003. /**
  102004. * Does exist one action manager with at least one trigger
  102005. **/
  102006. static get HasTriggers(): boolean;
  102007. /**
  102008. * Does exist one action manager with at least one pick trigger
  102009. **/
  102010. static get HasPickTriggers(): boolean;
  102011. /**
  102012. * Does exist one action manager that handles actions of a given trigger
  102013. * @param trigger defines the trigger to be tested
  102014. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102015. **/
  102016. static HasSpecificTrigger(trigger: number): boolean;
  102017. }
  102018. }
  102019. declare module BABYLON {
  102020. /**
  102021. * Defines how a node can be built from a string name.
  102022. */
  102023. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102024. /**
  102025. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102026. */
  102027. export class Node implements IBehaviorAware<Node> {
  102028. /** @hidden */
  102029. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102030. private static _NodeConstructors;
  102031. /**
  102032. * Add a new node constructor
  102033. * @param type defines the type name of the node to construct
  102034. * @param constructorFunc defines the constructor function
  102035. */
  102036. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102037. /**
  102038. * Returns a node constructor based on type name
  102039. * @param type defines the type name
  102040. * @param name defines the new node name
  102041. * @param scene defines the hosting scene
  102042. * @param options defines optional options to transmit to constructors
  102043. * @returns the new constructor or null
  102044. */
  102045. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102046. /**
  102047. * Gets or sets the name of the node
  102048. */
  102049. name: string;
  102050. /**
  102051. * Gets or sets the id of the node
  102052. */
  102053. id: string;
  102054. /**
  102055. * Gets or sets the unique id of the node
  102056. */
  102057. uniqueId: number;
  102058. /**
  102059. * Gets or sets a string used to store user defined state for the node
  102060. */
  102061. state: string;
  102062. /**
  102063. * Gets or sets an object used to store user defined information for the node
  102064. */
  102065. metadata: any;
  102066. /**
  102067. * For internal use only. Please do not use.
  102068. */
  102069. reservedDataStore: any;
  102070. /**
  102071. * List of inspectable custom properties (used by the Inspector)
  102072. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102073. */
  102074. inspectableCustomProperties: IInspectable[];
  102075. private _doNotSerialize;
  102076. /**
  102077. * Gets or sets a boolean used to define if the node must be serialized
  102078. */
  102079. get doNotSerialize(): boolean;
  102080. set doNotSerialize(value: boolean);
  102081. /** @hidden */
  102082. _isDisposed: boolean;
  102083. /**
  102084. * Gets a list of Animations associated with the node
  102085. */
  102086. animations: Animation[];
  102087. protected _ranges: {
  102088. [name: string]: Nullable<AnimationRange>;
  102089. };
  102090. /**
  102091. * Callback raised when the node is ready to be used
  102092. */
  102093. onReady: Nullable<(node: Node) => void>;
  102094. private _isEnabled;
  102095. private _isParentEnabled;
  102096. private _isReady;
  102097. /** @hidden */
  102098. _currentRenderId: number;
  102099. private _parentUpdateId;
  102100. /** @hidden */
  102101. _childUpdateId: number;
  102102. /** @hidden */
  102103. _waitingParentId: Nullable<string>;
  102104. /** @hidden */
  102105. _scene: Scene;
  102106. /** @hidden */
  102107. _cache: any;
  102108. private _parentNode;
  102109. private _children;
  102110. /** @hidden */
  102111. _worldMatrix: Matrix;
  102112. /** @hidden */
  102113. _worldMatrixDeterminant: number;
  102114. /** @hidden */
  102115. _worldMatrixDeterminantIsDirty: boolean;
  102116. /** @hidden */
  102117. private _sceneRootNodesIndex;
  102118. /**
  102119. * Gets a boolean indicating if the node has been disposed
  102120. * @returns true if the node was disposed
  102121. */
  102122. isDisposed(): boolean;
  102123. /**
  102124. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102125. * @see https://doc.babylonjs.com/how_to/parenting
  102126. */
  102127. set parent(parent: Nullable<Node>);
  102128. get parent(): Nullable<Node>;
  102129. /** @hidden */
  102130. _addToSceneRootNodes(): void;
  102131. /** @hidden */
  102132. _removeFromSceneRootNodes(): void;
  102133. private _animationPropertiesOverride;
  102134. /**
  102135. * Gets or sets the animation properties override
  102136. */
  102137. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102138. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102139. /**
  102140. * Gets a string idenfifying the name of the class
  102141. * @returns "Node" string
  102142. */
  102143. getClassName(): string;
  102144. /** @hidden */
  102145. readonly _isNode: boolean;
  102146. /**
  102147. * An event triggered when the mesh is disposed
  102148. */
  102149. onDisposeObservable: Observable<Node>;
  102150. private _onDisposeObserver;
  102151. /**
  102152. * Sets a callback that will be raised when the node will be disposed
  102153. */
  102154. set onDispose(callback: () => void);
  102155. /**
  102156. * Creates a new Node
  102157. * @param name the name and id to be given to this node
  102158. * @param scene the scene this node will be added to
  102159. */
  102160. constructor(name: string, scene?: Nullable<Scene>);
  102161. /**
  102162. * Gets the scene of the node
  102163. * @returns a scene
  102164. */
  102165. getScene(): Scene;
  102166. /**
  102167. * Gets the engine of the node
  102168. * @returns a Engine
  102169. */
  102170. getEngine(): Engine;
  102171. private _behaviors;
  102172. /**
  102173. * Attach a behavior to the node
  102174. * @see http://doc.babylonjs.com/features/behaviour
  102175. * @param behavior defines the behavior to attach
  102176. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102177. * @returns the current Node
  102178. */
  102179. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102180. /**
  102181. * Remove an attached behavior
  102182. * @see http://doc.babylonjs.com/features/behaviour
  102183. * @param behavior defines the behavior to attach
  102184. * @returns the current Node
  102185. */
  102186. removeBehavior(behavior: Behavior<Node>): Node;
  102187. /**
  102188. * Gets the list of attached behaviors
  102189. * @see http://doc.babylonjs.com/features/behaviour
  102190. */
  102191. get behaviors(): Behavior<Node>[];
  102192. /**
  102193. * Gets an attached behavior by name
  102194. * @param name defines the name of the behavior to look for
  102195. * @see http://doc.babylonjs.com/features/behaviour
  102196. * @returns null if behavior was not found else the requested behavior
  102197. */
  102198. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102199. /**
  102200. * Returns the latest update of the World matrix
  102201. * @returns a Matrix
  102202. */
  102203. getWorldMatrix(): Matrix;
  102204. /** @hidden */
  102205. _getWorldMatrixDeterminant(): number;
  102206. /**
  102207. * Returns directly the latest state of the mesh World matrix.
  102208. * A Matrix is returned.
  102209. */
  102210. get worldMatrixFromCache(): Matrix;
  102211. /** @hidden */
  102212. _initCache(): void;
  102213. /** @hidden */
  102214. updateCache(force?: boolean): void;
  102215. /** @hidden */
  102216. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102217. /** @hidden */
  102218. _updateCache(ignoreParentClass?: boolean): void;
  102219. /** @hidden */
  102220. _isSynchronized(): boolean;
  102221. /** @hidden */
  102222. _markSyncedWithParent(): void;
  102223. /** @hidden */
  102224. isSynchronizedWithParent(): boolean;
  102225. /** @hidden */
  102226. isSynchronized(): boolean;
  102227. /**
  102228. * Is this node ready to be used/rendered
  102229. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102230. * @return true if the node is ready
  102231. */
  102232. isReady(completeCheck?: boolean): boolean;
  102233. /**
  102234. * Is this node enabled?
  102235. * 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
  102236. * @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
  102237. * @return whether this node (and its parent) is enabled
  102238. */
  102239. isEnabled(checkAncestors?: boolean): boolean;
  102240. /** @hidden */
  102241. protected _syncParentEnabledState(): void;
  102242. /**
  102243. * Set the enabled state of this node
  102244. * @param value defines the new enabled state
  102245. */
  102246. setEnabled(value: boolean): void;
  102247. /**
  102248. * Is this node a descendant of the given node?
  102249. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102250. * @param ancestor defines the parent node to inspect
  102251. * @returns a boolean indicating if this node is a descendant of the given node
  102252. */
  102253. isDescendantOf(ancestor: Node): boolean;
  102254. /** @hidden */
  102255. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102256. /**
  102257. * Will return all nodes that have this node as ascendant
  102258. * @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
  102259. * @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
  102260. * @return all children nodes of all types
  102261. */
  102262. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102263. /**
  102264. * Get all child-meshes of this node
  102265. * @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)
  102266. * @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
  102267. * @returns an array of AbstractMesh
  102268. */
  102269. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102270. /**
  102271. * Get all direct children of this node
  102272. * @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
  102273. * @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)
  102274. * @returns an array of Node
  102275. */
  102276. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102277. /** @hidden */
  102278. _setReady(state: boolean): void;
  102279. /**
  102280. * Get an animation by name
  102281. * @param name defines the name of the animation to look for
  102282. * @returns null if not found else the requested animation
  102283. */
  102284. getAnimationByName(name: string): Nullable<Animation>;
  102285. /**
  102286. * Creates an animation range for this node
  102287. * @param name defines the name of the range
  102288. * @param from defines the starting key
  102289. * @param to defines the end key
  102290. */
  102291. createAnimationRange(name: string, from: number, to: number): void;
  102292. /**
  102293. * Delete a specific animation range
  102294. * @param name defines the name of the range to delete
  102295. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102296. */
  102297. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102298. /**
  102299. * Get an animation range by name
  102300. * @param name defines the name of the animation range to look for
  102301. * @returns null if not found else the requested animation range
  102302. */
  102303. getAnimationRange(name: string): Nullable<AnimationRange>;
  102304. /**
  102305. * Gets the list of all animation ranges defined on this node
  102306. * @returns an array
  102307. */
  102308. getAnimationRanges(): Nullable<AnimationRange>[];
  102309. /**
  102310. * Will start the animation sequence
  102311. * @param name defines the range frames for animation sequence
  102312. * @param loop defines if the animation should loop (false by default)
  102313. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102314. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102315. * @returns the object created for this animation. If range does not exist, it will return null
  102316. */
  102317. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102318. /**
  102319. * Serialize animation ranges into a JSON compatible object
  102320. * @returns serialization object
  102321. */
  102322. serializeAnimationRanges(): any;
  102323. /**
  102324. * Computes the world matrix of the node
  102325. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102326. * @returns the world matrix
  102327. */
  102328. computeWorldMatrix(force?: boolean): Matrix;
  102329. /**
  102330. * Releases resources associated with this node.
  102331. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102332. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102333. */
  102334. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102335. /**
  102336. * Parse animation range data from a serialization object and store them into a given node
  102337. * @param node defines where to store the animation ranges
  102338. * @param parsedNode defines the serialization object to read data from
  102339. * @param scene defines the hosting scene
  102340. */
  102341. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102342. /**
  102343. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102344. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102345. * @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
  102346. * @returns the new bounding vectors
  102347. */
  102348. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102349. min: Vector3;
  102350. max: Vector3;
  102351. };
  102352. }
  102353. }
  102354. declare module BABYLON {
  102355. /**
  102356. * @hidden
  102357. */
  102358. export class _IAnimationState {
  102359. key: number;
  102360. repeatCount: number;
  102361. workValue?: any;
  102362. loopMode?: number;
  102363. offsetValue?: any;
  102364. highLimitValue?: any;
  102365. }
  102366. /**
  102367. * Class used to store any kind of animation
  102368. */
  102369. export class Animation {
  102370. /**Name of the animation */
  102371. name: string;
  102372. /**Property to animate */
  102373. targetProperty: string;
  102374. /**The frames per second of the animation */
  102375. framePerSecond: number;
  102376. /**The data type of the animation */
  102377. dataType: number;
  102378. /**The loop mode of the animation */
  102379. loopMode?: number | undefined;
  102380. /**Specifies if blending should be enabled */
  102381. enableBlending?: boolean | undefined;
  102382. /**
  102383. * Use matrix interpolation instead of using direct key value when animating matrices
  102384. */
  102385. static AllowMatricesInterpolation: boolean;
  102386. /**
  102387. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102388. */
  102389. static AllowMatrixDecomposeForInterpolation: boolean;
  102390. /**
  102391. * Stores the key frames of the animation
  102392. */
  102393. private _keys;
  102394. /**
  102395. * Stores the easing function of the animation
  102396. */
  102397. private _easingFunction;
  102398. /**
  102399. * @hidden Internal use only
  102400. */
  102401. _runtimeAnimations: RuntimeAnimation[];
  102402. /**
  102403. * The set of event that will be linked to this animation
  102404. */
  102405. private _events;
  102406. /**
  102407. * Stores an array of target property paths
  102408. */
  102409. targetPropertyPath: string[];
  102410. /**
  102411. * Stores the blending speed of the animation
  102412. */
  102413. blendingSpeed: number;
  102414. /**
  102415. * Stores the animation ranges for the animation
  102416. */
  102417. private _ranges;
  102418. /**
  102419. * @hidden Internal use
  102420. */
  102421. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102422. /**
  102423. * Sets up an animation
  102424. * @param property The property to animate
  102425. * @param animationType The animation type to apply
  102426. * @param framePerSecond The frames per second of the animation
  102427. * @param easingFunction The easing function used in the animation
  102428. * @returns The created animation
  102429. */
  102430. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102431. /**
  102432. * Create and start an animation on a node
  102433. * @param name defines the name of the global animation that will be run on all nodes
  102434. * @param node defines the root node where the animation will take place
  102435. * @param targetProperty defines property to animate
  102436. * @param framePerSecond defines the number of frame per second yo use
  102437. * @param totalFrame defines the number of frames in total
  102438. * @param from defines the initial value
  102439. * @param to defines the final value
  102440. * @param loopMode defines which loop mode you want to use (off by default)
  102441. * @param easingFunction defines the easing function to use (linear by default)
  102442. * @param onAnimationEnd defines the callback to call when animation end
  102443. * @returns the animatable created for this animation
  102444. */
  102445. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102446. /**
  102447. * Create and start an animation on a node and its descendants
  102448. * @param name defines the name of the global animation that will be run on all nodes
  102449. * @param node defines the root node where the animation will take place
  102450. * @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
  102451. * @param targetProperty defines property to animate
  102452. * @param framePerSecond defines the number of frame per second to use
  102453. * @param totalFrame defines the number of frames in total
  102454. * @param from defines the initial value
  102455. * @param to defines the final value
  102456. * @param loopMode defines which loop mode you want to use (off by default)
  102457. * @param easingFunction defines the easing function to use (linear by default)
  102458. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102459. * @returns the list of animatables created for all nodes
  102460. * @example https://www.babylonjs-playground.com/#MH0VLI
  102461. */
  102462. 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[]>;
  102463. /**
  102464. * Creates a new animation, merges it with the existing animations and starts it
  102465. * @param name Name of the animation
  102466. * @param node Node which contains the scene that begins the animations
  102467. * @param targetProperty Specifies which property to animate
  102468. * @param framePerSecond The frames per second of the animation
  102469. * @param totalFrame The total number of frames
  102470. * @param from The frame at the beginning of the animation
  102471. * @param to The frame at the end of the animation
  102472. * @param loopMode Specifies the loop mode of the animation
  102473. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102474. * @param onAnimationEnd Callback to run once the animation is complete
  102475. * @returns Nullable animation
  102476. */
  102477. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102478. /**
  102479. * Transition property of an host to the target Value
  102480. * @param property The property to transition
  102481. * @param targetValue The target Value of the property
  102482. * @param host The object where the property to animate belongs
  102483. * @param scene Scene used to run the animation
  102484. * @param frameRate Framerate (in frame/s) to use
  102485. * @param transition The transition type we want to use
  102486. * @param duration The duration of the animation, in milliseconds
  102487. * @param onAnimationEnd Callback trigger at the end of the animation
  102488. * @returns Nullable animation
  102489. */
  102490. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102491. /**
  102492. * Return the array of runtime animations currently using this animation
  102493. */
  102494. get runtimeAnimations(): RuntimeAnimation[];
  102495. /**
  102496. * Specifies if any of the runtime animations are currently running
  102497. */
  102498. get hasRunningRuntimeAnimations(): boolean;
  102499. /**
  102500. * Initializes the animation
  102501. * @param name Name of the animation
  102502. * @param targetProperty Property to animate
  102503. * @param framePerSecond The frames per second of the animation
  102504. * @param dataType The data type of the animation
  102505. * @param loopMode The loop mode of the animation
  102506. * @param enableBlending Specifies if blending should be enabled
  102507. */
  102508. constructor(
  102509. /**Name of the animation */
  102510. name: string,
  102511. /**Property to animate */
  102512. targetProperty: string,
  102513. /**The frames per second of the animation */
  102514. framePerSecond: number,
  102515. /**The data type of the animation */
  102516. dataType: number,
  102517. /**The loop mode of the animation */
  102518. loopMode?: number | undefined,
  102519. /**Specifies if blending should be enabled */
  102520. enableBlending?: boolean | undefined);
  102521. /**
  102522. * Converts the animation to a string
  102523. * @param fullDetails support for multiple levels of logging within scene loading
  102524. * @returns String form of the animation
  102525. */
  102526. toString(fullDetails?: boolean): string;
  102527. /**
  102528. * Add an event to this animation
  102529. * @param event Event to add
  102530. */
  102531. addEvent(event: AnimationEvent): void;
  102532. /**
  102533. * Remove all events found at the given frame
  102534. * @param frame The frame to remove events from
  102535. */
  102536. removeEvents(frame: number): void;
  102537. /**
  102538. * Retrieves all the events from the animation
  102539. * @returns Events from the animation
  102540. */
  102541. getEvents(): AnimationEvent[];
  102542. /**
  102543. * Creates an animation range
  102544. * @param name Name of the animation range
  102545. * @param from Starting frame of the animation range
  102546. * @param to Ending frame of the animation
  102547. */
  102548. createRange(name: string, from: number, to: number): void;
  102549. /**
  102550. * Deletes an animation range by name
  102551. * @param name Name of the animation range to delete
  102552. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102553. */
  102554. deleteRange(name: string, deleteFrames?: boolean): void;
  102555. /**
  102556. * Gets the animation range by name, or null if not defined
  102557. * @param name Name of the animation range
  102558. * @returns Nullable animation range
  102559. */
  102560. getRange(name: string): Nullable<AnimationRange>;
  102561. /**
  102562. * Gets the key frames from the animation
  102563. * @returns The key frames of the animation
  102564. */
  102565. getKeys(): Array<IAnimationKey>;
  102566. /**
  102567. * Gets the highest frame rate of the animation
  102568. * @returns Highest frame rate of the animation
  102569. */
  102570. getHighestFrame(): number;
  102571. /**
  102572. * Gets the easing function of the animation
  102573. * @returns Easing function of the animation
  102574. */
  102575. getEasingFunction(): IEasingFunction;
  102576. /**
  102577. * Sets the easing function of the animation
  102578. * @param easingFunction A custom mathematical formula for animation
  102579. */
  102580. setEasingFunction(easingFunction: EasingFunction): void;
  102581. /**
  102582. * Interpolates a scalar linearly
  102583. * @param startValue Start value of the animation curve
  102584. * @param endValue End value of the animation curve
  102585. * @param gradient Scalar amount to interpolate
  102586. * @returns Interpolated scalar value
  102587. */
  102588. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102589. /**
  102590. * Interpolates a scalar cubically
  102591. * @param startValue Start value of the animation curve
  102592. * @param outTangent End tangent of the animation
  102593. * @param endValue End value of the animation curve
  102594. * @param inTangent Start tangent of the animation curve
  102595. * @param gradient Scalar amount to interpolate
  102596. * @returns Interpolated scalar value
  102597. */
  102598. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102599. /**
  102600. * Interpolates a quaternion using a spherical linear interpolation
  102601. * @param startValue Start value of the animation curve
  102602. * @param endValue End value of the animation curve
  102603. * @param gradient Scalar amount to interpolate
  102604. * @returns Interpolated quaternion value
  102605. */
  102606. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102607. /**
  102608. * Interpolates a quaternion cubically
  102609. * @param startValue Start value of the animation curve
  102610. * @param outTangent End tangent of the animation curve
  102611. * @param endValue End value of the animation curve
  102612. * @param inTangent Start tangent of the animation curve
  102613. * @param gradient Scalar amount to interpolate
  102614. * @returns Interpolated quaternion value
  102615. */
  102616. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102617. /**
  102618. * Interpolates a Vector3 linearl
  102619. * @param startValue Start value of the animation curve
  102620. * @param endValue End value of the animation curve
  102621. * @param gradient Scalar amount to interpolate
  102622. * @returns Interpolated scalar value
  102623. */
  102624. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102625. /**
  102626. * Interpolates a Vector3 cubically
  102627. * @param startValue Start value of the animation curve
  102628. * @param outTangent End tangent of the animation
  102629. * @param endValue End value of the animation curve
  102630. * @param inTangent Start tangent of the animation curve
  102631. * @param gradient Scalar amount to interpolate
  102632. * @returns InterpolatedVector3 value
  102633. */
  102634. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102635. /**
  102636. * Interpolates a Vector2 linearly
  102637. * @param startValue Start value of the animation curve
  102638. * @param endValue End value of the animation curve
  102639. * @param gradient Scalar amount to interpolate
  102640. * @returns Interpolated Vector2 value
  102641. */
  102642. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102643. /**
  102644. * Interpolates a Vector2 cubically
  102645. * @param startValue Start value of the animation curve
  102646. * @param outTangent End tangent of the animation
  102647. * @param endValue End value of the animation curve
  102648. * @param inTangent Start tangent of the animation curve
  102649. * @param gradient Scalar amount to interpolate
  102650. * @returns Interpolated Vector2 value
  102651. */
  102652. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102653. /**
  102654. * Interpolates a size linearly
  102655. * @param startValue Start value of the animation curve
  102656. * @param endValue End value of the animation curve
  102657. * @param gradient Scalar amount to interpolate
  102658. * @returns Interpolated Size value
  102659. */
  102660. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102661. /**
  102662. * Interpolates a Color3 linearly
  102663. * @param startValue Start value of the animation curve
  102664. * @param endValue End value of the animation curve
  102665. * @param gradient Scalar amount to interpolate
  102666. * @returns Interpolated Color3 value
  102667. */
  102668. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102669. /**
  102670. * Interpolates a Color4 linearly
  102671. * @param startValue Start value of the animation curve
  102672. * @param endValue End value of the animation curve
  102673. * @param gradient Scalar amount to interpolate
  102674. * @returns Interpolated Color3 value
  102675. */
  102676. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102677. /**
  102678. * @hidden Internal use only
  102679. */
  102680. _getKeyValue(value: any): any;
  102681. /**
  102682. * @hidden Internal use only
  102683. */
  102684. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102685. /**
  102686. * Defines the function to use to interpolate matrices
  102687. * @param startValue defines the start matrix
  102688. * @param endValue defines the end matrix
  102689. * @param gradient defines the gradient between both matrices
  102690. * @param result defines an optional target matrix where to store the interpolation
  102691. * @returns the interpolated matrix
  102692. */
  102693. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102694. /**
  102695. * Makes a copy of the animation
  102696. * @returns Cloned animation
  102697. */
  102698. clone(): Animation;
  102699. /**
  102700. * Sets the key frames of the animation
  102701. * @param values The animation key frames to set
  102702. */
  102703. setKeys(values: Array<IAnimationKey>): void;
  102704. /**
  102705. * Serializes the animation to an object
  102706. * @returns Serialized object
  102707. */
  102708. serialize(): any;
  102709. /**
  102710. * Float animation type
  102711. */
  102712. static readonly ANIMATIONTYPE_FLOAT: number;
  102713. /**
  102714. * Vector3 animation type
  102715. */
  102716. static readonly ANIMATIONTYPE_VECTOR3: number;
  102717. /**
  102718. * Quaternion animation type
  102719. */
  102720. static readonly ANIMATIONTYPE_QUATERNION: number;
  102721. /**
  102722. * Matrix animation type
  102723. */
  102724. static readonly ANIMATIONTYPE_MATRIX: number;
  102725. /**
  102726. * Color3 animation type
  102727. */
  102728. static readonly ANIMATIONTYPE_COLOR3: number;
  102729. /**
  102730. * Color3 animation type
  102731. */
  102732. static readonly ANIMATIONTYPE_COLOR4: number;
  102733. /**
  102734. * Vector2 animation type
  102735. */
  102736. static readonly ANIMATIONTYPE_VECTOR2: number;
  102737. /**
  102738. * Size animation type
  102739. */
  102740. static readonly ANIMATIONTYPE_SIZE: number;
  102741. /**
  102742. * Relative Loop Mode
  102743. */
  102744. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102745. /**
  102746. * Cycle Loop Mode
  102747. */
  102748. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102749. /**
  102750. * Constant Loop Mode
  102751. */
  102752. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102753. /** @hidden */
  102754. static _UniversalLerp(left: any, right: any, amount: number): any;
  102755. /**
  102756. * Parses an animation object and creates an animation
  102757. * @param parsedAnimation Parsed animation object
  102758. * @returns Animation object
  102759. */
  102760. static Parse(parsedAnimation: any): Animation;
  102761. /**
  102762. * Appends the serialized animations from the source animations
  102763. * @param source Source containing the animations
  102764. * @param destination Target to store the animations
  102765. */
  102766. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102767. }
  102768. }
  102769. declare module BABYLON {
  102770. /**
  102771. * Interface containing an array of animations
  102772. */
  102773. export interface IAnimatable {
  102774. /**
  102775. * Array of animations
  102776. */
  102777. animations: Nullable<Array<Animation>>;
  102778. }
  102779. }
  102780. declare module BABYLON {
  102781. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102782. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102783. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102784. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102785. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102786. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102787. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102788. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102789. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102790. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102791. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102792. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102793. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102794. /**
  102795. * Decorator used to define property that can be serialized as reference to a camera
  102796. * @param sourceName defines the name of the property to decorate
  102797. */
  102798. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102799. /**
  102800. * Class used to help serialization objects
  102801. */
  102802. export class SerializationHelper {
  102803. /** @hidden */
  102804. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102805. /** @hidden */
  102806. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102807. /** @hidden */
  102808. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102809. /** @hidden */
  102810. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102811. /**
  102812. * Appends the serialized animations from the source animations
  102813. * @param source Source containing the animations
  102814. * @param destination Target to store the animations
  102815. */
  102816. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102817. /**
  102818. * Static function used to serialized a specific entity
  102819. * @param entity defines the entity to serialize
  102820. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102821. * @returns a JSON compatible object representing the serialization of the entity
  102822. */
  102823. static Serialize<T>(entity: T, serializationObject?: any): any;
  102824. /**
  102825. * Creates a new entity from a serialization data object
  102826. * @param creationFunction defines a function used to instanciated the new entity
  102827. * @param source defines the source serialization data
  102828. * @param scene defines the hosting scene
  102829. * @param rootUrl defines the root url for resources
  102830. * @returns a new entity
  102831. */
  102832. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102833. /**
  102834. * Clones an object
  102835. * @param creationFunction defines the function used to instanciate the new object
  102836. * @param source defines the source object
  102837. * @returns the cloned object
  102838. */
  102839. static Clone<T>(creationFunction: () => T, source: T): T;
  102840. /**
  102841. * Instanciates a new object based on a source one (some data will be shared between both object)
  102842. * @param creationFunction defines the function used to instanciate the new object
  102843. * @param source defines the source object
  102844. * @returns the new object
  102845. */
  102846. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102847. }
  102848. }
  102849. declare module BABYLON {
  102850. /**
  102851. * Class used to manipulate GUIDs
  102852. */
  102853. export class GUID {
  102854. /**
  102855. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102856. * Be aware Math.random() could cause collisions, but:
  102857. * "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"
  102858. * @returns a pseudo random id
  102859. */
  102860. static RandomId(): string;
  102861. }
  102862. }
  102863. declare module BABYLON {
  102864. /**
  102865. * Base class of all the textures in babylon.
  102866. * It groups all the common properties the materials, post process, lights... might need
  102867. * in order to make a correct use of the texture.
  102868. */
  102869. export class BaseTexture implements IAnimatable {
  102870. /**
  102871. * Default anisotropic filtering level for the application.
  102872. * It is set to 4 as a good tradeoff between perf and quality.
  102873. */
  102874. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102875. /**
  102876. * Gets or sets the unique id of the texture
  102877. */
  102878. uniqueId: number;
  102879. /**
  102880. * Define the name of the texture.
  102881. */
  102882. name: string;
  102883. /**
  102884. * Gets or sets an object used to store user defined information.
  102885. */
  102886. metadata: any;
  102887. /**
  102888. * For internal use only. Please do not use.
  102889. */
  102890. reservedDataStore: any;
  102891. private _hasAlpha;
  102892. /**
  102893. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102894. */
  102895. set hasAlpha(value: boolean);
  102896. get hasAlpha(): boolean;
  102897. /**
  102898. * Defines if the alpha value should be determined via the rgb values.
  102899. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102900. */
  102901. getAlphaFromRGB: boolean;
  102902. /**
  102903. * Intensity or strength of the texture.
  102904. * It is commonly used by materials to fine tune the intensity of the texture
  102905. */
  102906. level: number;
  102907. /**
  102908. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102909. * This is part of the texture as textures usually maps to one uv set.
  102910. */
  102911. coordinatesIndex: number;
  102912. private _coordinatesMode;
  102913. /**
  102914. * How a texture is mapped.
  102915. *
  102916. * | Value | Type | Description |
  102917. * | ----- | ----------------------------------- | ----------- |
  102918. * | 0 | EXPLICIT_MODE | |
  102919. * | 1 | SPHERICAL_MODE | |
  102920. * | 2 | PLANAR_MODE | |
  102921. * | 3 | CUBIC_MODE | |
  102922. * | 4 | PROJECTION_MODE | |
  102923. * | 5 | SKYBOX_MODE | |
  102924. * | 6 | INVCUBIC_MODE | |
  102925. * | 7 | EQUIRECTANGULAR_MODE | |
  102926. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102927. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102928. */
  102929. set coordinatesMode(value: number);
  102930. get coordinatesMode(): number;
  102931. /**
  102932. * | Value | Type | Description |
  102933. * | ----- | ------------------ | ----------- |
  102934. * | 0 | CLAMP_ADDRESSMODE | |
  102935. * | 1 | WRAP_ADDRESSMODE | |
  102936. * | 2 | MIRROR_ADDRESSMODE | |
  102937. */
  102938. wrapU: number;
  102939. /**
  102940. * | Value | Type | Description |
  102941. * | ----- | ------------------ | ----------- |
  102942. * | 0 | CLAMP_ADDRESSMODE | |
  102943. * | 1 | WRAP_ADDRESSMODE | |
  102944. * | 2 | MIRROR_ADDRESSMODE | |
  102945. */
  102946. wrapV: number;
  102947. /**
  102948. * | Value | Type | Description |
  102949. * | ----- | ------------------ | ----------- |
  102950. * | 0 | CLAMP_ADDRESSMODE | |
  102951. * | 1 | WRAP_ADDRESSMODE | |
  102952. * | 2 | MIRROR_ADDRESSMODE | |
  102953. */
  102954. wrapR: number;
  102955. /**
  102956. * With compliant hardware and browser (supporting anisotropic filtering)
  102957. * this defines the level of anisotropic filtering in the texture.
  102958. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102959. */
  102960. anisotropicFilteringLevel: number;
  102961. /**
  102962. * Define if the texture is a cube texture or if false a 2d texture.
  102963. */
  102964. get isCube(): boolean;
  102965. set isCube(value: boolean);
  102966. /**
  102967. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102968. */
  102969. get is3D(): boolean;
  102970. set is3D(value: boolean);
  102971. /**
  102972. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102973. */
  102974. get is2DArray(): boolean;
  102975. set is2DArray(value: boolean);
  102976. /**
  102977. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102978. * HDR texture are usually stored in linear space.
  102979. * This only impacts the PBR and Background materials
  102980. */
  102981. gammaSpace: boolean;
  102982. /**
  102983. * Gets or sets whether or not the texture contains RGBD data.
  102984. */
  102985. get isRGBD(): boolean;
  102986. set isRGBD(value: boolean);
  102987. /**
  102988. * Is Z inverted in the texture (useful in a cube texture).
  102989. */
  102990. invertZ: boolean;
  102991. /**
  102992. * Are mip maps generated for this texture or not.
  102993. */
  102994. get noMipmap(): boolean;
  102995. /**
  102996. * @hidden
  102997. */
  102998. lodLevelInAlpha: boolean;
  102999. /**
  103000. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103001. */
  103002. get lodGenerationOffset(): number;
  103003. set lodGenerationOffset(value: number);
  103004. /**
  103005. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103006. */
  103007. get lodGenerationScale(): number;
  103008. set lodGenerationScale(value: number);
  103009. /**
  103010. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103011. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103012. * average roughness values.
  103013. */
  103014. get linearSpecularLOD(): boolean;
  103015. set linearSpecularLOD(value: boolean);
  103016. /**
  103017. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103018. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103019. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103020. */
  103021. get irradianceTexture(): Nullable<BaseTexture>;
  103022. set irradianceTexture(value: Nullable<BaseTexture>);
  103023. /**
  103024. * Define if the texture is a render target.
  103025. */
  103026. isRenderTarget: boolean;
  103027. /**
  103028. * Define the unique id of the texture in the scene.
  103029. */
  103030. get uid(): string;
  103031. /**
  103032. * Return a string representation of the texture.
  103033. * @returns the texture as a string
  103034. */
  103035. toString(): string;
  103036. /**
  103037. * Get the class name of the texture.
  103038. * @returns "BaseTexture"
  103039. */
  103040. getClassName(): string;
  103041. /**
  103042. * Define the list of animation attached to the texture.
  103043. */
  103044. animations: Animation[];
  103045. /**
  103046. * An event triggered when the texture is disposed.
  103047. */
  103048. onDisposeObservable: Observable<BaseTexture>;
  103049. private _onDisposeObserver;
  103050. /**
  103051. * Callback triggered when the texture has been disposed.
  103052. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103053. */
  103054. set onDispose(callback: () => void);
  103055. /**
  103056. * Define the current state of the loading sequence when in delayed load mode.
  103057. */
  103058. delayLoadState: number;
  103059. private _scene;
  103060. /** @hidden */
  103061. _texture: Nullable<InternalTexture>;
  103062. private _uid;
  103063. /**
  103064. * Define if the texture is preventinga material to render or not.
  103065. * If not and the texture is not ready, the engine will use a default black texture instead.
  103066. */
  103067. get isBlocking(): boolean;
  103068. /**
  103069. * Instantiates a new BaseTexture.
  103070. * Base class of all the textures in babylon.
  103071. * It groups all the common properties the materials, post process, lights... might need
  103072. * in order to make a correct use of the texture.
  103073. * @param scene Define the scene the texture blongs to
  103074. */
  103075. constructor(scene: Nullable<Scene>);
  103076. /**
  103077. * Get the scene the texture belongs to.
  103078. * @returns the scene or null if undefined
  103079. */
  103080. getScene(): Nullable<Scene>;
  103081. /**
  103082. * Get the texture transform matrix used to offset tile the texture for istance.
  103083. * @returns the transformation matrix
  103084. */
  103085. getTextureMatrix(): Matrix;
  103086. /**
  103087. * Get the texture reflection matrix used to rotate/transform the reflection.
  103088. * @returns the reflection matrix
  103089. */
  103090. getReflectionTextureMatrix(): Matrix;
  103091. /**
  103092. * Get the underlying lower level texture from Babylon.
  103093. * @returns the insternal texture
  103094. */
  103095. getInternalTexture(): Nullable<InternalTexture>;
  103096. /**
  103097. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103098. * @returns true if ready or not blocking
  103099. */
  103100. isReadyOrNotBlocking(): boolean;
  103101. /**
  103102. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103103. * @returns true if fully ready
  103104. */
  103105. isReady(): boolean;
  103106. private _cachedSize;
  103107. /**
  103108. * Get the size of the texture.
  103109. * @returns the texture size.
  103110. */
  103111. getSize(): ISize;
  103112. /**
  103113. * Get the base size of the texture.
  103114. * It can be different from the size if the texture has been resized for POT for instance
  103115. * @returns the base size
  103116. */
  103117. getBaseSize(): ISize;
  103118. /**
  103119. * Update the sampling mode of the texture.
  103120. * Default is Trilinear mode.
  103121. *
  103122. * | Value | Type | Description |
  103123. * | ----- | ------------------ | ----------- |
  103124. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103125. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103126. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103127. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103128. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103129. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103130. * | 7 | NEAREST_LINEAR | |
  103131. * | 8 | NEAREST_NEAREST | |
  103132. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103133. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103134. * | 11 | LINEAR_LINEAR | |
  103135. * | 12 | LINEAR_NEAREST | |
  103136. *
  103137. * > _mag_: magnification filter (close to the viewer)
  103138. * > _min_: minification filter (far from the viewer)
  103139. * > _mip_: filter used between mip map levels
  103140. *@param samplingMode Define the new sampling mode of the texture
  103141. */
  103142. updateSamplingMode(samplingMode: number): void;
  103143. /**
  103144. * Scales the texture if is `canRescale()`
  103145. * @param ratio the resize factor we want to use to rescale
  103146. */
  103147. scale(ratio: number): void;
  103148. /**
  103149. * Get if the texture can rescale.
  103150. */
  103151. get canRescale(): boolean;
  103152. /** @hidden */
  103153. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103154. /** @hidden */
  103155. _rebuild(): void;
  103156. /**
  103157. * Triggers the load sequence in delayed load mode.
  103158. */
  103159. delayLoad(): void;
  103160. /**
  103161. * Clones the texture.
  103162. * @returns the cloned texture
  103163. */
  103164. clone(): Nullable<BaseTexture>;
  103165. /**
  103166. * Get the texture underlying type (INT, FLOAT...)
  103167. */
  103168. get textureType(): number;
  103169. /**
  103170. * Get the texture underlying format (RGB, RGBA...)
  103171. */
  103172. get textureFormat(): number;
  103173. /**
  103174. * Indicates that textures need to be re-calculated for all materials
  103175. */
  103176. protected _markAllSubMeshesAsTexturesDirty(): void;
  103177. /**
  103178. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103179. * This will returns an RGBA array buffer containing either in values (0-255) or
  103180. * float values (0-1) depending of the underlying buffer type.
  103181. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103182. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103183. * @param buffer defines a user defined buffer to fill with data (can be null)
  103184. * @returns The Array buffer containing the pixels data.
  103185. */
  103186. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103187. /**
  103188. * Release and destroy the underlying lower level texture aka internalTexture.
  103189. */
  103190. releaseInternalTexture(): void;
  103191. /** @hidden */
  103192. get _lodTextureHigh(): Nullable<BaseTexture>;
  103193. /** @hidden */
  103194. get _lodTextureMid(): Nullable<BaseTexture>;
  103195. /** @hidden */
  103196. get _lodTextureLow(): Nullable<BaseTexture>;
  103197. /**
  103198. * Dispose the texture and release its associated resources.
  103199. */
  103200. dispose(): void;
  103201. /**
  103202. * Serialize the texture into a JSON representation that can be parsed later on.
  103203. * @returns the JSON representation of the texture
  103204. */
  103205. serialize(): any;
  103206. /**
  103207. * Helper function to be called back once a list of texture contains only ready textures.
  103208. * @param textures Define the list of textures to wait for
  103209. * @param callback Define the callback triggered once the entire list will be ready
  103210. */
  103211. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103212. }
  103213. }
  103214. declare module BABYLON {
  103215. /**
  103216. * Options to be used when creating an effect.
  103217. */
  103218. export interface IEffectCreationOptions {
  103219. /**
  103220. * Atrributes that will be used in the shader.
  103221. */
  103222. attributes: string[];
  103223. /**
  103224. * Uniform varible names that will be set in the shader.
  103225. */
  103226. uniformsNames: string[];
  103227. /**
  103228. * Uniform buffer variable names that will be set in the shader.
  103229. */
  103230. uniformBuffersNames: string[];
  103231. /**
  103232. * Sampler texture variable names that will be set in the shader.
  103233. */
  103234. samplers: string[];
  103235. /**
  103236. * Define statements that will be set in the shader.
  103237. */
  103238. defines: any;
  103239. /**
  103240. * Possible fallbacks for this effect to improve performance when needed.
  103241. */
  103242. fallbacks: Nullable<IEffectFallbacks>;
  103243. /**
  103244. * Callback that will be called when the shader is compiled.
  103245. */
  103246. onCompiled: Nullable<(effect: Effect) => void>;
  103247. /**
  103248. * Callback that will be called if an error occurs during shader compilation.
  103249. */
  103250. onError: Nullable<(effect: Effect, errors: string) => void>;
  103251. /**
  103252. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103253. */
  103254. indexParameters?: any;
  103255. /**
  103256. * Max number of lights that can be used in the shader.
  103257. */
  103258. maxSimultaneousLights?: number;
  103259. /**
  103260. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103261. */
  103262. transformFeedbackVaryings?: Nullable<string[]>;
  103263. }
  103264. /**
  103265. * Effect containing vertex and fragment shader that can be executed on an object.
  103266. */
  103267. export class Effect implements IDisposable {
  103268. /**
  103269. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103270. */
  103271. static ShadersRepository: string;
  103272. /**
  103273. * Name of the effect.
  103274. */
  103275. name: any;
  103276. /**
  103277. * String container all the define statements that should be set on the shader.
  103278. */
  103279. defines: string;
  103280. /**
  103281. * Callback that will be called when the shader is compiled.
  103282. */
  103283. onCompiled: Nullable<(effect: Effect) => void>;
  103284. /**
  103285. * Callback that will be called if an error occurs during shader compilation.
  103286. */
  103287. onError: Nullable<(effect: Effect, errors: string) => void>;
  103288. /**
  103289. * Callback that will be called when effect is bound.
  103290. */
  103291. onBind: Nullable<(effect: Effect) => void>;
  103292. /**
  103293. * Unique ID of the effect.
  103294. */
  103295. uniqueId: number;
  103296. /**
  103297. * Observable that will be called when the shader is compiled.
  103298. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103299. */
  103300. onCompileObservable: Observable<Effect>;
  103301. /**
  103302. * Observable that will be called if an error occurs during shader compilation.
  103303. */
  103304. onErrorObservable: Observable<Effect>;
  103305. /** @hidden */
  103306. _onBindObservable: Nullable<Observable<Effect>>;
  103307. /**
  103308. * @hidden
  103309. * Specifies if the effect was previously ready
  103310. */
  103311. _wasPreviouslyReady: boolean;
  103312. /**
  103313. * Observable that will be called when effect is bound.
  103314. */
  103315. get onBindObservable(): Observable<Effect>;
  103316. /** @hidden */
  103317. _bonesComputationForcedToCPU: boolean;
  103318. private static _uniqueIdSeed;
  103319. private _engine;
  103320. private _uniformBuffersNames;
  103321. private _uniformsNames;
  103322. private _samplerList;
  103323. private _samplers;
  103324. private _isReady;
  103325. private _compilationError;
  103326. private _allFallbacksProcessed;
  103327. private _attributesNames;
  103328. private _attributes;
  103329. private _attributeLocationByName;
  103330. private _uniforms;
  103331. /**
  103332. * Key for the effect.
  103333. * @hidden
  103334. */
  103335. _key: string;
  103336. private _indexParameters;
  103337. private _fallbacks;
  103338. private _vertexSourceCode;
  103339. private _fragmentSourceCode;
  103340. private _vertexSourceCodeOverride;
  103341. private _fragmentSourceCodeOverride;
  103342. private _transformFeedbackVaryings;
  103343. /**
  103344. * Compiled shader to webGL program.
  103345. * @hidden
  103346. */
  103347. _pipelineContext: Nullable<IPipelineContext>;
  103348. private _valueCache;
  103349. private static _baseCache;
  103350. /**
  103351. * Instantiates an effect.
  103352. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103353. * @param baseName Name of the effect.
  103354. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103355. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103356. * @param samplers List of sampler variables that will be passed to the shader.
  103357. * @param engine Engine to be used to render the effect
  103358. * @param defines Define statements to be added to the shader.
  103359. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103360. * @param onCompiled Callback that will be called when the shader is compiled.
  103361. * @param onError Callback that will be called if an error occurs during shader compilation.
  103362. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103363. */
  103364. 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);
  103365. private _useFinalCode;
  103366. /**
  103367. * Unique key for this effect
  103368. */
  103369. get key(): string;
  103370. /**
  103371. * If the effect has been compiled and prepared.
  103372. * @returns if the effect is compiled and prepared.
  103373. */
  103374. isReady(): boolean;
  103375. private _isReadyInternal;
  103376. /**
  103377. * The engine the effect was initialized with.
  103378. * @returns the engine.
  103379. */
  103380. getEngine(): Engine;
  103381. /**
  103382. * The pipeline context for this effect
  103383. * @returns the associated pipeline context
  103384. */
  103385. getPipelineContext(): Nullable<IPipelineContext>;
  103386. /**
  103387. * The set of names of attribute variables for the shader.
  103388. * @returns An array of attribute names.
  103389. */
  103390. getAttributesNames(): string[];
  103391. /**
  103392. * Returns the attribute at the given index.
  103393. * @param index The index of the attribute.
  103394. * @returns The location of the attribute.
  103395. */
  103396. getAttributeLocation(index: number): number;
  103397. /**
  103398. * Returns the attribute based on the name of the variable.
  103399. * @param name of the attribute to look up.
  103400. * @returns the attribute location.
  103401. */
  103402. getAttributeLocationByName(name: string): number;
  103403. /**
  103404. * The number of attributes.
  103405. * @returns the numnber of attributes.
  103406. */
  103407. getAttributesCount(): number;
  103408. /**
  103409. * Gets the index of a uniform variable.
  103410. * @param uniformName of the uniform to look up.
  103411. * @returns the index.
  103412. */
  103413. getUniformIndex(uniformName: string): number;
  103414. /**
  103415. * Returns the attribute based on the name of the variable.
  103416. * @param uniformName of the uniform to look up.
  103417. * @returns the location of the uniform.
  103418. */
  103419. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103420. /**
  103421. * Returns an array of sampler variable names
  103422. * @returns The array of sampler variable neames.
  103423. */
  103424. getSamplers(): string[];
  103425. /**
  103426. * The error from the last compilation.
  103427. * @returns the error string.
  103428. */
  103429. getCompilationError(): string;
  103430. /**
  103431. * Gets a boolean indicating that all fallbacks were used during compilation
  103432. * @returns true if all fallbacks were used
  103433. */
  103434. allFallbacksProcessed(): boolean;
  103435. /**
  103436. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103437. * @param func The callback to be used.
  103438. */
  103439. executeWhenCompiled(func: (effect: Effect) => void): void;
  103440. private _checkIsReady;
  103441. private _loadShader;
  103442. /**
  103443. * Recompiles the webGL program
  103444. * @param vertexSourceCode The source code for the vertex shader.
  103445. * @param fragmentSourceCode The source code for the fragment shader.
  103446. * @param onCompiled Callback called when completed.
  103447. * @param onError Callback called on error.
  103448. * @hidden
  103449. */
  103450. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103451. /**
  103452. * Prepares the effect
  103453. * @hidden
  103454. */
  103455. _prepareEffect(): void;
  103456. private _processCompilationErrors;
  103457. /**
  103458. * Checks if the effect is supported. (Must be called after compilation)
  103459. */
  103460. get isSupported(): boolean;
  103461. /**
  103462. * Binds a texture to the engine to be used as output of the shader.
  103463. * @param channel Name of the output variable.
  103464. * @param texture Texture to bind.
  103465. * @hidden
  103466. */
  103467. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103468. /**
  103469. * Sets a texture on the engine to be used in the shader.
  103470. * @param channel Name of the sampler variable.
  103471. * @param texture Texture to set.
  103472. */
  103473. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103474. /**
  103475. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103476. * @param channel Name of the sampler variable.
  103477. * @param texture Texture to set.
  103478. */
  103479. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103480. /**
  103481. * Sets an array of textures on the engine to be used in the shader.
  103482. * @param channel Name of the variable.
  103483. * @param textures Textures to set.
  103484. */
  103485. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103486. /**
  103487. * 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)
  103488. * @param channel Name of the sampler variable.
  103489. * @param postProcess Post process to get the input texture from.
  103490. */
  103491. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103492. /**
  103493. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103494. * 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)
  103495. * @param channel Name of the sampler variable.
  103496. * @param postProcess Post process to get the output texture from.
  103497. */
  103498. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103499. /** @hidden */
  103500. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103501. /** @hidden */
  103502. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103503. /** @hidden */
  103504. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103505. /** @hidden */
  103506. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103507. /**
  103508. * Binds a buffer to a uniform.
  103509. * @param buffer Buffer to bind.
  103510. * @param name Name of the uniform variable to bind to.
  103511. */
  103512. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103513. /**
  103514. * Binds block to a uniform.
  103515. * @param blockName Name of the block to bind.
  103516. * @param index Index to bind.
  103517. */
  103518. bindUniformBlock(blockName: string, index: number): void;
  103519. /**
  103520. * Sets an interger value on a uniform variable.
  103521. * @param uniformName Name of the variable.
  103522. * @param value Value to be set.
  103523. * @returns this effect.
  103524. */
  103525. setInt(uniformName: string, value: number): Effect;
  103526. /**
  103527. * Sets an int array on a uniform variable.
  103528. * @param uniformName Name of the variable.
  103529. * @param array array to be set.
  103530. * @returns this effect.
  103531. */
  103532. setIntArray(uniformName: string, array: Int32Array): Effect;
  103533. /**
  103534. * 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)
  103535. * @param uniformName Name of the variable.
  103536. * @param array array to be set.
  103537. * @returns this effect.
  103538. */
  103539. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103540. /**
  103541. * 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)
  103542. * @param uniformName Name of the variable.
  103543. * @param array array to be set.
  103544. * @returns this effect.
  103545. */
  103546. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103547. /**
  103548. * 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)
  103549. * @param uniformName Name of the variable.
  103550. * @param array array to be set.
  103551. * @returns this effect.
  103552. */
  103553. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103554. /**
  103555. * Sets an float array on a uniform variable.
  103556. * @param uniformName Name of the variable.
  103557. * @param array array to be set.
  103558. * @returns this effect.
  103559. */
  103560. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103561. /**
  103562. * 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)
  103563. * @param uniformName Name of the variable.
  103564. * @param array array to be set.
  103565. * @returns this effect.
  103566. */
  103567. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103568. /**
  103569. * 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)
  103570. * @param uniformName Name of the variable.
  103571. * @param array array to be set.
  103572. * @returns this effect.
  103573. */
  103574. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103575. /**
  103576. * 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)
  103577. * @param uniformName Name of the variable.
  103578. * @param array array to be set.
  103579. * @returns this effect.
  103580. */
  103581. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103582. /**
  103583. * Sets an array on a uniform variable.
  103584. * @param uniformName Name of the variable.
  103585. * @param array array to be set.
  103586. * @returns this effect.
  103587. */
  103588. setArray(uniformName: string, array: number[]): Effect;
  103589. /**
  103590. * 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)
  103591. * @param uniformName Name of the variable.
  103592. * @param array array to be set.
  103593. * @returns this effect.
  103594. */
  103595. setArray2(uniformName: string, array: number[]): Effect;
  103596. /**
  103597. * 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)
  103598. * @param uniformName Name of the variable.
  103599. * @param array array to be set.
  103600. * @returns this effect.
  103601. */
  103602. setArray3(uniformName: string, array: number[]): Effect;
  103603. /**
  103604. * 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)
  103605. * @param uniformName Name of the variable.
  103606. * @param array array to be set.
  103607. * @returns this effect.
  103608. */
  103609. setArray4(uniformName: string, array: number[]): Effect;
  103610. /**
  103611. * Sets matrices on a uniform variable.
  103612. * @param uniformName Name of the variable.
  103613. * @param matrices matrices to be set.
  103614. * @returns this effect.
  103615. */
  103616. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103617. /**
  103618. * Sets matrix on a uniform variable.
  103619. * @param uniformName Name of the variable.
  103620. * @param matrix matrix to be set.
  103621. * @returns this effect.
  103622. */
  103623. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103624. /**
  103625. * 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)
  103626. * @param uniformName Name of the variable.
  103627. * @param matrix matrix to be set.
  103628. * @returns this effect.
  103629. */
  103630. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103631. /**
  103632. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103633. * @param uniformName Name of the variable.
  103634. * @param matrix matrix to be set.
  103635. * @returns this effect.
  103636. */
  103637. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103638. /**
  103639. * Sets a float on a uniform variable.
  103640. * @param uniformName Name of the variable.
  103641. * @param value value to be set.
  103642. * @returns this effect.
  103643. */
  103644. setFloat(uniformName: string, value: number): Effect;
  103645. /**
  103646. * Sets a boolean on a uniform variable.
  103647. * @param uniformName Name of the variable.
  103648. * @param bool value to be set.
  103649. * @returns this effect.
  103650. */
  103651. setBool(uniformName: string, bool: boolean): Effect;
  103652. /**
  103653. * Sets a Vector2 on a uniform variable.
  103654. * @param uniformName Name of the variable.
  103655. * @param vector2 vector2 to be set.
  103656. * @returns this effect.
  103657. */
  103658. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103659. /**
  103660. * Sets a float2 on a uniform variable.
  103661. * @param uniformName Name of the variable.
  103662. * @param x First float in float2.
  103663. * @param y Second float in float2.
  103664. * @returns this effect.
  103665. */
  103666. setFloat2(uniformName: string, x: number, y: number): Effect;
  103667. /**
  103668. * Sets a Vector3 on a uniform variable.
  103669. * @param uniformName Name of the variable.
  103670. * @param vector3 Value to be set.
  103671. * @returns this effect.
  103672. */
  103673. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103674. /**
  103675. * Sets a float3 on a uniform variable.
  103676. * @param uniformName Name of the variable.
  103677. * @param x First float in float3.
  103678. * @param y Second float in float3.
  103679. * @param z Third float in float3.
  103680. * @returns this effect.
  103681. */
  103682. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103683. /**
  103684. * Sets a Vector4 on a uniform variable.
  103685. * @param uniformName Name of the variable.
  103686. * @param vector4 Value to be set.
  103687. * @returns this effect.
  103688. */
  103689. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103690. /**
  103691. * Sets a float4 on a uniform variable.
  103692. * @param uniformName Name of the variable.
  103693. * @param x First float in float4.
  103694. * @param y Second float in float4.
  103695. * @param z Third float in float4.
  103696. * @param w Fourth float in float4.
  103697. * @returns this effect.
  103698. */
  103699. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103700. /**
  103701. * Sets a Color3 on a uniform variable.
  103702. * @param uniformName Name of the variable.
  103703. * @param color3 Value to be set.
  103704. * @returns this effect.
  103705. */
  103706. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103707. /**
  103708. * Sets a Color4 on a uniform variable.
  103709. * @param uniformName Name of the variable.
  103710. * @param color3 Value to be set.
  103711. * @param alpha Alpha value to be set.
  103712. * @returns this effect.
  103713. */
  103714. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103715. /**
  103716. * Sets a Color4 on a uniform variable
  103717. * @param uniformName defines the name of the variable
  103718. * @param color4 defines the value to be set
  103719. * @returns this effect.
  103720. */
  103721. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103722. /** Release all associated resources */
  103723. dispose(): void;
  103724. /**
  103725. * This function will add a new shader to the shader store
  103726. * @param name the name of the shader
  103727. * @param pixelShader optional pixel shader content
  103728. * @param vertexShader optional vertex shader content
  103729. */
  103730. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103731. /**
  103732. * Store of each shader (The can be looked up using effect.key)
  103733. */
  103734. static ShadersStore: {
  103735. [key: string]: string;
  103736. };
  103737. /**
  103738. * Store of each included file for a shader (The can be looked up using effect.key)
  103739. */
  103740. static IncludesShadersStore: {
  103741. [key: string]: string;
  103742. };
  103743. /**
  103744. * Resets the cache of effects.
  103745. */
  103746. static ResetCache(): void;
  103747. }
  103748. }
  103749. declare module BABYLON {
  103750. /**
  103751. * Interface used to describe the capabilities of the engine relatively to the current browser
  103752. */
  103753. export interface EngineCapabilities {
  103754. /** Maximum textures units per fragment shader */
  103755. maxTexturesImageUnits: number;
  103756. /** Maximum texture units per vertex shader */
  103757. maxVertexTextureImageUnits: number;
  103758. /** Maximum textures units in the entire pipeline */
  103759. maxCombinedTexturesImageUnits: number;
  103760. /** Maximum texture size */
  103761. maxTextureSize: number;
  103762. /** Maximum texture samples */
  103763. maxSamples?: number;
  103764. /** Maximum cube texture size */
  103765. maxCubemapTextureSize: number;
  103766. /** Maximum render texture size */
  103767. maxRenderTextureSize: number;
  103768. /** Maximum number of vertex attributes */
  103769. maxVertexAttribs: number;
  103770. /** Maximum number of varyings */
  103771. maxVaryingVectors: number;
  103772. /** Maximum number of uniforms per vertex shader */
  103773. maxVertexUniformVectors: number;
  103774. /** Maximum number of uniforms per fragment shader */
  103775. maxFragmentUniformVectors: number;
  103776. /** Defines if standard derivates (dx/dy) are supported */
  103777. standardDerivatives: boolean;
  103778. /** Defines if s3tc texture compression is supported */
  103779. s3tc?: WEBGL_compressed_texture_s3tc;
  103780. /** Defines if pvrtc texture compression is supported */
  103781. pvrtc: any;
  103782. /** Defines if etc1 texture compression is supported */
  103783. etc1: any;
  103784. /** Defines if etc2 texture compression is supported */
  103785. etc2: any;
  103786. /** Defines if astc texture compression is supported */
  103787. astc: any;
  103788. /** Defines if float textures are supported */
  103789. textureFloat: boolean;
  103790. /** Defines if vertex array objects are supported */
  103791. vertexArrayObject: boolean;
  103792. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103793. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103794. /** Gets the maximum level of anisotropy supported */
  103795. maxAnisotropy: number;
  103796. /** Defines if instancing is supported */
  103797. instancedArrays: boolean;
  103798. /** Defines if 32 bits indices are supported */
  103799. uintIndices: boolean;
  103800. /** Defines if high precision shaders are supported */
  103801. highPrecisionShaderSupported: boolean;
  103802. /** Defines if depth reading in the fragment shader is supported */
  103803. fragmentDepthSupported: boolean;
  103804. /** Defines if float texture linear filtering is supported*/
  103805. textureFloatLinearFiltering: boolean;
  103806. /** Defines if rendering to float textures is supported */
  103807. textureFloatRender: boolean;
  103808. /** Defines if half float textures are supported*/
  103809. textureHalfFloat: boolean;
  103810. /** Defines if half float texture linear filtering is supported*/
  103811. textureHalfFloatLinearFiltering: boolean;
  103812. /** Defines if rendering to half float textures is supported */
  103813. textureHalfFloatRender: boolean;
  103814. /** Defines if textureLOD shader command is supported */
  103815. textureLOD: boolean;
  103816. /** Defines if draw buffers extension is supported */
  103817. drawBuffersExtension: boolean;
  103818. /** Defines if depth textures are supported */
  103819. depthTextureExtension: boolean;
  103820. /** Defines if float color buffer are supported */
  103821. colorBufferFloat: boolean;
  103822. /** Gets disjoint timer query extension (null if not supported) */
  103823. timerQuery?: EXT_disjoint_timer_query;
  103824. /** Defines if timestamp can be used with timer query */
  103825. canUseTimestampForTimerQuery: boolean;
  103826. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103827. multiview?: any;
  103828. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103829. oculusMultiview?: any;
  103830. /** Function used to let the system compiles shaders in background */
  103831. parallelShaderCompile?: {
  103832. COMPLETION_STATUS_KHR: number;
  103833. };
  103834. /** Max number of texture samples for MSAA */
  103835. maxMSAASamples: number;
  103836. /** Defines if the blend min max extension is supported */
  103837. blendMinMax: boolean;
  103838. }
  103839. }
  103840. declare module BABYLON {
  103841. /**
  103842. * @hidden
  103843. **/
  103844. export class DepthCullingState {
  103845. private _isDepthTestDirty;
  103846. private _isDepthMaskDirty;
  103847. private _isDepthFuncDirty;
  103848. private _isCullFaceDirty;
  103849. private _isCullDirty;
  103850. private _isZOffsetDirty;
  103851. private _isFrontFaceDirty;
  103852. private _depthTest;
  103853. private _depthMask;
  103854. private _depthFunc;
  103855. private _cull;
  103856. private _cullFace;
  103857. private _zOffset;
  103858. private _frontFace;
  103859. /**
  103860. * Initializes the state.
  103861. */
  103862. constructor();
  103863. get isDirty(): boolean;
  103864. get zOffset(): number;
  103865. set zOffset(value: number);
  103866. get cullFace(): Nullable<number>;
  103867. set cullFace(value: Nullable<number>);
  103868. get cull(): Nullable<boolean>;
  103869. set cull(value: Nullable<boolean>);
  103870. get depthFunc(): Nullable<number>;
  103871. set depthFunc(value: Nullable<number>);
  103872. get depthMask(): boolean;
  103873. set depthMask(value: boolean);
  103874. get depthTest(): boolean;
  103875. set depthTest(value: boolean);
  103876. get frontFace(): Nullable<number>;
  103877. set frontFace(value: Nullable<number>);
  103878. reset(): void;
  103879. apply(gl: WebGLRenderingContext): void;
  103880. }
  103881. }
  103882. declare module BABYLON {
  103883. /**
  103884. * @hidden
  103885. **/
  103886. export class StencilState {
  103887. /** 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 */
  103888. static readonly ALWAYS: number;
  103889. /** Passed to stencilOperation to specify that stencil value must be kept */
  103890. static readonly KEEP: number;
  103891. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103892. static readonly REPLACE: number;
  103893. private _isStencilTestDirty;
  103894. private _isStencilMaskDirty;
  103895. private _isStencilFuncDirty;
  103896. private _isStencilOpDirty;
  103897. private _stencilTest;
  103898. private _stencilMask;
  103899. private _stencilFunc;
  103900. private _stencilFuncRef;
  103901. private _stencilFuncMask;
  103902. private _stencilOpStencilFail;
  103903. private _stencilOpDepthFail;
  103904. private _stencilOpStencilDepthPass;
  103905. get isDirty(): boolean;
  103906. get stencilFunc(): number;
  103907. set stencilFunc(value: number);
  103908. get stencilFuncRef(): number;
  103909. set stencilFuncRef(value: number);
  103910. get stencilFuncMask(): number;
  103911. set stencilFuncMask(value: number);
  103912. get stencilOpStencilFail(): number;
  103913. set stencilOpStencilFail(value: number);
  103914. get stencilOpDepthFail(): number;
  103915. set stencilOpDepthFail(value: number);
  103916. get stencilOpStencilDepthPass(): number;
  103917. set stencilOpStencilDepthPass(value: number);
  103918. get stencilMask(): number;
  103919. set stencilMask(value: number);
  103920. get stencilTest(): boolean;
  103921. set stencilTest(value: boolean);
  103922. constructor();
  103923. reset(): void;
  103924. apply(gl: WebGLRenderingContext): void;
  103925. }
  103926. }
  103927. declare module BABYLON {
  103928. /**
  103929. * @hidden
  103930. **/
  103931. export class AlphaState {
  103932. private _isAlphaBlendDirty;
  103933. private _isBlendFunctionParametersDirty;
  103934. private _isBlendEquationParametersDirty;
  103935. private _isBlendConstantsDirty;
  103936. private _alphaBlend;
  103937. private _blendFunctionParameters;
  103938. private _blendEquationParameters;
  103939. private _blendConstants;
  103940. /**
  103941. * Initializes the state.
  103942. */
  103943. constructor();
  103944. get isDirty(): boolean;
  103945. get alphaBlend(): boolean;
  103946. set alphaBlend(value: boolean);
  103947. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103948. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103949. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103950. reset(): void;
  103951. apply(gl: WebGLRenderingContext): void;
  103952. }
  103953. }
  103954. declare module BABYLON {
  103955. /** @hidden */
  103956. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103957. attributeProcessor(attribute: string): string;
  103958. varyingProcessor(varying: string, isFragment: boolean): string;
  103959. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103960. }
  103961. }
  103962. declare module BABYLON {
  103963. /**
  103964. * Interface for attribute information associated with buffer instanciation
  103965. */
  103966. export interface InstancingAttributeInfo {
  103967. /**
  103968. * Name of the GLSL attribute
  103969. * if attribute index is not specified, this is used to retrieve the index from the effect
  103970. */
  103971. attributeName: string;
  103972. /**
  103973. * Index/offset of the attribute in the vertex shader
  103974. * if not specified, this will be computes from the name.
  103975. */
  103976. index?: number;
  103977. /**
  103978. * size of the attribute, 1, 2, 3 or 4
  103979. */
  103980. attributeSize: number;
  103981. /**
  103982. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103983. */
  103984. offset: number;
  103985. /**
  103986. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103987. * default to 1
  103988. */
  103989. divisor?: number;
  103990. /**
  103991. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103992. * default is FLOAT
  103993. */
  103994. attributeType?: number;
  103995. /**
  103996. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103997. */
  103998. normalized?: boolean;
  103999. }
  104000. }
  104001. declare module BABYLON {
  104002. interface ThinEngine {
  104003. /**
  104004. * Update a video texture
  104005. * @param texture defines the texture to update
  104006. * @param video defines the video element to use
  104007. * @param invertY defines if data must be stored with Y axis inverted
  104008. */
  104009. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104010. }
  104011. }
  104012. declare module BABYLON {
  104013. /**
  104014. * Settings for finer control over video usage
  104015. */
  104016. export interface VideoTextureSettings {
  104017. /**
  104018. * Applies `autoplay` to video, if specified
  104019. */
  104020. autoPlay?: boolean;
  104021. /**
  104022. * Applies `loop` to video, if specified
  104023. */
  104024. loop?: boolean;
  104025. /**
  104026. * Automatically updates internal texture from video at every frame in the render loop
  104027. */
  104028. autoUpdateTexture: boolean;
  104029. /**
  104030. * Image src displayed during the video loading or until the user interacts with the video.
  104031. */
  104032. poster?: string;
  104033. }
  104034. /**
  104035. * If you want to display a video in your scene, this is the special texture for that.
  104036. * This special texture works similar to other textures, with the exception of a few parameters.
  104037. * @see https://doc.babylonjs.com/how_to/video_texture
  104038. */
  104039. export class VideoTexture extends Texture {
  104040. /**
  104041. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104042. */
  104043. readonly autoUpdateTexture: boolean;
  104044. /**
  104045. * The video instance used by the texture internally
  104046. */
  104047. readonly video: HTMLVideoElement;
  104048. private _onUserActionRequestedObservable;
  104049. /**
  104050. * Event triggerd when a dom action is required by the user to play the video.
  104051. * This happens due to recent changes in browser policies preventing video to auto start.
  104052. */
  104053. get onUserActionRequestedObservable(): Observable<Texture>;
  104054. private _generateMipMaps;
  104055. private _engine;
  104056. private _stillImageCaptured;
  104057. private _displayingPosterTexture;
  104058. private _settings;
  104059. private _createInternalTextureOnEvent;
  104060. private _frameId;
  104061. private _currentSrc;
  104062. /**
  104063. * Creates a video texture.
  104064. * If you want to display a video in your scene, this is the special texture for that.
  104065. * This special texture works similar to other textures, with the exception of a few parameters.
  104066. * @see https://doc.babylonjs.com/how_to/video_texture
  104067. * @param name optional name, will detect from video source, if not defined
  104068. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104069. * @param scene is obviously the current scene.
  104070. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104071. * @param invertY is false by default but can be used to invert video on Y axis
  104072. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104073. * @param settings allows finer control over video usage
  104074. */
  104075. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104076. private _getName;
  104077. private _getVideo;
  104078. private _createInternalTexture;
  104079. private reset;
  104080. /**
  104081. * @hidden Internal method to initiate `update`.
  104082. */
  104083. _rebuild(): void;
  104084. /**
  104085. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104086. */
  104087. update(): void;
  104088. /**
  104089. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104090. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104091. */
  104092. updateTexture(isVisible: boolean): void;
  104093. protected _updateInternalTexture: () => void;
  104094. /**
  104095. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104096. * @param url New url.
  104097. */
  104098. updateURL(url: string): void;
  104099. /**
  104100. * Clones the texture.
  104101. * @returns the cloned texture
  104102. */
  104103. clone(): VideoTexture;
  104104. /**
  104105. * Dispose the texture and release its associated resources.
  104106. */
  104107. dispose(): void;
  104108. /**
  104109. * Creates a video texture straight from a stream.
  104110. * @param scene Define the scene the texture should be created in
  104111. * @param stream Define the stream the texture should be created from
  104112. * @returns The created video texture as a promise
  104113. */
  104114. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104115. /**
  104116. * Creates a video texture straight from your WebCam video feed.
  104117. * @param scene Define the scene the texture should be created in
  104118. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104119. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104120. * @returns The created video texture as a promise
  104121. */
  104122. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104123. minWidth: number;
  104124. maxWidth: number;
  104125. minHeight: number;
  104126. maxHeight: number;
  104127. deviceId: string;
  104128. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104129. /**
  104130. * Creates a video texture straight from your WebCam video feed.
  104131. * @param scene Define the scene the texture should be created in
  104132. * @param onReady Define a callback to triggered once the texture will be ready
  104133. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104134. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104135. */
  104136. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104137. minWidth: number;
  104138. maxWidth: number;
  104139. minHeight: number;
  104140. maxHeight: number;
  104141. deviceId: string;
  104142. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104143. }
  104144. }
  104145. declare module BABYLON {
  104146. /**
  104147. * Defines the interface used by objects working like Scene
  104148. * @hidden
  104149. */
  104150. export interface ISceneLike {
  104151. _addPendingData(data: any): void;
  104152. _removePendingData(data: any): void;
  104153. offlineProvider: IOfflineProvider;
  104154. }
  104155. /** Interface defining initialization parameters for Engine class */
  104156. export interface EngineOptions extends WebGLContextAttributes {
  104157. /**
  104158. * Defines if the engine should no exceed a specified device ratio
  104159. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104160. */
  104161. limitDeviceRatio?: number;
  104162. /**
  104163. * Defines if webvr should be enabled automatically
  104164. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104165. */
  104166. autoEnableWebVR?: boolean;
  104167. /**
  104168. * Defines if webgl2 should be turned off even if supported
  104169. * @see http://doc.babylonjs.com/features/webgl2
  104170. */
  104171. disableWebGL2Support?: boolean;
  104172. /**
  104173. * Defines if webaudio should be initialized as well
  104174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104175. */
  104176. audioEngine?: boolean;
  104177. /**
  104178. * Defines if animations should run using a deterministic lock step
  104179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104180. */
  104181. deterministicLockstep?: boolean;
  104182. /** Defines the maximum steps to use with deterministic lock step mode */
  104183. lockstepMaxSteps?: number;
  104184. /** Defines the seconds between each deterministic lock step */
  104185. timeStep?: number;
  104186. /**
  104187. * Defines that engine should ignore context lost events
  104188. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104189. */
  104190. doNotHandleContextLost?: boolean;
  104191. /**
  104192. * Defines that engine should ignore modifying touch action attribute and style
  104193. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104194. */
  104195. doNotHandleTouchAction?: boolean;
  104196. /**
  104197. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104198. */
  104199. useHighPrecisionFloats?: boolean;
  104200. }
  104201. /**
  104202. * The base engine class (root of all engines)
  104203. */
  104204. export class ThinEngine {
  104205. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104206. static ExceptionList: ({
  104207. key: string;
  104208. capture: string;
  104209. captureConstraint: number;
  104210. targets: string[];
  104211. } | {
  104212. key: string;
  104213. capture: null;
  104214. captureConstraint: null;
  104215. targets: string[];
  104216. })[];
  104217. /** @hidden */
  104218. static _TextureLoaders: IInternalTextureLoader[];
  104219. /**
  104220. * Returns the current npm package of the sdk
  104221. */
  104222. static get NpmPackage(): string;
  104223. /**
  104224. * Returns the current version of the framework
  104225. */
  104226. static get Version(): string;
  104227. /**
  104228. * Returns a string describing the current engine
  104229. */
  104230. get description(): string;
  104231. /**
  104232. * Gets or sets the epsilon value used by collision engine
  104233. */
  104234. static CollisionsEpsilon: number;
  104235. /**
  104236. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104237. */
  104238. static get ShadersRepository(): string;
  104239. static set ShadersRepository(value: string);
  104240. /** @hidden */
  104241. _shaderProcessor: IShaderProcessor;
  104242. /**
  104243. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104244. */
  104245. forcePOTTextures: boolean;
  104246. /**
  104247. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104248. */
  104249. isFullscreen: boolean;
  104250. /**
  104251. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104252. */
  104253. cullBackFaces: boolean;
  104254. /**
  104255. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104256. */
  104257. renderEvenInBackground: boolean;
  104258. /**
  104259. * Gets or sets a boolean indicating that cache can be kept between frames
  104260. */
  104261. preventCacheWipeBetweenFrames: boolean;
  104262. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104263. validateShaderPrograms: boolean;
  104264. /**
  104265. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104266. * This can provide greater z depth for distant objects.
  104267. */
  104268. useReverseDepthBuffer: boolean;
  104269. /**
  104270. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104271. */
  104272. disableUniformBuffers: boolean;
  104273. /** @hidden */
  104274. _uniformBuffers: UniformBuffer[];
  104275. /**
  104276. * Gets a boolean indicating that the engine supports uniform buffers
  104277. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104278. */
  104279. get supportsUniformBuffers(): boolean;
  104280. /** @hidden */
  104281. _gl: WebGLRenderingContext;
  104282. /** @hidden */
  104283. _webGLVersion: number;
  104284. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104285. protected _windowIsBackground: boolean;
  104286. protected _creationOptions: EngineOptions;
  104287. protected _highPrecisionShadersAllowed: boolean;
  104288. /** @hidden */
  104289. get _shouldUseHighPrecisionShader(): boolean;
  104290. /**
  104291. * Gets a boolean indicating that only power of 2 textures are supported
  104292. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104293. */
  104294. get needPOTTextures(): boolean;
  104295. /** @hidden */
  104296. _badOS: boolean;
  104297. /** @hidden */
  104298. _badDesktopOS: boolean;
  104299. private _hardwareScalingLevel;
  104300. /** @hidden */
  104301. _caps: EngineCapabilities;
  104302. private _isStencilEnable;
  104303. private _glVersion;
  104304. private _glRenderer;
  104305. private _glVendor;
  104306. /** @hidden */
  104307. _videoTextureSupported: boolean;
  104308. protected _renderingQueueLaunched: boolean;
  104309. protected _activeRenderLoops: (() => void)[];
  104310. /**
  104311. * Observable signaled when a context lost event is raised
  104312. */
  104313. onContextLostObservable: Observable<ThinEngine>;
  104314. /**
  104315. * Observable signaled when a context restored event is raised
  104316. */
  104317. onContextRestoredObservable: Observable<ThinEngine>;
  104318. private _onContextLost;
  104319. private _onContextRestored;
  104320. protected _contextWasLost: boolean;
  104321. /** @hidden */
  104322. _doNotHandleContextLost: boolean;
  104323. /**
  104324. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104326. */
  104327. get doNotHandleContextLost(): boolean;
  104328. set doNotHandleContextLost(value: boolean);
  104329. /**
  104330. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104331. */
  104332. disableVertexArrayObjects: boolean;
  104333. /** @hidden */
  104334. protected _colorWrite: boolean;
  104335. /** @hidden */
  104336. protected _colorWriteChanged: boolean;
  104337. /** @hidden */
  104338. protected _depthCullingState: DepthCullingState;
  104339. /** @hidden */
  104340. protected _stencilState: StencilState;
  104341. /** @hidden */
  104342. _alphaState: AlphaState;
  104343. /** @hidden */
  104344. _alphaMode: number;
  104345. /** @hidden */
  104346. _alphaEquation: number;
  104347. /** @hidden */
  104348. _internalTexturesCache: InternalTexture[];
  104349. /** @hidden */
  104350. protected _activeChannel: number;
  104351. private _currentTextureChannel;
  104352. /** @hidden */
  104353. protected _boundTexturesCache: {
  104354. [key: string]: Nullable<InternalTexture>;
  104355. };
  104356. /** @hidden */
  104357. protected _currentEffect: Nullable<Effect>;
  104358. /** @hidden */
  104359. protected _currentProgram: Nullable<WebGLProgram>;
  104360. private _compiledEffects;
  104361. private _vertexAttribArraysEnabled;
  104362. /** @hidden */
  104363. protected _cachedViewport: Nullable<IViewportLike>;
  104364. private _cachedVertexArrayObject;
  104365. /** @hidden */
  104366. protected _cachedVertexBuffers: any;
  104367. /** @hidden */
  104368. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104369. /** @hidden */
  104370. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104371. /** @hidden */
  104372. _currentRenderTarget: Nullable<InternalTexture>;
  104373. private _uintIndicesCurrentlySet;
  104374. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104375. /** @hidden */
  104376. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104377. private _currentBufferPointers;
  104378. private _currentInstanceLocations;
  104379. private _currentInstanceBuffers;
  104380. private _textureUnits;
  104381. /** @hidden */
  104382. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104383. /** @hidden */
  104384. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104385. /** @hidden */
  104386. _boundRenderFunction: any;
  104387. private _vaoRecordInProgress;
  104388. private _mustWipeVertexAttributes;
  104389. private _emptyTexture;
  104390. private _emptyCubeTexture;
  104391. private _emptyTexture3D;
  104392. private _emptyTexture2DArray;
  104393. /** @hidden */
  104394. _frameHandler: number;
  104395. private _nextFreeTextureSlots;
  104396. private _maxSimultaneousTextures;
  104397. private _activeRequests;
  104398. protected _texturesSupported: string[];
  104399. /** @hidden */
  104400. _textureFormatInUse: Nullable<string>;
  104401. protected get _supportsHardwareTextureRescaling(): boolean;
  104402. /**
  104403. * Gets the list of texture formats supported
  104404. */
  104405. get texturesSupported(): Array<string>;
  104406. /**
  104407. * Gets the list of texture formats in use
  104408. */
  104409. get textureFormatInUse(): Nullable<string>;
  104410. /**
  104411. * Gets the current viewport
  104412. */
  104413. get currentViewport(): Nullable<IViewportLike>;
  104414. /**
  104415. * Gets the default empty texture
  104416. */
  104417. get emptyTexture(): InternalTexture;
  104418. /**
  104419. * Gets the default empty 3D texture
  104420. */
  104421. get emptyTexture3D(): InternalTexture;
  104422. /**
  104423. * Gets the default empty 2D array texture
  104424. */
  104425. get emptyTexture2DArray(): InternalTexture;
  104426. /**
  104427. * Gets the default empty cube texture
  104428. */
  104429. get emptyCubeTexture(): InternalTexture;
  104430. /**
  104431. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104432. */
  104433. readonly premultipliedAlpha: boolean;
  104434. /**
  104435. * Observable event triggered before each texture is initialized
  104436. */
  104437. onBeforeTextureInitObservable: Observable<Texture>;
  104438. /**
  104439. * Creates a new engine
  104440. * @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
  104441. * @param antialias defines enable antialiasing (default: false)
  104442. * @param options defines further options to be sent to the getContext() function
  104443. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104444. */
  104445. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104446. private _rebuildInternalTextures;
  104447. private _rebuildEffects;
  104448. /**
  104449. * Gets a boolean indicating if all created effects are ready
  104450. * @returns true if all effects are ready
  104451. */
  104452. areAllEffectsReady(): boolean;
  104453. protected _rebuildBuffers(): void;
  104454. private _initGLContext;
  104455. /**
  104456. * Gets version of the current webGL context
  104457. */
  104458. get webGLVersion(): number;
  104459. /**
  104460. * Gets a string idenfifying the name of the class
  104461. * @returns "Engine" string
  104462. */
  104463. getClassName(): string;
  104464. /**
  104465. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104466. */
  104467. get isStencilEnable(): boolean;
  104468. /** @hidden */
  104469. _prepareWorkingCanvas(): void;
  104470. /**
  104471. * Reset the texture cache to empty state
  104472. */
  104473. resetTextureCache(): void;
  104474. /**
  104475. * Gets an object containing information about the current webGL context
  104476. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104477. */
  104478. getGlInfo(): {
  104479. vendor: string;
  104480. renderer: string;
  104481. version: string;
  104482. };
  104483. /**
  104484. * Defines the hardware scaling level.
  104485. * By default the hardware scaling level is computed from the window device ratio.
  104486. * 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.
  104487. * @param level defines the level to use
  104488. */
  104489. setHardwareScalingLevel(level: number): void;
  104490. /**
  104491. * Gets the current hardware scaling level.
  104492. * By default the hardware scaling level is computed from the window device ratio.
  104493. * 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.
  104494. * @returns a number indicating the current hardware scaling level
  104495. */
  104496. getHardwareScalingLevel(): number;
  104497. /**
  104498. * Gets the list of loaded textures
  104499. * @returns an array containing all loaded textures
  104500. */
  104501. getLoadedTexturesCache(): InternalTexture[];
  104502. /**
  104503. * Gets the object containing all engine capabilities
  104504. * @returns the EngineCapabilities object
  104505. */
  104506. getCaps(): EngineCapabilities;
  104507. /**
  104508. * stop executing a render loop function and remove it from the execution array
  104509. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104510. */
  104511. stopRenderLoop(renderFunction?: () => void): void;
  104512. /** @hidden */
  104513. _renderLoop(): void;
  104514. /**
  104515. * Gets the HTML canvas attached with the current webGL context
  104516. * @returns a HTML canvas
  104517. */
  104518. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104519. /**
  104520. * Gets host window
  104521. * @returns the host window object
  104522. */
  104523. getHostWindow(): Nullable<Window>;
  104524. /**
  104525. * Gets the current render width
  104526. * @param useScreen defines if screen size must be used (or the current render target if any)
  104527. * @returns a number defining the current render width
  104528. */
  104529. getRenderWidth(useScreen?: boolean): number;
  104530. /**
  104531. * Gets the current render height
  104532. * @param useScreen defines if screen size must be used (or the current render target if any)
  104533. * @returns a number defining the current render height
  104534. */
  104535. getRenderHeight(useScreen?: boolean): number;
  104536. /**
  104537. * Can be used to override the current requestAnimationFrame requester.
  104538. * @hidden
  104539. */
  104540. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104541. /**
  104542. * Register and execute a render loop. The engine can have more than one render function
  104543. * @param renderFunction defines the function to continuously execute
  104544. */
  104545. runRenderLoop(renderFunction: () => void): void;
  104546. /**
  104547. * Clear the current render buffer or the current render target (if any is set up)
  104548. * @param color defines the color to use
  104549. * @param backBuffer defines if the back buffer must be cleared
  104550. * @param depth defines if the depth buffer must be cleared
  104551. * @param stencil defines if the stencil buffer must be cleared
  104552. */
  104553. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104554. private _viewportCached;
  104555. /** @hidden */
  104556. _viewport(x: number, y: number, width: number, height: number): void;
  104557. /**
  104558. * Set the WebGL's viewport
  104559. * @param viewport defines the viewport element to be used
  104560. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104561. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104562. */
  104563. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104564. /**
  104565. * Begin a new frame
  104566. */
  104567. beginFrame(): void;
  104568. /**
  104569. * Enf the current frame
  104570. */
  104571. endFrame(): void;
  104572. /**
  104573. * Resize the view according to the canvas' size
  104574. */
  104575. resize(): void;
  104576. /**
  104577. * Force a specific size of the canvas
  104578. * @param width defines the new canvas' width
  104579. * @param height defines the new canvas' height
  104580. */
  104581. setSize(width: number, height: number): void;
  104582. /**
  104583. * Binds the frame buffer to the specified texture.
  104584. * @param texture The texture to render to or null for the default canvas
  104585. * @param faceIndex The face of the texture to render to in case of cube texture
  104586. * @param requiredWidth The width of the target to render to
  104587. * @param requiredHeight The height of the target to render to
  104588. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104589. * @param lodLevel defines the lod level to bind to the frame buffer
  104590. * @param layer defines the 2d array index to bind to frame buffer to
  104591. */
  104592. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104593. /** @hidden */
  104594. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104595. /**
  104596. * Unbind the current render target texture from the webGL context
  104597. * @param texture defines the render target texture to unbind
  104598. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104599. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104600. */
  104601. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104602. /**
  104603. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104604. */
  104605. flushFramebuffer(): void;
  104606. /**
  104607. * Unbind the current render target and bind the default framebuffer
  104608. */
  104609. restoreDefaultFramebuffer(): void;
  104610. /** @hidden */
  104611. protected _resetVertexBufferBinding(): void;
  104612. /**
  104613. * Creates a vertex buffer
  104614. * @param data the data for the vertex buffer
  104615. * @returns the new WebGL static buffer
  104616. */
  104617. createVertexBuffer(data: DataArray): DataBuffer;
  104618. private _createVertexBuffer;
  104619. /**
  104620. * Creates a dynamic vertex buffer
  104621. * @param data the data for the dynamic vertex buffer
  104622. * @returns the new WebGL dynamic buffer
  104623. */
  104624. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104625. protected _resetIndexBufferBinding(): void;
  104626. /**
  104627. * Creates a new index buffer
  104628. * @param indices defines the content of the index buffer
  104629. * @param updatable defines if the index buffer must be updatable
  104630. * @returns a new webGL buffer
  104631. */
  104632. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104633. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104634. /**
  104635. * Bind a webGL buffer to the webGL context
  104636. * @param buffer defines the buffer to bind
  104637. */
  104638. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104639. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104640. private bindBuffer;
  104641. /**
  104642. * update the bound buffer with the given data
  104643. * @param data defines the data to update
  104644. */
  104645. updateArrayBuffer(data: Float32Array): void;
  104646. private _vertexAttribPointer;
  104647. /** @hidden */
  104648. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104649. private _bindVertexBuffersAttributes;
  104650. /**
  104651. * Records a vertex array object
  104652. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104653. * @param vertexBuffers defines the list of vertex buffers to store
  104654. * @param indexBuffer defines the index buffer to store
  104655. * @param effect defines the effect to store
  104656. * @returns the new vertex array object
  104657. */
  104658. recordVertexArrayObject(vertexBuffers: {
  104659. [key: string]: VertexBuffer;
  104660. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104661. /**
  104662. * Bind a specific vertex array object
  104663. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104664. * @param vertexArrayObject defines the vertex array object to bind
  104665. * @param indexBuffer defines the index buffer to bind
  104666. */
  104667. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104668. /**
  104669. * Bind webGl buffers directly to the webGL context
  104670. * @param vertexBuffer defines the vertex buffer to bind
  104671. * @param indexBuffer defines the index buffer to bind
  104672. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104673. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104674. * @param effect defines the effect associated with the vertex buffer
  104675. */
  104676. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104677. private _unbindVertexArrayObject;
  104678. /**
  104679. * Bind a list of vertex buffers to the webGL context
  104680. * @param vertexBuffers defines the list of vertex buffers to bind
  104681. * @param indexBuffer defines the index buffer to bind
  104682. * @param effect defines the effect associated with the vertex buffers
  104683. */
  104684. bindBuffers(vertexBuffers: {
  104685. [key: string]: Nullable<VertexBuffer>;
  104686. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104687. /**
  104688. * Unbind all instance attributes
  104689. */
  104690. unbindInstanceAttributes(): void;
  104691. /**
  104692. * Release and free the memory of a vertex array object
  104693. * @param vao defines the vertex array object to delete
  104694. */
  104695. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104696. /** @hidden */
  104697. _releaseBuffer(buffer: DataBuffer): boolean;
  104698. protected _deleteBuffer(buffer: DataBuffer): void;
  104699. /**
  104700. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104701. * @param instancesBuffer defines the webGL buffer to update and bind
  104702. * @param data defines the data to store in the buffer
  104703. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104704. */
  104705. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104706. /**
  104707. * Bind the content of a webGL buffer used with instantiation
  104708. * @param instancesBuffer defines the webGL buffer to bind
  104709. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104710. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104711. */
  104712. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104713. /**
  104714. * Disable the instance attribute corresponding to the name in parameter
  104715. * @param name defines the name of the attribute to disable
  104716. */
  104717. disableInstanceAttributeByName(name: string): void;
  104718. /**
  104719. * Disable the instance attribute corresponding to the location in parameter
  104720. * @param attributeLocation defines the attribute location of the attribute to disable
  104721. */
  104722. disableInstanceAttribute(attributeLocation: number): void;
  104723. /**
  104724. * Disable the attribute corresponding to the location in parameter
  104725. * @param attributeLocation defines the attribute location of the attribute to disable
  104726. */
  104727. disableAttributeByIndex(attributeLocation: number): void;
  104728. /**
  104729. * Send a draw order
  104730. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104731. * @param indexStart defines the starting index
  104732. * @param indexCount defines the number of index to draw
  104733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104734. */
  104735. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104736. /**
  104737. * Draw a list of points
  104738. * @param verticesStart defines the index of first vertex to draw
  104739. * @param verticesCount defines the count of vertices to draw
  104740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104741. */
  104742. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104743. /**
  104744. * Draw a list of unindexed primitives
  104745. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104746. * @param verticesStart defines the index of first vertex to draw
  104747. * @param verticesCount defines the count of vertices to draw
  104748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104749. */
  104750. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104751. /**
  104752. * Draw a list of indexed primitives
  104753. * @param fillMode defines the primitive to use
  104754. * @param indexStart defines the starting index
  104755. * @param indexCount defines the number of index to draw
  104756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104757. */
  104758. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104759. /**
  104760. * Draw a list of unindexed primitives
  104761. * @param fillMode defines the primitive to use
  104762. * @param verticesStart defines the index of first vertex to draw
  104763. * @param verticesCount defines the count of vertices to draw
  104764. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104765. */
  104766. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104767. private _drawMode;
  104768. /** @hidden */
  104769. protected _reportDrawCall(): void;
  104770. /** @hidden */
  104771. _releaseEffect(effect: Effect): void;
  104772. /** @hidden */
  104773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104774. /**
  104775. * Create a new effect (used to store vertex/fragment shaders)
  104776. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104777. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104778. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104779. * @param samplers defines an array of string used to represent textures
  104780. * @param defines defines the string containing the defines to use to compile the shaders
  104781. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104782. * @param onCompiled defines a function to call when the effect creation is successful
  104783. * @param onError defines a function to call when the effect creation has failed
  104784. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104785. * @returns the new Effect
  104786. */
  104787. 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;
  104788. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104789. private _compileShader;
  104790. private _compileRawShader;
  104791. /**
  104792. * Directly creates a webGL program
  104793. * @param pipelineContext defines the pipeline context to attach to
  104794. * @param vertexCode defines the vertex shader code to use
  104795. * @param fragmentCode defines the fragment shader code to use
  104796. * @param context defines the webGL context to use (if not set, the current one will be used)
  104797. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104798. * @returns the new webGL program
  104799. */
  104800. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104801. /**
  104802. * Creates a webGL program
  104803. * @param pipelineContext defines the pipeline context to attach to
  104804. * @param vertexCode defines the vertex shader code to use
  104805. * @param fragmentCode defines the fragment shader code to use
  104806. * @param defines defines the string containing the defines to use to compile the shaders
  104807. * @param context defines the webGL context to use (if not set, the current one will be used)
  104808. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104809. * @returns the new webGL program
  104810. */
  104811. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104812. /**
  104813. * Creates a new pipeline context
  104814. * @returns the new pipeline
  104815. */
  104816. createPipelineContext(): IPipelineContext;
  104817. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104818. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104819. /** @hidden */
  104820. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104821. /** @hidden */
  104822. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104823. /** @hidden */
  104824. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104825. /**
  104826. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104827. * @param pipelineContext defines the pipeline context to use
  104828. * @param uniformsNames defines the list of uniform names
  104829. * @returns an array of webGL uniform locations
  104830. */
  104831. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104832. /**
  104833. * Gets the lsit of active attributes for a given webGL program
  104834. * @param pipelineContext defines the pipeline context to use
  104835. * @param attributesNames defines the list of attribute names to get
  104836. * @returns an array of indices indicating the offset of each attribute
  104837. */
  104838. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104839. /**
  104840. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104841. * @param effect defines the effect to activate
  104842. */
  104843. enableEffect(effect: Nullable<Effect>): void;
  104844. /**
  104845. * Set the value of an uniform to a number (int)
  104846. * @param uniform defines the webGL uniform location where to store the value
  104847. * @param value defines the int number to store
  104848. */
  104849. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104850. /**
  104851. * Set the value of an uniform to an array of int32
  104852. * @param uniform defines the webGL uniform location where to store the value
  104853. * @param array defines the array of int32 to store
  104854. */
  104855. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104856. /**
  104857. * Set the value of an uniform to an array of int32 (stored as vec2)
  104858. * @param uniform defines the webGL uniform location where to store the value
  104859. * @param array defines the array of int32 to store
  104860. */
  104861. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104862. /**
  104863. * Set the value of an uniform to an array of int32 (stored as vec3)
  104864. * @param uniform defines the webGL uniform location where to store the value
  104865. * @param array defines the array of int32 to store
  104866. */
  104867. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104868. /**
  104869. * Set the value of an uniform to an array of int32 (stored as vec4)
  104870. * @param uniform defines the webGL uniform location where to store the value
  104871. * @param array defines the array of int32 to store
  104872. */
  104873. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104874. /**
  104875. * Set the value of an uniform to an array of number
  104876. * @param uniform defines the webGL uniform location where to store the value
  104877. * @param array defines the array of number to store
  104878. */
  104879. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104880. /**
  104881. * Set the value of an uniform to an array of number (stored as vec2)
  104882. * @param uniform defines the webGL uniform location where to store the value
  104883. * @param array defines the array of number to store
  104884. */
  104885. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104886. /**
  104887. * Set the value of an uniform to an array of number (stored as vec3)
  104888. * @param uniform defines the webGL uniform location where to store the value
  104889. * @param array defines the array of number to store
  104890. */
  104891. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104892. /**
  104893. * Set the value of an uniform to an array of number (stored as vec4)
  104894. * @param uniform defines the webGL uniform location where to store the value
  104895. * @param array defines the array of number to store
  104896. */
  104897. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104898. /**
  104899. * Set the value of an uniform to an array of float32 (stored as matrices)
  104900. * @param uniform defines the webGL uniform location where to store the value
  104901. * @param matrices defines the array of float32 to store
  104902. */
  104903. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104904. /**
  104905. * Set the value of an uniform to a matrix (3x3)
  104906. * @param uniform defines the webGL uniform location where to store the value
  104907. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104908. */
  104909. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104910. /**
  104911. * Set the value of an uniform to a matrix (2x2)
  104912. * @param uniform defines the webGL uniform location where to store the value
  104913. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104914. */
  104915. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104916. /**
  104917. * Set the value of an uniform to a number (float)
  104918. * @param uniform defines the webGL uniform location where to store the value
  104919. * @param value defines the float number to store
  104920. */
  104921. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104922. /**
  104923. * Set the value of an uniform to a vec2
  104924. * @param uniform defines the webGL uniform location where to store the value
  104925. * @param x defines the 1st component of the value
  104926. * @param y defines the 2nd component of the value
  104927. */
  104928. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104929. /**
  104930. * Set the value of an uniform to a vec3
  104931. * @param uniform defines the webGL uniform location where to store the value
  104932. * @param x defines the 1st component of the value
  104933. * @param y defines the 2nd component of the value
  104934. * @param z defines the 3rd component of the value
  104935. */
  104936. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104937. /**
  104938. * Set the value of an uniform to a vec4
  104939. * @param uniform defines the webGL uniform location where to store the value
  104940. * @param x defines the 1st component of the value
  104941. * @param y defines the 2nd component of the value
  104942. * @param z defines the 3rd component of the value
  104943. * @param w defines the 4th component of the value
  104944. */
  104945. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104946. /**
  104947. * Apply all cached states (depth, culling, stencil and alpha)
  104948. */
  104949. applyStates(): void;
  104950. /**
  104951. * Enable or disable color writing
  104952. * @param enable defines the state to set
  104953. */
  104954. setColorWrite(enable: boolean): void;
  104955. /**
  104956. * Gets a boolean indicating if color writing is enabled
  104957. * @returns the current color writing state
  104958. */
  104959. getColorWrite(): boolean;
  104960. /**
  104961. * Gets the depth culling state manager
  104962. */
  104963. get depthCullingState(): DepthCullingState;
  104964. /**
  104965. * Gets the alpha state manager
  104966. */
  104967. get alphaState(): AlphaState;
  104968. /**
  104969. * Gets the stencil state manager
  104970. */
  104971. get stencilState(): StencilState;
  104972. /**
  104973. * Clears the list of texture accessible through engine.
  104974. * This can help preventing texture load conflict due to name collision.
  104975. */
  104976. clearInternalTexturesCache(): void;
  104977. /**
  104978. * Force the entire cache to be cleared
  104979. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104980. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104981. */
  104982. wipeCaches(bruteForce?: boolean): void;
  104983. /** @hidden */
  104984. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104985. min: number;
  104986. mag: number;
  104987. };
  104988. /** @hidden */
  104989. _createTexture(): WebGLTexture;
  104990. /**
  104991. * Usually called from Texture.ts.
  104992. * Passed information to create a WebGLTexture
  104993. * @param urlArg defines a value which contains one of the following:
  104994. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104995. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104996. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104997. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104998. * @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)
  104999. * @param scene needed for loading to the correct scene
  105000. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105001. * @param onLoad optional callback to be called upon successful completion
  105002. * @param onError optional callback to be called upon failure
  105003. * @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
  105004. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105005. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105006. * @param forcedExtension defines the extension to use to pick the right loader
  105007. * @param mimeType defines an optional mime type
  105008. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105009. */
  105010. 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;
  105011. /**
  105012. * Loads an image as an HTMLImageElement.
  105013. * @param input url string, ArrayBuffer, or Blob to load
  105014. * @param onLoad callback called when the image successfully loads
  105015. * @param onError callback called when the image fails to load
  105016. * @param offlineProvider offline provider for caching
  105017. * @param mimeType optional mime type
  105018. * @returns the HTMLImageElement of the loaded image
  105019. * @hidden
  105020. */
  105021. 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>;
  105022. /**
  105023. * @hidden
  105024. */
  105025. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105026. /**
  105027. * Creates a raw texture
  105028. * @param data defines the data to store in the texture
  105029. * @param width defines the width of the texture
  105030. * @param height defines the height of the texture
  105031. * @param format defines the format of the data
  105032. * @param generateMipMaps defines if the engine should generate the mip levels
  105033. * @param invertY defines if data must be stored with Y axis inverted
  105034. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105035. * @param compression defines the compression used (null by default)
  105036. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105037. * @returns the raw texture inside an InternalTexture
  105038. */
  105039. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105040. /**
  105041. * Creates a new raw cube texture
  105042. * @param data defines the array of data to use to create each face
  105043. * @param size defines the size of the textures
  105044. * @param format defines the format of the data
  105045. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105046. * @param generateMipMaps defines if the engine should generate the mip levels
  105047. * @param invertY defines if data must be stored with Y axis inverted
  105048. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105049. * @param compression defines the compression used (null by default)
  105050. * @returns the cube texture as an InternalTexture
  105051. */
  105052. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105053. /**
  105054. * Creates a new raw 3D texture
  105055. * @param data defines the data used to create the texture
  105056. * @param width defines the width of the texture
  105057. * @param height defines the height of the texture
  105058. * @param depth defines the depth of the texture
  105059. * @param format defines the format of the texture
  105060. * @param generateMipMaps defines if the engine must generate mip levels
  105061. * @param invertY defines if data must be stored with Y axis inverted
  105062. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105063. * @param compression defines the compressed used (can be null)
  105064. * @param textureType defines the compressed used (can be null)
  105065. * @returns a new raw 3D texture (stored in an InternalTexture)
  105066. */
  105067. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105068. /**
  105069. * Creates a new raw 2D array texture
  105070. * @param data defines the data used to create the texture
  105071. * @param width defines the width of the texture
  105072. * @param height defines the height of the texture
  105073. * @param depth defines the number of layers of the texture
  105074. * @param format defines the format of the texture
  105075. * @param generateMipMaps defines if the engine must generate mip levels
  105076. * @param invertY defines if data must be stored with Y axis inverted
  105077. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105078. * @param compression defines the compressed used (can be null)
  105079. * @param textureType defines the compressed used (can be null)
  105080. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105081. */
  105082. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105083. private _unpackFlipYCached;
  105084. /**
  105085. * In case you are sharing the context with other applications, it might
  105086. * be interested to not cache the unpack flip y state to ensure a consistent
  105087. * value would be set.
  105088. */
  105089. enableUnpackFlipYCached: boolean;
  105090. /** @hidden */
  105091. _unpackFlipY(value: boolean): void;
  105092. /** @hidden */
  105093. _getUnpackAlignement(): number;
  105094. private _getTextureTarget;
  105095. /**
  105096. * Update the sampling mode of a given texture
  105097. * @param samplingMode defines the required sampling mode
  105098. * @param texture defines the texture to update
  105099. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105100. */
  105101. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105102. /**
  105103. * Update the sampling mode of a given texture
  105104. * @param texture defines the texture to update
  105105. * @param wrapU defines the texture wrap mode of the u coordinates
  105106. * @param wrapV defines the texture wrap mode of the v coordinates
  105107. * @param wrapR defines the texture wrap mode of the r coordinates
  105108. */
  105109. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105110. /** @hidden */
  105111. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105112. width: number;
  105113. height: number;
  105114. layers?: number;
  105115. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105116. /** @hidden */
  105117. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105118. /** @hidden */
  105119. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105120. /**
  105121. * Update a portion of an internal texture
  105122. * @param texture defines the texture to update
  105123. * @param imageData defines the data to store into the texture
  105124. * @param xOffset defines the x coordinates of the update rectangle
  105125. * @param yOffset defines the y coordinates of the update rectangle
  105126. * @param width defines the width of the update rectangle
  105127. * @param height defines the height of the update rectangle
  105128. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105129. * @param lod defines the lod level to update (0 by default)
  105130. */
  105131. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105132. /** @hidden */
  105133. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105134. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105135. private _prepareWebGLTexture;
  105136. /** @hidden */
  105137. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105138. private _getDepthStencilBuffer;
  105139. /** @hidden */
  105140. _releaseFramebufferObjects(texture: InternalTexture): void;
  105141. /** @hidden */
  105142. _releaseTexture(texture: InternalTexture): void;
  105143. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105144. protected _setProgram(program: WebGLProgram): void;
  105145. protected _boundUniforms: {
  105146. [key: number]: WebGLUniformLocation;
  105147. };
  105148. /**
  105149. * Binds an effect to the webGL context
  105150. * @param effect defines the effect to bind
  105151. */
  105152. bindSamplers(effect: Effect): void;
  105153. private _activateCurrentTexture;
  105154. /** @hidden */
  105155. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105156. /** @hidden */
  105157. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105158. /**
  105159. * Unbind all textures from the webGL context
  105160. */
  105161. unbindAllTextures(): void;
  105162. /**
  105163. * Sets a texture to the according uniform.
  105164. * @param channel The texture channel
  105165. * @param uniform The uniform to set
  105166. * @param texture The texture to apply
  105167. */
  105168. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105169. private _bindSamplerUniformToChannel;
  105170. private _getTextureWrapMode;
  105171. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105172. /**
  105173. * Sets an array of texture to the webGL context
  105174. * @param channel defines the channel where the texture array must be set
  105175. * @param uniform defines the associated uniform location
  105176. * @param textures defines the array of textures to bind
  105177. */
  105178. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105179. /** @hidden */
  105180. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105181. private _setTextureParameterFloat;
  105182. private _setTextureParameterInteger;
  105183. /**
  105184. * Unbind all vertex attributes from the webGL context
  105185. */
  105186. unbindAllAttributes(): void;
  105187. /**
  105188. * 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
  105189. */
  105190. releaseEffects(): void;
  105191. /**
  105192. * Dispose and release all associated resources
  105193. */
  105194. dispose(): void;
  105195. /**
  105196. * Attach a new callback raised when context lost event is fired
  105197. * @param callback defines the callback to call
  105198. */
  105199. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105200. /**
  105201. * Attach a new callback raised when context restored event is fired
  105202. * @param callback defines the callback to call
  105203. */
  105204. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105205. /**
  105206. * Get the current error code of the webGL context
  105207. * @returns the error code
  105208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105209. */
  105210. getError(): number;
  105211. private _canRenderToFloatFramebuffer;
  105212. private _canRenderToHalfFloatFramebuffer;
  105213. private _canRenderToFramebuffer;
  105214. /** @hidden */
  105215. _getWebGLTextureType(type: number): number;
  105216. /** @hidden */
  105217. _getInternalFormat(format: number): number;
  105218. /** @hidden */
  105219. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105220. /** @hidden */
  105221. _getRGBAMultiSampleBufferFormat(type: number): number;
  105222. /** @hidden */
  105223. _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;
  105224. /**
  105225. * Loads a file from a url
  105226. * @param url url to load
  105227. * @param onSuccess callback called when the file successfully loads
  105228. * @param onProgress callback called while file is loading (if the server supports this mode)
  105229. * @param offlineProvider defines the offline provider for caching
  105230. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105231. * @param onError callback called when the file fails to load
  105232. * @returns a file request object
  105233. * @hidden
  105234. */
  105235. 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;
  105236. /**
  105237. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105238. * @param x defines the x coordinate of the rectangle where pixels must be read
  105239. * @param y defines the y coordinate of the rectangle where pixels must be read
  105240. * @param width defines the width of the rectangle where pixels must be read
  105241. * @param height defines the height of the rectangle where pixels must be read
  105242. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105243. * @returns a Uint8Array containing RGBA colors
  105244. */
  105245. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105246. private static _isSupported;
  105247. /**
  105248. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105249. * @returns true if the engine can be created
  105250. * @ignorenaming
  105251. */
  105252. static isSupported(): boolean;
  105253. /**
  105254. * Find the next highest power of two.
  105255. * @param x Number to start search from.
  105256. * @return Next highest power of two.
  105257. */
  105258. static CeilingPOT(x: number): number;
  105259. /**
  105260. * Find the next lowest power of two.
  105261. * @param x Number to start search from.
  105262. * @return Next lowest power of two.
  105263. */
  105264. static FloorPOT(x: number): number;
  105265. /**
  105266. * Find the nearest power of two.
  105267. * @param x Number to start search from.
  105268. * @return Next nearest power of two.
  105269. */
  105270. static NearestPOT(x: number): number;
  105271. /**
  105272. * Get the closest exponent of two
  105273. * @param value defines the value to approximate
  105274. * @param max defines the maximum value to return
  105275. * @param mode defines how to define the closest value
  105276. * @returns closest exponent of two of the given value
  105277. */
  105278. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105279. /**
  105280. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105281. * @param func - the function to be called
  105282. * @param requester - the object that will request the next frame. Falls back to window.
  105283. * @returns frame number
  105284. */
  105285. static QueueNewFrame(func: () => void, requester?: any): number;
  105286. /**
  105287. * Gets host document
  105288. * @returns the host document object
  105289. */
  105290. getHostDocument(): Nullable<Document>;
  105291. }
  105292. }
  105293. declare module BABYLON {
  105294. /**
  105295. * Class representing spherical harmonics coefficients to the 3rd degree
  105296. */
  105297. export class SphericalHarmonics {
  105298. /**
  105299. * Defines whether or not the harmonics have been prescaled for rendering.
  105300. */
  105301. preScaled: boolean;
  105302. /**
  105303. * The l0,0 coefficients of the spherical harmonics
  105304. */
  105305. l00: Vector3;
  105306. /**
  105307. * The l1,-1 coefficients of the spherical harmonics
  105308. */
  105309. l1_1: Vector3;
  105310. /**
  105311. * The l1,0 coefficients of the spherical harmonics
  105312. */
  105313. l10: Vector3;
  105314. /**
  105315. * The l1,1 coefficients of the spherical harmonics
  105316. */
  105317. l11: Vector3;
  105318. /**
  105319. * The l2,-2 coefficients of the spherical harmonics
  105320. */
  105321. l2_2: Vector3;
  105322. /**
  105323. * The l2,-1 coefficients of the spherical harmonics
  105324. */
  105325. l2_1: Vector3;
  105326. /**
  105327. * The l2,0 coefficients of the spherical harmonics
  105328. */
  105329. l20: Vector3;
  105330. /**
  105331. * The l2,1 coefficients of the spherical harmonics
  105332. */
  105333. l21: Vector3;
  105334. /**
  105335. * The l2,2 coefficients of the spherical harmonics
  105336. */
  105337. l22: Vector3;
  105338. /**
  105339. * Adds a light to the spherical harmonics
  105340. * @param direction the direction of the light
  105341. * @param color the color of the light
  105342. * @param deltaSolidAngle the delta solid angle of the light
  105343. */
  105344. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105345. /**
  105346. * Scales the spherical harmonics by the given amount
  105347. * @param scale the amount to scale
  105348. */
  105349. scaleInPlace(scale: number): void;
  105350. /**
  105351. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105352. *
  105353. * ```
  105354. * E_lm = A_l * L_lm
  105355. * ```
  105356. *
  105357. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105358. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105359. * the scaling factors are given in equation 9.
  105360. */
  105361. convertIncidentRadianceToIrradiance(): void;
  105362. /**
  105363. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105364. *
  105365. * ```
  105366. * L = (1/pi) * E * rho
  105367. * ```
  105368. *
  105369. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105370. */
  105371. convertIrradianceToLambertianRadiance(): void;
  105372. /**
  105373. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105374. * required operations at run time.
  105375. *
  105376. * This is simply done by scaling back the SH with Ylm constants parameter.
  105377. * The trigonometric part being applied by the shader at run time.
  105378. */
  105379. preScaleForRendering(): void;
  105380. /**
  105381. * Constructs a spherical harmonics from an array.
  105382. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105383. * @returns the spherical harmonics
  105384. */
  105385. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105386. /**
  105387. * Gets the spherical harmonics from polynomial
  105388. * @param polynomial the spherical polynomial
  105389. * @returns the spherical harmonics
  105390. */
  105391. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105392. }
  105393. /**
  105394. * Class representing spherical polynomial coefficients to the 3rd degree
  105395. */
  105396. export class SphericalPolynomial {
  105397. private _harmonics;
  105398. /**
  105399. * The spherical harmonics used to create the polynomials.
  105400. */
  105401. get preScaledHarmonics(): SphericalHarmonics;
  105402. /**
  105403. * The x coefficients of the spherical polynomial
  105404. */
  105405. x: Vector3;
  105406. /**
  105407. * The y coefficients of the spherical polynomial
  105408. */
  105409. y: Vector3;
  105410. /**
  105411. * The z coefficients of the spherical polynomial
  105412. */
  105413. z: Vector3;
  105414. /**
  105415. * The xx coefficients of the spherical polynomial
  105416. */
  105417. xx: Vector3;
  105418. /**
  105419. * The yy coefficients of the spherical polynomial
  105420. */
  105421. yy: Vector3;
  105422. /**
  105423. * The zz coefficients of the spherical polynomial
  105424. */
  105425. zz: Vector3;
  105426. /**
  105427. * The xy coefficients of the spherical polynomial
  105428. */
  105429. xy: Vector3;
  105430. /**
  105431. * The yz coefficients of the spherical polynomial
  105432. */
  105433. yz: Vector3;
  105434. /**
  105435. * The zx coefficients of the spherical polynomial
  105436. */
  105437. zx: Vector3;
  105438. /**
  105439. * Adds an ambient color to the spherical polynomial
  105440. * @param color the color to add
  105441. */
  105442. addAmbient(color: Color3): void;
  105443. /**
  105444. * Scales the spherical polynomial by the given amount
  105445. * @param scale the amount to scale
  105446. */
  105447. scaleInPlace(scale: number): void;
  105448. /**
  105449. * Gets the spherical polynomial from harmonics
  105450. * @param harmonics the spherical harmonics
  105451. * @returns the spherical polynomial
  105452. */
  105453. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105454. /**
  105455. * Constructs a spherical polynomial from an array.
  105456. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105457. * @returns the spherical polynomial
  105458. */
  105459. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105460. }
  105461. }
  105462. declare module BABYLON {
  105463. /**
  105464. * Defines the source of the internal texture
  105465. */
  105466. export enum InternalTextureSource {
  105467. /**
  105468. * The source of the texture data is unknown
  105469. */
  105470. Unknown = 0,
  105471. /**
  105472. * Texture data comes from an URL
  105473. */
  105474. Url = 1,
  105475. /**
  105476. * Texture data is only used for temporary storage
  105477. */
  105478. Temp = 2,
  105479. /**
  105480. * Texture data comes from raw data (ArrayBuffer)
  105481. */
  105482. Raw = 3,
  105483. /**
  105484. * Texture content is dynamic (video or dynamic texture)
  105485. */
  105486. Dynamic = 4,
  105487. /**
  105488. * Texture content is generated by rendering to it
  105489. */
  105490. RenderTarget = 5,
  105491. /**
  105492. * Texture content is part of a multi render target process
  105493. */
  105494. MultiRenderTarget = 6,
  105495. /**
  105496. * Texture data comes from a cube data file
  105497. */
  105498. Cube = 7,
  105499. /**
  105500. * Texture data comes from a raw cube data
  105501. */
  105502. CubeRaw = 8,
  105503. /**
  105504. * Texture data come from a prefiltered cube data file
  105505. */
  105506. CubePrefiltered = 9,
  105507. /**
  105508. * Texture content is raw 3D data
  105509. */
  105510. Raw3D = 10,
  105511. /**
  105512. * Texture content is raw 2D array data
  105513. */
  105514. Raw2DArray = 11,
  105515. /**
  105516. * Texture content is a depth texture
  105517. */
  105518. Depth = 12,
  105519. /**
  105520. * Texture data comes from a raw cube data encoded with RGBD
  105521. */
  105522. CubeRawRGBD = 13
  105523. }
  105524. /**
  105525. * Class used to store data associated with WebGL texture data for the engine
  105526. * This class should not be used directly
  105527. */
  105528. export class InternalTexture {
  105529. /** @hidden */
  105530. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105531. /**
  105532. * Defines if the texture is ready
  105533. */
  105534. isReady: boolean;
  105535. /**
  105536. * Defines if the texture is a cube texture
  105537. */
  105538. isCube: boolean;
  105539. /**
  105540. * Defines if the texture contains 3D data
  105541. */
  105542. is3D: boolean;
  105543. /**
  105544. * Defines if the texture contains 2D array data
  105545. */
  105546. is2DArray: boolean;
  105547. /**
  105548. * Defines if the texture contains multiview data
  105549. */
  105550. isMultiview: boolean;
  105551. /**
  105552. * Gets the URL used to load this texture
  105553. */
  105554. url: string;
  105555. /**
  105556. * Gets the sampling mode of the texture
  105557. */
  105558. samplingMode: number;
  105559. /**
  105560. * Gets a boolean indicating if the texture needs mipmaps generation
  105561. */
  105562. generateMipMaps: boolean;
  105563. /**
  105564. * Gets the number of samples used by the texture (WebGL2+ only)
  105565. */
  105566. samples: number;
  105567. /**
  105568. * Gets the type of the texture (int, float...)
  105569. */
  105570. type: number;
  105571. /**
  105572. * Gets the format of the texture (RGB, RGBA...)
  105573. */
  105574. format: number;
  105575. /**
  105576. * Observable called when the texture is loaded
  105577. */
  105578. onLoadedObservable: Observable<InternalTexture>;
  105579. /**
  105580. * Gets the width of the texture
  105581. */
  105582. width: number;
  105583. /**
  105584. * Gets the height of the texture
  105585. */
  105586. height: number;
  105587. /**
  105588. * Gets the depth of the texture
  105589. */
  105590. depth: number;
  105591. /**
  105592. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105593. */
  105594. baseWidth: number;
  105595. /**
  105596. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105597. */
  105598. baseHeight: number;
  105599. /**
  105600. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105601. */
  105602. baseDepth: number;
  105603. /**
  105604. * Gets a boolean indicating if the texture is inverted on Y axis
  105605. */
  105606. invertY: boolean;
  105607. /** @hidden */
  105608. _invertVScale: boolean;
  105609. /** @hidden */
  105610. _associatedChannel: number;
  105611. /** @hidden */
  105612. _source: InternalTextureSource;
  105613. /** @hidden */
  105614. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105615. /** @hidden */
  105616. _bufferView: Nullable<ArrayBufferView>;
  105617. /** @hidden */
  105618. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105619. /** @hidden */
  105620. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105621. /** @hidden */
  105622. _size: number;
  105623. /** @hidden */
  105624. _extension: string;
  105625. /** @hidden */
  105626. _files: Nullable<string[]>;
  105627. /** @hidden */
  105628. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105629. /** @hidden */
  105630. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105631. /** @hidden */
  105632. _framebuffer: Nullable<WebGLFramebuffer>;
  105633. /** @hidden */
  105634. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105635. /** @hidden */
  105636. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105637. /** @hidden */
  105638. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105639. /** @hidden */
  105640. _attachments: Nullable<number[]>;
  105641. /** @hidden */
  105642. _cachedCoordinatesMode: Nullable<number>;
  105643. /** @hidden */
  105644. _cachedWrapU: Nullable<number>;
  105645. /** @hidden */
  105646. _cachedWrapV: Nullable<number>;
  105647. /** @hidden */
  105648. _cachedWrapR: Nullable<number>;
  105649. /** @hidden */
  105650. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105651. /** @hidden */
  105652. _isDisabled: boolean;
  105653. /** @hidden */
  105654. _compression: Nullable<string>;
  105655. /** @hidden */
  105656. _generateStencilBuffer: boolean;
  105657. /** @hidden */
  105658. _generateDepthBuffer: boolean;
  105659. /** @hidden */
  105660. _comparisonFunction: number;
  105661. /** @hidden */
  105662. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105663. /** @hidden */
  105664. _lodGenerationScale: number;
  105665. /** @hidden */
  105666. _lodGenerationOffset: number;
  105667. /** @hidden */
  105668. _depthStencilTexture: Nullable<InternalTexture>;
  105669. /** @hidden */
  105670. _colorTextureArray: Nullable<WebGLTexture>;
  105671. /** @hidden */
  105672. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105673. /** @hidden */
  105674. _lodTextureHigh: Nullable<BaseTexture>;
  105675. /** @hidden */
  105676. _lodTextureMid: Nullable<BaseTexture>;
  105677. /** @hidden */
  105678. _lodTextureLow: Nullable<BaseTexture>;
  105679. /** @hidden */
  105680. _isRGBD: boolean;
  105681. /** @hidden */
  105682. _linearSpecularLOD: boolean;
  105683. /** @hidden */
  105684. _irradianceTexture: Nullable<BaseTexture>;
  105685. /** @hidden */
  105686. _webGLTexture: Nullable<WebGLTexture>;
  105687. /** @hidden */
  105688. _references: number;
  105689. private _engine;
  105690. /**
  105691. * Gets the Engine the texture belongs to.
  105692. * @returns The babylon engine
  105693. */
  105694. getEngine(): ThinEngine;
  105695. /**
  105696. * Gets the data source type of the texture
  105697. */
  105698. get source(): InternalTextureSource;
  105699. /**
  105700. * Creates a new InternalTexture
  105701. * @param engine defines the engine to use
  105702. * @param source defines the type of data that will be used
  105703. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105704. */
  105705. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105706. /**
  105707. * Increments the number of references (ie. the number of Texture that point to it)
  105708. */
  105709. incrementReferences(): void;
  105710. /**
  105711. * Change the size of the texture (not the size of the content)
  105712. * @param width defines the new width
  105713. * @param height defines the new height
  105714. * @param depth defines the new depth (1 by default)
  105715. */
  105716. updateSize(width: int, height: int, depth?: int): void;
  105717. /** @hidden */
  105718. _rebuild(): void;
  105719. /** @hidden */
  105720. _swapAndDie(target: InternalTexture): void;
  105721. /**
  105722. * Dispose the current allocated resources
  105723. */
  105724. dispose(): void;
  105725. }
  105726. }
  105727. declare module BABYLON {
  105728. /**
  105729. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105731. */
  105732. export class Analyser {
  105733. /**
  105734. * Gets or sets the smoothing
  105735. * @ignorenaming
  105736. */
  105737. SMOOTHING: number;
  105738. /**
  105739. * Gets or sets the FFT table size
  105740. * @ignorenaming
  105741. */
  105742. FFT_SIZE: number;
  105743. /**
  105744. * Gets or sets the bar graph amplitude
  105745. * @ignorenaming
  105746. */
  105747. BARGRAPHAMPLITUDE: number;
  105748. /**
  105749. * Gets or sets the position of the debug canvas
  105750. * @ignorenaming
  105751. */
  105752. DEBUGCANVASPOS: {
  105753. x: number;
  105754. y: number;
  105755. };
  105756. /**
  105757. * Gets or sets the debug canvas size
  105758. * @ignorenaming
  105759. */
  105760. DEBUGCANVASSIZE: {
  105761. width: number;
  105762. height: number;
  105763. };
  105764. private _byteFreqs;
  105765. private _byteTime;
  105766. private _floatFreqs;
  105767. private _webAudioAnalyser;
  105768. private _debugCanvas;
  105769. private _debugCanvasContext;
  105770. private _scene;
  105771. private _registerFunc;
  105772. private _audioEngine;
  105773. /**
  105774. * Creates a new analyser
  105775. * @param scene defines hosting scene
  105776. */
  105777. constructor(scene: Scene);
  105778. /**
  105779. * Get the number of data values you will have to play with for the visualization
  105780. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105781. * @returns a number
  105782. */
  105783. getFrequencyBinCount(): number;
  105784. /**
  105785. * Gets the current frequency data as a byte array
  105786. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105787. * @returns a Uint8Array
  105788. */
  105789. getByteFrequencyData(): Uint8Array;
  105790. /**
  105791. * Gets the current waveform as a byte array
  105792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105793. * @returns a Uint8Array
  105794. */
  105795. getByteTimeDomainData(): Uint8Array;
  105796. /**
  105797. * Gets the current frequency data as a float array
  105798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105799. * @returns a Float32Array
  105800. */
  105801. getFloatFrequencyData(): Float32Array;
  105802. /**
  105803. * Renders the debug canvas
  105804. */
  105805. drawDebugCanvas(): void;
  105806. /**
  105807. * Stops rendering the debug canvas and removes it
  105808. */
  105809. stopDebugCanvas(): void;
  105810. /**
  105811. * Connects two audio nodes
  105812. * @param inputAudioNode defines first node to connect
  105813. * @param outputAudioNode defines second node to connect
  105814. */
  105815. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105816. /**
  105817. * Releases all associated resources
  105818. */
  105819. dispose(): void;
  105820. }
  105821. }
  105822. declare module BABYLON {
  105823. /**
  105824. * This represents an audio engine and it is responsible
  105825. * to play, synchronize and analyse sounds throughout the application.
  105826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105827. */
  105828. export interface IAudioEngine extends IDisposable {
  105829. /**
  105830. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105831. */
  105832. readonly canUseWebAudio: boolean;
  105833. /**
  105834. * Gets the current AudioContext if available.
  105835. */
  105836. readonly audioContext: Nullable<AudioContext>;
  105837. /**
  105838. * The master gain node defines the global audio volume of your audio engine.
  105839. */
  105840. readonly masterGain: GainNode;
  105841. /**
  105842. * Gets whether or not mp3 are supported by your browser.
  105843. */
  105844. readonly isMP3supported: boolean;
  105845. /**
  105846. * Gets whether or not ogg are supported by your browser.
  105847. */
  105848. readonly isOGGsupported: boolean;
  105849. /**
  105850. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105851. * @ignoreNaming
  105852. */
  105853. WarnedWebAudioUnsupported: boolean;
  105854. /**
  105855. * Defines if the audio engine relies on a custom unlocked button.
  105856. * In this case, the embedded button will not be displayed.
  105857. */
  105858. useCustomUnlockedButton: boolean;
  105859. /**
  105860. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105861. */
  105862. readonly unlocked: boolean;
  105863. /**
  105864. * Event raised when audio has been unlocked on the browser.
  105865. */
  105866. onAudioUnlockedObservable: Observable<AudioEngine>;
  105867. /**
  105868. * Event raised when audio has been locked on the browser.
  105869. */
  105870. onAudioLockedObservable: Observable<AudioEngine>;
  105871. /**
  105872. * Flags the audio engine in Locked state.
  105873. * This happens due to new browser policies preventing audio to autoplay.
  105874. */
  105875. lock(): void;
  105876. /**
  105877. * Unlocks the audio engine once a user action has been done on the dom.
  105878. * This is helpful to resume play once browser policies have been satisfied.
  105879. */
  105880. unlock(): void;
  105881. }
  105882. /**
  105883. * This represents the default audio engine used in babylon.
  105884. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105886. */
  105887. export class AudioEngine implements IAudioEngine {
  105888. private _audioContext;
  105889. private _audioContextInitialized;
  105890. private _muteButton;
  105891. private _hostElement;
  105892. /**
  105893. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105894. */
  105895. canUseWebAudio: boolean;
  105896. /**
  105897. * The master gain node defines the global audio volume of your audio engine.
  105898. */
  105899. masterGain: GainNode;
  105900. /**
  105901. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105902. * @ignoreNaming
  105903. */
  105904. WarnedWebAudioUnsupported: boolean;
  105905. /**
  105906. * Gets whether or not mp3 are supported by your browser.
  105907. */
  105908. isMP3supported: boolean;
  105909. /**
  105910. * Gets whether or not ogg are supported by your browser.
  105911. */
  105912. isOGGsupported: boolean;
  105913. /**
  105914. * Gets whether audio has been unlocked on the device.
  105915. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105916. * a user interaction has happened.
  105917. */
  105918. unlocked: boolean;
  105919. /**
  105920. * Defines if the audio engine relies on a custom unlocked button.
  105921. * In this case, the embedded button will not be displayed.
  105922. */
  105923. useCustomUnlockedButton: boolean;
  105924. /**
  105925. * Event raised when audio has been unlocked on the browser.
  105926. */
  105927. onAudioUnlockedObservable: Observable<AudioEngine>;
  105928. /**
  105929. * Event raised when audio has been locked on the browser.
  105930. */
  105931. onAudioLockedObservable: Observable<AudioEngine>;
  105932. /**
  105933. * Gets the current AudioContext if available.
  105934. */
  105935. get audioContext(): Nullable<AudioContext>;
  105936. private _connectedAnalyser;
  105937. /**
  105938. * Instantiates a new audio engine.
  105939. *
  105940. * There should be only one per page as some browsers restrict the number
  105941. * of audio contexts you can create.
  105942. * @param hostElement defines the host element where to display the mute icon if necessary
  105943. */
  105944. constructor(hostElement?: Nullable<HTMLElement>);
  105945. /**
  105946. * Flags the audio engine in Locked state.
  105947. * This happens due to new browser policies preventing audio to autoplay.
  105948. */
  105949. lock(): void;
  105950. /**
  105951. * Unlocks the audio engine once a user action has been done on the dom.
  105952. * This is helpful to resume play once browser policies have been satisfied.
  105953. */
  105954. unlock(): void;
  105955. private _resumeAudioContext;
  105956. private _initializeAudioContext;
  105957. private _tryToRun;
  105958. private _triggerRunningState;
  105959. private _triggerSuspendedState;
  105960. private _displayMuteButton;
  105961. private _moveButtonToTopLeft;
  105962. private _onResize;
  105963. private _hideMuteButton;
  105964. /**
  105965. * Destroy and release the resources associated with the audio ccontext.
  105966. */
  105967. dispose(): void;
  105968. /**
  105969. * Gets the global volume sets on the master gain.
  105970. * @returns the global volume if set or -1 otherwise
  105971. */
  105972. getGlobalVolume(): number;
  105973. /**
  105974. * Sets the global volume of your experience (sets on the master gain).
  105975. * @param newVolume Defines the new global volume of the application
  105976. */
  105977. setGlobalVolume(newVolume: number): void;
  105978. /**
  105979. * Connect the audio engine to an audio analyser allowing some amazing
  105980. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105982. * @param analyser The analyser to connect to the engine
  105983. */
  105984. connectToAnalyser(analyser: Analyser): void;
  105985. }
  105986. }
  105987. declare module BABYLON {
  105988. /**
  105989. * Interface used to present a loading screen while loading a scene
  105990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105991. */
  105992. export interface ILoadingScreen {
  105993. /**
  105994. * Function called to display the loading screen
  105995. */
  105996. displayLoadingUI: () => void;
  105997. /**
  105998. * Function called to hide the loading screen
  105999. */
  106000. hideLoadingUI: () => void;
  106001. /**
  106002. * Gets or sets the color to use for the background
  106003. */
  106004. loadingUIBackgroundColor: string;
  106005. /**
  106006. * Gets or sets the text to display while loading
  106007. */
  106008. loadingUIText: string;
  106009. }
  106010. /**
  106011. * Class used for the default loading screen
  106012. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106013. */
  106014. export class DefaultLoadingScreen implements ILoadingScreen {
  106015. private _renderingCanvas;
  106016. private _loadingText;
  106017. private _loadingDivBackgroundColor;
  106018. private _loadingDiv;
  106019. private _loadingTextDiv;
  106020. /** Gets or sets the logo url to use for the default loading screen */
  106021. static DefaultLogoUrl: string;
  106022. /** Gets or sets the spinner url to use for the default loading screen */
  106023. static DefaultSpinnerUrl: string;
  106024. /**
  106025. * Creates a new default loading screen
  106026. * @param _renderingCanvas defines the canvas used to render the scene
  106027. * @param _loadingText defines the default text to display
  106028. * @param _loadingDivBackgroundColor defines the default background color
  106029. */
  106030. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106031. /**
  106032. * Function called to display the loading screen
  106033. */
  106034. displayLoadingUI(): void;
  106035. /**
  106036. * Function called to hide the loading screen
  106037. */
  106038. hideLoadingUI(): void;
  106039. /**
  106040. * Gets or sets the text to display while loading
  106041. */
  106042. set loadingUIText(text: string);
  106043. get loadingUIText(): string;
  106044. /**
  106045. * Gets or sets the color to use for the background
  106046. */
  106047. get loadingUIBackgroundColor(): string;
  106048. set loadingUIBackgroundColor(color: string);
  106049. private _resizeLoadingUI;
  106050. }
  106051. }
  106052. declare module BABYLON {
  106053. /**
  106054. * Interface for any object that can request an animation frame
  106055. */
  106056. export interface ICustomAnimationFrameRequester {
  106057. /**
  106058. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106059. */
  106060. renderFunction?: Function;
  106061. /**
  106062. * Called to request the next frame to render to
  106063. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106064. */
  106065. requestAnimationFrame: Function;
  106066. /**
  106067. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106068. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106069. */
  106070. requestID?: number;
  106071. }
  106072. }
  106073. declare module BABYLON {
  106074. /**
  106075. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106076. */
  106077. export class PerformanceMonitor {
  106078. private _enabled;
  106079. private _rollingFrameTime;
  106080. private _lastFrameTimeMs;
  106081. /**
  106082. * constructor
  106083. * @param frameSampleSize The number of samples required to saturate the sliding window
  106084. */
  106085. constructor(frameSampleSize?: number);
  106086. /**
  106087. * Samples current frame
  106088. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106089. */
  106090. sampleFrame(timeMs?: number): void;
  106091. /**
  106092. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106093. */
  106094. get averageFrameTime(): number;
  106095. /**
  106096. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106097. */
  106098. get averageFrameTimeVariance(): number;
  106099. /**
  106100. * Returns the frame time of the most recent frame
  106101. */
  106102. get instantaneousFrameTime(): number;
  106103. /**
  106104. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106105. */
  106106. get averageFPS(): number;
  106107. /**
  106108. * Returns the average framerate in frames per second using the most recent frame time
  106109. */
  106110. get instantaneousFPS(): number;
  106111. /**
  106112. * Returns true if enough samples have been taken to completely fill the sliding window
  106113. */
  106114. get isSaturated(): boolean;
  106115. /**
  106116. * Enables contributions to the sliding window sample set
  106117. */
  106118. enable(): void;
  106119. /**
  106120. * Disables contributions to the sliding window sample set
  106121. * Samples will not be interpolated over the disabled period
  106122. */
  106123. disable(): void;
  106124. /**
  106125. * Returns true if sampling is enabled
  106126. */
  106127. get isEnabled(): boolean;
  106128. /**
  106129. * Resets performance monitor
  106130. */
  106131. reset(): void;
  106132. }
  106133. /**
  106134. * RollingAverage
  106135. *
  106136. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106137. */
  106138. export class RollingAverage {
  106139. /**
  106140. * Current average
  106141. */
  106142. average: number;
  106143. /**
  106144. * Current variance
  106145. */
  106146. variance: number;
  106147. protected _samples: Array<number>;
  106148. protected _sampleCount: number;
  106149. protected _pos: number;
  106150. protected _m2: number;
  106151. /**
  106152. * constructor
  106153. * @param length The number of samples required to saturate the sliding window
  106154. */
  106155. constructor(length: number);
  106156. /**
  106157. * Adds a sample to the sample set
  106158. * @param v The sample value
  106159. */
  106160. add(v: number): void;
  106161. /**
  106162. * Returns previously added values or null if outside of history or outside the sliding window domain
  106163. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106164. * @return Value previously recorded with add() or null if outside of range
  106165. */
  106166. history(i: number): number;
  106167. /**
  106168. * Returns true if enough samples have been taken to completely fill the sliding window
  106169. * @return true if sample-set saturated
  106170. */
  106171. isSaturated(): boolean;
  106172. /**
  106173. * Resets the rolling average (equivalent to 0 samples taken so far)
  106174. */
  106175. reset(): void;
  106176. /**
  106177. * Wraps a value around the sample range boundaries
  106178. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106179. * @return Wrapped position in sample range
  106180. */
  106181. protected _wrapPosition(i: number): number;
  106182. }
  106183. }
  106184. declare module BABYLON {
  106185. /**
  106186. * This class is used to track a performance counter which is number based.
  106187. * The user has access to many properties which give statistics of different nature.
  106188. *
  106189. * The implementer can track two kinds of Performance Counter: time and count.
  106190. * 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.
  106191. * 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.
  106192. */
  106193. export class PerfCounter {
  106194. /**
  106195. * Gets or sets a global boolean to turn on and off all the counters
  106196. */
  106197. static Enabled: boolean;
  106198. /**
  106199. * Returns the smallest value ever
  106200. */
  106201. get min(): number;
  106202. /**
  106203. * Returns the biggest value ever
  106204. */
  106205. get max(): number;
  106206. /**
  106207. * Returns the average value since the performance counter is running
  106208. */
  106209. get average(): number;
  106210. /**
  106211. * Returns the average value of the last second the counter was monitored
  106212. */
  106213. get lastSecAverage(): number;
  106214. /**
  106215. * Returns the current value
  106216. */
  106217. get current(): number;
  106218. /**
  106219. * Gets the accumulated total
  106220. */
  106221. get total(): number;
  106222. /**
  106223. * Gets the total value count
  106224. */
  106225. get count(): number;
  106226. /**
  106227. * Creates a new counter
  106228. */
  106229. constructor();
  106230. /**
  106231. * Call this method to start monitoring a new frame.
  106232. * 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.
  106233. */
  106234. fetchNewFrame(): void;
  106235. /**
  106236. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106237. * @param newCount the count value to add to the monitored count
  106238. * @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.
  106239. */
  106240. addCount(newCount: number, fetchResult: boolean): void;
  106241. /**
  106242. * Start monitoring this performance counter
  106243. */
  106244. beginMonitoring(): void;
  106245. /**
  106246. * Compute the time lapsed since the previous beginMonitoring() call.
  106247. * @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
  106248. */
  106249. endMonitoring(newFrame?: boolean): void;
  106250. private _fetchResult;
  106251. private _startMonitoringTime;
  106252. private _min;
  106253. private _max;
  106254. private _average;
  106255. private _current;
  106256. private _totalValueCount;
  106257. private _totalAccumulated;
  106258. private _lastSecAverage;
  106259. private _lastSecAccumulated;
  106260. private _lastSecTime;
  106261. private _lastSecValueCount;
  106262. }
  106263. }
  106264. declare module BABYLON {
  106265. interface ThinEngine {
  106266. /**
  106267. * Sets alpha constants used by some alpha blending modes
  106268. * @param r defines the red component
  106269. * @param g defines the green component
  106270. * @param b defines the blue component
  106271. * @param a defines the alpha component
  106272. */
  106273. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106274. /**
  106275. * Sets the current alpha mode
  106276. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106277. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106278. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106279. */
  106280. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106281. /**
  106282. * Gets the current alpha mode
  106283. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106284. * @returns the current alpha mode
  106285. */
  106286. getAlphaMode(): number;
  106287. /**
  106288. * Sets the current alpha equation
  106289. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106290. */
  106291. setAlphaEquation(equation: number): void;
  106292. /**
  106293. * Gets the current alpha equation.
  106294. * @returns the current alpha equation
  106295. */
  106296. getAlphaEquation(): number;
  106297. }
  106298. }
  106299. declare module BABYLON {
  106300. /**
  106301. * Defines the interface used by display changed events
  106302. */
  106303. export interface IDisplayChangedEventArgs {
  106304. /** Gets the vrDisplay object (if any) */
  106305. vrDisplay: Nullable<any>;
  106306. /** Gets a boolean indicating if webVR is supported */
  106307. vrSupported: boolean;
  106308. }
  106309. /**
  106310. * Defines the interface used by objects containing a viewport (like a camera)
  106311. */
  106312. interface IViewportOwnerLike {
  106313. /**
  106314. * Gets or sets the viewport
  106315. */
  106316. viewport: IViewportLike;
  106317. }
  106318. /**
  106319. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106320. */
  106321. export class Engine extends ThinEngine {
  106322. /** Defines that alpha blending is disabled */
  106323. static readonly ALPHA_DISABLE: number;
  106324. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106325. static readonly ALPHA_ADD: number;
  106326. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106327. static readonly ALPHA_COMBINE: number;
  106328. /** Defines that alpha blending to DEST - SRC * DEST */
  106329. static readonly ALPHA_SUBTRACT: number;
  106330. /** Defines that alpha blending to SRC * DEST */
  106331. static readonly ALPHA_MULTIPLY: number;
  106332. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106333. static readonly ALPHA_MAXIMIZED: number;
  106334. /** Defines that alpha blending to SRC + DEST */
  106335. static readonly ALPHA_ONEONE: number;
  106336. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106337. static readonly ALPHA_PREMULTIPLIED: number;
  106338. /**
  106339. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106340. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106341. */
  106342. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106343. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106344. static readonly ALPHA_INTERPOLATE: number;
  106345. /**
  106346. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106347. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106348. */
  106349. static readonly ALPHA_SCREENMODE: number;
  106350. /** Defines that the ressource is not delayed*/
  106351. static readonly DELAYLOADSTATE_NONE: number;
  106352. /** Defines that the ressource was successfully delay loaded */
  106353. static readonly DELAYLOADSTATE_LOADED: number;
  106354. /** Defines that the ressource is currently delay loading */
  106355. static readonly DELAYLOADSTATE_LOADING: number;
  106356. /** Defines that the ressource is delayed and has not started loading */
  106357. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106358. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106359. static readonly NEVER: number;
  106360. /** 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 */
  106361. static readonly ALWAYS: number;
  106362. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106363. static readonly LESS: number;
  106364. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106365. static readonly EQUAL: number;
  106366. /** 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 */
  106367. static readonly LEQUAL: number;
  106368. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106369. static readonly GREATER: number;
  106370. /** 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 */
  106371. static readonly GEQUAL: number;
  106372. /** 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 */
  106373. static readonly NOTEQUAL: number;
  106374. /** Passed to stencilOperation to specify that stencil value must be kept */
  106375. static readonly KEEP: number;
  106376. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106377. static readonly REPLACE: number;
  106378. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106379. static readonly INCR: number;
  106380. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106381. static readonly DECR: number;
  106382. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106383. static readonly INVERT: number;
  106384. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106385. static readonly INCR_WRAP: number;
  106386. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106387. static readonly DECR_WRAP: number;
  106388. /** Texture is not repeating outside of 0..1 UVs */
  106389. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106390. /** Texture is repeating outside of 0..1 UVs */
  106391. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106392. /** Texture is repeating and mirrored */
  106393. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106394. /** ALPHA */
  106395. static readonly TEXTUREFORMAT_ALPHA: number;
  106396. /** LUMINANCE */
  106397. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106398. /** LUMINANCE_ALPHA */
  106399. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106400. /** RGB */
  106401. static readonly TEXTUREFORMAT_RGB: number;
  106402. /** RGBA */
  106403. static readonly TEXTUREFORMAT_RGBA: number;
  106404. /** RED */
  106405. static readonly TEXTUREFORMAT_RED: number;
  106406. /** RED (2nd reference) */
  106407. static readonly TEXTUREFORMAT_R: number;
  106408. /** RG */
  106409. static readonly TEXTUREFORMAT_RG: number;
  106410. /** RED_INTEGER */
  106411. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106412. /** RED_INTEGER (2nd reference) */
  106413. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106414. /** RG_INTEGER */
  106415. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106416. /** RGB_INTEGER */
  106417. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106418. /** RGBA_INTEGER */
  106419. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106420. /** UNSIGNED_BYTE */
  106421. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106422. /** UNSIGNED_BYTE (2nd reference) */
  106423. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106424. /** FLOAT */
  106425. static readonly TEXTURETYPE_FLOAT: number;
  106426. /** HALF_FLOAT */
  106427. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106428. /** BYTE */
  106429. static readonly TEXTURETYPE_BYTE: number;
  106430. /** SHORT */
  106431. static readonly TEXTURETYPE_SHORT: number;
  106432. /** UNSIGNED_SHORT */
  106433. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106434. /** INT */
  106435. static readonly TEXTURETYPE_INT: number;
  106436. /** UNSIGNED_INT */
  106437. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106438. /** UNSIGNED_SHORT_4_4_4_4 */
  106439. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106440. /** UNSIGNED_SHORT_5_5_5_1 */
  106441. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106442. /** UNSIGNED_SHORT_5_6_5 */
  106443. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106444. /** UNSIGNED_INT_2_10_10_10_REV */
  106445. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106446. /** UNSIGNED_INT_24_8 */
  106447. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106448. /** UNSIGNED_INT_10F_11F_11F_REV */
  106449. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106450. /** UNSIGNED_INT_5_9_9_9_REV */
  106451. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106452. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106453. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106454. /** nearest is mag = nearest and min = nearest and mip = linear */
  106455. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106456. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106457. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106458. /** Trilinear is mag = linear and min = linear and mip = linear */
  106459. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106460. /** nearest is mag = nearest and min = nearest and mip = linear */
  106461. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106462. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106463. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106464. /** Trilinear is mag = linear and min = linear and mip = linear */
  106465. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106466. /** mag = nearest and min = nearest and mip = nearest */
  106467. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106468. /** mag = nearest and min = linear and mip = nearest */
  106469. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106470. /** mag = nearest and min = linear and mip = linear */
  106471. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106472. /** mag = nearest and min = linear and mip = none */
  106473. static readonly TEXTURE_NEAREST_LINEAR: number;
  106474. /** mag = nearest and min = nearest and mip = none */
  106475. static readonly TEXTURE_NEAREST_NEAREST: number;
  106476. /** mag = linear and min = nearest and mip = nearest */
  106477. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106478. /** mag = linear and min = nearest and mip = linear */
  106479. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106480. /** mag = linear and min = linear and mip = none */
  106481. static readonly TEXTURE_LINEAR_LINEAR: number;
  106482. /** mag = linear and min = nearest and mip = none */
  106483. static readonly TEXTURE_LINEAR_NEAREST: number;
  106484. /** Explicit coordinates mode */
  106485. static readonly TEXTURE_EXPLICIT_MODE: number;
  106486. /** Spherical coordinates mode */
  106487. static readonly TEXTURE_SPHERICAL_MODE: number;
  106488. /** Planar coordinates mode */
  106489. static readonly TEXTURE_PLANAR_MODE: number;
  106490. /** Cubic coordinates mode */
  106491. static readonly TEXTURE_CUBIC_MODE: number;
  106492. /** Projection coordinates mode */
  106493. static readonly TEXTURE_PROJECTION_MODE: number;
  106494. /** Skybox coordinates mode */
  106495. static readonly TEXTURE_SKYBOX_MODE: number;
  106496. /** Inverse Cubic coordinates mode */
  106497. static readonly TEXTURE_INVCUBIC_MODE: number;
  106498. /** Equirectangular coordinates mode */
  106499. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106500. /** Equirectangular Fixed coordinates mode */
  106501. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106502. /** Equirectangular Fixed Mirrored coordinates mode */
  106503. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106504. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106505. static readonly SCALEMODE_FLOOR: number;
  106506. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106507. static readonly SCALEMODE_NEAREST: number;
  106508. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106509. static readonly SCALEMODE_CEILING: number;
  106510. /**
  106511. * Returns the current npm package of the sdk
  106512. */
  106513. static get NpmPackage(): string;
  106514. /**
  106515. * Returns the current version of the framework
  106516. */
  106517. static get Version(): string;
  106518. /** Gets the list of created engines */
  106519. static get Instances(): Engine[];
  106520. /**
  106521. * Gets the latest created engine
  106522. */
  106523. static get LastCreatedEngine(): Nullable<Engine>;
  106524. /**
  106525. * Gets the latest created scene
  106526. */
  106527. static get LastCreatedScene(): Nullable<Scene>;
  106528. /**
  106529. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106530. * @param flag defines which part of the materials must be marked as dirty
  106531. * @param predicate defines a predicate used to filter which materials should be affected
  106532. */
  106533. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106534. /**
  106535. * Method called to create the default loading screen.
  106536. * This can be overriden in your own app.
  106537. * @param canvas The rendering canvas element
  106538. * @returns The loading screen
  106539. */
  106540. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106541. /**
  106542. * Method called to create the default rescale post process on each engine.
  106543. */
  106544. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106545. /**
  106546. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106547. **/
  106548. enableOfflineSupport: boolean;
  106549. /**
  106550. * 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)
  106551. **/
  106552. disableManifestCheck: boolean;
  106553. /**
  106554. * Gets the list of created scenes
  106555. */
  106556. scenes: Scene[];
  106557. /**
  106558. * Event raised when a new scene is created
  106559. */
  106560. onNewSceneAddedObservable: Observable<Scene>;
  106561. /**
  106562. * Gets the list of created postprocesses
  106563. */
  106564. postProcesses: PostProcess[];
  106565. /**
  106566. * Gets a boolean indicating if the pointer is currently locked
  106567. */
  106568. isPointerLock: boolean;
  106569. /**
  106570. * Observable event triggered each time the rendering canvas is resized
  106571. */
  106572. onResizeObservable: Observable<Engine>;
  106573. /**
  106574. * Observable event triggered each time the canvas loses focus
  106575. */
  106576. onCanvasBlurObservable: Observable<Engine>;
  106577. /**
  106578. * Observable event triggered each time the canvas gains focus
  106579. */
  106580. onCanvasFocusObservable: Observable<Engine>;
  106581. /**
  106582. * Observable event triggered each time the canvas receives pointerout event
  106583. */
  106584. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106585. /**
  106586. * Observable raised when the engine begins a new frame
  106587. */
  106588. onBeginFrameObservable: Observable<Engine>;
  106589. /**
  106590. * If set, will be used to request the next animation frame for the render loop
  106591. */
  106592. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106593. /**
  106594. * Observable raised when the engine ends the current frame
  106595. */
  106596. onEndFrameObservable: Observable<Engine>;
  106597. /**
  106598. * Observable raised when the engine is about to compile a shader
  106599. */
  106600. onBeforeShaderCompilationObservable: Observable<Engine>;
  106601. /**
  106602. * Observable raised when the engine has jsut compiled a shader
  106603. */
  106604. onAfterShaderCompilationObservable: Observable<Engine>;
  106605. /**
  106606. * Gets the audio engine
  106607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106608. * @ignorenaming
  106609. */
  106610. static audioEngine: IAudioEngine;
  106611. /**
  106612. * Default AudioEngine factory responsible of creating the Audio Engine.
  106613. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106614. */
  106615. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106616. /**
  106617. * Default offline support factory responsible of creating a tool used to store data locally.
  106618. * By default, this will create a Database object if the workload has been embedded.
  106619. */
  106620. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106621. private _loadingScreen;
  106622. private _pointerLockRequested;
  106623. private _dummyFramebuffer;
  106624. private _rescalePostProcess;
  106625. private _deterministicLockstep;
  106626. private _lockstepMaxSteps;
  106627. private _timeStep;
  106628. protected get _supportsHardwareTextureRescaling(): boolean;
  106629. private _fps;
  106630. private _deltaTime;
  106631. /** @hidden */
  106632. _drawCalls: PerfCounter;
  106633. /** 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 */
  106634. canvasTabIndex: number;
  106635. /**
  106636. * Turn this value on if you want to pause FPS computation when in background
  106637. */
  106638. disablePerformanceMonitorInBackground: boolean;
  106639. private _performanceMonitor;
  106640. /**
  106641. * Gets the performance monitor attached to this engine
  106642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106643. */
  106644. get performanceMonitor(): PerformanceMonitor;
  106645. private _onFocus;
  106646. private _onBlur;
  106647. private _onCanvasPointerOut;
  106648. private _onCanvasBlur;
  106649. private _onCanvasFocus;
  106650. private _onFullscreenChange;
  106651. private _onPointerLockChange;
  106652. /**
  106653. * Gets the HTML element used to attach event listeners
  106654. * @returns a HTML element
  106655. */
  106656. getInputElement(): Nullable<HTMLElement>;
  106657. /**
  106658. * Creates a new engine
  106659. * @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
  106660. * @param antialias defines enable antialiasing (default: false)
  106661. * @param options defines further options to be sent to the getContext() function
  106662. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106663. */
  106664. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106665. /**
  106666. * Gets current aspect ratio
  106667. * @param viewportOwner defines the camera to use to get the aspect ratio
  106668. * @param useScreen defines if screen size must be used (or the current render target if any)
  106669. * @returns a number defining the aspect ratio
  106670. */
  106671. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106672. /**
  106673. * Gets current screen aspect ratio
  106674. * @returns a number defining the aspect ratio
  106675. */
  106676. getScreenAspectRatio(): number;
  106677. /**
  106678. * Gets the client rect of the HTML canvas attached with the current webGL context
  106679. * @returns a client rectanglee
  106680. */
  106681. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106682. /**
  106683. * Gets the client rect of the HTML element used for events
  106684. * @returns a client rectanglee
  106685. */
  106686. getInputElementClientRect(): Nullable<ClientRect>;
  106687. /**
  106688. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106689. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106690. * @returns true if engine is in deterministic lock step mode
  106691. */
  106692. isDeterministicLockStep(): boolean;
  106693. /**
  106694. * Gets the max steps when engine is running in deterministic lock step
  106695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106696. * @returns the max steps
  106697. */
  106698. getLockstepMaxSteps(): number;
  106699. /**
  106700. * Returns the time in ms between steps when using deterministic lock step.
  106701. * @returns time step in (ms)
  106702. */
  106703. getTimeStep(): number;
  106704. /**
  106705. * Force the mipmap generation for the given render target texture
  106706. * @param texture defines the render target texture to use
  106707. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106708. */
  106709. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106710. /** States */
  106711. /**
  106712. * Set various states to the webGL context
  106713. * @param culling defines backface culling state
  106714. * @param zOffset defines the value to apply to zOffset (0 by default)
  106715. * @param force defines if states must be applied even if cache is up to date
  106716. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106717. */
  106718. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106719. /**
  106720. * Set the z offset to apply to current rendering
  106721. * @param value defines the offset to apply
  106722. */
  106723. setZOffset(value: number): void;
  106724. /**
  106725. * Gets the current value of the zOffset
  106726. * @returns the current zOffset state
  106727. */
  106728. getZOffset(): number;
  106729. /**
  106730. * Enable or disable depth buffering
  106731. * @param enable defines the state to set
  106732. */
  106733. setDepthBuffer(enable: boolean): void;
  106734. /**
  106735. * Gets a boolean indicating if depth writing is enabled
  106736. * @returns the current depth writing state
  106737. */
  106738. getDepthWrite(): boolean;
  106739. /**
  106740. * Enable or disable depth writing
  106741. * @param enable defines the state to set
  106742. */
  106743. setDepthWrite(enable: boolean): void;
  106744. /**
  106745. * Gets a boolean indicating if stencil buffer is enabled
  106746. * @returns the current stencil buffer state
  106747. */
  106748. getStencilBuffer(): boolean;
  106749. /**
  106750. * Enable or disable the stencil buffer
  106751. * @param enable defines if the stencil buffer must be enabled or disabled
  106752. */
  106753. setStencilBuffer(enable: boolean): void;
  106754. /**
  106755. * Gets the current stencil mask
  106756. * @returns a number defining the new stencil mask to use
  106757. */
  106758. getStencilMask(): number;
  106759. /**
  106760. * Sets the current stencil mask
  106761. * @param mask defines the new stencil mask to use
  106762. */
  106763. setStencilMask(mask: number): void;
  106764. /**
  106765. * Gets the current stencil function
  106766. * @returns a number defining the stencil function to use
  106767. */
  106768. getStencilFunction(): number;
  106769. /**
  106770. * Gets the current stencil reference value
  106771. * @returns a number defining the stencil reference value to use
  106772. */
  106773. getStencilFunctionReference(): number;
  106774. /**
  106775. * Gets the current stencil mask
  106776. * @returns a number defining the stencil mask to use
  106777. */
  106778. getStencilFunctionMask(): number;
  106779. /**
  106780. * Sets the current stencil function
  106781. * @param stencilFunc defines the new stencil function to use
  106782. */
  106783. setStencilFunction(stencilFunc: number): void;
  106784. /**
  106785. * Sets the current stencil reference
  106786. * @param reference defines the new stencil reference to use
  106787. */
  106788. setStencilFunctionReference(reference: number): void;
  106789. /**
  106790. * Sets the current stencil mask
  106791. * @param mask defines the new stencil mask to use
  106792. */
  106793. setStencilFunctionMask(mask: number): void;
  106794. /**
  106795. * Gets the current stencil operation when stencil fails
  106796. * @returns a number defining stencil operation to use when stencil fails
  106797. */
  106798. getStencilOperationFail(): number;
  106799. /**
  106800. * Gets the current stencil operation when depth fails
  106801. * @returns a number defining stencil operation to use when depth fails
  106802. */
  106803. getStencilOperationDepthFail(): number;
  106804. /**
  106805. * Gets the current stencil operation when stencil passes
  106806. * @returns a number defining stencil operation to use when stencil passes
  106807. */
  106808. getStencilOperationPass(): number;
  106809. /**
  106810. * Sets the stencil operation to use when stencil fails
  106811. * @param operation defines the stencil operation to use when stencil fails
  106812. */
  106813. setStencilOperationFail(operation: number): void;
  106814. /**
  106815. * Sets the stencil operation to use when depth fails
  106816. * @param operation defines the stencil operation to use when depth fails
  106817. */
  106818. setStencilOperationDepthFail(operation: number): void;
  106819. /**
  106820. * Sets the stencil operation to use when stencil passes
  106821. * @param operation defines the stencil operation to use when stencil passes
  106822. */
  106823. setStencilOperationPass(operation: number): void;
  106824. /**
  106825. * Sets a boolean indicating if the dithering state is enabled or disabled
  106826. * @param value defines the dithering state
  106827. */
  106828. setDitheringState(value: boolean): void;
  106829. /**
  106830. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106831. * @param value defines the rasterizer state
  106832. */
  106833. setRasterizerState(value: boolean): void;
  106834. /**
  106835. * Gets the current depth function
  106836. * @returns a number defining the depth function
  106837. */
  106838. getDepthFunction(): Nullable<number>;
  106839. /**
  106840. * Sets the current depth function
  106841. * @param depthFunc defines the function to use
  106842. */
  106843. setDepthFunction(depthFunc: number): void;
  106844. /**
  106845. * Sets the current depth function to GREATER
  106846. */
  106847. setDepthFunctionToGreater(): void;
  106848. /**
  106849. * Sets the current depth function to GEQUAL
  106850. */
  106851. setDepthFunctionToGreaterOrEqual(): void;
  106852. /**
  106853. * Sets the current depth function to LESS
  106854. */
  106855. setDepthFunctionToLess(): void;
  106856. /**
  106857. * Sets the current depth function to LEQUAL
  106858. */
  106859. setDepthFunctionToLessOrEqual(): void;
  106860. private _cachedStencilBuffer;
  106861. private _cachedStencilFunction;
  106862. private _cachedStencilMask;
  106863. private _cachedStencilOperationPass;
  106864. private _cachedStencilOperationFail;
  106865. private _cachedStencilOperationDepthFail;
  106866. private _cachedStencilReference;
  106867. /**
  106868. * Caches the the state of the stencil buffer
  106869. */
  106870. cacheStencilState(): void;
  106871. /**
  106872. * Restores the state of the stencil buffer
  106873. */
  106874. restoreStencilState(): void;
  106875. /**
  106876. * Directly set the WebGL Viewport
  106877. * @param x defines the x coordinate of the viewport (in screen space)
  106878. * @param y defines the y coordinate of the viewport (in screen space)
  106879. * @param width defines the width of the viewport (in screen space)
  106880. * @param height defines the height of the viewport (in screen space)
  106881. * @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
  106882. */
  106883. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106884. /**
  106885. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106886. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106887. * @param y defines the y-coordinate of the corner of the clear rectangle
  106888. * @param width defines the width of the clear rectangle
  106889. * @param height defines the height of the clear rectangle
  106890. * @param clearColor defines the clear color
  106891. */
  106892. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106893. /**
  106894. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106895. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106896. * @param y defines the y-coordinate of the corner of the clear rectangle
  106897. * @param width defines the width of the clear rectangle
  106898. * @param height defines the height of the clear rectangle
  106899. */
  106900. enableScissor(x: number, y: number, width: number, height: number): void;
  106901. /**
  106902. * Disable previously set scissor test rectangle
  106903. */
  106904. disableScissor(): void;
  106905. protected _reportDrawCall(): void;
  106906. /**
  106907. * Initializes a webVR display and starts listening to display change events
  106908. * The onVRDisplayChangedObservable will be notified upon these changes
  106909. * @returns The onVRDisplayChangedObservable
  106910. */
  106911. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106912. /** @hidden */
  106913. _prepareVRComponent(): void;
  106914. /** @hidden */
  106915. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106916. /** @hidden */
  106917. _submitVRFrame(): void;
  106918. /**
  106919. * Call this function to leave webVR mode
  106920. * Will do nothing if webVR is not supported or if there is no webVR device
  106921. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106922. */
  106923. disableVR(): void;
  106924. /**
  106925. * Gets a boolean indicating that the system is in VR mode and is presenting
  106926. * @returns true if VR mode is engaged
  106927. */
  106928. isVRPresenting(): boolean;
  106929. /** @hidden */
  106930. _requestVRFrame(): void;
  106931. /** @hidden */
  106932. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106933. /**
  106934. * Gets the source code of the vertex shader associated with a specific webGL program
  106935. * @param program defines the program to use
  106936. * @returns a string containing the source code of the vertex shader associated with the program
  106937. */
  106938. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106939. /**
  106940. * Gets the source code of the fragment shader associated with a specific webGL program
  106941. * @param program defines the program to use
  106942. * @returns a string containing the source code of the fragment shader associated with the program
  106943. */
  106944. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106945. /**
  106946. * Sets a depth stencil texture from a render target to the according uniform.
  106947. * @param channel The texture channel
  106948. * @param uniform The uniform to set
  106949. * @param texture The render target texture containing the depth stencil texture to apply
  106950. */
  106951. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106952. /**
  106953. * Sets a texture to the webGL context from a postprocess
  106954. * @param channel defines the channel to use
  106955. * @param postProcess defines the source postprocess
  106956. */
  106957. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106958. /**
  106959. * Binds the output of the passed in post process to the texture channel specified
  106960. * @param channel The channel the texture should be bound to
  106961. * @param postProcess The post process which's output should be bound
  106962. */
  106963. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106964. /** @hidden */
  106965. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106966. protected _rebuildBuffers(): void;
  106967. /** @hidden */
  106968. _renderFrame(): void;
  106969. _renderLoop(): void;
  106970. /** @hidden */
  106971. _renderViews(): boolean;
  106972. /**
  106973. * Toggle full screen mode
  106974. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106975. */
  106976. switchFullscreen(requestPointerLock: boolean): void;
  106977. /**
  106978. * Enters full screen mode
  106979. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106980. */
  106981. enterFullscreen(requestPointerLock: boolean): void;
  106982. /**
  106983. * Exits full screen mode
  106984. */
  106985. exitFullscreen(): void;
  106986. /**
  106987. * Enters Pointerlock mode
  106988. */
  106989. enterPointerlock(): void;
  106990. /**
  106991. * Exits Pointerlock mode
  106992. */
  106993. exitPointerlock(): void;
  106994. /**
  106995. * Begin a new frame
  106996. */
  106997. beginFrame(): void;
  106998. /**
  106999. * Enf the current frame
  107000. */
  107001. endFrame(): void;
  107002. resize(): void;
  107003. /**
  107004. * Force a specific size of the canvas
  107005. * @param width defines the new canvas' width
  107006. * @param height defines the new canvas' height
  107007. */
  107008. setSize(width: number, height: number): void;
  107009. /**
  107010. * Updates a dynamic vertex buffer.
  107011. * @param vertexBuffer the vertex buffer to update
  107012. * @param data the data used to update the vertex buffer
  107013. * @param byteOffset the byte offset of the data
  107014. * @param byteLength the byte length of the data
  107015. */
  107016. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107017. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107018. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107019. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107020. _releaseTexture(texture: InternalTexture): void;
  107021. /**
  107022. * @hidden
  107023. * Rescales a texture
  107024. * @param source input texutre
  107025. * @param destination destination texture
  107026. * @param scene scene to use to render the resize
  107027. * @param internalFormat format to use when resizing
  107028. * @param onComplete callback to be called when resize has completed
  107029. */
  107030. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107031. /**
  107032. * Gets the current framerate
  107033. * @returns a number representing the framerate
  107034. */
  107035. getFps(): number;
  107036. /**
  107037. * Gets the time spent between current and previous frame
  107038. * @returns a number representing the delta time in ms
  107039. */
  107040. getDeltaTime(): number;
  107041. private _measureFps;
  107042. /** @hidden */
  107043. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107044. /**
  107045. * Update a dynamic index buffer
  107046. * @param indexBuffer defines the target index buffer
  107047. * @param indices defines the data to update
  107048. * @param offset defines the offset in the target index buffer where update should start
  107049. */
  107050. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107051. /**
  107052. * Updates the sample count of a render target texture
  107053. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107054. * @param texture defines the texture to update
  107055. * @param samples defines the sample count to set
  107056. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107057. */
  107058. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107059. /**
  107060. * Updates a depth texture Comparison Mode and Function.
  107061. * If the comparison Function is equal to 0, the mode will be set to none.
  107062. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107063. * @param texture The texture to set the comparison function for
  107064. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107065. */
  107066. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107067. /**
  107068. * Creates a webGL buffer to use with instanciation
  107069. * @param capacity defines the size of the buffer
  107070. * @returns the webGL buffer
  107071. */
  107072. createInstancesBuffer(capacity: number): DataBuffer;
  107073. /**
  107074. * Delete a webGL buffer used with instanciation
  107075. * @param buffer defines the webGL buffer to delete
  107076. */
  107077. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107078. private _clientWaitAsync;
  107079. /** @hidden */
  107080. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107081. /** @hidden */
  107082. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107083. dispose(): void;
  107084. private _disableTouchAction;
  107085. /**
  107086. * Display the loading screen
  107087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107088. */
  107089. displayLoadingUI(): void;
  107090. /**
  107091. * Hide the loading screen
  107092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107093. */
  107094. hideLoadingUI(): void;
  107095. /**
  107096. * Gets the current loading screen object
  107097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107098. */
  107099. get loadingScreen(): ILoadingScreen;
  107100. /**
  107101. * Sets the current loading screen object
  107102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107103. */
  107104. set loadingScreen(loadingScreen: ILoadingScreen);
  107105. /**
  107106. * Sets the current loading screen text
  107107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107108. */
  107109. set loadingUIText(text: string);
  107110. /**
  107111. * Sets the current loading screen background color
  107112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107113. */
  107114. set loadingUIBackgroundColor(color: string);
  107115. /** Pointerlock and fullscreen */
  107116. /**
  107117. * Ask the browser to promote the current element to pointerlock mode
  107118. * @param element defines the DOM element to promote
  107119. */
  107120. static _RequestPointerlock(element: HTMLElement): void;
  107121. /**
  107122. * Asks the browser to exit pointerlock mode
  107123. */
  107124. static _ExitPointerlock(): void;
  107125. /**
  107126. * Ask the browser to promote the current element to fullscreen rendering mode
  107127. * @param element defines the DOM element to promote
  107128. */
  107129. static _RequestFullscreen(element: HTMLElement): void;
  107130. /**
  107131. * Asks the browser to exit fullscreen mode
  107132. */
  107133. static _ExitFullscreen(): void;
  107134. }
  107135. }
  107136. declare module BABYLON {
  107137. /**
  107138. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107139. * during the life time of the application.
  107140. */
  107141. export class EngineStore {
  107142. /** Gets the list of created engines */
  107143. static Instances: Engine[];
  107144. /** @hidden */
  107145. static _LastCreatedScene: Nullable<Scene>;
  107146. /**
  107147. * Gets the latest created engine
  107148. */
  107149. static get LastCreatedEngine(): Nullable<Engine>;
  107150. /**
  107151. * Gets the latest created scene
  107152. */
  107153. static get LastCreatedScene(): Nullable<Scene>;
  107154. /**
  107155. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107156. * @ignorenaming
  107157. */
  107158. static UseFallbackTexture: boolean;
  107159. /**
  107160. * Texture content used if a texture cannot loaded
  107161. * @ignorenaming
  107162. */
  107163. static FallbackTexture: string;
  107164. }
  107165. }
  107166. declare module BABYLON {
  107167. /**
  107168. * Helper class that provides a small promise polyfill
  107169. */
  107170. export class PromisePolyfill {
  107171. /**
  107172. * Static function used to check if the polyfill is required
  107173. * If this is the case then the function will inject the polyfill to window.Promise
  107174. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107175. */
  107176. static Apply(force?: boolean): void;
  107177. }
  107178. }
  107179. declare module BABYLON {
  107180. /**
  107181. * Interface for screenshot methods with describe argument called `size` as object with options
  107182. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107183. */
  107184. export interface IScreenshotSize {
  107185. /**
  107186. * number in pixels for canvas height
  107187. */
  107188. height?: number;
  107189. /**
  107190. * multiplier allowing render at a higher or lower resolution
  107191. * If value is defined then height and width will be ignored and taken from camera
  107192. */
  107193. precision?: number;
  107194. /**
  107195. * number in pixels for canvas width
  107196. */
  107197. width?: number;
  107198. }
  107199. }
  107200. declare module BABYLON {
  107201. interface IColor4Like {
  107202. r: float;
  107203. g: float;
  107204. b: float;
  107205. a: float;
  107206. }
  107207. /**
  107208. * Class containing a set of static utilities functions
  107209. */
  107210. export class Tools {
  107211. /**
  107212. * Gets or sets the base URL to use to load assets
  107213. */
  107214. static get BaseUrl(): string;
  107215. static set BaseUrl(value: string);
  107216. /**
  107217. * Enable/Disable Custom HTTP Request Headers globally.
  107218. * default = false
  107219. * @see CustomRequestHeaders
  107220. */
  107221. static UseCustomRequestHeaders: boolean;
  107222. /**
  107223. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107224. * i.e. when loading files, where the server/service expects an Authorization header
  107225. */
  107226. static CustomRequestHeaders: {
  107227. [key: string]: string;
  107228. };
  107229. /**
  107230. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107231. */
  107232. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107233. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107234. /**
  107235. * Default behaviour for cors in the application.
  107236. * It can be a string if the expected behavior is identical in the entire app.
  107237. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107238. */
  107239. static CorsBehavior: string | ((url: string | string[]) => string);
  107240. /**
  107241. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107242. * @ignorenaming
  107243. */
  107244. static get UseFallbackTexture(): boolean;
  107245. static set UseFallbackTexture(value: boolean);
  107246. /**
  107247. * Use this object to register external classes like custom textures or material
  107248. * to allow the laoders to instantiate them
  107249. */
  107250. static get RegisteredExternalClasses(): {
  107251. [key: string]: Object;
  107252. };
  107253. static set RegisteredExternalClasses(classes: {
  107254. [key: string]: Object;
  107255. });
  107256. /**
  107257. * Texture content used if a texture cannot loaded
  107258. * @ignorenaming
  107259. */
  107260. static get fallbackTexture(): string;
  107261. static set fallbackTexture(value: string);
  107262. /**
  107263. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107264. * @param u defines the coordinate on X axis
  107265. * @param v defines the coordinate on Y axis
  107266. * @param width defines the width of the source data
  107267. * @param height defines the height of the source data
  107268. * @param pixels defines the source byte array
  107269. * @param color defines the output color
  107270. */
  107271. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107272. /**
  107273. * Interpolates between a and b via alpha
  107274. * @param a The lower value (returned when alpha = 0)
  107275. * @param b The upper value (returned when alpha = 1)
  107276. * @param alpha The interpolation-factor
  107277. * @return The mixed value
  107278. */
  107279. static Mix(a: number, b: number, alpha: number): number;
  107280. /**
  107281. * Tries to instantiate a new object from a given class name
  107282. * @param className defines the class name to instantiate
  107283. * @returns the new object or null if the system was not able to do the instantiation
  107284. */
  107285. static Instantiate(className: string): any;
  107286. /**
  107287. * Provides a slice function that will work even on IE
  107288. * @param data defines the array to slice
  107289. * @param start defines the start of the data (optional)
  107290. * @param end defines the end of the data (optional)
  107291. * @returns the new sliced array
  107292. */
  107293. static Slice<T>(data: T, start?: number, end?: number): T;
  107294. /**
  107295. * Polyfill for setImmediate
  107296. * @param action defines the action to execute after the current execution block
  107297. */
  107298. static SetImmediate(action: () => void): void;
  107299. /**
  107300. * Function indicating if a number is an exponent of 2
  107301. * @param value defines the value to test
  107302. * @returns true if the value is an exponent of 2
  107303. */
  107304. static IsExponentOfTwo(value: number): boolean;
  107305. private static _tmpFloatArray;
  107306. /**
  107307. * Returns the nearest 32-bit single precision float representation of a Number
  107308. * @param value A Number. If the parameter is of a different type, it will get converted
  107309. * to a number or to NaN if it cannot be converted
  107310. * @returns number
  107311. */
  107312. static FloatRound(value: number): number;
  107313. /**
  107314. * Extracts the filename from a path
  107315. * @param path defines the path to use
  107316. * @returns the filename
  107317. */
  107318. static GetFilename(path: string): string;
  107319. /**
  107320. * Extracts the "folder" part of a path (everything before the filename).
  107321. * @param uri The URI to extract the info from
  107322. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107323. * @returns The "folder" part of the path
  107324. */
  107325. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107326. /**
  107327. * Extracts text content from a DOM element hierarchy
  107328. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107329. */
  107330. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107331. /**
  107332. * Convert an angle in radians to degrees
  107333. * @param angle defines the angle to convert
  107334. * @returns the angle in degrees
  107335. */
  107336. static ToDegrees(angle: number): number;
  107337. /**
  107338. * Convert an angle in degrees to radians
  107339. * @param angle defines the angle to convert
  107340. * @returns the angle in radians
  107341. */
  107342. static ToRadians(angle: number): number;
  107343. /**
  107344. * Returns an array if obj is not an array
  107345. * @param obj defines the object to evaluate as an array
  107346. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107347. * @returns either obj directly if obj is an array or a new array containing obj
  107348. */
  107349. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107350. /**
  107351. * Gets the pointer prefix to use
  107352. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107353. */
  107354. static GetPointerPrefix(): string;
  107355. /**
  107356. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107357. * @param url define the url we are trying
  107358. * @param element define the dom element where to configure the cors policy
  107359. */
  107360. static SetCorsBehavior(url: string | string[], element: {
  107361. crossOrigin: string | null;
  107362. }): void;
  107363. /**
  107364. * Removes unwanted characters from an url
  107365. * @param url defines the url to clean
  107366. * @returns the cleaned url
  107367. */
  107368. static CleanUrl(url: string): string;
  107369. /**
  107370. * Gets or sets a function used to pre-process url before using them to load assets
  107371. */
  107372. static get PreprocessUrl(): (url: string) => string;
  107373. static set PreprocessUrl(processor: (url: string) => string);
  107374. /**
  107375. * Loads an image as an HTMLImageElement.
  107376. * @param input url string, ArrayBuffer, or Blob to load
  107377. * @param onLoad callback called when the image successfully loads
  107378. * @param onError callback called when the image fails to load
  107379. * @param offlineProvider offline provider for caching
  107380. * @param mimeType optional mime type
  107381. * @returns the HTMLImageElement of the loaded image
  107382. */
  107383. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107384. /**
  107385. * Loads a file from a url
  107386. * @param url url string, ArrayBuffer, or Blob to load
  107387. * @param onSuccess callback called when the file successfully loads
  107388. * @param onProgress callback called while file is loading (if the server supports this mode)
  107389. * @param offlineProvider defines the offline provider for caching
  107390. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107391. * @param onError callback called when the file fails to load
  107392. * @returns a file request object
  107393. */
  107394. 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;
  107395. /**
  107396. * Loads a file from a url
  107397. * @param url the file url to load
  107398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107399. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107400. */
  107401. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107402. /**
  107403. * Load a script (identified by an url). When the url returns, the
  107404. * content of this file is added into a new script element, attached to the DOM (body element)
  107405. * @param scriptUrl defines the url of the script to laod
  107406. * @param onSuccess defines the callback called when the script is loaded
  107407. * @param onError defines the callback to call if an error occurs
  107408. * @param scriptId defines the id of the script element
  107409. */
  107410. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107411. /**
  107412. * Load an asynchronous script (identified by an url). When the url returns, the
  107413. * content of this file is added into a new script element, attached to the DOM (body element)
  107414. * @param scriptUrl defines the url of the script to laod
  107415. * @param scriptId defines the id of the script element
  107416. * @returns a promise request object
  107417. */
  107418. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107419. /**
  107420. * Loads a file from a blob
  107421. * @param fileToLoad defines the blob to use
  107422. * @param callback defines the callback to call when data is loaded
  107423. * @param progressCallback defines the callback to call during loading process
  107424. * @returns a file request object
  107425. */
  107426. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107427. /**
  107428. * Reads a file from a File object
  107429. * @param file defines the file to load
  107430. * @param onSuccess defines the callback to call when data is loaded
  107431. * @param onProgress defines the callback to call during loading process
  107432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107433. * @param onError defines the callback to call when an error occurs
  107434. * @returns a file request object
  107435. */
  107436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107437. /**
  107438. * Creates a data url from a given string content
  107439. * @param content defines the content to convert
  107440. * @returns the new data url link
  107441. */
  107442. static FileAsURL(content: string): string;
  107443. /**
  107444. * Format the given number to a specific decimal format
  107445. * @param value defines the number to format
  107446. * @param decimals defines the number of decimals to use
  107447. * @returns the formatted string
  107448. */
  107449. static Format(value: number, decimals?: number): string;
  107450. /**
  107451. * Tries to copy an object by duplicating every property
  107452. * @param source defines the source object
  107453. * @param destination defines the target object
  107454. * @param doNotCopyList defines a list of properties to avoid
  107455. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107456. */
  107457. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107458. /**
  107459. * Gets a boolean indicating if the given object has no own property
  107460. * @param obj defines the object to test
  107461. * @returns true if object has no own property
  107462. */
  107463. static IsEmpty(obj: any): boolean;
  107464. /**
  107465. * Function used to register events at window level
  107466. * @param windowElement defines the Window object to use
  107467. * @param events defines the events to register
  107468. */
  107469. static RegisterTopRootEvents(windowElement: Window, events: {
  107470. name: string;
  107471. handler: Nullable<(e: FocusEvent) => any>;
  107472. }[]): void;
  107473. /**
  107474. * Function used to unregister events from window level
  107475. * @param windowElement defines the Window object to use
  107476. * @param events defines the events to unregister
  107477. */
  107478. static UnregisterTopRootEvents(windowElement: Window, events: {
  107479. name: string;
  107480. handler: Nullable<(e: FocusEvent) => any>;
  107481. }[]): void;
  107482. /**
  107483. * @ignore
  107484. */
  107485. static _ScreenshotCanvas: HTMLCanvasElement;
  107486. /**
  107487. * Dumps the current bound framebuffer
  107488. * @param width defines the rendering width
  107489. * @param height defines the rendering height
  107490. * @param engine defines the hosting engine
  107491. * @param successCallback defines the callback triggered once the data are available
  107492. * @param mimeType defines the mime type of the result
  107493. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107494. */
  107495. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107496. /**
  107497. * Converts the canvas data to blob.
  107498. * This acts as a polyfill for browsers not supporting the to blob function.
  107499. * @param canvas Defines the canvas to extract the data from
  107500. * @param successCallback Defines the callback triggered once the data are available
  107501. * @param mimeType Defines the mime type of the result
  107502. */
  107503. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107504. /**
  107505. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107506. * @param successCallback defines the callback triggered once the data are available
  107507. * @param mimeType defines the mime type of the result
  107508. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107509. */
  107510. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107511. /**
  107512. * Downloads a blob in the browser
  107513. * @param blob defines the blob to download
  107514. * @param fileName defines the name of the downloaded file
  107515. */
  107516. static Download(blob: Blob, fileName: string): void;
  107517. /**
  107518. * Captures a screenshot of the current rendering
  107519. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107520. * @param engine defines the rendering engine
  107521. * @param camera defines the source camera
  107522. * @param size This parameter can be set to a single number or to an object with the
  107523. * following (optional) properties: precision, width, height. If a single number is passed,
  107524. * it will be used for both width and height. If an object is passed, the screenshot size
  107525. * will be derived from the parameters. The precision property is a multiplier allowing
  107526. * rendering at a higher or lower resolution
  107527. * @param successCallback defines the callback receives a single parameter which contains the
  107528. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107529. * src parameter of an <img> to display it
  107530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107531. * Check your browser for supported MIME types
  107532. */
  107533. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107534. /**
  107535. * Captures a screenshot of the current rendering
  107536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107537. * @param engine defines the rendering engine
  107538. * @param camera defines the source camera
  107539. * @param size This parameter can be set to a single number or to an object with the
  107540. * following (optional) properties: precision, width, height. If a single number is passed,
  107541. * it will be used for both width and height. If an object is passed, the screenshot size
  107542. * will be derived from the parameters. The precision property is a multiplier allowing
  107543. * rendering at a higher or lower resolution
  107544. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107545. * Check your browser for supported MIME types
  107546. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107547. * to the src parameter of an <img> to display it
  107548. */
  107549. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107550. /**
  107551. * Generates an image screenshot from the specified camera.
  107552. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107553. * @param engine The engine to use for rendering
  107554. * @param camera The camera to use for rendering
  107555. * @param size This parameter can be set to a single number or to an object with the
  107556. * following (optional) properties: precision, width, height. If a single number is passed,
  107557. * it will be used for both width and height. If an object is passed, the screenshot size
  107558. * will be derived from the parameters. The precision property is a multiplier allowing
  107559. * rendering at a higher or lower resolution
  107560. * @param successCallback The callback receives a single parameter which contains the
  107561. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107562. * src parameter of an <img> to display it
  107563. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107564. * Check your browser for supported MIME types
  107565. * @param samples Texture samples (default: 1)
  107566. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107567. * @param fileName A name for for the downloaded file.
  107568. */
  107569. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107570. /**
  107571. * Generates an image screenshot from the specified camera.
  107572. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107573. * @param engine The engine to use for rendering
  107574. * @param camera The camera to use for rendering
  107575. * @param size This parameter can be set to a single number or to an object with the
  107576. * following (optional) properties: precision, width, height. If a single number is passed,
  107577. * it will be used for both width and height. If an object is passed, the screenshot size
  107578. * will be derived from the parameters. The precision property is a multiplier allowing
  107579. * rendering at a higher or lower resolution
  107580. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107581. * Check your browser for supported MIME types
  107582. * @param samples Texture samples (default: 1)
  107583. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107584. * @param fileName A name for for the downloaded file.
  107585. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107586. * to the src parameter of an <img> to display it
  107587. */
  107588. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107589. /**
  107590. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107591. * Be aware Math.random() could cause collisions, but:
  107592. * "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"
  107593. * @returns a pseudo random id
  107594. */
  107595. static RandomId(): string;
  107596. /**
  107597. * Test if the given uri is a base64 string
  107598. * @param uri The uri to test
  107599. * @return True if the uri is a base64 string or false otherwise
  107600. */
  107601. static IsBase64(uri: string): boolean;
  107602. /**
  107603. * Decode the given base64 uri.
  107604. * @param uri The uri to decode
  107605. * @return The decoded base64 data.
  107606. */
  107607. static DecodeBase64(uri: string): ArrayBuffer;
  107608. /**
  107609. * Gets the absolute url.
  107610. * @param url the input url
  107611. * @return the absolute url
  107612. */
  107613. static GetAbsoluteUrl(url: string): string;
  107614. /**
  107615. * No log
  107616. */
  107617. static readonly NoneLogLevel: number;
  107618. /**
  107619. * Only message logs
  107620. */
  107621. static readonly MessageLogLevel: number;
  107622. /**
  107623. * Only warning logs
  107624. */
  107625. static readonly WarningLogLevel: number;
  107626. /**
  107627. * Only error logs
  107628. */
  107629. static readonly ErrorLogLevel: number;
  107630. /**
  107631. * All logs
  107632. */
  107633. static readonly AllLogLevel: number;
  107634. /**
  107635. * Gets a value indicating the number of loading errors
  107636. * @ignorenaming
  107637. */
  107638. static get errorsCount(): number;
  107639. /**
  107640. * Callback called when a new log is added
  107641. */
  107642. static OnNewCacheEntry: (entry: string) => void;
  107643. /**
  107644. * Log a message to the console
  107645. * @param message defines the message to log
  107646. */
  107647. static Log(message: string): void;
  107648. /**
  107649. * Write a warning message to the console
  107650. * @param message defines the message to log
  107651. */
  107652. static Warn(message: string): void;
  107653. /**
  107654. * Write an error message to the console
  107655. * @param message defines the message to log
  107656. */
  107657. static Error(message: string): void;
  107658. /**
  107659. * Gets current log cache (list of logs)
  107660. */
  107661. static get LogCache(): string;
  107662. /**
  107663. * Clears the log cache
  107664. */
  107665. static ClearLogCache(): void;
  107666. /**
  107667. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107668. */
  107669. static set LogLevels(level: number);
  107670. /**
  107671. * Checks if the window object exists
  107672. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107673. */
  107674. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107675. /**
  107676. * No performance log
  107677. */
  107678. static readonly PerformanceNoneLogLevel: number;
  107679. /**
  107680. * Use user marks to log performance
  107681. */
  107682. static readonly PerformanceUserMarkLogLevel: number;
  107683. /**
  107684. * Log performance to the console
  107685. */
  107686. static readonly PerformanceConsoleLogLevel: number;
  107687. private static _performance;
  107688. /**
  107689. * Sets the current performance log level
  107690. */
  107691. static set PerformanceLogLevel(level: number);
  107692. private static _StartPerformanceCounterDisabled;
  107693. private static _EndPerformanceCounterDisabled;
  107694. private static _StartUserMark;
  107695. private static _EndUserMark;
  107696. private static _StartPerformanceConsole;
  107697. private static _EndPerformanceConsole;
  107698. /**
  107699. * Starts a performance counter
  107700. */
  107701. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107702. /**
  107703. * Ends a specific performance coutner
  107704. */
  107705. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107706. /**
  107707. * Gets either window.performance.now() if supported or Date.now() else
  107708. */
  107709. static get Now(): number;
  107710. /**
  107711. * This method will return the name of the class used to create the instance of the given object.
  107712. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107713. * @param object the object to get the class name from
  107714. * @param isType defines if the object is actually a type
  107715. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107716. */
  107717. static GetClassName(object: any, isType?: boolean): string;
  107718. /**
  107719. * Gets the first element of an array satisfying a given predicate
  107720. * @param array defines the array to browse
  107721. * @param predicate defines the predicate to use
  107722. * @returns null if not found or the element
  107723. */
  107724. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107725. /**
  107726. * This method will return the name of the full name of the class, including its owning module (if any).
  107727. * 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).
  107728. * @param object the object to get the class name from
  107729. * @param isType defines if the object is actually a type
  107730. * @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.
  107731. * @ignorenaming
  107732. */
  107733. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107734. /**
  107735. * Returns a promise that resolves after the given amount of time.
  107736. * @param delay Number of milliseconds to delay
  107737. * @returns Promise that resolves after the given amount of time
  107738. */
  107739. static DelayAsync(delay: number): Promise<void>;
  107740. /**
  107741. * Utility function to detect if the current user agent is Safari
  107742. * @returns whether or not the current user agent is safari
  107743. */
  107744. static IsSafari(): boolean;
  107745. }
  107746. /**
  107747. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107748. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107749. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107750. * @param name The name of the class, case should be preserved
  107751. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107752. */
  107753. export function className(name: string, module?: string): (target: Object) => void;
  107754. /**
  107755. * An implementation of a loop for asynchronous functions.
  107756. */
  107757. export class AsyncLoop {
  107758. /**
  107759. * Defines the number of iterations for the loop
  107760. */
  107761. iterations: number;
  107762. /**
  107763. * Defines the current index of the loop.
  107764. */
  107765. index: number;
  107766. private _done;
  107767. private _fn;
  107768. private _successCallback;
  107769. /**
  107770. * Constructor.
  107771. * @param iterations the number of iterations.
  107772. * @param func the function to run each iteration
  107773. * @param successCallback the callback that will be called upon succesful execution
  107774. * @param offset starting offset.
  107775. */
  107776. constructor(
  107777. /**
  107778. * Defines the number of iterations for the loop
  107779. */
  107780. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107781. /**
  107782. * Execute the next iteration. Must be called after the last iteration was finished.
  107783. */
  107784. executeNext(): void;
  107785. /**
  107786. * Break the loop and run the success callback.
  107787. */
  107788. breakLoop(): void;
  107789. /**
  107790. * Create and run an async loop.
  107791. * @param iterations the number of iterations.
  107792. * @param fn the function to run each iteration
  107793. * @param successCallback the callback that will be called upon succesful execution
  107794. * @param offset starting offset.
  107795. * @returns the created async loop object
  107796. */
  107797. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107798. /**
  107799. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107800. * @param iterations total number of iterations
  107801. * @param syncedIterations number of synchronous iterations in each async iteration.
  107802. * @param fn the function to call each iteration.
  107803. * @param callback a success call back that will be called when iterating stops.
  107804. * @param breakFunction a break condition (optional)
  107805. * @param timeout timeout settings for the setTimeout function. default - 0.
  107806. * @returns the created async loop object
  107807. */
  107808. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107809. }
  107810. }
  107811. declare module BABYLON {
  107812. /**
  107813. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107814. * The underlying implementation relies on an associative array to ensure the best performances.
  107815. * The value can be anything including 'null' but except 'undefined'
  107816. */
  107817. export class StringDictionary<T> {
  107818. /**
  107819. * This will clear this dictionary and copy the content from the 'source' one.
  107820. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107821. * @param source the dictionary to take the content from and copy to this dictionary
  107822. */
  107823. copyFrom(source: StringDictionary<T>): void;
  107824. /**
  107825. * Get a value based from its key
  107826. * @param key the given key to get the matching value from
  107827. * @return the value if found, otherwise undefined is returned
  107828. */
  107829. get(key: string): T | undefined;
  107830. /**
  107831. * Get a value from its key or add it if it doesn't exist.
  107832. * This method will ensure you that a given key/data will be present in the dictionary.
  107833. * @param key the given key to get the matching value from
  107834. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107835. * The factory will only be invoked if there's no data for the given key.
  107836. * @return the value corresponding to the key.
  107837. */
  107838. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107839. /**
  107840. * Get a value from its key if present in the dictionary otherwise add it
  107841. * @param key the key to get the value from
  107842. * @param val if there's no such key/value pair in the dictionary add it with this value
  107843. * @return the value corresponding to the key
  107844. */
  107845. getOrAdd(key: string, val: T): T;
  107846. /**
  107847. * Check if there's a given key in the dictionary
  107848. * @param key the key to check for
  107849. * @return true if the key is present, false otherwise
  107850. */
  107851. contains(key: string): boolean;
  107852. /**
  107853. * Add a new key and its corresponding value
  107854. * @param key the key to add
  107855. * @param value the value corresponding to the key
  107856. * @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
  107857. */
  107858. add(key: string, value: T): boolean;
  107859. /**
  107860. * Update a specific value associated to a key
  107861. * @param key defines the key to use
  107862. * @param value defines the value to store
  107863. * @returns true if the value was updated (or false if the key was not found)
  107864. */
  107865. set(key: string, value: T): boolean;
  107866. /**
  107867. * Get the element of the given key and remove it from the dictionary
  107868. * @param key defines the key to search
  107869. * @returns the value associated with the key or null if not found
  107870. */
  107871. getAndRemove(key: string): Nullable<T>;
  107872. /**
  107873. * Remove a key/value from the dictionary.
  107874. * @param key the key to remove
  107875. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107876. */
  107877. remove(key: string): boolean;
  107878. /**
  107879. * Clear the whole content of the dictionary
  107880. */
  107881. clear(): void;
  107882. /**
  107883. * Gets the current count
  107884. */
  107885. get count(): number;
  107886. /**
  107887. * Execute a callback on each key/val of the dictionary.
  107888. * Note that you can remove any element in this dictionary in the callback implementation
  107889. * @param callback the callback to execute on a given key/value pair
  107890. */
  107891. forEach(callback: (key: string, val: T) => void): void;
  107892. /**
  107893. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107894. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107895. * Note that you can remove any element in this dictionary in the callback implementation
  107896. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107897. * @returns the first item
  107898. */
  107899. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107900. private _count;
  107901. private _data;
  107902. }
  107903. }
  107904. declare module BABYLON {
  107905. /** @hidden */
  107906. export interface ICollisionCoordinator {
  107907. createCollider(): Collider;
  107908. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107909. init(scene: Scene): void;
  107910. }
  107911. /** @hidden */
  107912. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107913. private _scene;
  107914. private _scaledPosition;
  107915. private _scaledVelocity;
  107916. private _finalPosition;
  107917. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107918. createCollider(): Collider;
  107919. init(scene: Scene): void;
  107920. private _collideWithWorld;
  107921. }
  107922. }
  107923. declare module BABYLON {
  107924. /**
  107925. * Class used to manage all inputs for the scene.
  107926. */
  107927. export class InputManager {
  107928. /** The distance in pixel that you have to move to prevent some events */
  107929. static DragMovementThreshold: number;
  107930. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107931. static LongPressDelay: number;
  107932. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107933. static DoubleClickDelay: number;
  107934. /** If you need to check double click without raising a single click at first click, enable this flag */
  107935. static ExclusiveDoubleClickMode: boolean;
  107936. private _wheelEventName;
  107937. private _onPointerMove;
  107938. private _onPointerDown;
  107939. private _onPointerUp;
  107940. private _initClickEvent;
  107941. private _initActionManager;
  107942. private _delayedSimpleClick;
  107943. private _delayedSimpleClickTimeout;
  107944. private _previousDelayedSimpleClickTimeout;
  107945. private _meshPickProceed;
  107946. private _previousButtonPressed;
  107947. private _currentPickResult;
  107948. private _previousPickResult;
  107949. private _totalPointersPressed;
  107950. private _doubleClickOccured;
  107951. private _pointerOverMesh;
  107952. private _pickedDownMesh;
  107953. private _pickedUpMesh;
  107954. private _pointerX;
  107955. private _pointerY;
  107956. private _unTranslatedPointerX;
  107957. private _unTranslatedPointerY;
  107958. private _startingPointerPosition;
  107959. private _previousStartingPointerPosition;
  107960. private _startingPointerTime;
  107961. private _previousStartingPointerTime;
  107962. private _pointerCaptures;
  107963. private _onKeyDown;
  107964. private _onKeyUp;
  107965. private _onCanvasFocusObserver;
  107966. private _onCanvasBlurObserver;
  107967. private _scene;
  107968. /**
  107969. * Creates a new InputManager
  107970. * @param scene defines the hosting scene
  107971. */
  107972. constructor(scene: Scene);
  107973. /**
  107974. * Gets the mesh that is currently under the pointer
  107975. */
  107976. get meshUnderPointer(): Nullable<AbstractMesh>;
  107977. /**
  107978. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107979. */
  107980. get unTranslatedPointer(): Vector2;
  107981. /**
  107982. * Gets or sets the current on-screen X position of the pointer
  107983. */
  107984. get pointerX(): number;
  107985. set pointerX(value: number);
  107986. /**
  107987. * Gets or sets the current on-screen Y position of the pointer
  107988. */
  107989. get pointerY(): number;
  107990. set pointerY(value: number);
  107991. private _updatePointerPosition;
  107992. private _processPointerMove;
  107993. private _setRayOnPointerInfo;
  107994. private _checkPrePointerObservable;
  107995. /**
  107996. * Use this method to simulate a pointer move on a mesh
  107997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108000. */
  108001. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108002. /**
  108003. * Use this method to simulate a pointer down on a mesh
  108004. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108005. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108006. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108007. */
  108008. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108009. private _processPointerDown;
  108010. /** @hidden */
  108011. _isPointerSwiping(): boolean;
  108012. /**
  108013. * Use this method to simulate a pointer up on a mesh
  108014. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108015. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108016. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108017. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108018. */
  108019. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108020. private _processPointerUp;
  108021. /**
  108022. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108023. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108024. * @returns true if the pointer was captured
  108025. */
  108026. isPointerCaptured(pointerId?: number): boolean;
  108027. /**
  108028. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108029. * @param attachUp defines if you want to attach events to pointerup
  108030. * @param attachDown defines if you want to attach events to pointerdown
  108031. * @param attachMove defines if you want to attach events to pointermove
  108032. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108033. */
  108034. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108035. /**
  108036. * Detaches all event handlers
  108037. */
  108038. detachControl(): void;
  108039. /**
  108040. * Force the value of meshUnderPointer
  108041. * @param mesh defines the mesh to use
  108042. */
  108043. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108044. /**
  108045. * Gets the mesh under the pointer
  108046. * @returns a Mesh or null if no mesh is under the pointer
  108047. */
  108048. getPointerOverMesh(): Nullable<AbstractMesh>;
  108049. }
  108050. }
  108051. declare module BABYLON {
  108052. /**
  108053. * Helper class used to generate session unique ID
  108054. */
  108055. export class UniqueIdGenerator {
  108056. private static _UniqueIdCounter;
  108057. /**
  108058. * Gets an unique (relatively to the current scene) Id
  108059. */
  108060. static get UniqueId(): number;
  108061. }
  108062. }
  108063. declare module BABYLON {
  108064. /**
  108065. * This class defines the direct association between an animation and a target
  108066. */
  108067. export class TargetedAnimation {
  108068. /**
  108069. * Animation to perform
  108070. */
  108071. animation: Animation;
  108072. /**
  108073. * Target to animate
  108074. */
  108075. target: any;
  108076. /**
  108077. * Serialize the object
  108078. * @returns the JSON object representing the current entity
  108079. */
  108080. serialize(): any;
  108081. }
  108082. /**
  108083. * Use this class to create coordinated animations on multiple targets
  108084. */
  108085. export class AnimationGroup implements IDisposable {
  108086. /** The name of the animation group */
  108087. name: string;
  108088. private _scene;
  108089. private _targetedAnimations;
  108090. private _animatables;
  108091. private _from;
  108092. private _to;
  108093. private _isStarted;
  108094. private _isPaused;
  108095. private _speedRatio;
  108096. private _loopAnimation;
  108097. /**
  108098. * Gets or sets the unique id of the node
  108099. */
  108100. uniqueId: number;
  108101. /**
  108102. * This observable will notify when one animation have ended
  108103. */
  108104. onAnimationEndObservable: Observable<TargetedAnimation>;
  108105. /**
  108106. * Observer raised when one animation loops
  108107. */
  108108. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108109. /**
  108110. * Observer raised when all animations have looped
  108111. */
  108112. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108113. /**
  108114. * This observable will notify when all animations have ended.
  108115. */
  108116. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108117. /**
  108118. * This observable will notify when all animations have paused.
  108119. */
  108120. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108121. /**
  108122. * This observable will notify when all animations are playing.
  108123. */
  108124. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108125. /**
  108126. * Gets the first frame
  108127. */
  108128. get from(): number;
  108129. /**
  108130. * Gets the last frame
  108131. */
  108132. get to(): number;
  108133. /**
  108134. * Define if the animations are started
  108135. */
  108136. get isStarted(): boolean;
  108137. /**
  108138. * Gets a value indicating that the current group is playing
  108139. */
  108140. get isPlaying(): boolean;
  108141. /**
  108142. * Gets or sets the speed ratio to use for all animations
  108143. */
  108144. get speedRatio(): number;
  108145. /**
  108146. * Gets or sets the speed ratio to use for all animations
  108147. */
  108148. set speedRatio(value: number);
  108149. /**
  108150. * Gets or sets if all animations should loop or not
  108151. */
  108152. get loopAnimation(): boolean;
  108153. set loopAnimation(value: boolean);
  108154. /**
  108155. * Gets the targeted animations for this animation group
  108156. */
  108157. get targetedAnimations(): Array<TargetedAnimation>;
  108158. /**
  108159. * returning the list of animatables controlled by this animation group.
  108160. */
  108161. get animatables(): Array<Animatable>;
  108162. /**
  108163. * Instantiates a new Animation Group.
  108164. * This helps managing several animations at once.
  108165. * @see http://doc.babylonjs.com/how_to/group
  108166. * @param name Defines the name of the group
  108167. * @param scene Defines the scene the group belongs to
  108168. */
  108169. constructor(
  108170. /** The name of the animation group */
  108171. name: string, scene?: Nullable<Scene>);
  108172. /**
  108173. * Add an animation (with its target) in the group
  108174. * @param animation defines the animation we want to add
  108175. * @param target defines the target of the animation
  108176. * @returns the TargetedAnimation object
  108177. */
  108178. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108179. /**
  108180. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108181. * It can add constant keys at begin or end
  108182. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108183. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108184. * @returns the animation group
  108185. */
  108186. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108187. private _animationLoopCount;
  108188. private _animationLoopFlags;
  108189. private _processLoop;
  108190. /**
  108191. * Start all animations on given targets
  108192. * @param loop defines if animations must loop
  108193. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108194. * @param from defines the from key (optional)
  108195. * @param to defines the to key (optional)
  108196. * @returns the current animation group
  108197. */
  108198. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108199. /**
  108200. * Pause all animations
  108201. * @returns the animation group
  108202. */
  108203. pause(): AnimationGroup;
  108204. /**
  108205. * Play all animations to initial state
  108206. * This function will start() the animations if they were not started or will restart() them if they were paused
  108207. * @param loop defines if animations must loop
  108208. * @returns the animation group
  108209. */
  108210. play(loop?: boolean): AnimationGroup;
  108211. /**
  108212. * Reset all animations to initial state
  108213. * @returns the animation group
  108214. */
  108215. reset(): AnimationGroup;
  108216. /**
  108217. * Restart animations from key 0
  108218. * @returns the animation group
  108219. */
  108220. restart(): AnimationGroup;
  108221. /**
  108222. * Stop all animations
  108223. * @returns the animation group
  108224. */
  108225. stop(): AnimationGroup;
  108226. /**
  108227. * Set animation weight for all animatables
  108228. * @param weight defines the weight to use
  108229. * @return the animationGroup
  108230. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108231. */
  108232. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108233. /**
  108234. * Synchronize and normalize all animatables with a source animatable
  108235. * @param root defines the root animatable to synchronize with
  108236. * @return the animationGroup
  108237. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108238. */
  108239. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108240. /**
  108241. * Goes to a specific frame in this animation group
  108242. * @param frame the frame number to go to
  108243. * @return the animationGroup
  108244. */
  108245. goToFrame(frame: number): AnimationGroup;
  108246. /**
  108247. * Dispose all associated resources
  108248. */
  108249. dispose(): void;
  108250. private _checkAnimationGroupEnded;
  108251. /**
  108252. * Clone the current animation group and returns a copy
  108253. * @param newName defines the name of the new group
  108254. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108255. * @returns the new aniamtion group
  108256. */
  108257. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108258. /**
  108259. * Serializes the animationGroup to an object
  108260. * @returns Serialized object
  108261. */
  108262. serialize(): any;
  108263. /**
  108264. * Returns a new AnimationGroup object parsed from the source provided.
  108265. * @param parsedAnimationGroup defines the source
  108266. * @param scene defines the scene that will receive the animationGroup
  108267. * @returns a new AnimationGroup
  108268. */
  108269. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108270. /**
  108271. * Returns the string "AnimationGroup"
  108272. * @returns "AnimationGroup"
  108273. */
  108274. getClassName(): string;
  108275. /**
  108276. * Creates a detailled string about the object
  108277. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108278. * @returns a string representing the object
  108279. */
  108280. toString(fullDetails?: boolean): string;
  108281. }
  108282. }
  108283. declare module BABYLON {
  108284. /**
  108285. * Define an interface for all classes that will hold resources
  108286. */
  108287. export interface IDisposable {
  108288. /**
  108289. * Releases all held resources
  108290. */
  108291. dispose(): void;
  108292. }
  108293. /** Interface defining initialization parameters for Scene class */
  108294. export interface SceneOptions {
  108295. /**
  108296. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108297. * It will improve performance when the number of geometries becomes important.
  108298. */
  108299. useGeometryUniqueIdsMap?: boolean;
  108300. /**
  108301. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108302. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108303. */
  108304. useMaterialMeshMap?: boolean;
  108305. /**
  108306. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108307. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108308. */
  108309. useClonedMeshMap?: boolean;
  108310. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108311. virtual?: boolean;
  108312. }
  108313. /**
  108314. * Represents a scene to be rendered by the engine.
  108315. * @see http://doc.babylonjs.com/features/scene
  108316. */
  108317. export class Scene extends AbstractScene implements IAnimatable {
  108318. /** The fog is deactivated */
  108319. static readonly FOGMODE_NONE: number;
  108320. /** The fog density is following an exponential function */
  108321. static readonly FOGMODE_EXP: number;
  108322. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108323. static readonly FOGMODE_EXP2: number;
  108324. /** The fog density is following a linear function. */
  108325. static readonly FOGMODE_LINEAR: number;
  108326. /**
  108327. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108329. */
  108330. static MinDeltaTime: number;
  108331. /**
  108332. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108333. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108334. */
  108335. static MaxDeltaTime: number;
  108336. /**
  108337. * Factory used to create the default material.
  108338. * @param name The name of the material to create
  108339. * @param scene The scene to create the material for
  108340. * @returns The default material
  108341. */
  108342. static DefaultMaterialFactory(scene: Scene): Material;
  108343. /**
  108344. * Factory used to create the a collision coordinator.
  108345. * @returns The collision coordinator
  108346. */
  108347. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108348. /** @hidden */
  108349. _inputManager: InputManager;
  108350. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108351. cameraToUseForPointers: Nullable<Camera>;
  108352. /** @hidden */
  108353. readonly _isScene: boolean;
  108354. /** @hidden */
  108355. _blockEntityCollection: boolean;
  108356. /**
  108357. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108358. */
  108359. autoClear: boolean;
  108360. /**
  108361. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108362. */
  108363. autoClearDepthAndStencil: boolean;
  108364. /**
  108365. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108366. */
  108367. clearColor: Color4;
  108368. /**
  108369. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108370. */
  108371. ambientColor: Color3;
  108372. /**
  108373. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108374. * It should only be one of the following (if not the default embedded one):
  108375. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108376. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108377. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108378. * The material properties need to be setup according to the type of texture in use.
  108379. */
  108380. environmentBRDFTexture: BaseTexture;
  108381. /** @hidden */
  108382. protected _environmentTexture: Nullable<BaseTexture>;
  108383. /**
  108384. * Texture used in all pbr material as the reflection texture.
  108385. * As in the majority of the scene they are the same (exception for multi room and so on),
  108386. * this is easier to reference from here than from all the materials.
  108387. */
  108388. get environmentTexture(): Nullable<BaseTexture>;
  108389. /**
  108390. * Texture used in all pbr material as the reflection texture.
  108391. * As in the majority of the scene they are the same (exception for multi room and so on),
  108392. * this is easier to set here than in all the materials.
  108393. */
  108394. set environmentTexture(value: Nullable<BaseTexture>);
  108395. /** @hidden */
  108396. protected _environmentIntensity: number;
  108397. /**
  108398. * Intensity of the environment in all pbr material.
  108399. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108400. * As in the majority of the scene they are the same (exception for multi room and so on),
  108401. * this is easier to reference from here than from all the materials.
  108402. */
  108403. get environmentIntensity(): number;
  108404. /**
  108405. * Intensity of the environment in all pbr material.
  108406. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108407. * As in the majority of the scene they are the same (exception for multi room and so on),
  108408. * this is easier to set here than in all the materials.
  108409. */
  108410. set environmentIntensity(value: number);
  108411. /** @hidden */
  108412. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108413. /**
  108414. * Default image processing configuration used either in the rendering
  108415. * Forward main pass or through the imageProcessingPostProcess if present.
  108416. * As in the majority of the scene they are the same (exception for multi camera),
  108417. * this is easier to reference from here than from all the materials and post process.
  108418. *
  108419. * No setter as we it is a shared configuration, you can set the values instead.
  108420. */
  108421. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108422. private _forceWireframe;
  108423. /**
  108424. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108425. */
  108426. set forceWireframe(value: boolean);
  108427. get forceWireframe(): boolean;
  108428. private _skipFrustumClipping;
  108429. /**
  108430. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108431. */
  108432. set skipFrustumClipping(value: boolean);
  108433. get skipFrustumClipping(): boolean;
  108434. private _forcePointsCloud;
  108435. /**
  108436. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108437. */
  108438. set forcePointsCloud(value: boolean);
  108439. get forcePointsCloud(): boolean;
  108440. /**
  108441. * Gets or sets the active clipplane 1
  108442. */
  108443. clipPlane: Nullable<Plane>;
  108444. /**
  108445. * Gets or sets the active clipplane 2
  108446. */
  108447. clipPlane2: Nullable<Plane>;
  108448. /**
  108449. * Gets or sets the active clipplane 3
  108450. */
  108451. clipPlane3: Nullable<Plane>;
  108452. /**
  108453. * Gets or sets the active clipplane 4
  108454. */
  108455. clipPlane4: Nullable<Plane>;
  108456. /**
  108457. * Gets or sets the active clipplane 5
  108458. */
  108459. clipPlane5: Nullable<Plane>;
  108460. /**
  108461. * Gets or sets the active clipplane 6
  108462. */
  108463. clipPlane6: Nullable<Plane>;
  108464. /**
  108465. * Gets or sets a boolean indicating if animations are enabled
  108466. */
  108467. animationsEnabled: boolean;
  108468. private _animationPropertiesOverride;
  108469. /**
  108470. * Gets or sets the animation properties override
  108471. */
  108472. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108473. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108474. /**
  108475. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108476. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108477. */
  108478. useConstantAnimationDeltaTime: boolean;
  108479. /**
  108480. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108481. * Please note that it requires to run a ray cast through the scene on every frame
  108482. */
  108483. constantlyUpdateMeshUnderPointer: boolean;
  108484. /**
  108485. * Defines the HTML cursor to use when hovering over interactive elements
  108486. */
  108487. hoverCursor: string;
  108488. /**
  108489. * Defines the HTML default cursor to use (empty by default)
  108490. */
  108491. defaultCursor: string;
  108492. /**
  108493. * Defines whether cursors are handled by the scene.
  108494. */
  108495. doNotHandleCursors: boolean;
  108496. /**
  108497. * This is used to call preventDefault() on pointer down
  108498. * in order to block unwanted artifacts like system double clicks
  108499. */
  108500. preventDefaultOnPointerDown: boolean;
  108501. /**
  108502. * This is used to call preventDefault() on pointer up
  108503. * in order to block unwanted artifacts like system double clicks
  108504. */
  108505. preventDefaultOnPointerUp: boolean;
  108506. /**
  108507. * Gets or sets user defined metadata
  108508. */
  108509. metadata: any;
  108510. /**
  108511. * For internal use only. Please do not use.
  108512. */
  108513. reservedDataStore: any;
  108514. /**
  108515. * Gets the name of the plugin used to load this scene (null by default)
  108516. */
  108517. loadingPluginName: string;
  108518. /**
  108519. * Use this array to add regular expressions used to disable offline support for specific urls
  108520. */
  108521. disableOfflineSupportExceptionRules: RegExp[];
  108522. /**
  108523. * An event triggered when the scene is disposed.
  108524. */
  108525. onDisposeObservable: Observable<Scene>;
  108526. private _onDisposeObserver;
  108527. /** Sets a function to be executed when this scene is disposed. */
  108528. set onDispose(callback: () => void);
  108529. /**
  108530. * An event triggered before rendering the scene (right after animations and physics)
  108531. */
  108532. onBeforeRenderObservable: Observable<Scene>;
  108533. private _onBeforeRenderObserver;
  108534. /** Sets a function to be executed before rendering this scene */
  108535. set beforeRender(callback: Nullable<() => void>);
  108536. /**
  108537. * An event triggered after rendering the scene
  108538. */
  108539. onAfterRenderObservable: Observable<Scene>;
  108540. /**
  108541. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108542. */
  108543. onAfterRenderCameraObservable: Observable<Camera>;
  108544. private _onAfterRenderObserver;
  108545. /** Sets a function to be executed after rendering this scene */
  108546. set afterRender(callback: Nullable<() => void>);
  108547. /**
  108548. * An event triggered before animating the scene
  108549. */
  108550. onBeforeAnimationsObservable: Observable<Scene>;
  108551. /**
  108552. * An event triggered after animations processing
  108553. */
  108554. onAfterAnimationsObservable: Observable<Scene>;
  108555. /**
  108556. * An event triggered before draw calls are ready to be sent
  108557. */
  108558. onBeforeDrawPhaseObservable: Observable<Scene>;
  108559. /**
  108560. * An event triggered after draw calls have been sent
  108561. */
  108562. onAfterDrawPhaseObservable: Observable<Scene>;
  108563. /**
  108564. * An event triggered when the scene is ready
  108565. */
  108566. onReadyObservable: Observable<Scene>;
  108567. /**
  108568. * An event triggered before rendering a camera
  108569. */
  108570. onBeforeCameraRenderObservable: Observable<Camera>;
  108571. private _onBeforeCameraRenderObserver;
  108572. /** Sets a function to be executed before rendering a camera*/
  108573. set beforeCameraRender(callback: () => void);
  108574. /**
  108575. * An event triggered after rendering a camera
  108576. */
  108577. onAfterCameraRenderObservable: Observable<Camera>;
  108578. private _onAfterCameraRenderObserver;
  108579. /** Sets a function to be executed after rendering a camera*/
  108580. set afterCameraRender(callback: () => void);
  108581. /**
  108582. * An event triggered when active meshes evaluation is about to start
  108583. */
  108584. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108585. /**
  108586. * An event triggered when active meshes evaluation is done
  108587. */
  108588. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108589. /**
  108590. * An event triggered when particles rendering is about to start
  108591. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108592. */
  108593. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108594. /**
  108595. * An event triggered when particles rendering is done
  108596. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108597. */
  108598. onAfterParticlesRenderingObservable: Observable<Scene>;
  108599. /**
  108600. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108601. */
  108602. onDataLoadedObservable: Observable<Scene>;
  108603. /**
  108604. * An event triggered when a camera is created
  108605. */
  108606. onNewCameraAddedObservable: Observable<Camera>;
  108607. /**
  108608. * An event triggered when a camera is removed
  108609. */
  108610. onCameraRemovedObservable: Observable<Camera>;
  108611. /**
  108612. * An event triggered when a light is created
  108613. */
  108614. onNewLightAddedObservable: Observable<Light>;
  108615. /**
  108616. * An event triggered when a light is removed
  108617. */
  108618. onLightRemovedObservable: Observable<Light>;
  108619. /**
  108620. * An event triggered when a geometry is created
  108621. */
  108622. onNewGeometryAddedObservable: Observable<Geometry>;
  108623. /**
  108624. * An event triggered when a geometry is removed
  108625. */
  108626. onGeometryRemovedObservable: Observable<Geometry>;
  108627. /**
  108628. * An event triggered when a transform node is created
  108629. */
  108630. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108631. /**
  108632. * An event triggered when a transform node is removed
  108633. */
  108634. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108635. /**
  108636. * An event triggered when a mesh is created
  108637. */
  108638. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108639. /**
  108640. * An event triggered when a mesh is removed
  108641. */
  108642. onMeshRemovedObservable: Observable<AbstractMesh>;
  108643. /**
  108644. * An event triggered when a skeleton is created
  108645. */
  108646. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108647. /**
  108648. * An event triggered when a skeleton is removed
  108649. */
  108650. onSkeletonRemovedObservable: Observable<Skeleton>;
  108651. /**
  108652. * An event triggered when a material is created
  108653. */
  108654. onNewMaterialAddedObservable: Observable<Material>;
  108655. /**
  108656. * An event triggered when a material is removed
  108657. */
  108658. onMaterialRemovedObservable: Observable<Material>;
  108659. /**
  108660. * An event triggered when a texture is created
  108661. */
  108662. onNewTextureAddedObservable: Observable<BaseTexture>;
  108663. /**
  108664. * An event triggered when a texture is removed
  108665. */
  108666. onTextureRemovedObservable: Observable<BaseTexture>;
  108667. /**
  108668. * An event triggered when render targets are about to be rendered
  108669. * Can happen multiple times per frame.
  108670. */
  108671. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108672. /**
  108673. * An event triggered when render targets were rendered.
  108674. * Can happen multiple times per frame.
  108675. */
  108676. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108677. /**
  108678. * An event triggered before calculating deterministic simulation step
  108679. */
  108680. onBeforeStepObservable: Observable<Scene>;
  108681. /**
  108682. * An event triggered after calculating deterministic simulation step
  108683. */
  108684. onAfterStepObservable: Observable<Scene>;
  108685. /**
  108686. * An event triggered when the activeCamera property is updated
  108687. */
  108688. onActiveCameraChanged: Observable<Scene>;
  108689. /**
  108690. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108691. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108692. * 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)
  108693. */
  108694. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108695. /**
  108696. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108697. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108698. * 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)
  108699. */
  108700. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108701. /**
  108702. * This Observable will when a mesh has been imported into the scene.
  108703. */
  108704. onMeshImportedObservable: Observable<AbstractMesh>;
  108705. /**
  108706. * This Observable will when an animation file has been imported into the scene.
  108707. */
  108708. onAnimationFileImportedObservable: Observable<Scene>;
  108709. /**
  108710. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108711. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108712. */
  108713. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108714. /** @hidden */
  108715. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108716. /**
  108717. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108718. */
  108719. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108720. /**
  108721. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108722. */
  108723. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108724. /**
  108725. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108726. */
  108727. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108728. /** Callback called when a pointer move is detected */
  108729. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108730. /** Callback called when a pointer down is detected */
  108731. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108732. /** Callback called when a pointer up is detected */
  108733. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108734. /** Callback called when a pointer pick is detected */
  108735. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108736. /**
  108737. * 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).
  108738. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108739. */
  108740. onPrePointerObservable: Observable<PointerInfoPre>;
  108741. /**
  108742. * Observable event triggered each time an input event is received from the rendering canvas
  108743. */
  108744. onPointerObservable: Observable<PointerInfo>;
  108745. /**
  108746. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108747. */
  108748. get unTranslatedPointer(): Vector2;
  108749. /**
  108750. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108751. */
  108752. static get DragMovementThreshold(): number;
  108753. static set DragMovementThreshold(value: number);
  108754. /**
  108755. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108756. */
  108757. static get LongPressDelay(): number;
  108758. static set LongPressDelay(value: number);
  108759. /**
  108760. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108761. */
  108762. static get DoubleClickDelay(): number;
  108763. static set DoubleClickDelay(value: number);
  108764. /** If you need to check double click without raising a single click at first click, enable this flag */
  108765. static get ExclusiveDoubleClickMode(): boolean;
  108766. static set ExclusiveDoubleClickMode(value: boolean);
  108767. /** @hidden */
  108768. _mirroredCameraPosition: Nullable<Vector3>;
  108769. /**
  108770. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108771. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108772. */
  108773. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108774. /**
  108775. * Observable event triggered each time an keyboard event is received from the hosting window
  108776. */
  108777. onKeyboardObservable: Observable<KeyboardInfo>;
  108778. private _useRightHandedSystem;
  108779. /**
  108780. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108781. */
  108782. set useRightHandedSystem(value: boolean);
  108783. get useRightHandedSystem(): boolean;
  108784. private _timeAccumulator;
  108785. private _currentStepId;
  108786. private _currentInternalStep;
  108787. /**
  108788. * Sets the step Id used by deterministic lock step
  108789. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108790. * @param newStepId defines the step Id
  108791. */
  108792. setStepId(newStepId: number): void;
  108793. /**
  108794. * Gets the step Id used by deterministic lock step
  108795. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108796. * @returns the step Id
  108797. */
  108798. getStepId(): number;
  108799. /**
  108800. * Gets the internal step used by deterministic lock step
  108801. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108802. * @returns the internal step
  108803. */
  108804. getInternalStep(): number;
  108805. private _fogEnabled;
  108806. /**
  108807. * Gets or sets a boolean indicating if fog is enabled on this scene
  108808. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108809. * (Default is true)
  108810. */
  108811. set fogEnabled(value: boolean);
  108812. get fogEnabled(): boolean;
  108813. private _fogMode;
  108814. /**
  108815. * Gets or sets the fog mode to use
  108816. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108817. * | mode | value |
  108818. * | --- | --- |
  108819. * | FOGMODE_NONE | 0 |
  108820. * | FOGMODE_EXP | 1 |
  108821. * | FOGMODE_EXP2 | 2 |
  108822. * | FOGMODE_LINEAR | 3 |
  108823. */
  108824. set fogMode(value: number);
  108825. get fogMode(): number;
  108826. /**
  108827. * Gets or sets the fog color to use
  108828. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108829. * (Default is Color3(0.2, 0.2, 0.3))
  108830. */
  108831. fogColor: Color3;
  108832. /**
  108833. * Gets or sets the fog density to use
  108834. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108835. * (Default is 0.1)
  108836. */
  108837. fogDensity: number;
  108838. /**
  108839. * Gets or sets the fog start distance to use
  108840. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108841. * (Default is 0)
  108842. */
  108843. fogStart: number;
  108844. /**
  108845. * Gets or sets the fog end distance to use
  108846. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108847. * (Default is 1000)
  108848. */
  108849. fogEnd: number;
  108850. private _shadowsEnabled;
  108851. /**
  108852. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108853. */
  108854. set shadowsEnabled(value: boolean);
  108855. get shadowsEnabled(): boolean;
  108856. private _lightsEnabled;
  108857. /**
  108858. * Gets or sets a boolean indicating if lights are enabled on this scene
  108859. */
  108860. set lightsEnabled(value: boolean);
  108861. get lightsEnabled(): boolean;
  108862. /** All of the active cameras added to this scene. */
  108863. activeCameras: Camera[];
  108864. /** @hidden */
  108865. _activeCamera: Nullable<Camera>;
  108866. /** Gets or sets the current active camera */
  108867. get activeCamera(): Nullable<Camera>;
  108868. set activeCamera(value: Nullable<Camera>);
  108869. private _defaultMaterial;
  108870. /** The default material used on meshes when no material is affected */
  108871. get defaultMaterial(): Material;
  108872. /** The default material used on meshes when no material is affected */
  108873. set defaultMaterial(value: Material);
  108874. private _texturesEnabled;
  108875. /**
  108876. * Gets or sets a boolean indicating if textures are enabled on this scene
  108877. */
  108878. set texturesEnabled(value: boolean);
  108879. get texturesEnabled(): boolean;
  108880. /**
  108881. * Gets or sets a boolean indicating if particles are enabled on this scene
  108882. */
  108883. particlesEnabled: boolean;
  108884. /**
  108885. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108886. */
  108887. spritesEnabled: boolean;
  108888. private _skeletonsEnabled;
  108889. /**
  108890. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108891. */
  108892. set skeletonsEnabled(value: boolean);
  108893. get skeletonsEnabled(): boolean;
  108894. /**
  108895. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108896. */
  108897. lensFlaresEnabled: boolean;
  108898. /**
  108899. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108901. */
  108902. collisionsEnabled: boolean;
  108903. private _collisionCoordinator;
  108904. /** @hidden */
  108905. get collisionCoordinator(): ICollisionCoordinator;
  108906. /**
  108907. * Defines the gravity applied to this scene (used only for collisions)
  108908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108909. */
  108910. gravity: Vector3;
  108911. /**
  108912. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108913. */
  108914. postProcessesEnabled: boolean;
  108915. /**
  108916. * The list of postprocesses added to the scene
  108917. */
  108918. postProcesses: PostProcess[];
  108919. /**
  108920. * Gets the current postprocess manager
  108921. */
  108922. postProcessManager: PostProcessManager;
  108923. /**
  108924. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108925. */
  108926. renderTargetsEnabled: boolean;
  108927. /**
  108928. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108929. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108930. */
  108931. dumpNextRenderTargets: boolean;
  108932. /**
  108933. * The list of user defined render targets added to the scene
  108934. */
  108935. customRenderTargets: RenderTargetTexture[];
  108936. /**
  108937. * Defines if texture loading must be delayed
  108938. * If true, textures will only be loaded when they need to be rendered
  108939. */
  108940. useDelayedTextureLoading: boolean;
  108941. /**
  108942. * Gets the list of meshes imported to the scene through SceneLoader
  108943. */
  108944. importedMeshesFiles: String[];
  108945. /**
  108946. * Gets or sets a boolean indicating if probes are enabled on this scene
  108947. */
  108948. probesEnabled: boolean;
  108949. /**
  108950. * Gets or sets the current offline provider to use to store scene data
  108951. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108952. */
  108953. offlineProvider: IOfflineProvider;
  108954. /**
  108955. * Gets or sets the action manager associated with the scene
  108956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108957. */
  108958. actionManager: AbstractActionManager;
  108959. private _meshesForIntersections;
  108960. /**
  108961. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108962. */
  108963. proceduralTexturesEnabled: boolean;
  108964. private _engine;
  108965. private _totalVertices;
  108966. /** @hidden */
  108967. _activeIndices: PerfCounter;
  108968. /** @hidden */
  108969. _activeParticles: PerfCounter;
  108970. /** @hidden */
  108971. _activeBones: PerfCounter;
  108972. private _animationRatio;
  108973. /** @hidden */
  108974. _animationTimeLast: number;
  108975. /** @hidden */
  108976. _animationTime: number;
  108977. /**
  108978. * Gets or sets a general scale for animation speed
  108979. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108980. */
  108981. animationTimeScale: number;
  108982. /** @hidden */
  108983. _cachedMaterial: Nullable<Material>;
  108984. /** @hidden */
  108985. _cachedEffect: Nullable<Effect>;
  108986. /** @hidden */
  108987. _cachedVisibility: Nullable<number>;
  108988. private _renderId;
  108989. private _frameId;
  108990. private _executeWhenReadyTimeoutId;
  108991. private _intermediateRendering;
  108992. private _viewUpdateFlag;
  108993. private _projectionUpdateFlag;
  108994. /** @hidden */
  108995. _toBeDisposed: Nullable<IDisposable>[];
  108996. private _activeRequests;
  108997. /** @hidden */
  108998. _pendingData: any[];
  108999. private _isDisposed;
  109000. /**
  109001. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109002. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109003. */
  109004. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109005. private _activeMeshes;
  109006. private _processedMaterials;
  109007. private _renderTargets;
  109008. /** @hidden */
  109009. _activeParticleSystems: SmartArray<IParticleSystem>;
  109010. private _activeSkeletons;
  109011. private _softwareSkinnedMeshes;
  109012. private _renderingManager;
  109013. /** @hidden */
  109014. _activeAnimatables: Animatable[];
  109015. private _transformMatrix;
  109016. private _sceneUbo;
  109017. /** @hidden */
  109018. _viewMatrix: Matrix;
  109019. private _projectionMatrix;
  109020. /** @hidden */
  109021. _forcedViewPosition: Nullable<Vector3>;
  109022. /** @hidden */
  109023. _frustumPlanes: Plane[];
  109024. /**
  109025. * Gets the list of frustum planes (built from the active camera)
  109026. */
  109027. get frustumPlanes(): Plane[];
  109028. /**
  109029. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109030. * This is useful if there are more lights that the maximum simulteanous authorized
  109031. */
  109032. requireLightSorting: boolean;
  109033. /** @hidden */
  109034. readonly useMaterialMeshMap: boolean;
  109035. /** @hidden */
  109036. readonly useClonedMeshMap: boolean;
  109037. private _externalData;
  109038. private _uid;
  109039. /**
  109040. * @hidden
  109041. * Backing store of defined scene components.
  109042. */
  109043. _components: ISceneComponent[];
  109044. /**
  109045. * @hidden
  109046. * Backing store of defined scene components.
  109047. */
  109048. _serializableComponents: ISceneSerializableComponent[];
  109049. /**
  109050. * List of components to register on the next registration step.
  109051. */
  109052. private _transientComponents;
  109053. /**
  109054. * Registers the transient components if needed.
  109055. */
  109056. private _registerTransientComponents;
  109057. /**
  109058. * @hidden
  109059. * Add a component to the scene.
  109060. * Note that the ccomponent could be registered on th next frame if this is called after
  109061. * the register component stage.
  109062. * @param component Defines the component to add to the scene
  109063. */
  109064. _addComponent(component: ISceneComponent): void;
  109065. /**
  109066. * @hidden
  109067. * Gets a component from the scene.
  109068. * @param name defines the name of the component to retrieve
  109069. * @returns the component or null if not present
  109070. */
  109071. _getComponent(name: string): Nullable<ISceneComponent>;
  109072. /**
  109073. * @hidden
  109074. * Defines the actions happening before camera updates.
  109075. */
  109076. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109077. /**
  109078. * @hidden
  109079. * Defines the actions happening before clear the canvas.
  109080. */
  109081. _beforeClearStage: Stage<SimpleStageAction>;
  109082. /**
  109083. * @hidden
  109084. * Defines the actions when collecting render targets for the frame.
  109085. */
  109086. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109087. /**
  109088. * @hidden
  109089. * Defines the actions happening for one camera in the frame.
  109090. */
  109091. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109092. /**
  109093. * @hidden
  109094. * Defines the actions happening during the per mesh ready checks.
  109095. */
  109096. _isReadyForMeshStage: Stage<MeshStageAction>;
  109097. /**
  109098. * @hidden
  109099. * Defines the actions happening before evaluate active mesh checks.
  109100. */
  109101. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109102. /**
  109103. * @hidden
  109104. * Defines the actions happening during the evaluate sub mesh checks.
  109105. */
  109106. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109107. /**
  109108. * @hidden
  109109. * Defines the actions happening during the active mesh stage.
  109110. */
  109111. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109112. /**
  109113. * @hidden
  109114. * Defines the actions happening during the per camera render target step.
  109115. */
  109116. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109117. /**
  109118. * @hidden
  109119. * Defines the actions happening just before the active camera is drawing.
  109120. */
  109121. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109122. /**
  109123. * @hidden
  109124. * Defines the actions happening just before a render target is drawing.
  109125. */
  109126. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109127. /**
  109128. * @hidden
  109129. * Defines the actions happening just before a rendering group is drawing.
  109130. */
  109131. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109132. /**
  109133. * @hidden
  109134. * Defines the actions happening just before a mesh is drawing.
  109135. */
  109136. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109137. /**
  109138. * @hidden
  109139. * Defines the actions happening just after a mesh has been drawn.
  109140. */
  109141. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109142. /**
  109143. * @hidden
  109144. * Defines the actions happening just after a rendering group has been drawn.
  109145. */
  109146. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109147. /**
  109148. * @hidden
  109149. * Defines the actions happening just after the active camera has been drawn.
  109150. */
  109151. _afterCameraDrawStage: Stage<CameraStageAction>;
  109152. /**
  109153. * @hidden
  109154. * Defines the actions happening just after a render target has been drawn.
  109155. */
  109156. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109157. /**
  109158. * @hidden
  109159. * Defines the actions happening just after rendering all cameras and computing intersections.
  109160. */
  109161. _afterRenderStage: Stage<SimpleStageAction>;
  109162. /**
  109163. * @hidden
  109164. * Defines the actions happening when a pointer move event happens.
  109165. */
  109166. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109167. /**
  109168. * @hidden
  109169. * Defines the actions happening when a pointer down event happens.
  109170. */
  109171. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109172. /**
  109173. * @hidden
  109174. * Defines the actions happening when a pointer up event happens.
  109175. */
  109176. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109177. /**
  109178. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109179. */
  109180. private geometriesByUniqueId;
  109181. /**
  109182. * Creates a new Scene
  109183. * @param engine defines the engine to use to render this scene
  109184. * @param options defines the scene options
  109185. */
  109186. constructor(engine: Engine, options?: SceneOptions);
  109187. /**
  109188. * Gets a string idenfifying the name of the class
  109189. * @returns "Scene" string
  109190. */
  109191. getClassName(): string;
  109192. private _defaultMeshCandidates;
  109193. /**
  109194. * @hidden
  109195. */
  109196. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109197. private _defaultSubMeshCandidates;
  109198. /**
  109199. * @hidden
  109200. */
  109201. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109202. /**
  109203. * Sets the default candidate providers for the scene.
  109204. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109205. * and getCollidingSubMeshCandidates to their default function
  109206. */
  109207. setDefaultCandidateProviders(): void;
  109208. /**
  109209. * Gets the mesh that is currently under the pointer
  109210. */
  109211. get meshUnderPointer(): Nullable<AbstractMesh>;
  109212. /**
  109213. * Gets or sets the current on-screen X position of the pointer
  109214. */
  109215. get pointerX(): number;
  109216. set pointerX(value: number);
  109217. /**
  109218. * Gets or sets the current on-screen Y position of the pointer
  109219. */
  109220. get pointerY(): number;
  109221. set pointerY(value: number);
  109222. /**
  109223. * Gets the cached material (ie. the latest rendered one)
  109224. * @returns the cached material
  109225. */
  109226. getCachedMaterial(): Nullable<Material>;
  109227. /**
  109228. * Gets the cached effect (ie. the latest rendered one)
  109229. * @returns the cached effect
  109230. */
  109231. getCachedEffect(): Nullable<Effect>;
  109232. /**
  109233. * Gets the cached visibility state (ie. the latest rendered one)
  109234. * @returns the cached visibility state
  109235. */
  109236. getCachedVisibility(): Nullable<number>;
  109237. /**
  109238. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109239. * @param material defines the current material
  109240. * @param effect defines the current effect
  109241. * @param visibility defines the current visibility state
  109242. * @returns true if one parameter is not cached
  109243. */
  109244. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109245. /**
  109246. * Gets the engine associated with the scene
  109247. * @returns an Engine
  109248. */
  109249. getEngine(): Engine;
  109250. /**
  109251. * Gets the total number of vertices rendered per frame
  109252. * @returns the total number of vertices rendered per frame
  109253. */
  109254. getTotalVertices(): number;
  109255. /**
  109256. * Gets the performance counter for total vertices
  109257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109258. */
  109259. get totalVerticesPerfCounter(): PerfCounter;
  109260. /**
  109261. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109262. * @returns the total number of active indices rendered per frame
  109263. */
  109264. getActiveIndices(): number;
  109265. /**
  109266. * Gets the performance counter for active indices
  109267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109268. */
  109269. get totalActiveIndicesPerfCounter(): PerfCounter;
  109270. /**
  109271. * Gets the total number of active particles rendered per frame
  109272. * @returns the total number of active particles rendered per frame
  109273. */
  109274. getActiveParticles(): number;
  109275. /**
  109276. * Gets the performance counter for active particles
  109277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109278. */
  109279. get activeParticlesPerfCounter(): PerfCounter;
  109280. /**
  109281. * Gets the total number of active bones rendered per frame
  109282. * @returns the total number of active bones rendered per frame
  109283. */
  109284. getActiveBones(): number;
  109285. /**
  109286. * Gets the performance counter for active bones
  109287. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109288. */
  109289. get activeBonesPerfCounter(): PerfCounter;
  109290. /**
  109291. * Gets the array of active meshes
  109292. * @returns an array of AbstractMesh
  109293. */
  109294. getActiveMeshes(): SmartArray<AbstractMesh>;
  109295. /**
  109296. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109297. * @returns a number
  109298. */
  109299. getAnimationRatio(): number;
  109300. /**
  109301. * Gets an unique Id for the current render phase
  109302. * @returns a number
  109303. */
  109304. getRenderId(): number;
  109305. /**
  109306. * Gets an unique Id for the current frame
  109307. * @returns a number
  109308. */
  109309. getFrameId(): number;
  109310. /** Call this function if you want to manually increment the render Id*/
  109311. incrementRenderId(): void;
  109312. private _createUbo;
  109313. /**
  109314. * Use this method to simulate a pointer move on a mesh
  109315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109318. * @returns the current scene
  109319. */
  109320. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109321. /**
  109322. * Use this method to simulate a pointer down on a mesh
  109323. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109324. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109325. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109326. * @returns the current scene
  109327. */
  109328. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109329. /**
  109330. * Use this method to simulate a pointer up on a mesh
  109331. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109332. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109333. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109334. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109335. * @returns the current scene
  109336. */
  109337. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109338. /**
  109339. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109340. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109341. * @returns true if the pointer was captured
  109342. */
  109343. isPointerCaptured(pointerId?: number): boolean;
  109344. /**
  109345. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109346. * @param attachUp defines if you want to attach events to pointerup
  109347. * @param attachDown defines if you want to attach events to pointerdown
  109348. * @param attachMove defines if you want to attach events to pointermove
  109349. */
  109350. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109351. /** Detaches all event handlers*/
  109352. detachControl(): void;
  109353. /**
  109354. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109355. * Delay loaded resources are not taking in account
  109356. * @return true if all required resources are ready
  109357. */
  109358. isReady(): boolean;
  109359. /** Resets all cached information relative to material (including effect and visibility) */
  109360. resetCachedMaterial(): void;
  109361. /**
  109362. * Registers a function to be called before every frame render
  109363. * @param func defines the function to register
  109364. */
  109365. registerBeforeRender(func: () => void): void;
  109366. /**
  109367. * Unregisters a function called before every frame render
  109368. * @param func defines the function to unregister
  109369. */
  109370. unregisterBeforeRender(func: () => void): void;
  109371. /**
  109372. * Registers a function to be called after every frame render
  109373. * @param func defines the function to register
  109374. */
  109375. registerAfterRender(func: () => void): void;
  109376. /**
  109377. * Unregisters a function called after every frame render
  109378. * @param func defines the function to unregister
  109379. */
  109380. unregisterAfterRender(func: () => void): void;
  109381. private _executeOnceBeforeRender;
  109382. /**
  109383. * The provided function will run before render once and will be disposed afterwards.
  109384. * A timeout delay can be provided so that the function will be executed in N ms.
  109385. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109386. * @param func The function to be executed.
  109387. * @param timeout optional delay in ms
  109388. */
  109389. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109390. /** @hidden */
  109391. _addPendingData(data: any): void;
  109392. /** @hidden */
  109393. _removePendingData(data: any): void;
  109394. /**
  109395. * Returns the number of items waiting to be loaded
  109396. * @returns the number of items waiting to be loaded
  109397. */
  109398. getWaitingItemsCount(): number;
  109399. /**
  109400. * Returns a boolean indicating if the scene is still loading data
  109401. */
  109402. get isLoading(): boolean;
  109403. /**
  109404. * Registers a function to be executed when the scene is ready
  109405. * @param {Function} func - the function to be executed
  109406. */
  109407. executeWhenReady(func: () => void): void;
  109408. /**
  109409. * Returns a promise that resolves when the scene is ready
  109410. * @returns A promise that resolves when the scene is ready
  109411. */
  109412. whenReadyAsync(): Promise<void>;
  109413. /** @hidden */
  109414. _checkIsReady(): void;
  109415. /**
  109416. * Gets all animatable attached to the scene
  109417. */
  109418. get animatables(): Animatable[];
  109419. /**
  109420. * Resets the last animation time frame.
  109421. * Useful to override when animations start running when loading a scene for the first time.
  109422. */
  109423. resetLastAnimationTimeFrame(): void;
  109424. /**
  109425. * Gets the current view matrix
  109426. * @returns a Matrix
  109427. */
  109428. getViewMatrix(): Matrix;
  109429. /**
  109430. * Gets the current projection matrix
  109431. * @returns a Matrix
  109432. */
  109433. getProjectionMatrix(): Matrix;
  109434. /**
  109435. * Gets the current transform matrix
  109436. * @returns a Matrix made of View * Projection
  109437. */
  109438. getTransformMatrix(): Matrix;
  109439. /**
  109440. * Sets the current transform matrix
  109441. * @param viewL defines the View matrix to use
  109442. * @param projectionL defines the Projection matrix to use
  109443. * @param viewR defines the right View matrix to use (if provided)
  109444. * @param projectionR defines the right Projection matrix to use (if provided)
  109445. */
  109446. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109447. /**
  109448. * Gets the uniform buffer used to store scene data
  109449. * @returns a UniformBuffer
  109450. */
  109451. getSceneUniformBuffer(): UniformBuffer;
  109452. /**
  109453. * Gets an unique (relatively to the current scene) Id
  109454. * @returns an unique number for the scene
  109455. */
  109456. getUniqueId(): number;
  109457. /**
  109458. * Add a mesh to the list of scene's meshes
  109459. * @param newMesh defines the mesh to add
  109460. * @param recursive if all child meshes should also be added to the scene
  109461. */
  109462. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109463. /**
  109464. * Remove a mesh for the list of scene's meshes
  109465. * @param toRemove defines the mesh to remove
  109466. * @param recursive if all child meshes should also be removed from the scene
  109467. * @returns the index where the mesh was in the mesh list
  109468. */
  109469. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109470. /**
  109471. * Add a transform node to the list of scene's transform nodes
  109472. * @param newTransformNode defines the transform node to add
  109473. */
  109474. addTransformNode(newTransformNode: TransformNode): void;
  109475. /**
  109476. * Remove a transform node for the list of scene's transform nodes
  109477. * @param toRemove defines the transform node to remove
  109478. * @returns the index where the transform node was in the transform node list
  109479. */
  109480. removeTransformNode(toRemove: TransformNode): number;
  109481. /**
  109482. * Remove a skeleton for the list of scene's skeletons
  109483. * @param toRemove defines the skeleton to remove
  109484. * @returns the index where the skeleton was in the skeleton list
  109485. */
  109486. removeSkeleton(toRemove: Skeleton): number;
  109487. /**
  109488. * Remove a morph target for the list of scene's morph targets
  109489. * @param toRemove defines the morph target to remove
  109490. * @returns the index where the morph target was in the morph target list
  109491. */
  109492. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109493. /**
  109494. * Remove a light for the list of scene's lights
  109495. * @param toRemove defines the light to remove
  109496. * @returns the index where the light was in the light list
  109497. */
  109498. removeLight(toRemove: Light): number;
  109499. /**
  109500. * Remove a camera for the list of scene's cameras
  109501. * @param toRemove defines the camera to remove
  109502. * @returns the index where the camera was in the camera list
  109503. */
  109504. removeCamera(toRemove: Camera): number;
  109505. /**
  109506. * Remove a particle system for the list of scene's particle systems
  109507. * @param toRemove defines the particle system to remove
  109508. * @returns the index where the particle system was in the particle system list
  109509. */
  109510. removeParticleSystem(toRemove: IParticleSystem): number;
  109511. /**
  109512. * Remove a animation for the list of scene's animations
  109513. * @param toRemove defines the animation to remove
  109514. * @returns the index where the animation was in the animation list
  109515. */
  109516. removeAnimation(toRemove: Animation): number;
  109517. /**
  109518. * Will stop the animation of the given target
  109519. * @param target - the target
  109520. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109521. * @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)
  109522. */
  109523. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109524. /**
  109525. * Removes the given animation group from this scene.
  109526. * @param toRemove The animation group to remove
  109527. * @returns The index of the removed animation group
  109528. */
  109529. removeAnimationGroup(toRemove: AnimationGroup): number;
  109530. /**
  109531. * Removes the given multi-material from this scene.
  109532. * @param toRemove The multi-material to remove
  109533. * @returns The index of the removed multi-material
  109534. */
  109535. removeMultiMaterial(toRemove: MultiMaterial): number;
  109536. /**
  109537. * Removes the given material from this scene.
  109538. * @param toRemove The material to remove
  109539. * @returns The index of the removed material
  109540. */
  109541. removeMaterial(toRemove: Material): number;
  109542. /**
  109543. * Removes the given action manager from this scene.
  109544. * @param toRemove The action manager to remove
  109545. * @returns The index of the removed action manager
  109546. */
  109547. removeActionManager(toRemove: AbstractActionManager): number;
  109548. /**
  109549. * Removes the given texture from this scene.
  109550. * @param toRemove The texture to remove
  109551. * @returns The index of the removed texture
  109552. */
  109553. removeTexture(toRemove: BaseTexture): number;
  109554. /**
  109555. * Adds the given light to this scene
  109556. * @param newLight The light to add
  109557. */
  109558. addLight(newLight: Light): void;
  109559. /**
  109560. * Sorts the list list based on light priorities
  109561. */
  109562. sortLightsByPriority(): void;
  109563. /**
  109564. * Adds the given camera to this scene
  109565. * @param newCamera The camera to add
  109566. */
  109567. addCamera(newCamera: Camera): void;
  109568. /**
  109569. * Adds the given skeleton to this scene
  109570. * @param newSkeleton The skeleton to add
  109571. */
  109572. addSkeleton(newSkeleton: Skeleton): void;
  109573. /**
  109574. * Adds the given particle system to this scene
  109575. * @param newParticleSystem The particle system to add
  109576. */
  109577. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109578. /**
  109579. * Adds the given animation to this scene
  109580. * @param newAnimation The animation to add
  109581. */
  109582. addAnimation(newAnimation: Animation): void;
  109583. /**
  109584. * Adds the given animation group to this scene.
  109585. * @param newAnimationGroup The animation group to add
  109586. */
  109587. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109588. /**
  109589. * Adds the given multi-material to this scene
  109590. * @param newMultiMaterial The multi-material to add
  109591. */
  109592. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109593. /**
  109594. * Adds the given material to this scene
  109595. * @param newMaterial The material to add
  109596. */
  109597. addMaterial(newMaterial: Material): void;
  109598. /**
  109599. * Adds the given morph target to this scene
  109600. * @param newMorphTargetManager The morph target to add
  109601. */
  109602. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109603. /**
  109604. * Adds the given geometry to this scene
  109605. * @param newGeometry The geometry to add
  109606. */
  109607. addGeometry(newGeometry: Geometry): void;
  109608. /**
  109609. * Adds the given action manager to this scene
  109610. * @param newActionManager The action manager to add
  109611. */
  109612. addActionManager(newActionManager: AbstractActionManager): void;
  109613. /**
  109614. * Adds the given texture to this scene.
  109615. * @param newTexture The texture to add
  109616. */
  109617. addTexture(newTexture: BaseTexture): void;
  109618. /**
  109619. * Switch active camera
  109620. * @param newCamera defines the new active camera
  109621. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109622. */
  109623. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109624. /**
  109625. * sets the active camera of the scene using its ID
  109626. * @param id defines the camera's ID
  109627. * @return the new active camera or null if none found.
  109628. */
  109629. setActiveCameraByID(id: string): Nullable<Camera>;
  109630. /**
  109631. * sets the active camera of the scene using its name
  109632. * @param name defines the camera's name
  109633. * @returns the new active camera or null if none found.
  109634. */
  109635. setActiveCameraByName(name: string): Nullable<Camera>;
  109636. /**
  109637. * get an animation group using its name
  109638. * @param name defines the material's name
  109639. * @return the animation group or null if none found.
  109640. */
  109641. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109642. /**
  109643. * Get a material using its unique id
  109644. * @param uniqueId defines the material's unique id
  109645. * @return the material or null if none found.
  109646. */
  109647. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109648. /**
  109649. * get a material using its id
  109650. * @param id defines the material's ID
  109651. * @return the material or null if none found.
  109652. */
  109653. getMaterialByID(id: string): Nullable<Material>;
  109654. /**
  109655. * Gets a the last added material using a given id
  109656. * @param id defines the material's ID
  109657. * @return the last material with the given id or null if none found.
  109658. */
  109659. getLastMaterialByID(id: string): Nullable<Material>;
  109660. /**
  109661. * Gets a material using its name
  109662. * @param name defines the material's name
  109663. * @return the material or null if none found.
  109664. */
  109665. getMaterialByName(name: string): Nullable<Material>;
  109666. /**
  109667. * Get a texture using its unique id
  109668. * @param uniqueId defines the texture's unique id
  109669. * @return the texture or null if none found.
  109670. */
  109671. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109672. /**
  109673. * Gets a camera using its id
  109674. * @param id defines the id to look for
  109675. * @returns the camera or null if not found
  109676. */
  109677. getCameraByID(id: string): Nullable<Camera>;
  109678. /**
  109679. * Gets a camera using its unique id
  109680. * @param uniqueId defines the unique id to look for
  109681. * @returns the camera or null if not found
  109682. */
  109683. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109684. /**
  109685. * Gets a camera using its name
  109686. * @param name defines the camera's name
  109687. * @return the camera or null if none found.
  109688. */
  109689. getCameraByName(name: string): Nullable<Camera>;
  109690. /**
  109691. * Gets a bone using its id
  109692. * @param id defines the bone's id
  109693. * @return the bone or null if not found
  109694. */
  109695. getBoneByID(id: string): Nullable<Bone>;
  109696. /**
  109697. * Gets a bone using its id
  109698. * @param name defines the bone's name
  109699. * @return the bone or null if not found
  109700. */
  109701. getBoneByName(name: string): Nullable<Bone>;
  109702. /**
  109703. * Gets a light node using its name
  109704. * @param name defines the the light's name
  109705. * @return the light or null if none found.
  109706. */
  109707. getLightByName(name: string): Nullable<Light>;
  109708. /**
  109709. * Gets a light node using its id
  109710. * @param id defines the light's id
  109711. * @return the light or null if none found.
  109712. */
  109713. getLightByID(id: string): Nullable<Light>;
  109714. /**
  109715. * Gets a light node using its scene-generated unique ID
  109716. * @param uniqueId defines the light's unique id
  109717. * @return the light or null if none found.
  109718. */
  109719. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109720. /**
  109721. * Gets a particle system by id
  109722. * @param id defines the particle system id
  109723. * @return the corresponding system or null if none found
  109724. */
  109725. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109726. /**
  109727. * Gets a geometry using its ID
  109728. * @param id defines the geometry's id
  109729. * @return the geometry or null if none found.
  109730. */
  109731. getGeometryByID(id: string): Nullable<Geometry>;
  109732. private _getGeometryByUniqueID;
  109733. /**
  109734. * Add a new geometry to this scene
  109735. * @param geometry defines the geometry to be added to the scene.
  109736. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109737. * @return a boolean defining if the geometry was added or not
  109738. */
  109739. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109740. /**
  109741. * Removes an existing geometry
  109742. * @param geometry defines the geometry to be removed from the scene
  109743. * @return a boolean defining if the geometry was removed or not
  109744. */
  109745. removeGeometry(geometry: Geometry): boolean;
  109746. /**
  109747. * Gets the list of geometries attached to the scene
  109748. * @returns an array of Geometry
  109749. */
  109750. getGeometries(): Geometry[];
  109751. /**
  109752. * Gets the first added mesh found of a given ID
  109753. * @param id defines the id to search for
  109754. * @return the mesh found or null if not found at all
  109755. */
  109756. getMeshByID(id: string): Nullable<AbstractMesh>;
  109757. /**
  109758. * Gets a list of meshes using their id
  109759. * @param id defines the id to search for
  109760. * @returns a list of meshes
  109761. */
  109762. getMeshesByID(id: string): Array<AbstractMesh>;
  109763. /**
  109764. * Gets the first added transform node found of a given ID
  109765. * @param id defines the id to search for
  109766. * @return the found transform node or null if not found at all.
  109767. */
  109768. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109769. /**
  109770. * Gets a transform node with its auto-generated unique id
  109771. * @param uniqueId efines the unique id to search for
  109772. * @return the found transform node or null if not found at all.
  109773. */
  109774. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109775. /**
  109776. * Gets a list of transform nodes using their id
  109777. * @param id defines the id to search for
  109778. * @returns a list of transform nodes
  109779. */
  109780. getTransformNodesByID(id: string): Array<TransformNode>;
  109781. /**
  109782. * Gets a mesh with its auto-generated unique id
  109783. * @param uniqueId defines the unique id to search for
  109784. * @return the found mesh or null if not found at all.
  109785. */
  109786. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109787. /**
  109788. * Gets a the last added mesh using a given id
  109789. * @param id defines the id to search for
  109790. * @return the found mesh or null if not found at all.
  109791. */
  109792. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109793. /**
  109794. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109795. * @param id defines the id to search for
  109796. * @return the found node or null if not found at all
  109797. */
  109798. getLastEntryByID(id: string): Nullable<Node>;
  109799. /**
  109800. * Gets a node (Mesh, Camera, Light) using a given id
  109801. * @param id defines the id to search for
  109802. * @return the found node or null if not found at all
  109803. */
  109804. getNodeByID(id: string): Nullable<Node>;
  109805. /**
  109806. * Gets a node (Mesh, Camera, Light) using a given name
  109807. * @param name defines the name to search for
  109808. * @return the found node or null if not found at all.
  109809. */
  109810. getNodeByName(name: string): Nullable<Node>;
  109811. /**
  109812. * Gets a mesh using a given name
  109813. * @param name defines the name to search for
  109814. * @return the found mesh or null if not found at all.
  109815. */
  109816. getMeshByName(name: string): Nullable<AbstractMesh>;
  109817. /**
  109818. * Gets a transform node using a given name
  109819. * @param name defines the name to search for
  109820. * @return the found transform node or null if not found at all.
  109821. */
  109822. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109823. /**
  109824. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109825. * @param id defines the id to search for
  109826. * @return the found skeleton or null if not found at all.
  109827. */
  109828. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109829. /**
  109830. * Gets a skeleton using a given auto generated unique id
  109831. * @param uniqueId defines the unique id to search for
  109832. * @return the found skeleton or null if not found at all.
  109833. */
  109834. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109835. /**
  109836. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109837. * @param id defines the id to search for
  109838. * @return the found skeleton or null if not found at all.
  109839. */
  109840. getSkeletonById(id: string): Nullable<Skeleton>;
  109841. /**
  109842. * Gets a skeleton using a given name
  109843. * @param name defines the name to search for
  109844. * @return the found skeleton or null if not found at all.
  109845. */
  109846. getSkeletonByName(name: string): Nullable<Skeleton>;
  109847. /**
  109848. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109849. * @param id defines the id to search for
  109850. * @return the found morph target manager or null if not found at all.
  109851. */
  109852. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109853. /**
  109854. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109855. * @param id defines the id to search for
  109856. * @return the found morph target or null if not found at all.
  109857. */
  109858. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109859. /**
  109860. * Gets a boolean indicating if the given mesh is active
  109861. * @param mesh defines the mesh to look for
  109862. * @returns true if the mesh is in the active list
  109863. */
  109864. isActiveMesh(mesh: AbstractMesh): boolean;
  109865. /**
  109866. * Return a unique id as a string which can serve as an identifier for the scene
  109867. */
  109868. get uid(): string;
  109869. /**
  109870. * Add an externaly attached data from its key.
  109871. * This method call will fail and return false, if such key already exists.
  109872. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109873. * @param key the unique key that identifies the data
  109874. * @param data the data object to associate to the key for this Engine instance
  109875. * @return true if no such key were already present and the data was added successfully, false otherwise
  109876. */
  109877. addExternalData<T>(key: string, data: T): boolean;
  109878. /**
  109879. * Get an externaly attached data from its key
  109880. * @param key the unique key that identifies the data
  109881. * @return the associated data, if present (can be null), or undefined if not present
  109882. */
  109883. getExternalData<T>(key: string): Nullable<T>;
  109884. /**
  109885. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109886. * @param key the unique key that identifies the data
  109887. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109888. * @return the associated data, can be null if the factory returned null.
  109889. */
  109890. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109891. /**
  109892. * Remove an externaly attached data from the Engine instance
  109893. * @param key the unique key that identifies the data
  109894. * @return true if the data was successfully removed, false if it doesn't exist
  109895. */
  109896. removeExternalData(key: string): boolean;
  109897. private _evaluateSubMesh;
  109898. /**
  109899. * Clear the processed materials smart array preventing retention point in material dispose.
  109900. */
  109901. freeProcessedMaterials(): void;
  109902. private _preventFreeActiveMeshesAndRenderingGroups;
  109903. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109904. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109905. * when disposing several meshes in a row or a hierarchy of meshes.
  109906. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109907. */
  109908. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109909. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109910. /**
  109911. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109912. */
  109913. freeActiveMeshes(): void;
  109914. /**
  109915. * Clear the info related to rendering groups preventing retention points during dispose.
  109916. */
  109917. freeRenderingGroups(): void;
  109918. /** @hidden */
  109919. _isInIntermediateRendering(): boolean;
  109920. /**
  109921. * Lambda returning the list of potentially active meshes.
  109922. */
  109923. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109924. /**
  109925. * Lambda returning the list of potentially active sub meshes.
  109926. */
  109927. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109928. /**
  109929. * Lambda returning the list of potentially intersecting sub meshes.
  109930. */
  109931. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109932. /**
  109933. * Lambda returning the list of potentially colliding sub meshes.
  109934. */
  109935. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109936. private _activeMeshesFrozen;
  109937. private _skipEvaluateActiveMeshesCompletely;
  109938. /**
  109939. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109940. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109941. * @returns the current scene
  109942. */
  109943. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109944. /**
  109945. * Use this function to restart evaluating active meshes on every frame
  109946. * @returns the current scene
  109947. */
  109948. unfreezeActiveMeshes(): Scene;
  109949. private _evaluateActiveMeshes;
  109950. private _activeMesh;
  109951. /**
  109952. * Update the transform matrix to update from the current active camera
  109953. * @param force defines a boolean used to force the update even if cache is up to date
  109954. */
  109955. updateTransformMatrix(force?: boolean): void;
  109956. private _bindFrameBuffer;
  109957. /** @hidden */
  109958. _allowPostProcessClearColor: boolean;
  109959. /** @hidden */
  109960. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109961. private _processSubCameras;
  109962. private _checkIntersections;
  109963. /** @hidden */
  109964. _advancePhysicsEngineStep(step: number): void;
  109965. /**
  109966. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109967. */
  109968. getDeterministicFrameTime: () => number;
  109969. /** @hidden */
  109970. _animate(): void;
  109971. /** Execute all animations (for a frame) */
  109972. animate(): void;
  109973. /**
  109974. * Render the scene
  109975. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109976. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109977. */
  109978. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109979. /**
  109980. * Freeze all materials
  109981. * A frozen material will not be updatable but should be faster to render
  109982. */
  109983. freezeMaterials(): void;
  109984. /**
  109985. * Unfreeze all materials
  109986. * A frozen material will not be updatable but should be faster to render
  109987. */
  109988. unfreezeMaterials(): void;
  109989. /**
  109990. * Releases all held ressources
  109991. */
  109992. dispose(): void;
  109993. /**
  109994. * Gets if the scene is already disposed
  109995. */
  109996. get isDisposed(): boolean;
  109997. /**
  109998. * Call this function to reduce memory footprint of the scene.
  109999. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110000. */
  110001. clearCachedVertexData(): void;
  110002. /**
  110003. * This function will remove the local cached buffer data from texture.
  110004. * It will save memory but will prevent the texture from being rebuilt
  110005. */
  110006. cleanCachedTextureBuffer(): void;
  110007. /**
  110008. * Get the world extend vectors with an optional filter
  110009. *
  110010. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110011. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110012. */
  110013. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110014. min: Vector3;
  110015. max: Vector3;
  110016. };
  110017. /**
  110018. * Creates a ray that can be used to pick in the scene
  110019. * @param x defines the x coordinate of the origin (on-screen)
  110020. * @param y defines the y coordinate of the origin (on-screen)
  110021. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110022. * @param camera defines the camera to use for the picking
  110023. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110024. * @returns a Ray
  110025. */
  110026. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110027. /**
  110028. * Creates a ray that can be used to pick in the scene
  110029. * @param x defines the x coordinate of the origin (on-screen)
  110030. * @param y defines the y coordinate of the origin (on-screen)
  110031. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110032. * @param result defines the ray where to store the picking ray
  110033. * @param camera defines the camera to use for the picking
  110034. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110035. * @returns the current scene
  110036. */
  110037. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110038. /**
  110039. * Creates a ray that can be used to pick in the scene
  110040. * @param x defines the x coordinate of the origin (on-screen)
  110041. * @param y defines the y coordinate of the origin (on-screen)
  110042. * @param camera defines the camera to use for the picking
  110043. * @returns a Ray
  110044. */
  110045. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110046. /**
  110047. * Creates a ray that can be used to pick in the scene
  110048. * @param x defines the x coordinate of the origin (on-screen)
  110049. * @param y defines the y coordinate of the origin (on-screen)
  110050. * @param result defines the ray where to store the picking ray
  110051. * @param camera defines the camera to use for the picking
  110052. * @returns the current scene
  110053. */
  110054. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110055. /** Launch a ray to try to pick a mesh in the scene
  110056. * @param x position on screen
  110057. * @param y position on screen
  110058. * @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
  110059. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110060. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110061. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110062. * @returns a PickingInfo
  110063. */
  110064. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110065. /** Use the given ray to pick a mesh in the scene
  110066. * @param ray The ray to use to pick meshes
  110067. * @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
  110068. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110070. * @returns a PickingInfo
  110071. */
  110072. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110073. /**
  110074. * Launch a ray to try to pick a mesh in the scene
  110075. * @param x X position on screen
  110076. * @param y Y position on screen
  110077. * @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
  110078. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110080. * @returns an array of PickingInfo
  110081. */
  110082. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110083. /**
  110084. * Launch a ray to try to pick a mesh in the scene
  110085. * @param ray Ray to use
  110086. * @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
  110087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110088. * @returns an array of PickingInfo
  110089. */
  110090. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110091. /**
  110092. * Force the value of meshUnderPointer
  110093. * @param mesh defines the mesh to use
  110094. */
  110095. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110096. /**
  110097. * Gets the mesh under the pointer
  110098. * @returns a Mesh or null if no mesh is under the pointer
  110099. */
  110100. getPointerOverMesh(): Nullable<AbstractMesh>;
  110101. /** @hidden */
  110102. _rebuildGeometries(): void;
  110103. /** @hidden */
  110104. _rebuildTextures(): void;
  110105. private _getByTags;
  110106. /**
  110107. * Get a list of meshes by tags
  110108. * @param tagsQuery defines the tags query to use
  110109. * @param forEach defines a predicate used to filter results
  110110. * @returns an array of Mesh
  110111. */
  110112. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110113. /**
  110114. * Get a list of cameras by tags
  110115. * @param tagsQuery defines the tags query to use
  110116. * @param forEach defines a predicate used to filter results
  110117. * @returns an array of Camera
  110118. */
  110119. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110120. /**
  110121. * Get a list of lights by tags
  110122. * @param tagsQuery defines the tags query to use
  110123. * @param forEach defines a predicate used to filter results
  110124. * @returns an array of Light
  110125. */
  110126. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110127. /**
  110128. * Get a list of materials by tags
  110129. * @param tagsQuery defines the tags query to use
  110130. * @param forEach defines a predicate used to filter results
  110131. * @returns an array of Material
  110132. */
  110133. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110134. /**
  110135. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110136. * This allowed control for front to back rendering or reversly depending of the special needs.
  110137. *
  110138. * @param renderingGroupId The rendering group id corresponding to its index
  110139. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110140. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110141. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110142. */
  110143. 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;
  110144. /**
  110145. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110146. *
  110147. * @param renderingGroupId The rendering group id corresponding to its index
  110148. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110149. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110150. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110151. */
  110152. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110153. /**
  110154. * Gets the current auto clear configuration for one rendering group of the rendering
  110155. * manager.
  110156. * @param index the rendering group index to get the information for
  110157. * @returns The auto clear setup for the requested rendering group
  110158. */
  110159. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110160. private _blockMaterialDirtyMechanism;
  110161. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110162. get blockMaterialDirtyMechanism(): boolean;
  110163. set blockMaterialDirtyMechanism(value: boolean);
  110164. /**
  110165. * Will flag all materials as dirty to trigger new shader compilation
  110166. * @param flag defines the flag used to specify which material part must be marked as dirty
  110167. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110168. */
  110169. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110170. /** @hidden */
  110171. _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;
  110172. /** @hidden */
  110173. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110174. /** @hidden */
  110175. _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;
  110176. /** @hidden */
  110177. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110178. /** @hidden */
  110179. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110180. /** @hidden */
  110181. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110182. }
  110183. }
  110184. declare module BABYLON {
  110185. /**
  110186. * Set of assets to keep when moving a scene into an asset container.
  110187. */
  110188. export class KeepAssets extends AbstractScene {
  110189. }
  110190. /**
  110191. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110192. */
  110193. export class InstantiatedEntries {
  110194. /**
  110195. * List of new root nodes (eg. nodes with no parent)
  110196. */
  110197. rootNodes: TransformNode[];
  110198. /**
  110199. * List of new skeletons
  110200. */
  110201. skeletons: Skeleton[];
  110202. /**
  110203. * List of new animation groups
  110204. */
  110205. animationGroups: AnimationGroup[];
  110206. }
  110207. /**
  110208. * Container with a set of assets that can be added or removed from a scene.
  110209. */
  110210. export class AssetContainer extends AbstractScene {
  110211. private _wasAddedToScene;
  110212. /**
  110213. * The scene the AssetContainer belongs to.
  110214. */
  110215. scene: Scene;
  110216. /**
  110217. * Instantiates an AssetContainer.
  110218. * @param scene The scene the AssetContainer belongs to.
  110219. */
  110220. constructor(scene: Scene);
  110221. /**
  110222. * Instantiate or clone all meshes and add the new ones to the scene.
  110223. * Skeletons and animation groups will all be cloned
  110224. * @param nameFunction defines an optional function used to get new names for clones
  110225. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110226. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110227. */
  110228. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110229. /**
  110230. * Adds all the assets from the container to the scene.
  110231. */
  110232. addAllToScene(): void;
  110233. /**
  110234. * Removes all the assets in the container from the scene
  110235. */
  110236. removeAllFromScene(): void;
  110237. /**
  110238. * Disposes all the assets in the container
  110239. */
  110240. dispose(): void;
  110241. private _moveAssets;
  110242. /**
  110243. * Removes all the assets contained in the scene and adds them to the container.
  110244. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110245. */
  110246. moveAllFromScene(keepAssets?: KeepAssets): void;
  110247. /**
  110248. * 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.
  110249. * @returns the root mesh
  110250. */
  110251. createRootMesh(): Mesh;
  110252. /**
  110253. * Merge animations from this asset container into a scene
  110254. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110255. * @param animatables set of animatables to retarget to a node from the scene
  110256. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110257. */
  110258. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /**
  110263. * Defines how the parser contract is defined.
  110264. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110265. */
  110266. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110267. /**
  110268. * Defines how the individual parser contract is defined.
  110269. * These parser can parse an individual asset
  110270. */
  110271. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110272. /**
  110273. * Base class of the scene acting as a container for the different elements composing a scene.
  110274. * This class is dynamically extended by the different components of the scene increasing
  110275. * flexibility and reducing coupling
  110276. */
  110277. export abstract class AbstractScene {
  110278. /**
  110279. * Stores the list of available parsers in the application.
  110280. */
  110281. private static _BabylonFileParsers;
  110282. /**
  110283. * Stores the list of available individual parsers in the application.
  110284. */
  110285. private static _IndividualBabylonFileParsers;
  110286. /**
  110287. * Adds a parser in the list of available ones
  110288. * @param name Defines the name of the parser
  110289. * @param parser Defines the parser to add
  110290. */
  110291. static AddParser(name: string, parser: BabylonFileParser): void;
  110292. /**
  110293. * Gets a general parser from the list of avaialble ones
  110294. * @param name Defines the name of the parser
  110295. * @returns the requested parser or null
  110296. */
  110297. static GetParser(name: string): Nullable<BabylonFileParser>;
  110298. /**
  110299. * Adds n individual parser in the list of available ones
  110300. * @param name Defines the name of the parser
  110301. * @param parser Defines the parser to add
  110302. */
  110303. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110304. /**
  110305. * Gets an individual parser from the list of avaialble ones
  110306. * @param name Defines the name of the parser
  110307. * @returns the requested parser or null
  110308. */
  110309. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110310. /**
  110311. * Parser json data and populate both a scene and its associated container object
  110312. * @param jsonData Defines the data to parse
  110313. * @param scene Defines the scene to parse the data for
  110314. * @param container Defines the container attached to the parsing sequence
  110315. * @param rootUrl Defines the root url of the data
  110316. */
  110317. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110318. /**
  110319. * Gets the list of root nodes (ie. nodes with no parent)
  110320. */
  110321. rootNodes: Node[];
  110322. /** All of the cameras added to this scene
  110323. * @see http://doc.babylonjs.com/babylon101/cameras
  110324. */
  110325. cameras: Camera[];
  110326. /**
  110327. * All of the lights added to this scene
  110328. * @see http://doc.babylonjs.com/babylon101/lights
  110329. */
  110330. lights: Light[];
  110331. /**
  110332. * All of the (abstract) meshes added to this scene
  110333. */
  110334. meshes: AbstractMesh[];
  110335. /**
  110336. * The list of skeletons added to the scene
  110337. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110338. */
  110339. skeletons: Skeleton[];
  110340. /**
  110341. * All of the particle systems added to this scene
  110342. * @see http://doc.babylonjs.com/babylon101/particles
  110343. */
  110344. particleSystems: IParticleSystem[];
  110345. /**
  110346. * Gets a list of Animations associated with the scene
  110347. */
  110348. animations: Animation[];
  110349. /**
  110350. * All of the animation groups added to this scene
  110351. * @see http://doc.babylonjs.com/how_to/group
  110352. */
  110353. animationGroups: AnimationGroup[];
  110354. /**
  110355. * All of the multi-materials added to this scene
  110356. * @see http://doc.babylonjs.com/how_to/multi_materials
  110357. */
  110358. multiMaterials: MultiMaterial[];
  110359. /**
  110360. * All of the materials added to this scene
  110361. * In the context of a Scene, it is not supposed to be modified manually.
  110362. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110363. * Note also that the order of the Material within the array is not significant and might change.
  110364. * @see http://doc.babylonjs.com/babylon101/materials
  110365. */
  110366. materials: Material[];
  110367. /**
  110368. * The list of morph target managers added to the scene
  110369. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110370. */
  110371. morphTargetManagers: MorphTargetManager[];
  110372. /**
  110373. * The list of geometries used in the scene.
  110374. */
  110375. geometries: Geometry[];
  110376. /**
  110377. * All of the tranform nodes added to this scene
  110378. * In the context of a Scene, it is not supposed to be modified manually.
  110379. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110380. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110381. * @see http://doc.babylonjs.com/how_to/transformnode
  110382. */
  110383. transformNodes: TransformNode[];
  110384. /**
  110385. * ActionManagers available on the scene.
  110386. */
  110387. actionManagers: AbstractActionManager[];
  110388. /**
  110389. * Textures to keep.
  110390. */
  110391. textures: BaseTexture[];
  110392. /**
  110393. * Environment texture for the scene
  110394. */
  110395. environmentTexture: Nullable<BaseTexture>;
  110396. /**
  110397. * @returns all meshes, lights, cameras, transformNodes and bones
  110398. */
  110399. getNodes(): Array<Node>;
  110400. }
  110401. }
  110402. declare module BABYLON {
  110403. /**
  110404. * Interface used to define options for Sound class
  110405. */
  110406. export interface ISoundOptions {
  110407. /**
  110408. * Does the sound autoplay once loaded.
  110409. */
  110410. autoplay?: boolean;
  110411. /**
  110412. * Does the sound loop after it finishes playing once.
  110413. */
  110414. loop?: boolean;
  110415. /**
  110416. * Sound's volume
  110417. */
  110418. volume?: number;
  110419. /**
  110420. * Is it a spatial sound?
  110421. */
  110422. spatialSound?: boolean;
  110423. /**
  110424. * Maximum distance to hear that sound
  110425. */
  110426. maxDistance?: number;
  110427. /**
  110428. * Uses user defined attenuation function
  110429. */
  110430. useCustomAttenuation?: boolean;
  110431. /**
  110432. * Define the roll off factor of spatial sounds.
  110433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110434. */
  110435. rolloffFactor?: number;
  110436. /**
  110437. * Define the reference distance the sound should be heard perfectly.
  110438. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110439. */
  110440. refDistance?: number;
  110441. /**
  110442. * Define the distance attenuation model the sound will follow.
  110443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110444. */
  110445. distanceModel?: string;
  110446. /**
  110447. * Defines the playback speed (1 by default)
  110448. */
  110449. playbackRate?: number;
  110450. /**
  110451. * Defines if the sound is from a streaming source
  110452. */
  110453. streaming?: boolean;
  110454. /**
  110455. * Defines an optional length (in seconds) inside the sound file
  110456. */
  110457. length?: number;
  110458. /**
  110459. * Defines an optional offset (in seconds) inside the sound file
  110460. */
  110461. offset?: number;
  110462. /**
  110463. * If true, URLs will not be required to state the audio file codec to use.
  110464. */
  110465. skipCodecCheck?: boolean;
  110466. }
  110467. /**
  110468. * Defines a sound that can be played in the application.
  110469. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110471. */
  110472. export class Sound {
  110473. /**
  110474. * The name of the sound in the scene.
  110475. */
  110476. name: string;
  110477. /**
  110478. * Does the sound autoplay once loaded.
  110479. */
  110480. autoplay: boolean;
  110481. /**
  110482. * Does the sound loop after it finishes playing once.
  110483. */
  110484. loop: boolean;
  110485. /**
  110486. * Does the sound use a custom attenuation curve to simulate the falloff
  110487. * happening when the source gets further away from the camera.
  110488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110489. */
  110490. useCustomAttenuation: boolean;
  110491. /**
  110492. * The sound track id this sound belongs to.
  110493. */
  110494. soundTrackId: number;
  110495. /**
  110496. * Is this sound currently played.
  110497. */
  110498. isPlaying: boolean;
  110499. /**
  110500. * Is this sound currently paused.
  110501. */
  110502. isPaused: boolean;
  110503. /**
  110504. * Does this sound enables spatial sound.
  110505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110506. */
  110507. spatialSound: boolean;
  110508. /**
  110509. * Define the reference distance the sound should be heard perfectly.
  110510. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110511. */
  110512. refDistance: number;
  110513. /**
  110514. * Define the roll off factor of spatial sounds.
  110515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110516. */
  110517. rolloffFactor: number;
  110518. /**
  110519. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110521. */
  110522. maxDistance: number;
  110523. /**
  110524. * Define the distance attenuation model the sound will follow.
  110525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110526. */
  110527. distanceModel: string;
  110528. /**
  110529. * @hidden
  110530. * Back Compat
  110531. **/
  110532. onended: () => any;
  110533. /**
  110534. * Observable event when the current playing sound finishes.
  110535. */
  110536. onEndedObservable: Observable<Sound>;
  110537. private _panningModel;
  110538. private _playbackRate;
  110539. private _streaming;
  110540. private _startTime;
  110541. private _startOffset;
  110542. private _position;
  110543. /** @hidden */
  110544. _positionInEmitterSpace: boolean;
  110545. private _localDirection;
  110546. private _volume;
  110547. private _isReadyToPlay;
  110548. private _isDirectional;
  110549. private _readyToPlayCallback;
  110550. private _audioBuffer;
  110551. private _soundSource;
  110552. private _streamingSource;
  110553. private _soundPanner;
  110554. private _soundGain;
  110555. private _inputAudioNode;
  110556. private _outputAudioNode;
  110557. private _coneInnerAngle;
  110558. private _coneOuterAngle;
  110559. private _coneOuterGain;
  110560. private _scene;
  110561. private _connectedTransformNode;
  110562. private _customAttenuationFunction;
  110563. private _registerFunc;
  110564. private _isOutputConnected;
  110565. private _htmlAudioElement;
  110566. private _urlType;
  110567. private _length?;
  110568. private _offset?;
  110569. /** @hidden */
  110570. static _SceneComponentInitialization: (scene: Scene) => void;
  110571. /**
  110572. * Create a sound and attach it to a scene
  110573. * @param name Name of your sound
  110574. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110575. * @param scene defines the scene the sound belongs to
  110576. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110577. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110578. */
  110579. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110580. /**
  110581. * Release the sound and its associated resources
  110582. */
  110583. dispose(): void;
  110584. /**
  110585. * Gets if the sounds is ready to be played or not.
  110586. * @returns true if ready, otherwise false
  110587. */
  110588. isReady(): boolean;
  110589. private _soundLoaded;
  110590. /**
  110591. * Sets the data of the sound from an audiobuffer
  110592. * @param audioBuffer The audioBuffer containing the data
  110593. */
  110594. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110595. /**
  110596. * Updates the current sounds options such as maxdistance, loop...
  110597. * @param options A JSON object containing values named as the object properties
  110598. */
  110599. updateOptions(options: ISoundOptions): void;
  110600. private _createSpatialParameters;
  110601. private _updateSpatialParameters;
  110602. /**
  110603. * Switch the panning model to HRTF:
  110604. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110606. */
  110607. switchPanningModelToHRTF(): void;
  110608. /**
  110609. * Switch the panning model to Equal Power:
  110610. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110612. */
  110613. switchPanningModelToEqualPower(): void;
  110614. private _switchPanningModel;
  110615. /**
  110616. * Connect this sound to a sound track audio node like gain...
  110617. * @param soundTrackAudioNode the sound track audio node to connect to
  110618. */
  110619. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110620. /**
  110621. * Transform this sound into a directional source
  110622. * @param coneInnerAngle Size of the inner cone in degree
  110623. * @param coneOuterAngle Size of the outer cone in degree
  110624. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110625. */
  110626. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110627. /**
  110628. * Gets or sets the inner angle for the directional cone.
  110629. */
  110630. get directionalConeInnerAngle(): number;
  110631. /**
  110632. * Gets or sets the inner angle for the directional cone.
  110633. */
  110634. set directionalConeInnerAngle(value: number);
  110635. /**
  110636. * Gets or sets the outer angle for the directional cone.
  110637. */
  110638. get directionalConeOuterAngle(): number;
  110639. /**
  110640. * Gets or sets the outer angle for the directional cone.
  110641. */
  110642. set directionalConeOuterAngle(value: number);
  110643. /**
  110644. * Sets the position of the emitter if spatial sound is enabled
  110645. * @param newPosition Defines the new posisiton
  110646. */
  110647. setPosition(newPosition: Vector3): void;
  110648. /**
  110649. * Sets the local direction of the emitter if spatial sound is enabled
  110650. * @param newLocalDirection Defines the new local direction
  110651. */
  110652. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110653. private _updateDirection;
  110654. /** @hidden */
  110655. updateDistanceFromListener(): void;
  110656. /**
  110657. * Sets a new custom attenuation function for the sound.
  110658. * @param callback Defines the function used for the attenuation
  110659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110660. */
  110661. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110662. /**
  110663. * Play the sound
  110664. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110665. * @param offset (optional) Start the sound at a specific time in seconds
  110666. * @param length (optional) Sound duration (in seconds)
  110667. */
  110668. play(time?: number, offset?: number, length?: number): void;
  110669. private _onended;
  110670. /**
  110671. * Stop the sound
  110672. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110673. */
  110674. stop(time?: number): void;
  110675. /**
  110676. * Put the sound in pause
  110677. */
  110678. pause(): void;
  110679. /**
  110680. * Sets a dedicated volume for this sounds
  110681. * @param newVolume Define the new volume of the sound
  110682. * @param time Define time for gradual change to new volume
  110683. */
  110684. setVolume(newVolume: number, time?: number): void;
  110685. /**
  110686. * Set the sound play back rate
  110687. * @param newPlaybackRate Define the playback rate the sound should be played at
  110688. */
  110689. setPlaybackRate(newPlaybackRate: number): void;
  110690. /**
  110691. * Gets the volume of the sound.
  110692. * @returns the volume of the sound
  110693. */
  110694. getVolume(): number;
  110695. /**
  110696. * Attach the sound to a dedicated mesh
  110697. * @param transformNode The transform node to connect the sound with
  110698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110699. */
  110700. attachToMesh(transformNode: TransformNode): void;
  110701. /**
  110702. * Detach the sound from the previously attached mesh
  110703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110704. */
  110705. detachFromMesh(): void;
  110706. private _onRegisterAfterWorldMatrixUpdate;
  110707. /**
  110708. * Clone the current sound in the scene.
  110709. * @returns the new sound clone
  110710. */
  110711. clone(): Nullable<Sound>;
  110712. /**
  110713. * Gets the current underlying audio buffer containing the data
  110714. * @returns the audio buffer
  110715. */
  110716. getAudioBuffer(): Nullable<AudioBuffer>;
  110717. /**
  110718. * Serializes the Sound in a JSON representation
  110719. * @returns the JSON representation of the sound
  110720. */
  110721. serialize(): any;
  110722. /**
  110723. * Parse a JSON representation of a sound to innstantiate in a given scene
  110724. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110725. * @param scene Define the scene the new parsed sound should be created in
  110726. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110727. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110728. * @returns the newly parsed sound
  110729. */
  110730. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110731. }
  110732. }
  110733. declare module BABYLON {
  110734. /**
  110735. * This defines an action helpful to play a defined sound on a triggered action.
  110736. */
  110737. export class PlaySoundAction extends Action {
  110738. private _sound;
  110739. /**
  110740. * Instantiate the action
  110741. * @param triggerOptions defines the trigger options
  110742. * @param sound defines the sound to play
  110743. * @param condition defines the trigger related conditions
  110744. */
  110745. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110746. /** @hidden */
  110747. _prepare(): void;
  110748. /**
  110749. * Execute the action and play the sound.
  110750. */
  110751. execute(): void;
  110752. /**
  110753. * Serializes the actions and its related information.
  110754. * @param parent defines the object to serialize in
  110755. * @returns the serialized object
  110756. */
  110757. serialize(parent: any): any;
  110758. }
  110759. /**
  110760. * This defines an action helpful to stop a defined sound on a triggered action.
  110761. */
  110762. export class StopSoundAction extends Action {
  110763. private _sound;
  110764. /**
  110765. * Instantiate the action
  110766. * @param triggerOptions defines the trigger options
  110767. * @param sound defines the sound to stop
  110768. * @param condition defines the trigger related conditions
  110769. */
  110770. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110771. /** @hidden */
  110772. _prepare(): void;
  110773. /**
  110774. * Execute the action and stop the sound.
  110775. */
  110776. execute(): void;
  110777. /**
  110778. * Serializes the actions and its related information.
  110779. * @param parent defines the object to serialize in
  110780. * @returns the serialized object
  110781. */
  110782. serialize(parent: any): any;
  110783. }
  110784. }
  110785. declare module BABYLON {
  110786. /**
  110787. * This defines an action responsible to change the value of a property
  110788. * by interpolating between its current value and the newly set one once triggered.
  110789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110790. */
  110791. export class InterpolateValueAction extends Action {
  110792. /**
  110793. * Defines the path of the property where the value should be interpolated
  110794. */
  110795. propertyPath: string;
  110796. /**
  110797. * Defines the target value at the end of the interpolation.
  110798. */
  110799. value: any;
  110800. /**
  110801. * Defines the time it will take for the property to interpolate to the value.
  110802. */
  110803. duration: number;
  110804. /**
  110805. * Defines if the other scene animations should be stopped when the action has been triggered
  110806. */
  110807. stopOtherAnimations?: boolean;
  110808. /**
  110809. * Defines a callback raised once the interpolation animation has been done.
  110810. */
  110811. onInterpolationDone?: () => void;
  110812. /**
  110813. * Observable triggered once the interpolation animation has been done.
  110814. */
  110815. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110816. private _target;
  110817. private _effectiveTarget;
  110818. private _property;
  110819. /**
  110820. * Instantiate the action
  110821. * @param triggerOptions defines the trigger options
  110822. * @param target defines the object containing the value to interpolate
  110823. * @param propertyPath defines the path to the property in the target object
  110824. * @param value defines the target value at the end of the interpolation
  110825. * @param duration deines the time it will take for the property to interpolate to the value.
  110826. * @param condition defines the trigger related conditions
  110827. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110828. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110829. */
  110830. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110831. /** @hidden */
  110832. _prepare(): void;
  110833. /**
  110834. * Execute the action starts the value interpolation.
  110835. */
  110836. execute(): void;
  110837. /**
  110838. * Serializes the actions and its related information.
  110839. * @param parent defines the object to serialize in
  110840. * @returns the serialized object
  110841. */
  110842. serialize(parent: any): any;
  110843. }
  110844. }
  110845. declare module BABYLON {
  110846. /**
  110847. * Options allowed during the creation of a sound track.
  110848. */
  110849. export interface ISoundTrackOptions {
  110850. /**
  110851. * The volume the sound track should take during creation
  110852. */
  110853. volume?: number;
  110854. /**
  110855. * Define if the sound track is the main sound track of the scene
  110856. */
  110857. mainTrack?: boolean;
  110858. }
  110859. /**
  110860. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110861. * It will be also used in a future release to apply effects on a specific track.
  110862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110863. */
  110864. export class SoundTrack {
  110865. /**
  110866. * The unique identifier of the sound track in the scene.
  110867. */
  110868. id: number;
  110869. /**
  110870. * The list of sounds included in the sound track.
  110871. */
  110872. soundCollection: Array<Sound>;
  110873. private _outputAudioNode;
  110874. private _scene;
  110875. private _connectedAnalyser;
  110876. private _options;
  110877. private _isInitialized;
  110878. /**
  110879. * Creates a new sound track.
  110880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110881. * @param scene Define the scene the sound track belongs to
  110882. * @param options
  110883. */
  110884. constructor(scene: Scene, options?: ISoundTrackOptions);
  110885. private _initializeSoundTrackAudioGraph;
  110886. /**
  110887. * Release the sound track and its associated resources
  110888. */
  110889. dispose(): void;
  110890. /**
  110891. * Adds a sound to this sound track
  110892. * @param sound define the cound to add
  110893. * @ignoreNaming
  110894. */
  110895. AddSound(sound: Sound): void;
  110896. /**
  110897. * Removes a sound to this sound track
  110898. * @param sound define the cound to remove
  110899. * @ignoreNaming
  110900. */
  110901. RemoveSound(sound: Sound): void;
  110902. /**
  110903. * Set a global volume for the full sound track.
  110904. * @param newVolume Define the new volume of the sound track
  110905. */
  110906. setVolume(newVolume: number): void;
  110907. /**
  110908. * Switch the panning model to HRTF:
  110909. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110911. */
  110912. switchPanningModelToHRTF(): void;
  110913. /**
  110914. * Switch the panning model to Equal Power:
  110915. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110917. */
  110918. switchPanningModelToEqualPower(): void;
  110919. /**
  110920. * Connect the sound track to an audio analyser allowing some amazing
  110921. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110923. * @param analyser The analyser to connect to the engine
  110924. */
  110925. connectToAnalyser(analyser: Analyser): void;
  110926. }
  110927. }
  110928. declare module BABYLON {
  110929. interface AbstractScene {
  110930. /**
  110931. * The list of sounds used in the scene.
  110932. */
  110933. sounds: Nullable<Array<Sound>>;
  110934. }
  110935. interface Scene {
  110936. /**
  110937. * @hidden
  110938. * Backing field
  110939. */
  110940. _mainSoundTrack: SoundTrack;
  110941. /**
  110942. * The main sound track played by the scene.
  110943. * It cotains your primary collection of sounds.
  110944. */
  110945. mainSoundTrack: SoundTrack;
  110946. /**
  110947. * The list of sound tracks added to the scene
  110948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110949. */
  110950. soundTracks: Nullable<Array<SoundTrack>>;
  110951. /**
  110952. * Gets a sound using a given name
  110953. * @param name defines the name to search for
  110954. * @return the found sound or null if not found at all.
  110955. */
  110956. getSoundByName(name: string): Nullable<Sound>;
  110957. /**
  110958. * Gets or sets if audio support is enabled
  110959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110960. */
  110961. audioEnabled: boolean;
  110962. /**
  110963. * Gets or sets if audio will be output to headphones
  110964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110965. */
  110966. headphone: boolean;
  110967. /**
  110968. * Gets or sets custom audio listener position provider
  110969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110970. */
  110971. audioListenerPositionProvider: Nullable<() => Vector3>;
  110972. /**
  110973. * Gets or sets a refresh rate when using 3D audio positioning
  110974. */
  110975. audioPositioningRefreshRate: number;
  110976. }
  110977. /**
  110978. * Defines the sound scene component responsible to manage any sounds
  110979. * in a given scene.
  110980. */
  110981. export class AudioSceneComponent implements ISceneSerializableComponent {
  110982. /**
  110983. * The component name helpfull to identify the component in the list of scene components.
  110984. */
  110985. readonly name: string;
  110986. /**
  110987. * The scene the component belongs to.
  110988. */
  110989. scene: Scene;
  110990. private _audioEnabled;
  110991. /**
  110992. * Gets whether audio is enabled or not.
  110993. * Please use related enable/disable method to switch state.
  110994. */
  110995. get audioEnabled(): boolean;
  110996. private _headphone;
  110997. /**
  110998. * Gets whether audio is outputing to headphone or not.
  110999. * Please use the according Switch methods to change output.
  111000. */
  111001. get headphone(): boolean;
  111002. /**
  111003. * Gets or sets a refresh rate when using 3D audio positioning
  111004. */
  111005. audioPositioningRefreshRate: number;
  111006. private _audioListenerPositionProvider;
  111007. /**
  111008. * Gets the current audio listener position provider
  111009. */
  111010. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111011. /**
  111012. * Sets a custom listener position for all sounds in the scene
  111013. * By default, this is the position of the first active camera
  111014. */
  111015. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111016. /**
  111017. * Creates a new instance of the component for the given scene
  111018. * @param scene Defines the scene to register the component in
  111019. */
  111020. constructor(scene: Scene);
  111021. /**
  111022. * Registers the component in a given scene
  111023. */
  111024. register(): void;
  111025. /**
  111026. * Rebuilds the elements related to this component in case of
  111027. * context lost for instance.
  111028. */
  111029. rebuild(): void;
  111030. /**
  111031. * Serializes the component data to the specified json object
  111032. * @param serializationObject The object to serialize to
  111033. */
  111034. serialize(serializationObject: any): void;
  111035. /**
  111036. * Adds all the elements from the container to the scene
  111037. * @param container the container holding the elements
  111038. */
  111039. addFromContainer(container: AbstractScene): void;
  111040. /**
  111041. * Removes all the elements in the container from the scene
  111042. * @param container contains the elements to remove
  111043. * @param dispose if the removed element should be disposed (default: false)
  111044. */
  111045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111046. /**
  111047. * Disposes the component and the associated ressources.
  111048. */
  111049. dispose(): void;
  111050. /**
  111051. * Disables audio in the associated scene.
  111052. */
  111053. disableAudio(): void;
  111054. /**
  111055. * Enables audio in the associated scene.
  111056. */
  111057. enableAudio(): void;
  111058. /**
  111059. * Switch audio to headphone output.
  111060. */
  111061. switchAudioModeForHeadphones(): void;
  111062. /**
  111063. * Switch audio to normal speakers.
  111064. */
  111065. switchAudioModeForNormalSpeakers(): void;
  111066. private _cachedCameraDirection;
  111067. private _cachedCameraPosition;
  111068. private _lastCheck;
  111069. private _afterRender;
  111070. }
  111071. }
  111072. declare module BABYLON {
  111073. /**
  111074. * Wraps one or more Sound objects and selects one with random weight for playback.
  111075. */
  111076. export class WeightedSound {
  111077. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111078. loop: boolean;
  111079. private _coneInnerAngle;
  111080. private _coneOuterAngle;
  111081. private _volume;
  111082. /** A Sound is currently playing. */
  111083. isPlaying: boolean;
  111084. /** A Sound is currently paused. */
  111085. isPaused: boolean;
  111086. private _sounds;
  111087. private _weights;
  111088. private _currentIndex?;
  111089. /**
  111090. * Creates a new WeightedSound from the list of sounds given.
  111091. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111092. * @param sounds Array of Sounds that will be selected from.
  111093. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111094. */
  111095. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111096. /**
  111097. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111098. */
  111099. get directionalConeInnerAngle(): number;
  111100. /**
  111101. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111102. */
  111103. set directionalConeInnerAngle(value: number);
  111104. /**
  111105. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111106. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111107. */
  111108. get directionalConeOuterAngle(): number;
  111109. /**
  111110. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111111. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111112. */
  111113. set directionalConeOuterAngle(value: number);
  111114. /**
  111115. * Playback volume.
  111116. */
  111117. get volume(): number;
  111118. /**
  111119. * Playback volume.
  111120. */
  111121. set volume(value: number);
  111122. private _onended;
  111123. /**
  111124. * Suspend playback
  111125. */
  111126. pause(): void;
  111127. /**
  111128. * Stop playback
  111129. */
  111130. stop(): void;
  111131. /**
  111132. * Start playback.
  111133. * @param startOffset Position the clip head at a specific time in seconds.
  111134. */
  111135. play(startOffset?: number): void;
  111136. }
  111137. }
  111138. declare module BABYLON {
  111139. /**
  111140. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111142. */
  111143. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111144. /**
  111145. * Gets the name of the behavior.
  111146. */
  111147. get name(): string;
  111148. /**
  111149. * The easing function used by animations
  111150. */
  111151. static EasingFunction: BackEase;
  111152. /**
  111153. * The easing mode used by animations
  111154. */
  111155. static EasingMode: number;
  111156. /**
  111157. * The duration of the animation, in milliseconds
  111158. */
  111159. transitionDuration: number;
  111160. /**
  111161. * Length of the distance animated by the transition when lower radius is reached
  111162. */
  111163. lowerRadiusTransitionRange: number;
  111164. /**
  111165. * Length of the distance animated by the transition when upper radius is reached
  111166. */
  111167. upperRadiusTransitionRange: number;
  111168. private _autoTransitionRange;
  111169. /**
  111170. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111171. */
  111172. get autoTransitionRange(): boolean;
  111173. /**
  111174. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111175. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111176. */
  111177. set autoTransitionRange(value: boolean);
  111178. private _attachedCamera;
  111179. private _onAfterCheckInputsObserver;
  111180. private _onMeshTargetChangedObserver;
  111181. /**
  111182. * Initializes the behavior.
  111183. */
  111184. init(): void;
  111185. /**
  111186. * Attaches the behavior to its arc rotate camera.
  111187. * @param camera Defines the camera to attach the behavior to
  111188. */
  111189. attach(camera: ArcRotateCamera): void;
  111190. /**
  111191. * Detaches the behavior from its current arc rotate camera.
  111192. */
  111193. detach(): void;
  111194. private _radiusIsAnimating;
  111195. private _radiusBounceTransition;
  111196. private _animatables;
  111197. private _cachedWheelPrecision;
  111198. /**
  111199. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111200. * @param radiusLimit The limit to check against.
  111201. * @return Bool to indicate if at limit.
  111202. */
  111203. private _isRadiusAtLimit;
  111204. /**
  111205. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111206. * @param radiusDelta The delta by which to animate to. Can be negative.
  111207. */
  111208. private _applyBoundRadiusAnimation;
  111209. /**
  111210. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111211. */
  111212. protected _clearAnimationLocks(): void;
  111213. /**
  111214. * Stops and removes all animations that have been applied to the camera
  111215. */
  111216. stopAllAnimations(): void;
  111217. }
  111218. }
  111219. declare module BABYLON {
  111220. /**
  111221. * 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.
  111222. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111223. */
  111224. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111225. /**
  111226. * Gets the name of the behavior.
  111227. */
  111228. get name(): string;
  111229. private _mode;
  111230. private _radiusScale;
  111231. private _positionScale;
  111232. private _defaultElevation;
  111233. private _elevationReturnTime;
  111234. private _elevationReturnWaitTime;
  111235. private _zoomStopsAnimation;
  111236. private _framingTime;
  111237. /**
  111238. * The easing function used by animations
  111239. */
  111240. static EasingFunction: ExponentialEase;
  111241. /**
  111242. * The easing mode used by animations
  111243. */
  111244. static EasingMode: number;
  111245. /**
  111246. * Sets the current mode used by the behavior
  111247. */
  111248. set mode(mode: number);
  111249. /**
  111250. * Gets current mode used by the behavior.
  111251. */
  111252. get mode(): number;
  111253. /**
  111254. * Sets the scale applied to the radius (1 by default)
  111255. */
  111256. set radiusScale(radius: number);
  111257. /**
  111258. * Gets the scale applied to the radius
  111259. */
  111260. get radiusScale(): number;
  111261. /**
  111262. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111263. */
  111264. set positionScale(scale: number);
  111265. /**
  111266. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111267. */
  111268. get positionScale(): number;
  111269. /**
  111270. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111271. * behaviour is triggered, in radians.
  111272. */
  111273. set defaultElevation(elevation: number);
  111274. /**
  111275. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111276. * behaviour is triggered, in radians.
  111277. */
  111278. get defaultElevation(): number;
  111279. /**
  111280. * Sets the time (in milliseconds) taken to return to the default beta position.
  111281. * Negative value indicates camera should not return to default.
  111282. */
  111283. set elevationReturnTime(speed: number);
  111284. /**
  111285. * Gets the time (in milliseconds) taken to return to the default beta position.
  111286. * Negative value indicates camera should not return to default.
  111287. */
  111288. get elevationReturnTime(): number;
  111289. /**
  111290. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111291. */
  111292. set elevationReturnWaitTime(time: number);
  111293. /**
  111294. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111295. */
  111296. get elevationReturnWaitTime(): number;
  111297. /**
  111298. * Sets the flag that indicates if user zooming should stop animation.
  111299. */
  111300. set zoomStopsAnimation(flag: boolean);
  111301. /**
  111302. * Gets the flag that indicates if user zooming should stop animation.
  111303. */
  111304. get zoomStopsAnimation(): boolean;
  111305. /**
  111306. * Sets the transition time when framing the mesh, in milliseconds
  111307. */
  111308. set framingTime(time: number);
  111309. /**
  111310. * Gets the transition time when framing the mesh, in milliseconds
  111311. */
  111312. get framingTime(): number;
  111313. /**
  111314. * Define if the behavior should automatically change the configured
  111315. * camera limits and sensibilities.
  111316. */
  111317. autoCorrectCameraLimitsAndSensibility: boolean;
  111318. private _onPrePointerObservableObserver;
  111319. private _onAfterCheckInputsObserver;
  111320. private _onMeshTargetChangedObserver;
  111321. private _attachedCamera;
  111322. private _isPointerDown;
  111323. private _lastInteractionTime;
  111324. /**
  111325. * Initializes the behavior.
  111326. */
  111327. init(): void;
  111328. /**
  111329. * Attaches the behavior to its arc rotate camera.
  111330. * @param camera Defines the camera to attach the behavior to
  111331. */
  111332. attach(camera: ArcRotateCamera): void;
  111333. /**
  111334. * Detaches the behavior from its current arc rotate camera.
  111335. */
  111336. detach(): void;
  111337. private _animatables;
  111338. private _betaIsAnimating;
  111339. private _betaTransition;
  111340. private _radiusTransition;
  111341. private _vectorTransition;
  111342. /**
  111343. * Targets the given mesh and updates zoom level accordingly.
  111344. * @param mesh The mesh to target.
  111345. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111346. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111347. */
  111348. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111349. /**
  111350. * Targets the given mesh with its children and updates zoom level accordingly.
  111351. * @param mesh The mesh to target.
  111352. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111353. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111354. */
  111355. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111356. /**
  111357. * Targets the given meshes with their children and updates zoom level accordingly.
  111358. * @param meshes The mesh to target.
  111359. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111360. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111361. */
  111362. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111363. /**
  111364. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111365. * @param minimumWorld Determines the smaller position of the bounding box extend
  111366. * @param maximumWorld Determines the bigger position of the bounding box extend
  111367. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111368. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111369. */
  111370. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111371. /**
  111372. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111373. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111374. * frustum width.
  111375. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111376. * to fully enclose the mesh in the viewing frustum.
  111377. */
  111378. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111379. /**
  111380. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111381. * is automatically returned to its default position (expected to be above ground plane).
  111382. */
  111383. private _maintainCameraAboveGround;
  111384. /**
  111385. * Returns the frustum slope based on the canvas ratio and camera FOV
  111386. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111387. */
  111388. private _getFrustumSlope;
  111389. /**
  111390. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111391. */
  111392. private _clearAnimationLocks;
  111393. /**
  111394. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111395. */
  111396. private _applyUserInteraction;
  111397. /**
  111398. * Stops and removes all animations that have been applied to the camera
  111399. */
  111400. stopAllAnimations(): void;
  111401. /**
  111402. * Gets a value indicating if the user is moving the camera
  111403. */
  111404. get isUserIsMoving(): boolean;
  111405. /**
  111406. * The camera can move all the way towards the mesh.
  111407. */
  111408. static IgnoreBoundsSizeMode: number;
  111409. /**
  111410. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111411. */
  111412. static FitFrustumSidesMode: number;
  111413. }
  111414. }
  111415. declare module BABYLON {
  111416. /**
  111417. * Base class for Camera Pointer Inputs.
  111418. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111419. * for example usage.
  111420. */
  111421. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111422. /**
  111423. * Defines the camera the input is attached to.
  111424. */
  111425. abstract camera: Camera;
  111426. /**
  111427. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111428. */
  111429. protected _altKey: boolean;
  111430. protected _ctrlKey: boolean;
  111431. protected _metaKey: boolean;
  111432. protected _shiftKey: boolean;
  111433. /**
  111434. * Which mouse buttons were pressed at time of last mouse event.
  111435. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111436. */
  111437. protected _buttonsPressed: number;
  111438. /**
  111439. * Defines the buttons associated with the input to handle camera move.
  111440. */
  111441. buttons: number[];
  111442. /**
  111443. * Attach the input controls to a specific dom element to get the input from.
  111444. * @param element Defines the element the controls should be listened from
  111445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111446. */
  111447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111448. /**
  111449. * Detach the current controls from the specified dom element.
  111450. * @param element Defines the element to stop listening the inputs from
  111451. */
  111452. detachControl(element: Nullable<HTMLElement>): void;
  111453. /**
  111454. * Gets the class name of the current input.
  111455. * @returns the class name
  111456. */
  111457. getClassName(): string;
  111458. /**
  111459. * Get the friendly name associated with the input class.
  111460. * @returns the input friendly name
  111461. */
  111462. getSimpleName(): string;
  111463. /**
  111464. * Called on pointer POINTERDOUBLETAP event.
  111465. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111466. */
  111467. protected onDoubleTap(type: string): void;
  111468. /**
  111469. * Called on pointer POINTERMOVE event if only a single touch is active.
  111470. * Override this method to provide functionality.
  111471. */
  111472. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111473. /**
  111474. * Called on pointer POINTERMOVE event if multiple touches are active.
  111475. * Override this method to provide functionality.
  111476. */
  111477. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111478. /**
  111479. * Called on JS contextmenu event.
  111480. * Override this method to provide functionality.
  111481. */
  111482. protected onContextMenu(evt: PointerEvent): void;
  111483. /**
  111484. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111485. * press.
  111486. * Override this method to provide functionality.
  111487. */
  111488. protected onButtonDown(evt: PointerEvent): void;
  111489. /**
  111490. * Called each time a new POINTERUP event occurs. Ie, for each button
  111491. * release.
  111492. * Override this method to provide functionality.
  111493. */
  111494. protected onButtonUp(evt: PointerEvent): void;
  111495. /**
  111496. * Called when window becomes inactive.
  111497. * Override this method to provide functionality.
  111498. */
  111499. protected onLostFocus(): void;
  111500. private _pointerInput;
  111501. private _observer;
  111502. private _onLostFocus;
  111503. private pointA;
  111504. private pointB;
  111505. }
  111506. }
  111507. declare module BABYLON {
  111508. /**
  111509. * Manage the pointers inputs to control an arc rotate camera.
  111510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111511. */
  111512. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111513. /**
  111514. * Defines the camera the input is attached to.
  111515. */
  111516. camera: ArcRotateCamera;
  111517. /**
  111518. * Gets the class name of the current input.
  111519. * @returns the class name
  111520. */
  111521. getClassName(): string;
  111522. /**
  111523. * Defines the buttons associated with the input to handle camera move.
  111524. */
  111525. buttons: number[];
  111526. /**
  111527. * Defines the pointer angular sensibility along the X axis or how fast is
  111528. * the camera rotating.
  111529. */
  111530. angularSensibilityX: number;
  111531. /**
  111532. * Defines the pointer angular sensibility along the Y axis or how fast is
  111533. * the camera rotating.
  111534. */
  111535. angularSensibilityY: number;
  111536. /**
  111537. * Defines the pointer pinch precision or how fast is the camera zooming.
  111538. */
  111539. pinchPrecision: number;
  111540. /**
  111541. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111542. * from 0.
  111543. * It defines the percentage of current camera.radius to use as delta when
  111544. * pinch zoom is used.
  111545. */
  111546. pinchDeltaPercentage: number;
  111547. /**
  111548. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111549. * that any object in the plane at the camera's target point will scale
  111550. * perfectly with finger motion.
  111551. * Overrides pinchDeltaPercentage and pinchPrecision.
  111552. */
  111553. useNaturalPinchZoom: boolean;
  111554. /**
  111555. * Defines the pointer panning sensibility or how fast is the camera moving.
  111556. */
  111557. panningSensibility: number;
  111558. /**
  111559. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111560. */
  111561. multiTouchPanning: boolean;
  111562. /**
  111563. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111564. * zoom (pinch) through multitouch.
  111565. */
  111566. multiTouchPanAndZoom: boolean;
  111567. /**
  111568. * Revers pinch action direction.
  111569. */
  111570. pinchInwards: boolean;
  111571. private _isPanClick;
  111572. private _twoFingerActivityCount;
  111573. private _isPinching;
  111574. /**
  111575. * Called on pointer POINTERMOVE event if only a single touch is active.
  111576. */
  111577. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111578. /**
  111579. * Called on pointer POINTERDOUBLETAP event.
  111580. */
  111581. protected onDoubleTap(type: string): void;
  111582. /**
  111583. * Called on pointer POINTERMOVE event if multiple touches are active.
  111584. */
  111585. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111586. /**
  111587. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111588. * press.
  111589. */
  111590. protected onButtonDown(evt: PointerEvent): void;
  111591. /**
  111592. * Called each time a new POINTERUP event occurs. Ie, for each button
  111593. * release.
  111594. */
  111595. protected onButtonUp(evt: PointerEvent): void;
  111596. /**
  111597. * Called when window becomes inactive.
  111598. */
  111599. protected onLostFocus(): void;
  111600. }
  111601. }
  111602. declare module BABYLON {
  111603. /**
  111604. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111606. */
  111607. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111608. /**
  111609. * Defines the camera the input is attached to.
  111610. */
  111611. camera: ArcRotateCamera;
  111612. /**
  111613. * Defines the list of key codes associated with the up action (increase alpha)
  111614. */
  111615. keysUp: number[];
  111616. /**
  111617. * Defines the list of key codes associated with the down action (decrease alpha)
  111618. */
  111619. keysDown: number[];
  111620. /**
  111621. * Defines the list of key codes associated with the left action (increase beta)
  111622. */
  111623. keysLeft: number[];
  111624. /**
  111625. * Defines the list of key codes associated with the right action (decrease beta)
  111626. */
  111627. keysRight: number[];
  111628. /**
  111629. * Defines the list of key codes associated with the reset action.
  111630. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111631. */
  111632. keysReset: number[];
  111633. /**
  111634. * Defines the panning sensibility of the inputs.
  111635. * (How fast is the camera panning)
  111636. */
  111637. panningSensibility: number;
  111638. /**
  111639. * Defines the zooming sensibility of the inputs.
  111640. * (How fast is the camera zooming)
  111641. */
  111642. zoomingSensibility: number;
  111643. /**
  111644. * Defines whether maintaining the alt key down switch the movement mode from
  111645. * orientation to zoom.
  111646. */
  111647. useAltToZoom: boolean;
  111648. /**
  111649. * Rotation speed of the camera
  111650. */
  111651. angularSpeed: number;
  111652. private _keys;
  111653. private _ctrlPressed;
  111654. private _altPressed;
  111655. private _onCanvasBlurObserver;
  111656. private _onKeyboardObserver;
  111657. private _engine;
  111658. private _scene;
  111659. /**
  111660. * Attach the input controls to a specific dom element to get the input from.
  111661. * @param element Defines the element the controls should be listened from
  111662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111663. */
  111664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111665. /**
  111666. * Detach the current controls from the specified dom element.
  111667. * @param element Defines the element to stop listening the inputs from
  111668. */
  111669. detachControl(element: Nullable<HTMLElement>): void;
  111670. /**
  111671. * Update the current camera state depending on the inputs that have been used this frame.
  111672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111673. */
  111674. checkInputs(): void;
  111675. /**
  111676. * Gets the class name of the current intput.
  111677. * @returns the class name
  111678. */
  111679. getClassName(): string;
  111680. /**
  111681. * Get the friendly name associated with the input class.
  111682. * @returns the input friendly name
  111683. */
  111684. getSimpleName(): string;
  111685. }
  111686. }
  111687. declare module BABYLON {
  111688. /**
  111689. * Manage the mouse wheel inputs to control an arc rotate camera.
  111690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111691. */
  111692. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111693. /**
  111694. * Defines the camera the input is attached to.
  111695. */
  111696. camera: ArcRotateCamera;
  111697. /**
  111698. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111699. */
  111700. wheelPrecision: number;
  111701. /**
  111702. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111703. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111704. */
  111705. wheelDeltaPercentage: number;
  111706. private _wheel;
  111707. private _observer;
  111708. private computeDeltaFromMouseWheelLegacyEvent;
  111709. /**
  111710. * Attach the input controls to a specific dom element to get the input from.
  111711. * @param element Defines the element the controls should be listened from
  111712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111713. */
  111714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111715. /**
  111716. * Detach the current controls from the specified dom element.
  111717. * @param element Defines the element to stop listening the inputs from
  111718. */
  111719. detachControl(element: Nullable<HTMLElement>): void;
  111720. /**
  111721. * Gets the class name of the current intput.
  111722. * @returns the class name
  111723. */
  111724. getClassName(): string;
  111725. /**
  111726. * Get the friendly name associated with the input class.
  111727. * @returns the input friendly name
  111728. */
  111729. getSimpleName(): string;
  111730. }
  111731. }
  111732. declare module BABYLON {
  111733. /**
  111734. * Default Inputs manager for the ArcRotateCamera.
  111735. * It groups all the default supported inputs for ease of use.
  111736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111737. */
  111738. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111739. /**
  111740. * Instantiates a new ArcRotateCameraInputsManager.
  111741. * @param camera Defines the camera the inputs belong to
  111742. */
  111743. constructor(camera: ArcRotateCamera);
  111744. /**
  111745. * Add mouse wheel input support to the input manager.
  111746. * @returns the current input manager
  111747. */
  111748. addMouseWheel(): ArcRotateCameraInputsManager;
  111749. /**
  111750. * Add pointers input support to the input manager.
  111751. * @returns the current input manager
  111752. */
  111753. addPointers(): ArcRotateCameraInputsManager;
  111754. /**
  111755. * Add keyboard input support to the input manager.
  111756. * @returns the current input manager
  111757. */
  111758. addKeyboard(): ArcRotateCameraInputsManager;
  111759. }
  111760. }
  111761. declare module BABYLON {
  111762. /**
  111763. * This represents an orbital type of camera.
  111764. *
  111765. * 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.
  111766. * 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.
  111767. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111768. */
  111769. export class ArcRotateCamera extends TargetCamera {
  111770. /**
  111771. * Defines the rotation angle of the camera along the longitudinal axis.
  111772. */
  111773. alpha: number;
  111774. /**
  111775. * Defines the rotation angle of the camera along the latitudinal axis.
  111776. */
  111777. beta: number;
  111778. /**
  111779. * Defines the radius of the camera from it s target point.
  111780. */
  111781. radius: number;
  111782. protected _target: Vector3;
  111783. protected _targetHost: Nullable<AbstractMesh>;
  111784. /**
  111785. * Defines the target point of the camera.
  111786. * The camera looks towards it form the radius distance.
  111787. */
  111788. get target(): Vector3;
  111789. set target(value: Vector3);
  111790. /**
  111791. * Define the current local position of the camera in the scene
  111792. */
  111793. get position(): Vector3;
  111794. set position(newPosition: Vector3);
  111795. protected _upVector: Vector3;
  111796. protected _upToYMatrix: Matrix;
  111797. protected _YToUpMatrix: Matrix;
  111798. /**
  111799. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111800. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111801. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111802. */
  111803. set upVector(vec: Vector3);
  111804. get upVector(): Vector3;
  111805. /**
  111806. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111807. */
  111808. setMatUp(): void;
  111809. /**
  111810. * Current inertia value on the longitudinal axis.
  111811. * The bigger this number the longer it will take for the camera to stop.
  111812. */
  111813. inertialAlphaOffset: number;
  111814. /**
  111815. * Current inertia value on the latitudinal axis.
  111816. * The bigger this number the longer it will take for the camera to stop.
  111817. */
  111818. inertialBetaOffset: number;
  111819. /**
  111820. * Current inertia value on the radius axis.
  111821. * The bigger this number the longer it will take for the camera to stop.
  111822. */
  111823. inertialRadiusOffset: number;
  111824. /**
  111825. * Minimum allowed angle on the longitudinal axis.
  111826. * This can help limiting how the Camera is able to move in the scene.
  111827. */
  111828. lowerAlphaLimit: Nullable<number>;
  111829. /**
  111830. * Maximum allowed angle on the longitudinal axis.
  111831. * This can help limiting how the Camera is able to move in the scene.
  111832. */
  111833. upperAlphaLimit: Nullable<number>;
  111834. /**
  111835. * Minimum allowed angle on the latitudinal axis.
  111836. * This can help limiting how the Camera is able to move in the scene.
  111837. */
  111838. lowerBetaLimit: number;
  111839. /**
  111840. * Maximum allowed angle on the latitudinal axis.
  111841. * This can help limiting how the Camera is able to move in the scene.
  111842. */
  111843. upperBetaLimit: number;
  111844. /**
  111845. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111846. * This can help limiting how the Camera is able to move in the scene.
  111847. */
  111848. lowerRadiusLimit: Nullable<number>;
  111849. /**
  111850. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111851. * This can help limiting how the Camera is able to move in the scene.
  111852. */
  111853. upperRadiusLimit: Nullable<number>;
  111854. /**
  111855. * Defines the current inertia value used during panning of the camera along the X axis.
  111856. */
  111857. inertialPanningX: number;
  111858. /**
  111859. * Defines the current inertia value used during panning of the camera along the Y axis.
  111860. */
  111861. inertialPanningY: number;
  111862. /**
  111863. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111864. * Basically if your fingers moves away from more than this distance you will be considered
  111865. * in pinch mode.
  111866. */
  111867. pinchToPanMaxDistance: number;
  111868. /**
  111869. * Defines the maximum distance the camera can pan.
  111870. * This could help keeping the cammera always in your scene.
  111871. */
  111872. panningDistanceLimit: Nullable<number>;
  111873. /**
  111874. * Defines the target of the camera before paning.
  111875. */
  111876. panningOriginTarget: Vector3;
  111877. /**
  111878. * Defines the value of the inertia used during panning.
  111879. * 0 would mean stop inertia and one would mean no decelleration at all.
  111880. */
  111881. panningInertia: number;
  111882. /**
  111883. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111884. */
  111885. get angularSensibilityX(): number;
  111886. set angularSensibilityX(value: number);
  111887. /**
  111888. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111889. */
  111890. get angularSensibilityY(): number;
  111891. set angularSensibilityY(value: number);
  111892. /**
  111893. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111894. */
  111895. get pinchPrecision(): number;
  111896. set pinchPrecision(value: number);
  111897. /**
  111898. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111899. * It will be used instead of pinchDeltaPrecision if different from 0.
  111900. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111901. */
  111902. get pinchDeltaPercentage(): number;
  111903. set pinchDeltaPercentage(value: number);
  111904. /**
  111905. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111906. * and pinch delta percentage.
  111907. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111908. * that any object in the plane at the camera's target point will scale
  111909. * perfectly with finger motion.
  111910. */
  111911. get useNaturalPinchZoom(): boolean;
  111912. set useNaturalPinchZoom(value: boolean);
  111913. /**
  111914. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111915. */
  111916. get panningSensibility(): number;
  111917. set panningSensibility(value: number);
  111918. /**
  111919. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111920. */
  111921. get keysUp(): number[];
  111922. set keysUp(value: number[]);
  111923. /**
  111924. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111925. */
  111926. get keysDown(): number[];
  111927. set keysDown(value: number[]);
  111928. /**
  111929. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111930. */
  111931. get keysLeft(): number[];
  111932. set keysLeft(value: number[]);
  111933. /**
  111934. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111935. */
  111936. get keysRight(): number[];
  111937. set keysRight(value: number[]);
  111938. /**
  111939. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111940. */
  111941. get wheelPrecision(): number;
  111942. set wheelPrecision(value: number);
  111943. /**
  111944. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111945. * It will be used instead of pinchDeltaPrecision if different from 0.
  111946. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111947. */
  111948. get wheelDeltaPercentage(): number;
  111949. set wheelDeltaPercentage(value: number);
  111950. /**
  111951. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111952. */
  111953. zoomOnFactor: number;
  111954. /**
  111955. * Defines a screen offset for the camera position.
  111956. */
  111957. targetScreenOffset: Vector2;
  111958. /**
  111959. * Allows the camera to be completely reversed.
  111960. * If false the camera can not arrive upside down.
  111961. */
  111962. allowUpsideDown: boolean;
  111963. /**
  111964. * Define if double tap/click is used to restore the previously saved state of the camera.
  111965. */
  111966. useInputToRestoreState: boolean;
  111967. /** @hidden */
  111968. _viewMatrix: Matrix;
  111969. /** @hidden */
  111970. _useCtrlForPanning: boolean;
  111971. /** @hidden */
  111972. _panningMouseButton: number;
  111973. /**
  111974. * Defines the input associated to the camera.
  111975. */
  111976. inputs: ArcRotateCameraInputsManager;
  111977. /** @hidden */
  111978. _reset: () => void;
  111979. /**
  111980. * Defines the allowed panning axis.
  111981. */
  111982. panningAxis: Vector3;
  111983. protected _localDirection: Vector3;
  111984. protected _transformedDirection: Vector3;
  111985. private _bouncingBehavior;
  111986. /**
  111987. * Gets the bouncing behavior of the camera if it has been enabled.
  111988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111989. */
  111990. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111991. /**
  111992. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111994. */
  111995. get useBouncingBehavior(): boolean;
  111996. set useBouncingBehavior(value: boolean);
  111997. private _framingBehavior;
  111998. /**
  111999. * Gets the framing behavior of the camera if it has been enabled.
  112000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112001. */
  112002. get framingBehavior(): Nullable<FramingBehavior>;
  112003. /**
  112004. * Defines if the framing behavior of the camera is enabled on the camera.
  112005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112006. */
  112007. get useFramingBehavior(): boolean;
  112008. set useFramingBehavior(value: boolean);
  112009. private _autoRotationBehavior;
  112010. /**
  112011. * Gets the auto rotation behavior of the camera if it has been enabled.
  112012. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112013. */
  112014. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112015. /**
  112016. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112017. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112018. */
  112019. get useAutoRotationBehavior(): boolean;
  112020. set useAutoRotationBehavior(value: boolean);
  112021. /**
  112022. * Observable triggered when the mesh target has been changed on the camera.
  112023. */
  112024. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112025. /**
  112026. * Event raised when the camera is colliding with a mesh.
  112027. */
  112028. onCollide: (collidedMesh: AbstractMesh) => void;
  112029. /**
  112030. * Defines whether the camera should check collision with the objects oh the scene.
  112031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112032. */
  112033. checkCollisions: boolean;
  112034. /**
  112035. * Defines the collision radius of the camera.
  112036. * This simulates a sphere around the camera.
  112037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112038. */
  112039. collisionRadius: Vector3;
  112040. protected _collider: Collider;
  112041. protected _previousPosition: Vector3;
  112042. protected _collisionVelocity: Vector3;
  112043. protected _newPosition: Vector3;
  112044. protected _previousAlpha: number;
  112045. protected _previousBeta: number;
  112046. protected _previousRadius: number;
  112047. protected _collisionTriggered: boolean;
  112048. protected _targetBoundingCenter: Nullable<Vector3>;
  112049. private _computationVector;
  112050. /**
  112051. * Instantiates a new ArcRotateCamera in a given scene
  112052. * @param name Defines the name of the camera
  112053. * @param alpha Defines the camera rotation along the logitudinal axis
  112054. * @param beta Defines the camera rotation along the latitudinal axis
  112055. * @param radius Defines the camera distance from its target
  112056. * @param target Defines the camera target
  112057. * @param scene Defines the scene the camera belongs to
  112058. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112059. */
  112060. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112061. /** @hidden */
  112062. _initCache(): void;
  112063. /** @hidden */
  112064. _updateCache(ignoreParentClass?: boolean): void;
  112065. protected _getTargetPosition(): Vector3;
  112066. private _storedAlpha;
  112067. private _storedBeta;
  112068. private _storedRadius;
  112069. private _storedTarget;
  112070. private _storedTargetScreenOffset;
  112071. /**
  112072. * Stores the current state of the camera (alpha, beta, radius and target)
  112073. * @returns the camera itself
  112074. */
  112075. storeState(): Camera;
  112076. /**
  112077. * @hidden
  112078. * Restored camera state. You must call storeState() first
  112079. */
  112080. _restoreStateValues(): boolean;
  112081. /** @hidden */
  112082. _isSynchronizedViewMatrix(): boolean;
  112083. /**
  112084. * Attached controls to the current camera.
  112085. * @param element Defines the element the controls should be listened from
  112086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112087. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112088. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112089. */
  112090. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112091. /**
  112092. * Detach the current controls from the camera.
  112093. * The camera will stop reacting to inputs.
  112094. * @param element Defines the element to stop listening the inputs from
  112095. */
  112096. detachControl(element: HTMLElement): void;
  112097. /** @hidden */
  112098. _checkInputs(): void;
  112099. protected _checkLimits(): void;
  112100. /**
  112101. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112102. */
  112103. rebuildAnglesAndRadius(): void;
  112104. /**
  112105. * Use a position to define the current camera related information like alpha, beta and radius
  112106. * @param position Defines the position to set the camera at
  112107. */
  112108. setPosition(position: Vector3): void;
  112109. /**
  112110. * Defines the target the camera should look at.
  112111. * This will automatically adapt alpha beta and radius to fit within the new target.
  112112. * @param target Defines the new target as a Vector or a mesh
  112113. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112114. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112115. */
  112116. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112117. /** @hidden */
  112118. _getViewMatrix(): Matrix;
  112119. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112120. /**
  112121. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112122. * @param meshes Defines the mesh to zoom on
  112123. * @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)
  112124. */
  112125. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112126. /**
  112127. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112128. * The target will be changed but the radius
  112129. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112130. * @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)
  112131. */
  112132. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112133. min: Vector3;
  112134. max: Vector3;
  112135. distance: number;
  112136. }, doNotUpdateMaxZ?: boolean): void;
  112137. /**
  112138. * @override
  112139. * Override Camera.createRigCamera
  112140. */
  112141. createRigCamera(name: string, cameraIndex: number): Camera;
  112142. /**
  112143. * @hidden
  112144. * @override
  112145. * Override Camera._updateRigCameras
  112146. */
  112147. _updateRigCameras(): void;
  112148. /**
  112149. * Destroy the camera and release the current resources hold by it.
  112150. */
  112151. dispose(): void;
  112152. /**
  112153. * Gets the current object class name.
  112154. * @return the class name
  112155. */
  112156. getClassName(): string;
  112157. }
  112158. }
  112159. declare module BABYLON {
  112160. /**
  112161. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112163. */
  112164. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112165. /**
  112166. * Gets the name of the behavior.
  112167. */
  112168. get name(): string;
  112169. private _zoomStopsAnimation;
  112170. private _idleRotationSpeed;
  112171. private _idleRotationWaitTime;
  112172. private _idleRotationSpinupTime;
  112173. /**
  112174. * Sets the flag that indicates if user zooming should stop animation.
  112175. */
  112176. set zoomStopsAnimation(flag: boolean);
  112177. /**
  112178. * Gets the flag that indicates if user zooming should stop animation.
  112179. */
  112180. get zoomStopsAnimation(): boolean;
  112181. /**
  112182. * Sets the default speed at which the camera rotates around the model.
  112183. */
  112184. set idleRotationSpeed(speed: number);
  112185. /**
  112186. * Gets the default speed at which the camera rotates around the model.
  112187. */
  112188. get idleRotationSpeed(): number;
  112189. /**
  112190. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112191. */
  112192. set idleRotationWaitTime(time: number);
  112193. /**
  112194. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112195. */
  112196. get idleRotationWaitTime(): number;
  112197. /**
  112198. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112199. */
  112200. set idleRotationSpinupTime(time: number);
  112201. /**
  112202. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112203. */
  112204. get idleRotationSpinupTime(): number;
  112205. /**
  112206. * Gets a value indicating if the camera is currently rotating because of this behavior
  112207. */
  112208. get rotationInProgress(): boolean;
  112209. private _onPrePointerObservableObserver;
  112210. private _onAfterCheckInputsObserver;
  112211. private _attachedCamera;
  112212. private _isPointerDown;
  112213. private _lastFrameTime;
  112214. private _lastInteractionTime;
  112215. private _cameraRotationSpeed;
  112216. /**
  112217. * Initializes the behavior.
  112218. */
  112219. init(): void;
  112220. /**
  112221. * Attaches the behavior to its arc rotate camera.
  112222. * @param camera Defines the camera to attach the behavior to
  112223. */
  112224. attach(camera: ArcRotateCamera): void;
  112225. /**
  112226. * Detaches the behavior from its current arc rotate camera.
  112227. */
  112228. detach(): void;
  112229. /**
  112230. * Returns true if user is scrolling.
  112231. * @return true if user is scrolling.
  112232. */
  112233. private _userIsZooming;
  112234. private _lastFrameRadius;
  112235. private _shouldAnimationStopForInteraction;
  112236. /**
  112237. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112238. */
  112239. private _applyUserInteraction;
  112240. private _userIsMoving;
  112241. }
  112242. }
  112243. declare module BABYLON {
  112244. /**
  112245. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112246. */
  112247. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112248. private ui;
  112249. /**
  112250. * The name of the behavior
  112251. */
  112252. name: string;
  112253. /**
  112254. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112255. */
  112256. distanceAwayFromFace: number;
  112257. /**
  112258. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112259. */
  112260. distanceAwayFromBottomOfFace: number;
  112261. private _faceVectors;
  112262. private _target;
  112263. private _scene;
  112264. private _onRenderObserver;
  112265. private _tmpMatrix;
  112266. private _tmpVector;
  112267. /**
  112268. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112269. * @param ui The transform node that should be attched to the mesh
  112270. */
  112271. constructor(ui: TransformNode);
  112272. /**
  112273. * Initializes the behavior
  112274. */
  112275. init(): void;
  112276. private _closestFace;
  112277. private _zeroVector;
  112278. private _lookAtTmpMatrix;
  112279. private _lookAtToRef;
  112280. /**
  112281. * Attaches the AttachToBoxBehavior to the passed in mesh
  112282. * @param target The mesh that the specified node will be attached to
  112283. */
  112284. attach(target: Mesh): void;
  112285. /**
  112286. * Detaches the behavior from the mesh
  112287. */
  112288. detach(): void;
  112289. }
  112290. }
  112291. declare module BABYLON {
  112292. /**
  112293. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112294. */
  112295. export class FadeInOutBehavior implements Behavior<Mesh> {
  112296. /**
  112297. * Time in milliseconds to delay before fading in (Default: 0)
  112298. */
  112299. delay: number;
  112300. /**
  112301. * Time in milliseconds for the mesh to fade in (Default: 300)
  112302. */
  112303. fadeInTime: number;
  112304. private _millisecondsPerFrame;
  112305. private _hovered;
  112306. private _hoverValue;
  112307. private _ownerNode;
  112308. /**
  112309. * Instatiates the FadeInOutBehavior
  112310. */
  112311. constructor();
  112312. /**
  112313. * The name of the behavior
  112314. */
  112315. get name(): string;
  112316. /**
  112317. * Initializes the behavior
  112318. */
  112319. init(): void;
  112320. /**
  112321. * Attaches the fade behavior on the passed in mesh
  112322. * @param ownerNode The mesh that will be faded in/out once attached
  112323. */
  112324. attach(ownerNode: Mesh): void;
  112325. /**
  112326. * Detaches the behavior from the mesh
  112327. */
  112328. detach(): void;
  112329. /**
  112330. * Triggers the mesh to begin fading in or out
  112331. * @param value if the object should fade in or out (true to fade in)
  112332. */
  112333. fadeIn(value: boolean): void;
  112334. private _update;
  112335. private _setAllVisibility;
  112336. }
  112337. }
  112338. declare module BABYLON {
  112339. /**
  112340. * Class containing a set of static utilities functions for managing Pivots
  112341. * @hidden
  112342. */
  112343. export class PivotTools {
  112344. private static _PivotCached;
  112345. private static _OldPivotPoint;
  112346. private static _PivotTranslation;
  112347. private static _PivotTmpVector;
  112348. /** @hidden */
  112349. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112350. /** @hidden */
  112351. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112352. }
  112353. }
  112354. declare module BABYLON {
  112355. /**
  112356. * Class containing static functions to help procedurally build meshes
  112357. */
  112358. export class PlaneBuilder {
  112359. /**
  112360. * Creates a plane mesh
  112361. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112362. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112363. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112367. * @param name defines the name of the mesh
  112368. * @param options defines the options used to create the mesh
  112369. * @param scene defines the hosting scene
  112370. * @returns the plane mesh
  112371. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112372. */
  112373. static CreatePlane(name: string, options: {
  112374. size?: number;
  112375. width?: number;
  112376. height?: number;
  112377. sideOrientation?: number;
  112378. frontUVs?: Vector4;
  112379. backUVs?: Vector4;
  112380. updatable?: boolean;
  112381. sourcePlane?: Plane;
  112382. }, scene?: Nullable<Scene>): Mesh;
  112383. }
  112384. }
  112385. declare module BABYLON {
  112386. /**
  112387. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112388. */
  112389. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112390. private static _AnyMouseID;
  112391. /**
  112392. * Abstract mesh the behavior is set on
  112393. */
  112394. attachedNode: AbstractMesh;
  112395. private _dragPlane;
  112396. private _scene;
  112397. private _pointerObserver;
  112398. private _beforeRenderObserver;
  112399. private static _planeScene;
  112400. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112401. /**
  112402. * 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)
  112403. */
  112404. maxDragAngle: number;
  112405. /**
  112406. * @hidden
  112407. */
  112408. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112409. /**
  112410. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112411. */
  112412. currentDraggingPointerID: number;
  112413. /**
  112414. * The last position where the pointer hit the drag plane in world space
  112415. */
  112416. lastDragPosition: Vector3;
  112417. /**
  112418. * If the behavior is currently in a dragging state
  112419. */
  112420. dragging: boolean;
  112421. /**
  112422. * 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)
  112423. */
  112424. dragDeltaRatio: number;
  112425. /**
  112426. * If the drag plane orientation should be updated during the dragging (Default: true)
  112427. */
  112428. updateDragPlane: boolean;
  112429. private _debugMode;
  112430. private _moving;
  112431. /**
  112432. * Fires each time the attached mesh is dragged with the pointer
  112433. * * delta between last drag position and current drag position in world space
  112434. * * dragDistance along the drag axis
  112435. * * dragPlaneNormal normal of the current drag plane used during the drag
  112436. * * dragPlanePoint in world space where the drag intersects the drag plane
  112437. */
  112438. onDragObservable: Observable<{
  112439. delta: Vector3;
  112440. dragPlanePoint: Vector3;
  112441. dragPlaneNormal: Vector3;
  112442. dragDistance: number;
  112443. pointerId: number;
  112444. }>;
  112445. /**
  112446. * Fires each time a drag begins (eg. mouse down on mesh)
  112447. */
  112448. onDragStartObservable: Observable<{
  112449. dragPlanePoint: Vector3;
  112450. pointerId: number;
  112451. }>;
  112452. /**
  112453. * Fires each time a drag ends (eg. mouse release after drag)
  112454. */
  112455. onDragEndObservable: Observable<{
  112456. dragPlanePoint: Vector3;
  112457. pointerId: number;
  112458. }>;
  112459. /**
  112460. * If the attached mesh should be moved when dragged
  112461. */
  112462. moveAttached: boolean;
  112463. /**
  112464. * If the drag behavior will react to drag events (Default: true)
  112465. */
  112466. enabled: boolean;
  112467. /**
  112468. * If pointer events should start and release the drag (Default: true)
  112469. */
  112470. startAndReleaseDragOnPointerEvents: boolean;
  112471. /**
  112472. * If camera controls should be detached during the drag
  112473. */
  112474. detachCameraControls: boolean;
  112475. /**
  112476. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112477. */
  112478. useObjectOrientationForDragging: boolean;
  112479. private _options;
  112480. /**
  112481. * Gets the options used by the behavior
  112482. */
  112483. get options(): {
  112484. dragAxis?: Vector3;
  112485. dragPlaneNormal?: Vector3;
  112486. };
  112487. /**
  112488. * Sets the options used by the behavior
  112489. */
  112490. set options(options: {
  112491. dragAxis?: Vector3;
  112492. dragPlaneNormal?: Vector3;
  112493. });
  112494. /**
  112495. * Creates a pointer drag behavior that can be attached to a mesh
  112496. * @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)
  112497. */
  112498. constructor(options?: {
  112499. dragAxis?: Vector3;
  112500. dragPlaneNormal?: Vector3;
  112501. });
  112502. /**
  112503. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112504. */
  112505. validateDrag: (targetPosition: Vector3) => boolean;
  112506. /**
  112507. * The name of the behavior
  112508. */
  112509. get name(): string;
  112510. /**
  112511. * Initializes the behavior
  112512. */
  112513. init(): void;
  112514. private _tmpVector;
  112515. private _alternatePickedPoint;
  112516. private _worldDragAxis;
  112517. private _targetPosition;
  112518. private _attachedElement;
  112519. /**
  112520. * Attaches the drag behavior the passed in mesh
  112521. * @param ownerNode The mesh that will be dragged around once attached
  112522. * @param predicate Predicate to use for pick filtering
  112523. */
  112524. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112525. /**
  112526. * Force relase the drag action by code.
  112527. */
  112528. releaseDrag(): void;
  112529. private _startDragRay;
  112530. private _lastPointerRay;
  112531. /**
  112532. * Simulates the start of a pointer drag event on the behavior
  112533. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112534. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112535. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112536. */
  112537. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112538. private _startDrag;
  112539. private _dragDelta;
  112540. private _moveDrag;
  112541. private _pickWithRayOnDragPlane;
  112542. private _pointA;
  112543. private _pointB;
  112544. private _pointC;
  112545. private _lineA;
  112546. private _lineB;
  112547. private _localAxis;
  112548. private _lookAt;
  112549. private _updateDragPlanePosition;
  112550. /**
  112551. * Detaches the behavior from the mesh
  112552. */
  112553. detach(): void;
  112554. }
  112555. }
  112556. declare module BABYLON {
  112557. /**
  112558. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112559. */
  112560. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112561. private _dragBehaviorA;
  112562. private _dragBehaviorB;
  112563. private _startDistance;
  112564. private _initialScale;
  112565. private _targetScale;
  112566. private _ownerNode;
  112567. private _sceneRenderObserver;
  112568. /**
  112569. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112570. */
  112571. constructor();
  112572. /**
  112573. * The name of the behavior
  112574. */
  112575. get name(): string;
  112576. /**
  112577. * Initializes the behavior
  112578. */
  112579. init(): void;
  112580. private _getCurrentDistance;
  112581. /**
  112582. * Attaches the scale behavior the passed in mesh
  112583. * @param ownerNode The mesh that will be scaled around once attached
  112584. */
  112585. attach(ownerNode: Mesh): void;
  112586. /**
  112587. * Detaches the behavior from the mesh
  112588. */
  112589. detach(): void;
  112590. }
  112591. }
  112592. declare module BABYLON {
  112593. /**
  112594. * 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
  112595. */
  112596. export class SixDofDragBehavior implements Behavior<Mesh> {
  112597. private static _virtualScene;
  112598. private _ownerNode;
  112599. private _sceneRenderObserver;
  112600. private _scene;
  112601. private _targetPosition;
  112602. private _virtualOriginMesh;
  112603. private _virtualDragMesh;
  112604. private _pointerObserver;
  112605. private _moving;
  112606. private _startingOrientation;
  112607. /**
  112608. * 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)
  112609. */
  112610. private zDragFactor;
  112611. /**
  112612. * If the object should rotate to face the drag origin
  112613. */
  112614. rotateDraggedObject: boolean;
  112615. /**
  112616. * If the behavior is currently in a dragging state
  112617. */
  112618. dragging: boolean;
  112619. /**
  112620. * 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)
  112621. */
  112622. dragDeltaRatio: number;
  112623. /**
  112624. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112625. */
  112626. currentDraggingPointerID: number;
  112627. /**
  112628. * If camera controls should be detached during the drag
  112629. */
  112630. detachCameraControls: boolean;
  112631. /**
  112632. * Fires each time a drag starts
  112633. */
  112634. onDragStartObservable: Observable<{}>;
  112635. /**
  112636. * Fires each time a drag ends (eg. mouse release after drag)
  112637. */
  112638. onDragEndObservable: Observable<{}>;
  112639. /**
  112640. * 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
  112641. */
  112642. constructor();
  112643. /**
  112644. * The name of the behavior
  112645. */
  112646. get name(): string;
  112647. /**
  112648. * Initializes the behavior
  112649. */
  112650. init(): void;
  112651. /**
  112652. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112653. */
  112654. private get _pointerCamera();
  112655. /**
  112656. * Attaches the scale behavior the passed in mesh
  112657. * @param ownerNode The mesh that will be scaled around once attached
  112658. */
  112659. attach(ownerNode: Mesh): void;
  112660. /**
  112661. * Detaches the behavior from the mesh
  112662. */
  112663. detach(): void;
  112664. }
  112665. }
  112666. declare module BABYLON {
  112667. /**
  112668. * Class used to apply inverse kinematics to bones
  112669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112670. */
  112671. export class BoneIKController {
  112672. private static _tmpVecs;
  112673. private static _tmpQuat;
  112674. private static _tmpMats;
  112675. /**
  112676. * Gets or sets the target mesh
  112677. */
  112678. targetMesh: AbstractMesh;
  112679. /** Gets or sets the mesh used as pole */
  112680. poleTargetMesh: AbstractMesh;
  112681. /**
  112682. * Gets or sets the bone used as pole
  112683. */
  112684. poleTargetBone: Nullable<Bone>;
  112685. /**
  112686. * Gets or sets the target position
  112687. */
  112688. targetPosition: Vector3;
  112689. /**
  112690. * Gets or sets the pole target position
  112691. */
  112692. poleTargetPosition: Vector3;
  112693. /**
  112694. * Gets or sets the pole target local offset
  112695. */
  112696. poleTargetLocalOffset: Vector3;
  112697. /**
  112698. * Gets or sets the pole angle
  112699. */
  112700. poleAngle: number;
  112701. /**
  112702. * Gets or sets the mesh associated with the controller
  112703. */
  112704. mesh: AbstractMesh;
  112705. /**
  112706. * 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)
  112707. */
  112708. slerpAmount: number;
  112709. private _bone1Quat;
  112710. private _bone1Mat;
  112711. private _bone2Ang;
  112712. private _bone1;
  112713. private _bone2;
  112714. private _bone1Length;
  112715. private _bone2Length;
  112716. private _maxAngle;
  112717. private _maxReach;
  112718. private _rightHandedSystem;
  112719. private _bendAxis;
  112720. private _slerping;
  112721. private _adjustRoll;
  112722. /**
  112723. * Gets or sets maximum allowed angle
  112724. */
  112725. get maxAngle(): number;
  112726. set maxAngle(value: number);
  112727. /**
  112728. * Creates a new BoneIKController
  112729. * @param mesh defines the mesh to control
  112730. * @param bone defines the bone to control
  112731. * @param options defines options to set up the controller
  112732. */
  112733. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112734. targetMesh?: AbstractMesh;
  112735. poleTargetMesh?: AbstractMesh;
  112736. poleTargetBone?: Bone;
  112737. poleTargetLocalOffset?: Vector3;
  112738. poleAngle?: number;
  112739. bendAxis?: Vector3;
  112740. maxAngle?: number;
  112741. slerpAmount?: number;
  112742. });
  112743. private _setMaxAngle;
  112744. /**
  112745. * Force the controller to update the bones
  112746. */
  112747. update(): void;
  112748. }
  112749. }
  112750. declare module BABYLON {
  112751. /**
  112752. * Class used to make a bone look toward a point in space
  112753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112754. */
  112755. export class BoneLookController {
  112756. private static _tmpVecs;
  112757. private static _tmpQuat;
  112758. private static _tmpMats;
  112759. /**
  112760. * The target Vector3 that the bone will look at
  112761. */
  112762. target: Vector3;
  112763. /**
  112764. * The mesh that the bone is attached to
  112765. */
  112766. mesh: AbstractMesh;
  112767. /**
  112768. * The bone that will be looking to the target
  112769. */
  112770. bone: Bone;
  112771. /**
  112772. * The up axis of the coordinate system that is used when the bone is rotated
  112773. */
  112774. upAxis: Vector3;
  112775. /**
  112776. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112777. */
  112778. upAxisSpace: Space;
  112779. /**
  112780. * Used to make an adjustment to the yaw of the bone
  112781. */
  112782. adjustYaw: number;
  112783. /**
  112784. * Used to make an adjustment to the pitch of the bone
  112785. */
  112786. adjustPitch: number;
  112787. /**
  112788. * Used to make an adjustment to the roll of the bone
  112789. */
  112790. adjustRoll: number;
  112791. /**
  112792. * 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)
  112793. */
  112794. slerpAmount: number;
  112795. private _minYaw;
  112796. private _maxYaw;
  112797. private _minPitch;
  112798. private _maxPitch;
  112799. private _minYawSin;
  112800. private _minYawCos;
  112801. private _maxYawSin;
  112802. private _maxYawCos;
  112803. private _midYawConstraint;
  112804. private _minPitchTan;
  112805. private _maxPitchTan;
  112806. private _boneQuat;
  112807. private _slerping;
  112808. private _transformYawPitch;
  112809. private _transformYawPitchInv;
  112810. private _firstFrameSkipped;
  112811. private _yawRange;
  112812. private _fowardAxis;
  112813. /**
  112814. * Gets or sets the minimum yaw angle that the bone can look to
  112815. */
  112816. get minYaw(): number;
  112817. set minYaw(value: number);
  112818. /**
  112819. * Gets or sets the maximum yaw angle that the bone can look to
  112820. */
  112821. get maxYaw(): number;
  112822. set maxYaw(value: number);
  112823. /**
  112824. * Gets or sets the minimum pitch angle that the bone can look to
  112825. */
  112826. get minPitch(): number;
  112827. set minPitch(value: number);
  112828. /**
  112829. * Gets or sets the maximum pitch angle that the bone can look to
  112830. */
  112831. get maxPitch(): number;
  112832. set maxPitch(value: number);
  112833. /**
  112834. * Create a BoneLookController
  112835. * @param mesh the mesh that the bone belongs to
  112836. * @param bone the bone that will be looking to the target
  112837. * @param target the target Vector3 to look at
  112838. * @param options optional settings:
  112839. * * maxYaw: the maximum angle the bone will yaw to
  112840. * * minYaw: the minimum angle the bone will yaw to
  112841. * * maxPitch: the maximum angle the bone will pitch to
  112842. * * minPitch: the minimum angle the bone will yaw to
  112843. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112844. * * upAxis: the up axis of the coordinate system
  112845. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112846. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112847. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112848. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112849. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112850. * * adjustRoll: used to make an adjustment to the roll of the bone
  112851. **/
  112852. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112853. maxYaw?: number;
  112854. minYaw?: number;
  112855. maxPitch?: number;
  112856. minPitch?: number;
  112857. slerpAmount?: number;
  112858. upAxis?: Vector3;
  112859. upAxisSpace?: Space;
  112860. yawAxis?: Vector3;
  112861. pitchAxis?: Vector3;
  112862. adjustYaw?: number;
  112863. adjustPitch?: number;
  112864. adjustRoll?: number;
  112865. });
  112866. /**
  112867. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112868. */
  112869. update(): void;
  112870. private _getAngleDiff;
  112871. private _getAngleBetween;
  112872. private _isAngleBetween;
  112873. }
  112874. }
  112875. declare module BABYLON {
  112876. /**
  112877. * Manage the gamepad inputs to control an arc rotate camera.
  112878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112879. */
  112880. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112881. /**
  112882. * Defines the camera the input is attached to.
  112883. */
  112884. camera: ArcRotateCamera;
  112885. /**
  112886. * Defines the gamepad the input is gathering event from.
  112887. */
  112888. gamepad: Nullable<Gamepad>;
  112889. /**
  112890. * Defines the gamepad rotation sensiblity.
  112891. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112892. */
  112893. gamepadRotationSensibility: number;
  112894. /**
  112895. * Defines the gamepad move sensiblity.
  112896. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112897. */
  112898. gamepadMoveSensibility: number;
  112899. private _yAxisScale;
  112900. /**
  112901. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112902. */
  112903. get invertYAxis(): boolean;
  112904. set invertYAxis(value: boolean);
  112905. private _onGamepadConnectedObserver;
  112906. private _onGamepadDisconnectedObserver;
  112907. /**
  112908. * Attach the input controls to a specific dom element to get the input from.
  112909. * @param element Defines the element the controls should be listened from
  112910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112911. */
  112912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112913. /**
  112914. * Detach the current controls from the specified dom element.
  112915. * @param element Defines the element to stop listening the inputs from
  112916. */
  112917. detachControl(element: Nullable<HTMLElement>): void;
  112918. /**
  112919. * Update the current camera state depending on the inputs that have been used this frame.
  112920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112921. */
  112922. checkInputs(): void;
  112923. /**
  112924. * Gets the class name of the current intput.
  112925. * @returns the class name
  112926. */
  112927. getClassName(): string;
  112928. /**
  112929. * Get the friendly name associated with the input class.
  112930. * @returns the input friendly name
  112931. */
  112932. getSimpleName(): string;
  112933. }
  112934. }
  112935. declare module BABYLON {
  112936. interface ArcRotateCameraInputsManager {
  112937. /**
  112938. * Add orientation input support to the input manager.
  112939. * @returns the current input manager
  112940. */
  112941. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112942. }
  112943. /**
  112944. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112946. */
  112947. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112948. /**
  112949. * Defines the camera the input is attached to.
  112950. */
  112951. camera: ArcRotateCamera;
  112952. /**
  112953. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112954. */
  112955. alphaCorrection: number;
  112956. /**
  112957. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112958. */
  112959. gammaCorrection: number;
  112960. private _alpha;
  112961. private _gamma;
  112962. private _dirty;
  112963. private _deviceOrientationHandler;
  112964. /**
  112965. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112966. */
  112967. constructor();
  112968. /**
  112969. * Attach the input controls to a specific dom element to get the input from.
  112970. * @param element Defines the element the controls should be listened from
  112971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112972. */
  112973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112974. /** @hidden */
  112975. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112976. /**
  112977. * Update the current camera state depending on the inputs that have been used this frame.
  112978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112979. */
  112980. checkInputs(): void;
  112981. /**
  112982. * Detach the current controls from the specified dom element.
  112983. * @param element Defines the element to stop listening the inputs from
  112984. */
  112985. detachControl(element: Nullable<HTMLElement>): void;
  112986. /**
  112987. * Gets the class name of the current intput.
  112988. * @returns the class name
  112989. */
  112990. getClassName(): string;
  112991. /**
  112992. * Get the friendly name associated with the input class.
  112993. * @returns the input friendly name
  112994. */
  112995. getSimpleName(): string;
  112996. }
  112997. }
  112998. declare module BABYLON {
  112999. /**
  113000. * Listen to mouse events to control the camera.
  113001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113002. */
  113003. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113004. /**
  113005. * Defines the camera the input is attached to.
  113006. */
  113007. camera: FlyCamera;
  113008. /**
  113009. * Defines if touch is enabled. (Default is true.)
  113010. */
  113011. touchEnabled: boolean;
  113012. /**
  113013. * Defines the buttons associated with the input to handle camera rotation.
  113014. */
  113015. buttons: number[];
  113016. /**
  113017. * Assign buttons for Yaw control.
  113018. */
  113019. buttonsYaw: number[];
  113020. /**
  113021. * Assign buttons for Pitch control.
  113022. */
  113023. buttonsPitch: number[];
  113024. /**
  113025. * Assign buttons for Roll control.
  113026. */
  113027. buttonsRoll: number[];
  113028. /**
  113029. * Detect if any button is being pressed while mouse is moved.
  113030. * -1 = Mouse locked.
  113031. * 0 = Left button.
  113032. * 1 = Middle Button.
  113033. * 2 = Right Button.
  113034. */
  113035. activeButton: number;
  113036. /**
  113037. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113038. * Higher values reduce its sensitivity.
  113039. */
  113040. angularSensibility: number;
  113041. private _mousemoveCallback;
  113042. private _observer;
  113043. private _rollObserver;
  113044. private previousPosition;
  113045. private noPreventDefault;
  113046. private element;
  113047. /**
  113048. * Listen to mouse events to control the camera.
  113049. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113051. */
  113052. constructor(touchEnabled?: boolean);
  113053. /**
  113054. * Attach the mouse control to the HTML DOM element.
  113055. * @param element Defines the element that listens to the input events.
  113056. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113057. */
  113058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113059. /**
  113060. * Detach the current controls from the specified dom element.
  113061. * @param element Defines the element to stop listening the inputs from
  113062. */
  113063. detachControl(element: Nullable<HTMLElement>): void;
  113064. /**
  113065. * Gets the class name of the current input.
  113066. * @returns the class name.
  113067. */
  113068. getClassName(): string;
  113069. /**
  113070. * Get the friendly name associated with the input class.
  113071. * @returns the input's friendly name.
  113072. */
  113073. getSimpleName(): string;
  113074. private _pointerInput;
  113075. private _onMouseMove;
  113076. /**
  113077. * Rotate camera by mouse offset.
  113078. */
  113079. private rotateCamera;
  113080. }
  113081. }
  113082. declare module BABYLON {
  113083. /**
  113084. * Default Inputs manager for the FlyCamera.
  113085. * It groups all the default supported inputs for ease of use.
  113086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113087. */
  113088. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113089. /**
  113090. * Instantiates a new FlyCameraInputsManager.
  113091. * @param camera Defines the camera the inputs belong to.
  113092. */
  113093. constructor(camera: FlyCamera);
  113094. /**
  113095. * Add keyboard input support to the input manager.
  113096. * @returns the new FlyCameraKeyboardMoveInput().
  113097. */
  113098. addKeyboard(): FlyCameraInputsManager;
  113099. /**
  113100. * Add mouse input support to the input manager.
  113101. * @param touchEnabled Enable touch screen support.
  113102. * @returns the new FlyCameraMouseInput().
  113103. */
  113104. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113105. }
  113106. }
  113107. declare module BABYLON {
  113108. /**
  113109. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113110. * such as in a 3D Space Shooter or a Flight Simulator.
  113111. */
  113112. export class FlyCamera extends TargetCamera {
  113113. /**
  113114. * Define the collision ellipsoid of the camera.
  113115. * This is helpful for simulating a camera body, like a player's body.
  113116. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113117. */
  113118. ellipsoid: Vector3;
  113119. /**
  113120. * Define an offset for the position of the ellipsoid around the camera.
  113121. * This can be helpful if the camera is attached away from the player's body center,
  113122. * such as at its head.
  113123. */
  113124. ellipsoidOffset: Vector3;
  113125. /**
  113126. * Enable or disable collisions of the camera with the rest of the scene objects.
  113127. */
  113128. checkCollisions: boolean;
  113129. /**
  113130. * Enable or disable gravity on the camera.
  113131. */
  113132. applyGravity: boolean;
  113133. /**
  113134. * Define the current direction the camera is moving to.
  113135. */
  113136. cameraDirection: Vector3;
  113137. /**
  113138. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113139. * This overrides and empties cameraRotation.
  113140. */
  113141. rotationQuaternion: Quaternion;
  113142. /**
  113143. * Track Roll to maintain the wanted Rolling when looking around.
  113144. */
  113145. _trackRoll: number;
  113146. /**
  113147. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113148. */
  113149. rollCorrect: number;
  113150. /**
  113151. * Mimic a banked turn, Rolling the camera when Yawing.
  113152. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113153. */
  113154. bankedTurn: boolean;
  113155. /**
  113156. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113157. */
  113158. bankedTurnLimit: number;
  113159. /**
  113160. * Value of 0 disables the banked Roll.
  113161. * Value of 1 is equal to the Yaw angle in radians.
  113162. */
  113163. bankedTurnMultiplier: number;
  113164. /**
  113165. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113166. */
  113167. inputs: FlyCameraInputsManager;
  113168. /**
  113169. * Gets the input sensibility for mouse input.
  113170. * Higher values reduce sensitivity.
  113171. */
  113172. get angularSensibility(): number;
  113173. /**
  113174. * Sets the input sensibility for a mouse input.
  113175. * Higher values reduce sensitivity.
  113176. */
  113177. set angularSensibility(value: number);
  113178. /**
  113179. * Get the keys for camera movement forward.
  113180. */
  113181. get keysForward(): number[];
  113182. /**
  113183. * Set the keys for camera movement forward.
  113184. */
  113185. set keysForward(value: number[]);
  113186. /**
  113187. * Get the keys for camera movement backward.
  113188. */
  113189. get keysBackward(): number[];
  113190. set keysBackward(value: number[]);
  113191. /**
  113192. * Get the keys for camera movement up.
  113193. */
  113194. get keysUp(): number[];
  113195. /**
  113196. * Set the keys for camera movement up.
  113197. */
  113198. set keysUp(value: number[]);
  113199. /**
  113200. * Get the keys for camera movement down.
  113201. */
  113202. get keysDown(): number[];
  113203. /**
  113204. * Set the keys for camera movement down.
  113205. */
  113206. set keysDown(value: number[]);
  113207. /**
  113208. * Get the keys for camera movement left.
  113209. */
  113210. get keysLeft(): number[];
  113211. /**
  113212. * Set the keys for camera movement left.
  113213. */
  113214. set keysLeft(value: number[]);
  113215. /**
  113216. * Set the keys for camera movement right.
  113217. */
  113218. get keysRight(): number[];
  113219. /**
  113220. * Set the keys for camera movement right.
  113221. */
  113222. set keysRight(value: number[]);
  113223. /**
  113224. * Event raised when the camera collides with a mesh in the scene.
  113225. */
  113226. onCollide: (collidedMesh: AbstractMesh) => void;
  113227. private _collider;
  113228. private _needMoveForGravity;
  113229. private _oldPosition;
  113230. private _diffPosition;
  113231. private _newPosition;
  113232. /** @hidden */
  113233. _localDirection: Vector3;
  113234. /** @hidden */
  113235. _transformedDirection: Vector3;
  113236. /**
  113237. * Instantiates a FlyCamera.
  113238. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113239. * such as in a 3D Space Shooter or a Flight Simulator.
  113240. * @param name Define the name of the camera in the scene.
  113241. * @param position Define the starting position of the camera in the scene.
  113242. * @param scene Define the scene the camera belongs to.
  113243. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113244. */
  113245. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113246. /**
  113247. * Attach a control to the HTML DOM element.
  113248. * @param element Defines the element that listens to the input events.
  113249. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113250. */
  113251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113252. /**
  113253. * Detach a control from the HTML DOM element.
  113254. * The camera will stop reacting to that input.
  113255. * @param element Defines the element that listens to the input events.
  113256. */
  113257. detachControl(element: HTMLElement): void;
  113258. private _collisionMask;
  113259. /**
  113260. * Get the mask that the camera ignores in collision events.
  113261. */
  113262. get collisionMask(): number;
  113263. /**
  113264. * Set the mask that the camera ignores in collision events.
  113265. */
  113266. set collisionMask(mask: number);
  113267. /** @hidden */
  113268. _collideWithWorld(displacement: Vector3): void;
  113269. /** @hidden */
  113270. private _onCollisionPositionChange;
  113271. /** @hidden */
  113272. _checkInputs(): void;
  113273. /** @hidden */
  113274. _decideIfNeedsToMove(): boolean;
  113275. /** @hidden */
  113276. _updatePosition(): void;
  113277. /**
  113278. * Restore the Roll to its target value at the rate specified.
  113279. * @param rate - Higher means slower restoring.
  113280. * @hidden
  113281. */
  113282. restoreRoll(rate: number): void;
  113283. /**
  113284. * Destroy the camera and release the current resources held by it.
  113285. */
  113286. dispose(): void;
  113287. /**
  113288. * Get the current object class name.
  113289. * @returns the class name.
  113290. */
  113291. getClassName(): string;
  113292. }
  113293. }
  113294. declare module BABYLON {
  113295. /**
  113296. * Listen to keyboard events to control the camera.
  113297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113298. */
  113299. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113300. /**
  113301. * Defines the camera the input is attached to.
  113302. */
  113303. camera: FlyCamera;
  113304. /**
  113305. * The list of keyboard keys used to control the forward move of the camera.
  113306. */
  113307. keysForward: number[];
  113308. /**
  113309. * The list of keyboard keys used to control the backward move of the camera.
  113310. */
  113311. keysBackward: number[];
  113312. /**
  113313. * The list of keyboard keys used to control the forward move of the camera.
  113314. */
  113315. keysUp: number[];
  113316. /**
  113317. * The list of keyboard keys used to control the backward move of the camera.
  113318. */
  113319. keysDown: number[];
  113320. /**
  113321. * The list of keyboard keys used to control the right strafe move of the camera.
  113322. */
  113323. keysRight: number[];
  113324. /**
  113325. * The list of keyboard keys used to control the left strafe move of the camera.
  113326. */
  113327. keysLeft: number[];
  113328. private _keys;
  113329. private _onCanvasBlurObserver;
  113330. private _onKeyboardObserver;
  113331. private _engine;
  113332. private _scene;
  113333. /**
  113334. * Attach the input controls to a specific dom element to get the input from.
  113335. * @param element Defines the element the controls should be listened from
  113336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113337. */
  113338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113339. /**
  113340. * Detach the current controls from the specified dom element.
  113341. * @param element Defines the element to stop listening the inputs from
  113342. */
  113343. detachControl(element: Nullable<HTMLElement>): void;
  113344. /**
  113345. * Gets the class name of the current intput.
  113346. * @returns the class name
  113347. */
  113348. getClassName(): string;
  113349. /** @hidden */
  113350. _onLostFocus(e: FocusEvent): void;
  113351. /**
  113352. * Get the friendly name associated with the input class.
  113353. * @returns the input friendly name
  113354. */
  113355. getSimpleName(): string;
  113356. /**
  113357. * Update the current camera state depending on the inputs that have been used this frame.
  113358. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113359. */
  113360. checkInputs(): void;
  113361. }
  113362. }
  113363. declare module BABYLON {
  113364. /**
  113365. * Manage the mouse wheel inputs to control a follow camera.
  113366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113367. */
  113368. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113369. /**
  113370. * Defines the camera the input is attached to.
  113371. */
  113372. camera: FollowCamera;
  113373. /**
  113374. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113375. */
  113376. axisControlRadius: boolean;
  113377. /**
  113378. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113379. */
  113380. axisControlHeight: boolean;
  113381. /**
  113382. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113383. */
  113384. axisControlRotation: boolean;
  113385. /**
  113386. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113387. * relation to mouseWheel events.
  113388. */
  113389. wheelPrecision: number;
  113390. /**
  113391. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113392. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113393. */
  113394. wheelDeltaPercentage: number;
  113395. private _wheel;
  113396. private _observer;
  113397. /**
  113398. * Attach the input controls to a specific dom element to get the input from.
  113399. * @param element Defines the element the controls should be listened from
  113400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113401. */
  113402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113403. /**
  113404. * Detach the current controls from the specified dom element.
  113405. * @param element Defines the element to stop listening the inputs from
  113406. */
  113407. detachControl(element: Nullable<HTMLElement>): void;
  113408. /**
  113409. * Gets the class name of the current intput.
  113410. * @returns the class name
  113411. */
  113412. getClassName(): string;
  113413. /**
  113414. * Get the friendly name associated with the input class.
  113415. * @returns the input friendly name
  113416. */
  113417. getSimpleName(): string;
  113418. }
  113419. }
  113420. declare module BABYLON {
  113421. /**
  113422. * Manage the pointers inputs to control an follow camera.
  113423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113424. */
  113425. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113426. /**
  113427. * Defines the camera the input is attached to.
  113428. */
  113429. camera: FollowCamera;
  113430. /**
  113431. * Gets the class name of the current input.
  113432. * @returns the class name
  113433. */
  113434. getClassName(): string;
  113435. /**
  113436. * Defines the pointer angular sensibility along the X axis or how fast is
  113437. * the camera rotating.
  113438. * A negative number will reverse the axis direction.
  113439. */
  113440. angularSensibilityX: number;
  113441. /**
  113442. * Defines the pointer angular sensibility along the Y axis or how fast is
  113443. * the camera rotating.
  113444. * A negative number will reverse the axis direction.
  113445. */
  113446. angularSensibilityY: number;
  113447. /**
  113448. * Defines the pointer pinch precision or how fast is the camera zooming.
  113449. * A negative number will reverse the axis direction.
  113450. */
  113451. pinchPrecision: number;
  113452. /**
  113453. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113454. * from 0.
  113455. * It defines the percentage of current camera.radius to use as delta when
  113456. * pinch zoom is used.
  113457. */
  113458. pinchDeltaPercentage: number;
  113459. /**
  113460. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113461. */
  113462. axisXControlRadius: boolean;
  113463. /**
  113464. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113465. */
  113466. axisXControlHeight: boolean;
  113467. /**
  113468. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113469. */
  113470. axisXControlRotation: boolean;
  113471. /**
  113472. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113473. */
  113474. axisYControlRadius: boolean;
  113475. /**
  113476. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113477. */
  113478. axisYControlHeight: boolean;
  113479. /**
  113480. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113481. */
  113482. axisYControlRotation: boolean;
  113483. /**
  113484. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113485. */
  113486. axisPinchControlRadius: boolean;
  113487. /**
  113488. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113489. */
  113490. axisPinchControlHeight: boolean;
  113491. /**
  113492. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113493. */
  113494. axisPinchControlRotation: boolean;
  113495. /**
  113496. * Log error messages if basic misconfiguration has occurred.
  113497. */
  113498. warningEnable: boolean;
  113499. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113500. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113501. private _warningCounter;
  113502. private _warning;
  113503. }
  113504. }
  113505. declare module BABYLON {
  113506. /**
  113507. * Default Inputs manager for the FollowCamera.
  113508. * It groups all the default supported inputs for ease of use.
  113509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113510. */
  113511. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113512. /**
  113513. * Instantiates a new FollowCameraInputsManager.
  113514. * @param camera Defines the camera the inputs belong to
  113515. */
  113516. constructor(camera: FollowCamera);
  113517. /**
  113518. * Add keyboard input support to the input manager.
  113519. * @returns the current input manager
  113520. */
  113521. addKeyboard(): FollowCameraInputsManager;
  113522. /**
  113523. * Add mouse wheel input support to the input manager.
  113524. * @returns the current input manager
  113525. */
  113526. addMouseWheel(): FollowCameraInputsManager;
  113527. /**
  113528. * Add pointers input support to the input manager.
  113529. * @returns the current input manager
  113530. */
  113531. addPointers(): FollowCameraInputsManager;
  113532. /**
  113533. * Add orientation input support to the input manager.
  113534. * @returns the current input manager
  113535. */
  113536. addVRDeviceOrientation(): FollowCameraInputsManager;
  113537. }
  113538. }
  113539. declare module BABYLON {
  113540. /**
  113541. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113542. * an arc rotate version arcFollowCamera are available.
  113543. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113544. */
  113545. export class FollowCamera extends TargetCamera {
  113546. /**
  113547. * Distance the follow camera should follow an object at
  113548. */
  113549. radius: number;
  113550. /**
  113551. * Minimum allowed distance of the camera to the axis of rotation
  113552. * (The camera can not get closer).
  113553. * This can help limiting how the Camera is able to move in the scene.
  113554. */
  113555. lowerRadiusLimit: Nullable<number>;
  113556. /**
  113557. * Maximum allowed distance of the camera to the axis of rotation
  113558. * (The camera can not get further).
  113559. * This can help limiting how the Camera is able to move in the scene.
  113560. */
  113561. upperRadiusLimit: Nullable<number>;
  113562. /**
  113563. * Define a rotation offset between the camera and the object it follows
  113564. */
  113565. rotationOffset: number;
  113566. /**
  113567. * Minimum allowed angle to camera position relative to target object.
  113568. * This can help limiting how the Camera is able to move in the scene.
  113569. */
  113570. lowerRotationOffsetLimit: Nullable<number>;
  113571. /**
  113572. * Maximum allowed angle to camera position relative to target object.
  113573. * This can help limiting how the Camera is able to move in the scene.
  113574. */
  113575. upperRotationOffsetLimit: Nullable<number>;
  113576. /**
  113577. * Define a height offset between the camera and the object it follows.
  113578. * It can help following an object from the top (like a car chaing a plane)
  113579. */
  113580. heightOffset: number;
  113581. /**
  113582. * Minimum allowed height of camera position relative to target object.
  113583. * This can help limiting how the Camera is able to move in the scene.
  113584. */
  113585. lowerHeightOffsetLimit: Nullable<number>;
  113586. /**
  113587. * Maximum allowed height of camera position relative to target object.
  113588. * This can help limiting how the Camera is able to move in the scene.
  113589. */
  113590. upperHeightOffsetLimit: Nullable<number>;
  113591. /**
  113592. * Define how fast the camera can accelerate to follow it s target.
  113593. */
  113594. cameraAcceleration: number;
  113595. /**
  113596. * Define the speed limit of the camera following an object.
  113597. */
  113598. maxCameraSpeed: number;
  113599. /**
  113600. * Define the target of the camera.
  113601. */
  113602. lockedTarget: Nullable<AbstractMesh>;
  113603. /**
  113604. * Defines the input associated with the camera.
  113605. */
  113606. inputs: FollowCameraInputsManager;
  113607. /**
  113608. * Instantiates the follow camera.
  113609. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113610. * @param name Define the name of the camera in the scene
  113611. * @param position Define the position of the camera
  113612. * @param scene Define the scene the camera belong to
  113613. * @param lockedTarget Define the target of the camera
  113614. */
  113615. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113616. private _follow;
  113617. /**
  113618. * Attached controls to the current camera.
  113619. * @param element Defines the element the controls should be listened from
  113620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113621. */
  113622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113623. /**
  113624. * Detach the current controls from the camera.
  113625. * The camera will stop reacting to inputs.
  113626. * @param element Defines the element to stop listening the inputs from
  113627. */
  113628. detachControl(element: HTMLElement): void;
  113629. /** @hidden */
  113630. _checkInputs(): void;
  113631. private _checkLimits;
  113632. /**
  113633. * Gets the camera class name.
  113634. * @returns the class name
  113635. */
  113636. getClassName(): string;
  113637. }
  113638. /**
  113639. * Arc Rotate version of the follow camera.
  113640. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113641. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113642. */
  113643. export class ArcFollowCamera extends TargetCamera {
  113644. /** The longitudinal angle of the camera */
  113645. alpha: number;
  113646. /** The latitudinal angle of the camera */
  113647. beta: number;
  113648. /** The radius of the camera from its target */
  113649. radius: number;
  113650. /** Define the camera target (the messh it should follow) */
  113651. target: Nullable<AbstractMesh>;
  113652. private _cartesianCoordinates;
  113653. /**
  113654. * Instantiates a new ArcFollowCamera
  113655. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113656. * @param name Define the name of the camera
  113657. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113658. * @param beta Define the rotation angle of the camera around the elevation axis
  113659. * @param radius Define the radius of the camera from its target point
  113660. * @param target Define the target of the camera
  113661. * @param scene Define the scene the camera belongs to
  113662. */
  113663. constructor(name: string,
  113664. /** The longitudinal angle of the camera */
  113665. alpha: number,
  113666. /** The latitudinal angle of the camera */
  113667. beta: number,
  113668. /** The radius of the camera from its target */
  113669. radius: number,
  113670. /** Define the camera target (the messh it should follow) */
  113671. target: Nullable<AbstractMesh>, scene: Scene);
  113672. private _follow;
  113673. /** @hidden */
  113674. _checkInputs(): void;
  113675. /**
  113676. * Returns the class name of the object.
  113677. * It is mostly used internally for serialization purposes.
  113678. */
  113679. getClassName(): string;
  113680. }
  113681. }
  113682. declare module BABYLON {
  113683. /**
  113684. * Manage the keyboard inputs to control the movement of a follow camera.
  113685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113686. */
  113687. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113688. /**
  113689. * Defines the camera the input is attached to.
  113690. */
  113691. camera: FollowCamera;
  113692. /**
  113693. * Defines the list of key codes associated with the up action (increase heightOffset)
  113694. */
  113695. keysHeightOffsetIncr: number[];
  113696. /**
  113697. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113698. */
  113699. keysHeightOffsetDecr: number[];
  113700. /**
  113701. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113702. */
  113703. keysHeightOffsetModifierAlt: boolean;
  113704. /**
  113705. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113706. */
  113707. keysHeightOffsetModifierCtrl: boolean;
  113708. /**
  113709. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113710. */
  113711. keysHeightOffsetModifierShift: boolean;
  113712. /**
  113713. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113714. */
  113715. keysRotationOffsetIncr: number[];
  113716. /**
  113717. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113718. */
  113719. keysRotationOffsetDecr: number[];
  113720. /**
  113721. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113722. */
  113723. keysRotationOffsetModifierAlt: boolean;
  113724. /**
  113725. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113726. */
  113727. keysRotationOffsetModifierCtrl: boolean;
  113728. /**
  113729. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113730. */
  113731. keysRotationOffsetModifierShift: boolean;
  113732. /**
  113733. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113734. */
  113735. keysRadiusIncr: number[];
  113736. /**
  113737. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113738. */
  113739. keysRadiusDecr: number[];
  113740. /**
  113741. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113742. */
  113743. keysRadiusModifierAlt: boolean;
  113744. /**
  113745. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113746. */
  113747. keysRadiusModifierCtrl: boolean;
  113748. /**
  113749. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113750. */
  113751. keysRadiusModifierShift: boolean;
  113752. /**
  113753. * Defines the rate of change of heightOffset.
  113754. */
  113755. heightSensibility: number;
  113756. /**
  113757. * Defines the rate of change of rotationOffset.
  113758. */
  113759. rotationSensibility: number;
  113760. /**
  113761. * Defines the rate of change of radius.
  113762. */
  113763. radiusSensibility: number;
  113764. private _keys;
  113765. private _ctrlPressed;
  113766. private _altPressed;
  113767. private _shiftPressed;
  113768. private _onCanvasBlurObserver;
  113769. private _onKeyboardObserver;
  113770. private _engine;
  113771. private _scene;
  113772. /**
  113773. * Attach the input controls to a specific dom element to get the input from.
  113774. * @param element Defines the element the controls should be listened from
  113775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113776. */
  113777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113778. /**
  113779. * Detach the current controls from the specified dom element.
  113780. * @param element Defines the element to stop listening the inputs from
  113781. */
  113782. detachControl(element: Nullable<HTMLElement>): void;
  113783. /**
  113784. * Update the current camera state depending on the inputs that have been used this frame.
  113785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113786. */
  113787. checkInputs(): void;
  113788. /**
  113789. * Gets the class name of the current input.
  113790. * @returns the class name
  113791. */
  113792. getClassName(): string;
  113793. /**
  113794. * Get the friendly name associated with the input class.
  113795. * @returns the input friendly name
  113796. */
  113797. getSimpleName(): string;
  113798. /**
  113799. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113800. * allow modification of the heightOffset value.
  113801. */
  113802. private _modifierHeightOffset;
  113803. /**
  113804. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113805. * allow modification of the rotationOffset value.
  113806. */
  113807. private _modifierRotationOffset;
  113808. /**
  113809. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113810. * allow modification of the radius value.
  113811. */
  113812. private _modifierRadius;
  113813. }
  113814. }
  113815. declare module BABYLON {
  113816. interface FreeCameraInputsManager {
  113817. /**
  113818. * @hidden
  113819. */
  113820. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113821. /**
  113822. * Add orientation input support to the input manager.
  113823. * @returns the current input manager
  113824. */
  113825. addDeviceOrientation(): FreeCameraInputsManager;
  113826. }
  113827. /**
  113828. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113829. * Screen rotation is taken into account.
  113830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113831. */
  113832. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113833. private _camera;
  113834. private _screenOrientationAngle;
  113835. private _constantTranform;
  113836. private _screenQuaternion;
  113837. private _alpha;
  113838. private _beta;
  113839. private _gamma;
  113840. /**
  113841. * Can be used to detect if a device orientation sensor is available on a device
  113842. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113843. * @returns a promise that will resolve on orientation change
  113844. */
  113845. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113846. /**
  113847. * @hidden
  113848. */
  113849. _onDeviceOrientationChangedObservable: Observable<void>;
  113850. /**
  113851. * Instantiates a new input
  113852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113853. */
  113854. constructor();
  113855. /**
  113856. * Define the camera controlled by the input.
  113857. */
  113858. get camera(): FreeCamera;
  113859. set camera(camera: FreeCamera);
  113860. /**
  113861. * Attach the input controls to a specific dom element to get the input from.
  113862. * @param element Defines the element the controls should be listened from
  113863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113864. */
  113865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113866. private _orientationChanged;
  113867. private _deviceOrientation;
  113868. /**
  113869. * Detach the current controls from the specified dom element.
  113870. * @param element Defines the element to stop listening the inputs from
  113871. */
  113872. detachControl(element: Nullable<HTMLElement>): void;
  113873. /**
  113874. * Update the current camera state depending on the inputs that have been used this frame.
  113875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113876. */
  113877. checkInputs(): void;
  113878. /**
  113879. * Gets the class name of the current intput.
  113880. * @returns the class name
  113881. */
  113882. getClassName(): string;
  113883. /**
  113884. * Get the friendly name associated with the input class.
  113885. * @returns the input friendly name
  113886. */
  113887. getSimpleName(): string;
  113888. }
  113889. }
  113890. declare module BABYLON {
  113891. /**
  113892. * Manage the gamepad inputs to control a free camera.
  113893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113894. */
  113895. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113896. /**
  113897. * Define the camera the input is attached to.
  113898. */
  113899. camera: FreeCamera;
  113900. /**
  113901. * Define the Gamepad controlling the input
  113902. */
  113903. gamepad: Nullable<Gamepad>;
  113904. /**
  113905. * Defines the gamepad rotation sensiblity.
  113906. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113907. */
  113908. gamepadAngularSensibility: number;
  113909. /**
  113910. * Defines the gamepad move sensiblity.
  113911. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113912. */
  113913. gamepadMoveSensibility: number;
  113914. private _yAxisScale;
  113915. /**
  113916. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113917. */
  113918. get invertYAxis(): boolean;
  113919. set invertYAxis(value: boolean);
  113920. private _onGamepadConnectedObserver;
  113921. private _onGamepadDisconnectedObserver;
  113922. private _cameraTransform;
  113923. private _deltaTransform;
  113924. private _vector3;
  113925. private _vector2;
  113926. /**
  113927. * Attach the input controls to a specific dom element to get the input from.
  113928. * @param element Defines the element the controls should be listened from
  113929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113930. */
  113931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113932. /**
  113933. * Detach the current controls from the specified dom element.
  113934. * @param element Defines the element to stop listening the inputs from
  113935. */
  113936. detachControl(element: Nullable<HTMLElement>): void;
  113937. /**
  113938. * Update the current camera state depending on the inputs that have been used this frame.
  113939. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113940. */
  113941. checkInputs(): void;
  113942. /**
  113943. * Gets the class name of the current intput.
  113944. * @returns the class name
  113945. */
  113946. getClassName(): string;
  113947. /**
  113948. * Get the friendly name associated with the input class.
  113949. * @returns the input friendly name
  113950. */
  113951. getSimpleName(): string;
  113952. }
  113953. }
  113954. declare module BABYLON {
  113955. /**
  113956. * Defines the potential axis of a Joystick
  113957. */
  113958. export enum JoystickAxis {
  113959. /** X axis */
  113960. X = 0,
  113961. /** Y axis */
  113962. Y = 1,
  113963. /** Z axis */
  113964. Z = 2
  113965. }
  113966. /**
  113967. * Class used to define virtual joystick (used in touch mode)
  113968. */
  113969. export class VirtualJoystick {
  113970. /**
  113971. * Gets or sets a boolean indicating that left and right values must be inverted
  113972. */
  113973. reverseLeftRight: boolean;
  113974. /**
  113975. * Gets or sets a boolean indicating that up and down values must be inverted
  113976. */
  113977. reverseUpDown: boolean;
  113978. /**
  113979. * Gets the offset value for the position (ie. the change of the position value)
  113980. */
  113981. deltaPosition: Vector3;
  113982. /**
  113983. * Gets a boolean indicating if the virtual joystick was pressed
  113984. */
  113985. pressed: boolean;
  113986. /**
  113987. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113988. */
  113989. static Canvas: Nullable<HTMLCanvasElement>;
  113990. private static _globalJoystickIndex;
  113991. private static vjCanvasContext;
  113992. private static vjCanvasWidth;
  113993. private static vjCanvasHeight;
  113994. private static halfWidth;
  113995. private _action;
  113996. private _axisTargetedByLeftAndRight;
  113997. private _axisTargetedByUpAndDown;
  113998. private _joystickSensibility;
  113999. private _inversedSensibility;
  114000. private _joystickPointerID;
  114001. private _joystickColor;
  114002. private _joystickPointerPos;
  114003. private _joystickPreviousPointerPos;
  114004. private _joystickPointerStartPos;
  114005. private _deltaJoystickVector;
  114006. private _leftJoystick;
  114007. private _touches;
  114008. private _onPointerDownHandlerRef;
  114009. private _onPointerMoveHandlerRef;
  114010. private _onPointerUpHandlerRef;
  114011. private _onResize;
  114012. /**
  114013. * Creates a new virtual joystick
  114014. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114015. */
  114016. constructor(leftJoystick?: boolean);
  114017. /**
  114018. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114019. * @param newJoystickSensibility defines the new sensibility
  114020. */
  114021. setJoystickSensibility(newJoystickSensibility: number): void;
  114022. private _onPointerDown;
  114023. private _onPointerMove;
  114024. private _onPointerUp;
  114025. /**
  114026. * Change the color of the virtual joystick
  114027. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114028. */
  114029. setJoystickColor(newColor: string): void;
  114030. /**
  114031. * Defines a callback to call when the joystick is touched
  114032. * @param action defines the callback
  114033. */
  114034. setActionOnTouch(action: () => any): void;
  114035. /**
  114036. * Defines which axis you'd like to control for left & right
  114037. * @param axis defines the axis to use
  114038. */
  114039. setAxisForLeftRight(axis: JoystickAxis): void;
  114040. /**
  114041. * Defines which axis you'd like to control for up & down
  114042. * @param axis defines the axis to use
  114043. */
  114044. setAxisForUpDown(axis: JoystickAxis): void;
  114045. private _drawVirtualJoystick;
  114046. /**
  114047. * Release internal HTML canvas
  114048. */
  114049. releaseCanvas(): void;
  114050. }
  114051. }
  114052. declare module BABYLON {
  114053. interface FreeCameraInputsManager {
  114054. /**
  114055. * Add virtual joystick input support to the input manager.
  114056. * @returns the current input manager
  114057. */
  114058. addVirtualJoystick(): FreeCameraInputsManager;
  114059. }
  114060. /**
  114061. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114063. */
  114064. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114065. /**
  114066. * Defines the camera the input is attached to.
  114067. */
  114068. camera: FreeCamera;
  114069. private _leftjoystick;
  114070. private _rightjoystick;
  114071. /**
  114072. * Gets the left stick of the virtual joystick.
  114073. * @returns The virtual Joystick
  114074. */
  114075. getLeftJoystick(): VirtualJoystick;
  114076. /**
  114077. * Gets the right stick of the virtual joystick.
  114078. * @returns The virtual Joystick
  114079. */
  114080. getRightJoystick(): VirtualJoystick;
  114081. /**
  114082. * Update the current camera state depending on the inputs that have been used this frame.
  114083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114084. */
  114085. checkInputs(): void;
  114086. /**
  114087. * Attach the input controls to a specific dom element to get the input from.
  114088. * @param element Defines the element the controls should be listened from
  114089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114090. */
  114091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114092. /**
  114093. * Detach the current controls from the specified dom element.
  114094. * @param element Defines the element to stop listening the inputs from
  114095. */
  114096. detachControl(element: Nullable<HTMLElement>): void;
  114097. /**
  114098. * Gets the class name of the current intput.
  114099. * @returns the class name
  114100. */
  114101. getClassName(): string;
  114102. /**
  114103. * Get the friendly name associated with the input class.
  114104. * @returns the input friendly name
  114105. */
  114106. getSimpleName(): string;
  114107. }
  114108. }
  114109. declare module BABYLON {
  114110. /**
  114111. * This represents a FPS type of camera controlled by touch.
  114112. * This is like a universal camera minus the Gamepad controls.
  114113. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114114. */
  114115. export class TouchCamera extends FreeCamera {
  114116. /**
  114117. * Defines the touch sensibility for rotation.
  114118. * The higher the faster.
  114119. */
  114120. get touchAngularSensibility(): number;
  114121. set touchAngularSensibility(value: number);
  114122. /**
  114123. * Defines the touch sensibility for move.
  114124. * The higher the faster.
  114125. */
  114126. get touchMoveSensibility(): number;
  114127. set touchMoveSensibility(value: number);
  114128. /**
  114129. * Instantiates a new touch camera.
  114130. * This represents a FPS type of camera controlled by touch.
  114131. * This is like a universal camera minus the Gamepad controls.
  114132. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114133. * @param name Define the name of the camera in the scene
  114134. * @param position Define the start position of the camera in the scene
  114135. * @param scene Define the scene the camera belongs to
  114136. */
  114137. constructor(name: string, position: Vector3, scene: Scene);
  114138. /**
  114139. * Gets the current object class name.
  114140. * @return the class name
  114141. */
  114142. getClassName(): string;
  114143. /** @hidden */
  114144. _setupInputs(): void;
  114145. }
  114146. }
  114147. declare module BABYLON {
  114148. /**
  114149. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114150. * being tilted forward or back and left or right.
  114151. */
  114152. export class DeviceOrientationCamera extends FreeCamera {
  114153. private _initialQuaternion;
  114154. private _quaternionCache;
  114155. private _tmpDragQuaternion;
  114156. private _disablePointerInputWhenUsingDeviceOrientation;
  114157. /**
  114158. * Creates a new device orientation camera
  114159. * @param name The name of the camera
  114160. * @param position The start position camera
  114161. * @param scene The scene the camera belongs to
  114162. */
  114163. constructor(name: string, position: Vector3, scene: Scene);
  114164. /**
  114165. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114166. */
  114167. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114168. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114169. private _dragFactor;
  114170. /**
  114171. * Enabled turning on the y axis when the orientation sensor is active
  114172. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114173. */
  114174. enableHorizontalDragging(dragFactor?: number): void;
  114175. /**
  114176. * Gets the current instance class name ("DeviceOrientationCamera").
  114177. * This helps avoiding instanceof at run time.
  114178. * @returns the class name
  114179. */
  114180. getClassName(): string;
  114181. /**
  114182. * @hidden
  114183. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114184. */
  114185. _checkInputs(): void;
  114186. /**
  114187. * Reset the camera to its default orientation on the specified axis only.
  114188. * @param axis The axis to reset
  114189. */
  114190. resetToCurrentRotation(axis?: Axis): void;
  114191. }
  114192. }
  114193. declare module BABYLON {
  114194. /**
  114195. * Defines supported buttons for XBox360 compatible gamepads
  114196. */
  114197. export enum Xbox360Button {
  114198. /** A */
  114199. A = 0,
  114200. /** B */
  114201. B = 1,
  114202. /** X */
  114203. X = 2,
  114204. /** Y */
  114205. Y = 3,
  114206. /** Start */
  114207. Start = 4,
  114208. /** Back */
  114209. Back = 5,
  114210. /** Left button */
  114211. LB = 6,
  114212. /** Right button */
  114213. RB = 7,
  114214. /** Left stick */
  114215. LeftStick = 8,
  114216. /** Right stick */
  114217. RightStick = 9
  114218. }
  114219. /** Defines values for XBox360 DPad */
  114220. export enum Xbox360Dpad {
  114221. /** Up */
  114222. Up = 0,
  114223. /** Down */
  114224. Down = 1,
  114225. /** Left */
  114226. Left = 2,
  114227. /** Right */
  114228. Right = 3
  114229. }
  114230. /**
  114231. * Defines a XBox360 gamepad
  114232. */
  114233. export class Xbox360Pad extends Gamepad {
  114234. private _leftTrigger;
  114235. private _rightTrigger;
  114236. private _onlefttriggerchanged;
  114237. private _onrighttriggerchanged;
  114238. private _onbuttondown;
  114239. private _onbuttonup;
  114240. private _ondpaddown;
  114241. private _ondpadup;
  114242. /** Observable raised when a button is pressed */
  114243. onButtonDownObservable: Observable<Xbox360Button>;
  114244. /** Observable raised when a button is released */
  114245. onButtonUpObservable: Observable<Xbox360Button>;
  114246. /** Observable raised when a pad is pressed */
  114247. onPadDownObservable: Observable<Xbox360Dpad>;
  114248. /** Observable raised when a pad is released */
  114249. onPadUpObservable: Observable<Xbox360Dpad>;
  114250. private _buttonA;
  114251. private _buttonB;
  114252. private _buttonX;
  114253. private _buttonY;
  114254. private _buttonBack;
  114255. private _buttonStart;
  114256. private _buttonLB;
  114257. private _buttonRB;
  114258. private _buttonLeftStick;
  114259. private _buttonRightStick;
  114260. private _dPadUp;
  114261. private _dPadDown;
  114262. private _dPadLeft;
  114263. private _dPadRight;
  114264. private _isXboxOnePad;
  114265. /**
  114266. * Creates a new XBox360 gamepad object
  114267. * @param id defines the id of this gamepad
  114268. * @param index defines its index
  114269. * @param gamepad defines the internal HTML gamepad object
  114270. * @param xboxOne defines if it is a XBox One gamepad
  114271. */
  114272. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114273. /**
  114274. * Defines the callback to call when left trigger is pressed
  114275. * @param callback defines the callback to use
  114276. */
  114277. onlefttriggerchanged(callback: (value: number) => void): void;
  114278. /**
  114279. * Defines the callback to call when right trigger is pressed
  114280. * @param callback defines the callback to use
  114281. */
  114282. onrighttriggerchanged(callback: (value: number) => void): void;
  114283. /**
  114284. * Gets the left trigger value
  114285. */
  114286. get leftTrigger(): number;
  114287. /**
  114288. * Sets the left trigger value
  114289. */
  114290. set leftTrigger(newValue: number);
  114291. /**
  114292. * Gets the right trigger value
  114293. */
  114294. get rightTrigger(): number;
  114295. /**
  114296. * Sets the right trigger value
  114297. */
  114298. set rightTrigger(newValue: number);
  114299. /**
  114300. * Defines the callback to call when a button is pressed
  114301. * @param callback defines the callback to use
  114302. */
  114303. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114304. /**
  114305. * Defines the callback to call when a button is released
  114306. * @param callback defines the callback to use
  114307. */
  114308. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114309. /**
  114310. * Defines the callback to call when a pad is pressed
  114311. * @param callback defines the callback to use
  114312. */
  114313. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114314. /**
  114315. * Defines the callback to call when a pad is released
  114316. * @param callback defines the callback to use
  114317. */
  114318. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114319. private _setButtonValue;
  114320. private _setDPadValue;
  114321. /**
  114322. * Gets the value of the `A` button
  114323. */
  114324. get buttonA(): number;
  114325. /**
  114326. * Sets the value of the `A` button
  114327. */
  114328. set buttonA(value: number);
  114329. /**
  114330. * Gets the value of the `B` button
  114331. */
  114332. get buttonB(): number;
  114333. /**
  114334. * Sets the value of the `B` button
  114335. */
  114336. set buttonB(value: number);
  114337. /**
  114338. * Gets the value of the `X` button
  114339. */
  114340. get buttonX(): number;
  114341. /**
  114342. * Sets the value of the `X` button
  114343. */
  114344. set buttonX(value: number);
  114345. /**
  114346. * Gets the value of the `Y` button
  114347. */
  114348. get buttonY(): number;
  114349. /**
  114350. * Sets the value of the `Y` button
  114351. */
  114352. set buttonY(value: number);
  114353. /**
  114354. * Gets the value of the `Start` button
  114355. */
  114356. get buttonStart(): number;
  114357. /**
  114358. * Sets the value of the `Start` button
  114359. */
  114360. set buttonStart(value: number);
  114361. /**
  114362. * Gets the value of the `Back` button
  114363. */
  114364. get buttonBack(): number;
  114365. /**
  114366. * Sets the value of the `Back` button
  114367. */
  114368. set buttonBack(value: number);
  114369. /**
  114370. * Gets the value of the `Left` button
  114371. */
  114372. get buttonLB(): number;
  114373. /**
  114374. * Sets the value of the `Left` button
  114375. */
  114376. set buttonLB(value: number);
  114377. /**
  114378. * Gets the value of the `Right` button
  114379. */
  114380. get buttonRB(): number;
  114381. /**
  114382. * Sets the value of the `Right` button
  114383. */
  114384. set buttonRB(value: number);
  114385. /**
  114386. * Gets the value of the Left joystick
  114387. */
  114388. get buttonLeftStick(): number;
  114389. /**
  114390. * Sets the value of the Left joystick
  114391. */
  114392. set buttonLeftStick(value: number);
  114393. /**
  114394. * Gets the value of the Right joystick
  114395. */
  114396. get buttonRightStick(): number;
  114397. /**
  114398. * Sets the value of the Right joystick
  114399. */
  114400. set buttonRightStick(value: number);
  114401. /**
  114402. * Gets the value of D-pad up
  114403. */
  114404. get dPadUp(): number;
  114405. /**
  114406. * Sets the value of D-pad up
  114407. */
  114408. set dPadUp(value: number);
  114409. /**
  114410. * Gets the value of D-pad down
  114411. */
  114412. get dPadDown(): number;
  114413. /**
  114414. * Sets the value of D-pad down
  114415. */
  114416. set dPadDown(value: number);
  114417. /**
  114418. * Gets the value of D-pad left
  114419. */
  114420. get dPadLeft(): number;
  114421. /**
  114422. * Sets the value of D-pad left
  114423. */
  114424. set dPadLeft(value: number);
  114425. /**
  114426. * Gets the value of D-pad right
  114427. */
  114428. get dPadRight(): number;
  114429. /**
  114430. * Sets the value of D-pad right
  114431. */
  114432. set dPadRight(value: number);
  114433. /**
  114434. * Force the gamepad to synchronize with device values
  114435. */
  114436. update(): void;
  114437. /**
  114438. * Disposes the gamepad
  114439. */
  114440. dispose(): void;
  114441. }
  114442. }
  114443. declare module BABYLON {
  114444. /**
  114445. * Defines supported buttons for DualShock compatible gamepads
  114446. */
  114447. export enum DualShockButton {
  114448. /** Cross */
  114449. Cross = 0,
  114450. /** Circle */
  114451. Circle = 1,
  114452. /** Square */
  114453. Square = 2,
  114454. /** Triangle */
  114455. Triangle = 3,
  114456. /** Options */
  114457. Options = 4,
  114458. /** Share */
  114459. Share = 5,
  114460. /** L1 */
  114461. L1 = 6,
  114462. /** R1 */
  114463. R1 = 7,
  114464. /** Left stick */
  114465. LeftStick = 8,
  114466. /** Right stick */
  114467. RightStick = 9
  114468. }
  114469. /** Defines values for DualShock DPad */
  114470. export enum DualShockDpad {
  114471. /** Up */
  114472. Up = 0,
  114473. /** Down */
  114474. Down = 1,
  114475. /** Left */
  114476. Left = 2,
  114477. /** Right */
  114478. Right = 3
  114479. }
  114480. /**
  114481. * Defines a DualShock gamepad
  114482. */
  114483. export class DualShockPad extends Gamepad {
  114484. private _leftTrigger;
  114485. private _rightTrigger;
  114486. private _onlefttriggerchanged;
  114487. private _onrighttriggerchanged;
  114488. private _onbuttondown;
  114489. private _onbuttonup;
  114490. private _ondpaddown;
  114491. private _ondpadup;
  114492. /** Observable raised when a button is pressed */
  114493. onButtonDownObservable: Observable<DualShockButton>;
  114494. /** Observable raised when a button is released */
  114495. onButtonUpObservable: Observable<DualShockButton>;
  114496. /** Observable raised when a pad is pressed */
  114497. onPadDownObservable: Observable<DualShockDpad>;
  114498. /** Observable raised when a pad is released */
  114499. onPadUpObservable: Observable<DualShockDpad>;
  114500. private _buttonCross;
  114501. private _buttonCircle;
  114502. private _buttonSquare;
  114503. private _buttonTriangle;
  114504. private _buttonShare;
  114505. private _buttonOptions;
  114506. private _buttonL1;
  114507. private _buttonR1;
  114508. private _buttonLeftStick;
  114509. private _buttonRightStick;
  114510. private _dPadUp;
  114511. private _dPadDown;
  114512. private _dPadLeft;
  114513. private _dPadRight;
  114514. /**
  114515. * Creates a new DualShock gamepad object
  114516. * @param id defines the id of this gamepad
  114517. * @param index defines its index
  114518. * @param gamepad defines the internal HTML gamepad object
  114519. */
  114520. constructor(id: string, index: number, gamepad: any);
  114521. /**
  114522. * Defines the callback to call when left trigger is pressed
  114523. * @param callback defines the callback to use
  114524. */
  114525. onlefttriggerchanged(callback: (value: number) => void): void;
  114526. /**
  114527. * Defines the callback to call when right trigger is pressed
  114528. * @param callback defines the callback to use
  114529. */
  114530. onrighttriggerchanged(callback: (value: number) => void): void;
  114531. /**
  114532. * Gets the left trigger value
  114533. */
  114534. get leftTrigger(): number;
  114535. /**
  114536. * Sets the left trigger value
  114537. */
  114538. set leftTrigger(newValue: number);
  114539. /**
  114540. * Gets the right trigger value
  114541. */
  114542. get rightTrigger(): number;
  114543. /**
  114544. * Sets the right trigger value
  114545. */
  114546. set rightTrigger(newValue: number);
  114547. /**
  114548. * Defines the callback to call when a button is pressed
  114549. * @param callback defines the callback to use
  114550. */
  114551. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114552. /**
  114553. * Defines the callback to call when a button is released
  114554. * @param callback defines the callback to use
  114555. */
  114556. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114557. /**
  114558. * Defines the callback to call when a pad is pressed
  114559. * @param callback defines the callback to use
  114560. */
  114561. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114562. /**
  114563. * Defines the callback to call when a pad is released
  114564. * @param callback defines the callback to use
  114565. */
  114566. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114567. private _setButtonValue;
  114568. private _setDPadValue;
  114569. /**
  114570. * Gets the value of the `Cross` button
  114571. */
  114572. get buttonCross(): number;
  114573. /**
  114574. * Sets the value of the `Cross` button
  114575. */
  114576. set buttonCross(value: number);
  114577. /**
  114578. * Gets the value of the `Circle` button
  114579. */
  114580. get buttonCircle(): number;
  114581. /**
  114582. * Sets the value of the `Circle` button
  114583. */
  114584. set buttonCircle(value: number);
  114585. /**
  114586. * Gets the value of the `Square` button
  114587. */
  114588. get buttonSquare(): number;
  114589. /**
  114590. * Sets the value of the `Square` button
  114591. */
  114592. set buttonSquare(value: number);
  114593. /**
  114594. * Gets the value of the `Triangle` button
  114595. */
  114596. get buttonTriangle(): number;
  114597. /**
  114598. * Sets the value of the `Triangle` button
  114599. */
  114600. set buttonTriangle(value: number);
  114601. /**
  114602. * Gets the value of the `Options` button
  114603. */
  114604. get buttonOptions(): number;
  114605. /**
  114606. * Sets the value of the `Options` button
  114607. */
  114608. set buttonOptions(value: number);
  114609. /**
  114610. * Gets the value of the `Share` button
  114611. */
  114612. get buttonShare(): number;
  114613. /**
  114614. * Sets the value of the `Share` button
  114615. */
  114616. set buttonShare(value: number);
  114617. /**
  114618. * Gets the value of the `L1` button
  114619. */
  114620. get buttonL1(): number;
  114621. /**
  114622. * Sets the value of the `L1` button
  114623. */
  114624. set buttonL1(value: number);
  114625. /**
  114626. * Gets the value of the `R1` button
  114627. */
  114628. get buttonR1(): number;
  114629. /**
  114630. * Sets the value of the `R1` button
  114631. */
  114632. set buttonR1(value: number);
  114633. /**
  114634. * Gets the value of the Left joystick
  114635. */
  114636. get buttonLeftStick(): number;
  114637. /**
  114638. * Sets the value of the Left joystick
  114639. */
  114640. set buttonLeftStick(value: number);
  114641. /**
  114642. * Gets the value of the Right joystick
  114643. */
  114644. get buttonRightStick(): number;
  114645. /**
  114646. * Sets the value of the Right joystick
  114647. */
  114648. set buttonRightStick(value: number);
  114649. /**
  114650. * Gets the value of D-pad up
  114651. */
  114652. get dPadUp(): number;
  114653. /**
  114654. * Sets the value of D-pad up
  114655. */
  114656. set dPadUp(value: number);
  114657. /**
  114658. * Gets the value of D-pad down
  114659. */
  114660. get dPadDown(): number;
  114661. /**
  114662. * Sets the value of D-pad down
  114663. */
  114664. set dPadDown(value: number);
  114665. /**
  114666. * Gets the value of D-pad left
  114667. */
  114668. get dPadLeft(): number;
  114669. /**
  114670. * Sets the value of D-pad left
  114671. */
  114672. set dPadLeft(value: number);
  114673. /**
  114674. * Gets the value of D-pad right
  114675. */
  114676. get dPadRight(): number;
  114677. /**
  114678. * Sets the value of D-pad right
  114679. */
  114680. set dPadRight(value: number);
  114681. /**
  114682. * Force the gamepad to synchronize with device values
  114683. */
  114684. update(): void;
  114685. /**
  114686. * Disposes the gamepad
  114687. */
  114688. dispose(): void;
  114689. }
  114690. }
  114691. declare module BABYLON {
  114692. /**
  114693. * Manager for handling gamepads
  114694. */
  114695. export class GamepadManager {
  114696. private _scene?;
  114697. private _babylonGamepads;
  114698. private _oneGamepadConnected;
  114699. /** @hidden */
  114700. _isMonitoring: boolean;
  114701. private _gamepadEventSupported;
  114702. private _gamepadSupport?;
  114703. /**
  114704. * observable to be triggered when the gamepad controller has been connected
  114705. */
  114706. onGamepadConnectedObservable: Observable<Gamepad>;
  114707. /**
  114708. * observable to be triggered when the gamepad controller has been disconnected
  114709. */
  114710. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114711. private _onGamepadConnectedEvent;
  114712. private _onGamepadDisconnectedEvent;
  114713. /**
  114714. * Initializes the gamepad manager
  114715. * @param _scene BabylonJS scene
  114716. */
  114717. constructor(_scene?: Scene | undefined);
  114718. /**
  114719. * The gamepads in the game pad manager
  114720. */
  114721. get gamepads(): Gamepad[];
  114722. /**
  114723. * Get the gamepad controllers based on type
  114724. * @param type The type of gamepad controller
  114725. * @returns Nullable gamepad
  114726. */
  114727. getGamepadByType(type?: number): Nullable<Gamepad>;
  114728. /**
  114729. * Disposes the gamepad manager
  114730. */
  114731. dispose(): void;
  114732. private _addNewGamepad;
  114733. private _startMonitoringGamepads;
  114734. private _stopMonitoringGamepads;
  114735. /** @hidden */
  114736. _checkGamepadsStatus(): void;
  114737. private _updateGamepadObjects;
  114738. }
  114739. }
  114740. declare module BABYLON {
  114741. interface Scene {
  114742. /** @hidden */
  114743. _gamepadManager: Nullable<GamepadManager>;
  114744. /**
  114745. * Gets the gamepad manager associated with the scene
  114746. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114747. */
  114748. gamepadManager: GamepadManager;
  114749. }
  114750. /**
  114751. * Interface representing a free camera inputs manager
  114752. */
  114753. interface FreeCameraInputsManager {
  114754. /**
  114755. * Adds gamepad input support to the FreeCameraInputsManager.
  114756. * @returns the FreeCameraInputsManager
  114757. */
  114758. addGamepad(): FreeCameraInputsManager;
  114759. }
  114760. /**
  114761. * Interface representing an arc rotate camera inputs manager
  114762. */
  114763. interface ArcRotateCameraInputsManager {
  114764. /**
  114765. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114766. * @returns the camera inputs manager
  114767. */
  114768. addGamepad(): ArcRotateCameraInputsManager;
  114769. }
  114770. /**
  114771. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114772. */
  114773. export class GamepadSystemSceneComponent implements ISceneComponent {
  114774. /**
  114775. * The component name helpfull to identify the component in the list of scene components.
  114776. */
  114777. readonly name: string;
  114778. /**
  114779. * The scene the component belongs to.
  114780. */
  114781. scene: Scene;
  114782. /**
  114783. * Creates a new instance of the component for the given scene
  114784. * @param scene Defines the scene to register the component in
  114785. */
  114786. constructor(scene: Scene);
  114787. /**
  114788. * Registers the component in a given scene
  114789. */
  114790. register(): void;
  114791. /**
  114792. * Rebuilds the elements related to this component in case of
  114793. * context lost for instance.
  114794. */
  114795. rebuild(): void;
  114796. /**
  114797. * Disposes the component and the associated ressources
  114798. */
  114799. dispose(): void;
  114800. private _beforeCameraUpdate;
  114801. }
  114802. }
  114803. declare module BABYLON {
  114804. /**
  114805. * 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,
  114806. * which still works and will still be found in many Playgrounds.
  114807. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114808. */
  114809. export class UniversalCamera extends TouchCamera {
  114810. /**
  114811. * Defines the gamepad rotation sensiblity.
  114812. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114813. */
  114814. get gamepadAngularSensibility(): number;
  114815. set gamepadAngularSensibility(value: number);
  114816. /**
  114817. * Defines the gamepad move sensiblity.
  114818. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114819. */
  114820. get gamepadMoveSensibility(): number;
  114821. set gamepadMoveSensibility(value: number);
  114822. /**
  114823. * 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,
  114824. * which still works and will still be found in many Playgrounds.
  114825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114826. * @param name Define the name of the camera in the scene
  114827. * @param position Define the start position of the camera in the scene
  114828. * @param scene Define the scene the camera belongs to
  114829. */
  114830. constructor(name: string, position: Vector3, scene: Scene);
  114831. /**
  114832. * Gets the current object class name.
  114833. * @return the class name
  114834. */
  114835. getClassName(): string;
  114836. }
  114837. }
  114838. declare module BABYLON {
  114839. /**
  114840. * This represents a FPS type of camera. This is only here for back compat purpose.
  114841. * Please use the UniversalCamera instead as both are identical.
  114842. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114843. */
  114844. export class GamepadCamera extends UniversalCamera {
  114845. /**
  114846. * Instantiates a new Gamepad Camera
  114847. * This represents a FPS type of camera. This is only here for back compat purpose.
  114848. * Please use the UniversalCamera instead as both are identical.
  114849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114850. * @param name Define the name of the camera in the scene
  114851. * @param position Define the start position of the camera in the scene
  114852. * @param scene Define the scene the camera belongs to
  114853. */
  114854. constructor(name: string, position: Vector3, scene: Scene);
  114855. /**
  114856. * Gets the current object class name.
  114857. * @return the class name
  114858. */
  114859. getClassName(): string;
  114860. }
  114861. }
  114862. declare module BABYLON {
  114863. /** @hidden */
  114864. export var passPixelShader: {
  114865. name: string;
  114866. shader: string;
  114867. };
  114868. }
  114869. declare module BABYLON {
  114870. /** @hidden */
  114871. export var passCubePixelShader: {
  114872. name: string;
  114873. shader: string;
  114874. };
  114875. }
  114876. declare module BABYLON {
  114877. /**
  114878. * PassPostProcess which produces an output the same as it's input
  114879. */
  114880. export class PassPostProcess extends PostProcess {
  114881. /**
  114882. * Creates the PassPostProcess
  114883. * @param name The name of the effect.
  114884. * @param options The required width/height ratio to downsize to before computing the render pass.
  114885. * @param camera The camera to apply the render pass to.
  114886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114887. * @param engine The engine which the post process will be applied. (default: current engine)
  114888. * @param reusable If the post process can be reused on the same frame. (default: false)
  114889. * @param textureType The type of texture to be used when performing the post processing.
  114890. * @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)
  114891. */
  114892. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114893. }
  114894. /**
  114895. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114896. */
  114897. export class PassCubePostProcess extends PostProcess {
  114898. private _face;
  114899. /**
  114900. * Gets or sets the cube face to display.
  114901. * * 0 is +X
  114902. * * 1 is -X
  114903. * * 2 is +Y
  114904. * * 3 is -Y
  114905. * * 4 is +Z
  114906. * * 5 is -Z
  114907. */
  114908. get face(): number;
  114909. set face(value: number);
  114910. /**
  114911. * Creates the PassCubePostProcess
  114912. * @param name The name of the effect.
  114913. * @param options The required width/height ratio to downsize to before computing the render pass.
  114914. * @param camera The camera to apply the render pass to.
  114915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114916. * @param engine The engine which the post process will be applied. (default: current engine)
  114917. * @param reusable If the post process can be reused on the same frame. (default: false)
  114918. * @param textureType The type of texture to be used when performing the post processing.
  114919. * @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)
  114920. */
  114921. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114922. }
  114923. }
  114924. declare module BABYLON {
  114925. /** @hidden */
  114926. export var anaglyphPixelShader: {
  114927. name: string;
  114928. shader: string;
  114929. };
  114930. }
  114931. declare module BABYLON {
  114932. /**
  114933. * Postprocess used to generate anaglyphic rendering
  114934. */
  114935. export class AnaglyphPostProcess extends PostProcess {
  114936. private _passedProcess;
  114937. /**
  114938. * Creates a new AnaglyphPostProcess
  114939. * @param name defines postprocess name
  114940. * @param options defines creation options or target ratio scale
  114941. * @param rigCameras defines cameras using this postprocess
  114942. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114943. * @param engine defines hosting engine
  114944. * @param reusable defines if the postprocess will be reused multiple times per frame
  114945. */
  114946. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114947. }
  114948. }
  114949. declare module BABYLON {
  114950. /**
  114951. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114952. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114953. */
  114954. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114955. /**
  114956. * Creates a new AnaglyphArcRotateCamera
  114957. * @param name defines camera name
  114958. * @param alpha defines alpha angle (in radians)
  114959. * @param beta defines beta angle (in radians)
  114960. * @param radius defines radius
  114961. * @param target defines camera target
  114962. * @param interaxialDistance defines distance between each color axis
  114963. * @param scene defines the hosting scene
  114964. */
  114965. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114966. /**
  114967. * Gets camera class name
  114968. * @returns AnaglyphArcRotateCamera
  114969. */
  114970. getClassName(): string;
  114971. }
  114972. }
  114973. declare module BABYLON {
  114974. /**
  114975. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114976. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114977. */
  114978. export class AnaglyphFreeCamera extends FreeCamera {
  114979. /**
  114980. * Creates a new AnaglyphFreeCamera
  114981. * @param name defines camera name
  114982. * @param position defines initial position
  114983. * @param interaxialDistance defines distance between each color axis
  114984. * @param scene defines the hosting scene
  114985. */
  114986. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114987. /**
  114988. * Gets camera class name
  114989. * @returns AnaglyphFreeCamera
  114990. */
  114991. getClassName(): string;
  114992. }
  114993. }
  114994. declare module BABYLON {
  114995. /**
  114996. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114997. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114998. */
  114999. export class AnaglyphGamepadCamera extends GamepadCamera {
  115000. /**
  115001. * Creates a new AnaglyphGamepadCamera
  115002. * @param name defines camera name
  115003. * @param position defines initial position
  115004. * @param interaxialDistance defines distance between each color axis
  115005. * @param scene defines the hosting scene
  115006. */
  115007. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115008. /**
  115009. * Gets camera class name
  115010. * @returns AnaglyphGamepadCamera
  115011. */
  115012. getClassName(): string;
  115013. }
  115014. }
  115015. declare module BABYLON {
  115016. /**
  115017. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115018. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115019. */
  115020. export class AnaglyphUniversalCamera extends UniversalCamera {
  115021. /**
  115022. * Creates a new AnaglyphUniversalCamera
  115023. * @param name defines camera name
  115024. * @param position defines initial position
  115025. * @param interaxialDistance defines distance between each color axis
  115026. * @param scene defines the hosting scene
  115027. */
  115028. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115029. /**
  115030. * Gets camera class name
  115031. * @returns AnaglyphUniversalCamera
  115032. */
  115033. getClassName(): string;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /** @hidden */
  115038. export var stereoscopicInterlacePixelShader: {
  115039. name: string;
  115040. shader: string;
  115041. };
  115042. }
  115043. declare module BABYLON {
  115044. /**
  115045. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115046. */
  115047. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115048. private _stepSize;
  115049. private _passedProcess;
  115050. /**
  115051. * Initializes a StereoscopicInterlacePostProcessI
  115052. * @param name The name of the effect.
  115053. * @param rigCameras The rig cameras to be appled to the post process
  115054. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115055. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115057. * @param engine The engine which the post process will be applied. (default: current engine)
  115058. * @param reusable If the post process can be reused on the same frame. (default: false)
  115059. */
  115060. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115061. }
  115062. /**
  115063. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115064. */
  115065. export class StereoscopicInterlacePostProcess extends PostProcess {
  115066. private _stepSize;
  115067. private _passedProcess;
  115068. /**
  115069. * Initializes a StereoscopicInterlacePostProcess
  115070. * @param name The name of the effect.
  115071. * @param rigCameras The rig cameras to be appled to the post process
  115072. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  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. */
  115077. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115078. }
  115079. }
  115080. declare module BABYLON {
  115081. /**
  115082. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115083. * @see http://doc.babylonjs.com/features/cameras
  115084. */
  115085. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115086. /**
  115087. * Creates a new StereoscopicArcRotateCamera
  115088. * @param name defines camera name
  115089. * @param alpha defines alpha angle (in radians)
  115090. * @param beta defines beta angle (in radians)
  115091. * @param radius defines radius
  115092. * @param target defines camera target
  115093. * @param interaxialDistance defines distance between each color axis
  115094. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115095. * @param scene defines the hosting scene
  115096. */
  115097. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115098. /**
  115099. * Gets camera class name
  115100. * @returns StereoscopicArcRotateCamera
  115101. */
  115102. getClassName(): string;
  115103. }
  115104. }
  115105. declare module BABYLON {
  115106. /**
  115107. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115108. * @see http://doc.babylonjs.com/features/cameras
  115109. */
  115110. export class StereoscopicFreeCamera extends FreeCamera {
  115111. /**
  115112. * Creates a new StereoscopicFreeCamera
  115113. * @param name defines camera name
  115114. * @param position defines initial position
  115115. * @param interaxialDistance defines distance between each color axis
  115116. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115117. * @param scene defines the hosting scene
  115118. */
  115119. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115120. /**
  115121. * Gets camera class name
  115122. * @returns StereoscopicFreeCamera
  115123. */
  115124. getClassName(): string;
  115125. }
  115126. }
  115127. declare module BABYLON {
  115128. /**
  115129. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115130. * @see http://doc.babylonjs.com/features/cameras
  115131. */
  115132. export class StereoscopicGamepadCamera extends GamepadCamera {
  115133. /**
  115134. * Creates a new StereoscopicGamepadCamera
  115135. * @param name defines camera name
  115136. * @param position defines initial position
  115137. * @param interaxialDistance defines distance between each color axis
  115138. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115139. * @param scene defines the hosting scene
  115140. */
  115141. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115142. /**
  115143. * Gets camera class name
  115144. * @returns StereoscopicGamepadCamera
  115145. */
  115146. getClassName(): string;
  115147. }
  115148. }
  115149. declare module BABYLON {
  115150. /**
  115151. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115152. * @see http://doc.babylonjs.com/features/cameras
  115153. */
  115154. export class StereoscopicUniversalCamera extends UniversalCamera {
  115155. /**
  115156. * Creates a new StereoscopicUniversalCamera
  115157. * @param name defines camera name
  115158. * @param position defines initial position
  115159. * @param interaxialDistance defines distance between each color axis
  115160. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115161. * @param scene defines the hosting scene
  115162. */
  115163. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115164. /**
  115165. * Gets camera class name
  115166. * @returns StereoscopicUniversalCamera
  115167. */
  115168. getClassName(): string;
  115169. }
  115170. }
  115171. declare module BABYLON {
  115172. /**
  115173. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115174. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115175. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115176. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115177. */
  115178. export class VirtualJoysticksCamera extends FreeCamera {
  115179. /**
  115180. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115181. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115182. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115183. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115184. * @param name Define the name of the camera in the scene
  115185. * @param position Define the start position of the camera in the scene
  115186. * @param scene Define the scene the camera belongs to
  115187. */
  115188. constructor(name: string, position: Vector3, scene: Scene);
  115189. /**
  115190. * Gets the current object class name.
  115191. * @return the class name
  115192. */
  115193. getClassName(): string;
  115194. }
  115195. }
  115196. declare module BABYLON {
  115197. /**
  115198. * This represents all the required metrics to create a VR camera.
  115199. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115200. */
  115201. export class VRCameraMetrics {
  115202. /**
  115203. * Define the horizontal resolution off the screen.
  115204. */
  115205. hResolution: number;
  115206. /**
  115207. * Define the vertical resolution off the screen.
  115208. */
  115209. vResolution: number;
  115210. /**
  115211. * Define the horizontal screen size.
  115212. */
  115213. hScreenSize: number;
  115214. /**
  115215. * Define the vertical screen size.
  115216. */
  115217. vScreenSize: number;
  115218. /**
  115219. * Define the vertical screen center position.
  115220. */
  115221. vScreenCenter: number;
  115222. /**
  115223. * Define the distance of the eyes to the screen.
  115224. */
  115225. eyeToScreenDistance: number;
  115226. /**
  115227. * Define the distance between both lenses
  115228. */
  115229. lensSeparationDistance: number;
  115230. /**
  115231. * Define the distance between both viewer's eyes.
  115232. */
  115233. interpupillaryDistance: number;
  115234. /**
  115235. * Define the distortion factor of the VR postprocess.
  115236. * Please, touch with care.
  115237. */
  115238. distortionK: number[];
  115239. /**
  115240. * Define the chromatic aberration correction factors for the VR post process.
  115241. */
  115242. chromaAbCorrection: number[];
  115243. /**
  115244. * Define the scale factor of the post process.
  115245. * The smaller the better but the slower.
  115246. */
  115247. postProcessScaleFactor: number;
  115248. /**
  115249. * Define an offset for the lens center.
  115250. */
  115251. lensCenterOffset: number;
  115252. /**
  115253. * Define if the current vr camera should compensate the distortion of the lense or not.
  115254. */
  115255. compensateDistortion: boolean;
  115256. /**
  115257. * Defines if multiview should be enabled when rendering (Default: false)
  115258. */
  115259. multiviewEnabled: boolean;
  115260. /**
  115261. * Gets the rendering aspect ratio based on the provided resolutions.
  115262. */
  115263. get aspectRatio(): number;
  115264. /**
  115265. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115266. */
  115267. get aspectRatioFov(): number;
  115268. /**
  115269. * @hidden
  115270. */
  115271. get leftHMatrix(): Matrix;
  115272. /**
  115273. * @hidden
  115274. */
  115275. get rightHMatrix(): Matrix;
  115276. /**
  115277. * @hidden
  115278. */
  115279. get leftPreViewMatrix(): Matrix;
  115280. /**
  115281. * @hidden
  115282. */
  115283. get rightPreViewMatrix(): Matrix;
  115284. /**
  115285. * Get the default VRMetrics based on the most generic setup.
  115286. * @returns the default vr metrics
  115287. */
  115288. static GetDefault(): VRCameraMetrics;
  115289. }
  115290. }
  115291. declare module BABYLON {
  115292. /** @hidden */
  115293. export var vrDistortionCorrectionPixelShader: {
  115294. name: string;
  115295. shader: string;
  115296. };
  115297. }
  115298. declare module BABYLON {
  115299. /**
  115300. * VRDistortionCorrectionPostProcess used for mobile VR
  115301. */
  115302. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115303. private _isRightEye;
  115304. private _distortionFactors;
  115305. private _postProcessScaleFactor;
  115306. private _lensCenterOffset;
  115307. private _scaleIn;
  115308. private _scaleFactor;
  115309. private _lensCenter;
  115310. /**
  115311. * Initializes the VRDistortionCorrectionPostProcess
  115312. * @param name The name of the effect.
  115313. * @param camera The camera to apply the render pass to.
  115314. * @param isRightEye If this is for the right eye distortion
  115315. * @param vrMetrics All the required metrics for the VR camera
  115316. */
  115317. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115318. }
  115319. }
  115320. declare module BABYLON {
  115321. /**
  115322. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115323. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115324. */
  115325. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115326. /**
  115327. * Creates a new VRDeviceOrientationArcRotateCamera
  115328. * @param name defines camera name
  115329. * @param alpha defines the camera rotation along the logitudinal axis
  115330. * @param beta defines the camera rotation along the latitudinal axis
  115331. * @param radius defines the camera distance from its target
  115332. * @param target defines the camera target
  115333. * @param scene defines the scene the camera belongs to
  115334. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115335. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115336. */
  115337. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115338. /**
  115339. * Gets camera class name
  115340. * @returns VRDeviceOrientationArcRotateCamera
  115341. */
  115342. getClassName(): string;
  115343. }
  115344. }
  115345. declare module BABYLON {
  115346. /**
  115347. * Camera used to simulate VR rendering (based on FreeCamera)
  115348. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115349. */
  115350. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115351. /**
  115352. * Creates a new VRDeviceOrientationFreeCamera
  115353. * @param name defines camera name
  115354. * @param position defines the start position of the camera
  115355. * @param scene defines the scene the camera belongs to
  115356. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115357. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115358. */
  115359. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115360. /**
  115361. * Gets camera class name
  115362. * @returns VRDeviceOrientationFreeCamera
  115363. */
  115364. getClassName(): string;
  115365. }
  115366. }
  115367. declare module BABYLON {
  115368. /**
  115369. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115370. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115371. */
  115372. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115373. /**
  115374. * Creates a new VRDeviceOrientationGamepadCamera
  115375. * @param name defines camera name
  115376. * @param position defines the start position of the camera
  115377. * @param scene defines the scene the camera belongs to
  115378. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115379. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115380. */
  115381. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115382. /**
  115383. * Gets camera class name
  115384. * @returns VRDeviceOrientationGamepadCamera
  115385. */
  115386. getClassName(): string;
  115387. }
  115388. }
  115389. declare module BABYLON {
  115390. /** @hidden */
  115391. export var imageProcessingPixelShader: {
  115392. name: string;
  115393. shader: string;
  115394. };
  115395. }
  115396. declare module BABYLON {
  115397. /**
  115398. * ImageProcessingPostProcess
  115399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115400. */
  115401. export class ImageProcessingPostProcess extends PostProcess {
  115402. /**
  115403. * Default configuration related to image processing available in the PBR Material.
  115404. */
  115405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115406. /**
  115407. * Gets the image processing configuration used either in this material.
  115408. */
  115409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115410. /**
  115411. * Sets the Default image processing configuration used either in the this material.
  115412. *
  115413. * If sets to null, the scene one is in use.
  115414. */
  115415. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115416. /**
  115417. * Keep track of the image processing observer to allow dispose and replace.
  115418. */
  115419. private _imageProcessingObserver;
  115420. /**
  115421. * Attaches a new image processing configuration to the PBR Material.
  115422. * @param configuration
  115423. */
  115424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115425. /**
  115426. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115427. */
  115428. get colorCurves(): Nullable<ColorCurves>;
  115429. /**
  115430. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115431. */
  115432. set colorCurves(value: Nullable<ColorCurves>);
  115433. /**
  115434. * Gets wether the color curves effect is enabled.
  115435. */
  115436. get colorCurvesEnabled(): boolean;
  115437. /**
  115438. * Sets wether the color curves effect is enabled.
  115439. */
  115440. set colorCurvesEnabled(value: boolean);
  115441. /**
  115442. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115443. */
  115444. get colorGradingTexture(): Nullable<BaseTexture>;
  115445. /**
  115446. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115447. */
  115448. set colorGradingTexture(value: Nullable<BaseTexture>);
  115449. /**
  115450. * Gets wether the color grading effect is enabled.
  115451. */
  115452. get colorGradingEnabled(): boolean;
  115453. /**
  115454. * Gets wether the color grading effect is enabled.
  115455. */
  115456. set colorGradingEnabled(value: boolean);
  115457. /**
  115458. * Gets exposure used in the effect.
  115459. */
  115460. get exposure(): number;
  115461. /**
  115462. * Sets exposure used in the effect.
  115463. */
  115464. set exposure(value: number);
  115465. /**
  115466. * Gets wether tonemapping is enabled or not.
  115467. */
  115468. get toneMappingEnabled(): boolean;
  115469. /**
  115470. * Sets wether tonemapping is enabled or not
  115471. */
  115472. set toneMappingEnabled(value: boolean);
  115473. /**
  115474. * Gets the type of tone mapping effect.
  115475. */
  115476. get toneMappingType(): number;
  115477. /**
  115478. * Sets the type of tone mapping effect.
  115479. */
  115480. set toneMappingType(value: number);
  115481. /**
  115482. * Gets contrast used in the effect.
  115483. */
  115484. get contrast(): number;
  115485. /**
  115486. * Sets contrast used in the effect.
  115487. */
  115488. set contrast(value: number);
  115489. /**
  115490. * Gets Vignette stretch size.
  115491. */
  115492. get vignetteStretch(): number;
  115493. /**
  115494. * Sets Vignette stretch size.
  115495. */
  115496. set vignetteStretch(value: number);
  115497. /**
  115498. * Gets Vignette centre X Offset.
  115499. */
  115500. get vignetteCentreX(): number;
  115501. /**
  115502. * Sets Vignette centre X Offset.
  115503. */
  115504. set vignetteCentreX(value: number);
  115505. /**
  115506. * Gets Vignette centre Y Offset.
  115507. */
  115508. get vignetteCentreY(): number;
  115509. /**
  115510. * Sets Vignette centre Y Offset.
  115511. */
  115512. set vignetteCentreY(value: number);
  115513. /**
  115514. * Gets Vignette weight or intensity of the vignette effect.
  115515. */
  115516. get vignetteWeight(): number;
  115517. /**
  115518. * Sets Vignette weight or intensity of the vignette effect.
  115519. */
  115520. set vignetteWeight(value: number);
  115521. /**
  115522. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115523. * if vignetteEnabled is set to true.
  115524. */
  115525. get vignetteColor(): Color4;
  115526. /**
  115527. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115528. * if vignetteEnabled is set to true.
  115529. */
  115530. set vignetteColor(value: Color4);
  115531. /**
  115532. * Gets Camera field of view used by the Vignette effect.
  115533. */
  115534. get vignetteCameraFov(): number;
  115535. /**
  115536. * Sets Camera field of view used by the Vignette effect.
  115537. */
  115538. set vignetteCameraFov(value: number);
  115539. /**
  115540. * Gets the vignette blend mode allowing different kind of effect.
  115541. */
  115542. get vignetteBlendMode(): number;
  115543. /**
  115544. * Sets the vignette blend mode allowing different kind of effect.
  115545. */
  115546. set vignetteBlendMode(value: number);
  115547. /**
  115548. * Gets wether the vignette effect is enabled.
  115549. */
  115550. get vignetteEnabled(): boolean;
  115551. /**
  115552. * Sets wether the vignette effect is enabled.
  115553. */
  115554. set vignetteEnabled(value: boolean);
  115555. private _fromLinearSpace;
  115556. /**
  115557. * Gets wether the input of the processing is in Gamma or Linear Space.
  115558. */
  115559. get fromLinearSpace(): boolean;
  115560. /**
  115561. * Sets wether the input of the processing is in Gamma or Linear Space.
  115562. */
  115563. set fromLinearSpace(value: boolean);
  115564. /**
  115565. * Defines cache preventing GC.
  115566. */
  115567. private _defines;
  115568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115569. /**
  115570. * "ImageProcessingPostProcess"
  115571. * @returns "ImageProcessingPostProcess"
  115572. */
  115573. getClassName(): string;
  115574. protected _updateParameters(): void;
  115575. dispose(camera?: Camera): void;
  115576. }
  115577. }
  115578. declare module BABYLON {
  115579. /**
  115580. * Class containing static functions to help procedurally build meshes
  115581. */
  115582. export class GroundBuilder {
  115583. /**
  115584. * Creates a ground mesh
  115585. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115586. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115588. * @param name defines the name of the mesh
  115589. * @param options defines the options used to create the mesh
  115590. * @param scene defines the hosting scene
  115591. * @returns the ground mesh
  115592. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115593. */
  115594. static CreateGround(name: string, options: {
  115595. width?: number;
  115596. height?: number;
  115597. subdivisions?: number;
  115598. subdivisionsX?: number;
  115599. subdivisionsY?: number;
  115600. updatable?: boolean;
  115601. }, scene: any): Mesh;
  115602. /**
  115603. * Creates a tiled ground mesh
  115604. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115605. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115606. * * 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
  115607. * * 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
  115608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115609. * @param name defines the name of the mesh
  115610. * @param options defines the options used to create the mesh
  115611. * @param scene defines the hosting scene
  115612. * @returns the tiled ground mesh
  115613. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115614. */
  115615. static CreateTiledGround(name: string, options: {
  115616. xmin: number;
  115617. zmin: number;
  115618. xmax: number;
  115619. zmax: number;
  115620. subdivisions?: {
  115621. w: number;
  115622. h: number;
  115623. };
  115624. precision?: {
  115625. w: number;
  115626. h: number;
  115627. };
  115628. updatable?: boolean;
  115629. }, scene?: Nullable<Scene>): Mesh;
  115630. /**
  115631. * Creates a ground mesh from a height map
  115632. * * The parameter `url` sets the URL of the height map image resource.
  115633. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115634. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115635. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115636. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115637. * * 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.
  115638. * * 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).
  115639. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115641. * @param name defines the name of the mesh
  115642. * @param url defines the url to the height map
  115643. * @param options defines the options used to create the mesh
  115644. * @param scene defines the hosting scene
  115645. * @returns the ground mesh
  115646. * @see https://doc.babylonjs.com/babylon101/height_map
  115647. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115648. */
  115649. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115650. width?: number;
  115651. height?: number;
  115652. subdivisions?: number;
  115653. minHeight?: number;
  115654. maxHeight?: number;
  115655. colorFilter?: Color3;
  115656. alphaFilter?: number;
  115657. updatable?: boolean;
  115658. onReady?: (mesh: GroundMesh) => void;
  115659. }, scene?: Nullable<Scene>): GroundMesh;
  115660. }
  115661. }
  115662. declare module BABYLON {
  115663. /**
  115664. * Class containing static functions to help procedurally build meshes
  115665. */
  115666. export class TorusBuilder {
  115667. /**
  115668. * Creates a torus mesh
  115669. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115670. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115671. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115675. * @param name defines the name of the mesh
  115676. * @param options defines the options used to create the mesh
  115677. * @param scene defines the hosting scene
  115678. * @returns the torus mesh
  115679. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115680. */
  115681. static CreateTorus(name: string, options: {
  115682. diameter?: number;
  115683. thickness?: number;
  115684. tessellation?: number;
  115685. updatable?: boolean;
  115686. sideOrientation?: number;
  115687. frontUVs?: Vector4;
  115688. backUVs?: Vector4;
  115689. }, scene: any): Mesh;
  115690. }
  115691. }
  115692. declare module BABYLON {
  115693. /**
  115694. * Class containing static functions to help procedurally build meshes
  115695. */
  115696. export class CylinderBuilder {
  115697. /**
  115698. * Creates a cylinder or a cone mesh
  115699. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115700. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115701. * * 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.
  115702. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115703. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115704. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115705. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115706. * * 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).
  115707. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115708. * * 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).
  115709. * * 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
  115710. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115711. * * 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
  115712. * * 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.
  115713. * * If `enclose` is false, a ring surface is one element.
  115714. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115715. * * 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
  115716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115719. * @param name defines the name of the mesh
  115720. * @param options defines the options used to create the mesh
  115721. * @param scene defines the hosting scene
  115722. * @returns the cylinder mesh
  115723. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115724. */
  115725. static CreateCylinder(name: string, options: {
  115726. height?: number;
  115727. diameterTop?: number;
  115728. diameterBottom?: number;
  115729. diameter?: number;
  115730. tessellation?: number;
  115731. subdivisions?: number;
  115732. arc?: number;
  115733. faceColors?: Color4[];
  115734. faceUV?: Vector4[];
  115735. updatable?: boolean;
  115736. hasRings?: boolean;
  115737. enclose?: boolean;
  115738. cap?: number;
  115739. sideOrientation?: number;
  115740. frontUVs?: Vector4;
  115741. backUVs?: Vector4;
  115742. }, scene: any): Mesh;
  115743. }
  115744. }
  115745. declare module BABYLON {
  115746. /**
  115747. * States of the webXR experience
  115748. */
  115749. export enum WebXRState {
  115750. /**
  115751. * Transitioning to being in XR mode
  115752. */
  115753. ENTERING_XR = 0,
  115754. /**
  115755. * Transitioning to non XR mode
  115756. */
  115757. EXITING_XR = 1,
  115758. /**
  115759. * In XR mode and presenting
  115760. */
  115761. IN_XR = 2,
  115762. /**
  115763. * Not entered XR mode
  115764. */
  115765. NOT_IN_XR = 3
  115766. }
  115767. /**
  115768. * Abstraction of the XR render target
  115769. */
  115770. export interface WebXRRenderTarget extends IDisposable {
  115771. /**
  115772. * xrpresent context of the canvas which can be used to display/mirror xr content
  115773. */
  115774. canvasContext: WebGLRenderingContext;
  115775. /**
  115776. * xr layer for the canvas
  115777. */
  115778. xrLayer: Nullable<XRWebGLLayer>;
  115779. /**
  115780. * Initializes the xr layer for the session
  115781. * @param xrSession xr session
  115782. * @returns a promise that will resolve once the XR Layer has been created
  115783. */
  115784. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115785. }
  115786. }
  115787. declare module BABYLON {
  115788. /**
  115789. * COnfiguration object for WebXR output canvas
  115790. */
  115791. export class WebXRManagedOutputCanvasOptions {
  115792. /**
  115793. * An optional canvas in case you wish to create it yourself and provide it here.
  115794. * If not provided, a new canvas will be created
  115795. */
  115796. canvasElement?: HTMLCanvasElement;
  115797. /**
  115798. * Options for this XR Layer output
  115799. */
  115800. canvasOptions?: XRWebGLLayerOptions;
  115801. /**
  115802. * CSS styling for a newly created canvas (if not provided)
  115803. */
  115804. newCanvasCssStyle?: string;
  115805. /**
  115806. * Get the default values of the configuration object
  115807. * @returns default values of this configuration object
  115808. */
  115809. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115810. }
  115811. /**
  115812. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115813. */
  115814. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115815. private _options;
  115816. private _canvas;
  115817. private _engine;
  115818. /**
  115819. * Rendering context of the canvas which can be used to display/mirror xr content
  115820. */
  115821. canvasContext: WebGLRenderingContext;
  115822. /**
  115823. * xr layer for the canvas
  115824. */
  115825. xrLayer: Nullable<XRWebGLLayer>;
  115826. /**
  115827. * Initializes the canvas to be added/removed upon entering/exiting xr
  115828. * @param _xrSessionManager The XR Session manager
  115829. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115830. */
  115831. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115832. /**
  115833. * Disposes of the object
  115834. */
  115835. dispose(): void;
  115836. /**
  115837. * Initializes the xr layer for the session
  115838. * @param xrSession xr session
  115839. * @returns a promise that will resolve once the XR Layer has been created
  115840. */
  115841. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115842. private _addCanvas;
  115843. private _removeCanvas;
  115844. private _setManagedOutputCanvas;
  115845. }
  115846. }
  115847. declare module BABYLON {
  115848. /**
  115849. * Manages an XRSession to work with Babylon's engine
  115850. * @see https://doc.babylonjs.com/how_to/webxr
  115851. */
  115852. export class WebXRSessionManager implements IDisposable {
  115853. /** The scene which the session should be created for */
  115854. scene: Scene;
  115855. private _referenceSpace;
  115856. private _rttProvider;
  115857. private _sessionEnded;
  115858. private _xrNavigator;
  115859. private baseLayer;
  115860. /**
  115861. * The base reference space from which the session started. good if you want to reset your
  115862. * reference space
  115863. */
  115864. baseReferenceSpace: XRReferenceSpace;
  115865. /**
  115866. * Current XR frame
  115867. */
  115868. currentFrame: Nullable<XRFrame>;
  115869. /** WebXR timestamp updated every frame */
  115870. currentTimestamp: number;
  115871. /**
  115872. * Used just in case of a failure to initialize an immersive session.
  115873. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115874. */
  115875. defaultHeightCompensation: number;
  115876. /**
  115877. * Fires every time a new xrFrame arrives which can be used to update the camera
  115878. */
  115879. onXRFrameObservable: Observable<XRFrame>;
  115880. /**
  115881. * Fires when the reference space changed
  115882. */
  115883. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115884. /**
  115885. * Fires when the xr session is ended either by the device or manually done
  115886. */
  115887. onXRSessionEnded: Observable<any>;
  115888. /**
  115889. * Fires when the xr session is ended either by the device or manually done
  115890. */
  115891. onXRSessionInit: Observable<XRSession>;
  115892. /**
  115893. * Underlying xr session
  115894. */
  115895. session: XRSession;
  115896. /**
  115897. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115898. * or get the offset the player is currently at.
  115899. */
  115900. viewerReferenceSpace: XRReferenceSpace;
  115901. /**
  115902. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115903. * @param scene The scene which the session should be created for
  115904. */
  115905. constructor(
  115906. /** The scene which the session should be created for */
  115907. scene: Scene);
  115908. /**
  115909. * The current reference space used in this session. This reference space can constantly change!
  115910. * It is mainly used to offset the camera's position.
  115911. */
  115912. get referenceSpace(): XRReferenceSpace;
  115913. /**
  115914. * Set a new reference space and triggers the observable
  115915. */
  115916. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115917. /**
  115918. * Disposes of the session manager
  115919. */
  115920. dispose(): void;
  115921. /**
  115922. * Stops the xrSession and restores the render loop
  115923. * @returns Promise which resolves after it exits XR
  115924. */
  115925. exitXRAsync(): Promise<void>;
  115926. /**
  115927. * Gets the correct render target texture to be rendered this frame for this eye
  115928. * @param eye the eye for which to get the render target
  115929. * @returns the render target for the specified eye
  115930. */
  115931. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115932. /**
  115933. * Creates a WebXRRenderTarget object for the XR session
  115934. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115935. * @param options optional options to provide when creating a new render target
  115936. * @returns a WebXR render target to which the session can render
  115937. */
  115938. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115939. /**
  115940. * Initializes the manager
  115941. * After initialization enterXR can be called to start an XR session
  115942. * @returns Promise which resolves after it is initialized
  115943. */
  115944. initializeAsync(): Promise<void>;
  115945. /**
  115946. * Initializes an xr session
  115947. * @param xrSessionMode mode to initialize
  115948. * @param xrSessionInit defines optional and required values to pass to the session builder
  115949. * @returns a promise which will resolve once the session has been initialized
  115950. */
  115951. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115952. /**
  115953. * Checks if a session would be supported for the creation options specified
  115954. * @param sessionMode session mode to check if supported eg. immersive-vr
  115955. * @returns A Promise that resolves to true if supported and false if not
  115956. */
  115957. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115958. /**
  115959. * Resets the reference space to the one started the session
  115960. */
  115961. resetReferenceSpace(): void;
  115962. /**
  115963. * Starts rendering to the xr layer
  115964. */
  115965. runXRRenderLoop(): void;
  115966. /**
  115967. * Sets the reference space on the xr session
  115968. * @param referenceSpaceType space to set
  115969. * @returns a promise that will resolve once the reference space has been set
  115970. */
  115971. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115972. /**
  115973. * Updates the render state of the session
  115974. * @param state state to set
  115975. * @returns a promise that resolves once the render state has been updated
  115976. */
  115977. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115978. /**
  115979. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115980. * @param sessionMode defines the session to test
  115981. * @returns a promise with boolean as final value
  115982. */
  115983. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115984. private _createRenderTargetTexture;
  115985. }
  115986. }
  115987. declare module BABYLON {
  115988. /**
  115989. * WebXR Camera which holds the views for the xrSession
  115990. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115991. */
  115992. export class WebXRCamera extends FreeCamera {
  115993. private _xrSessionManager;
  115994. private _firstFrame;
  115995. private _referenceQuaternion;
  115996. private _referencedPosition;
  115997. private _xrInvPositionCache;
  115998. private _xrInvQuaternionCache;
  115999. /**
  116000. * Should position compensation execute on first frame.
  116001. * This is used when copying the position from a native (non XR) camera
  116002. */
  116003. compensateOnFirstFrame: boolean;
  116004. /**
  116005. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116006. * @param name the name of the camera
  116007. * @param scene the scene to add the camera to
  116008. * @param _xrSessionManager a constructed xr session manager
  116009. */
  116010. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116011. /**
  116012. * Return the user's height, unrelated to the current ground.
  116013. * This will be the y position of this camera, when ground level is 0.
  116014. */
  116015. get realWorldHeight(): number;
  116016. /** @hidden */
  116017. _updateForDualEyeDebugging(): void;
  116018. /**
  116019. * Sets this camera's transformation based on a non-vr camera
  116020. * @param otherCamera the non-vr camera to copy the transformation from
  116021. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116022. */
  116023. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116024. /**
  116025. * Gets the current instance class name ("WebXRCamera").
  116026. * @returns the class name
  116027. */
  116028. getClassName(): string;
  116029. private _updateFromXRSession;
  116030. private _updateNumberOfRigCameras;
  116031. private _updateReferenceSpace;
  116032. private _updateReferenceSpaceOffset;
  116033. }
  116034. }
  116035. declare module BABYLON {
  116036. /**
  116037. * Defining the interface required for a (webxr) feature
  116038. */
  116039. export interface IWebXRFeature extends IDisposable {
  116040. /**
  116041. * Is this feature attached
  116042. */
  116043. attached: boolean;
  116044. /**
  116045. * Should auto-attach be disabled?
  116046. */
  116047. disableAutoAttach: boolean;
  116048. /**
  116049. * Attach the feature to the session
  116050. * Will usually be called by the features manager
  116051. *
  116052. * @param force should attachment be forced (even when already attached)
  116053. * @returns true if successful.
  116054. */
  116055. attach(force?: boolean): boolean;
  116056. /**
  116057. * Detach the feature from the session
  116058. * Will usually be called by the features manager
  116059. *
  116060. * @returns true if successful.
  116061. */
  116062. detach(): boolean;
  116063. }
  116064. /**
  116065. * A list of the currently available features without referencing them
  116066. */
  116067. export class WebXRFeatureName {
  116068. /**
  116069. * The name of the anchor system feature
  116070. */
  116071. static ANCHOR_SYSTEM: string;
  116072. /**
  116073. * The name of the background remover feature
  116074. */
  116075. static BACKGROUND_REMOVER: string;
  116076. /**
  116077. * The name of the hit test feature
  116078. */
  116079. static HIT_TEST: string;
  116080. /**
  116081. * physics impostors for xr controllers feature
  116082. */
  116083. static PHYSICS_CONTROLLERS: string;
  116084. /**
  116085. * The name of the plane detection feature
  116086. */
  116087. static PLANE_DETECTION: string;
  116088. /**
  116089. * The name of the pointer selection feature
  116090. */
  116091. static POINTER_SELECTION: string;
  116092. /**
  116093. * The name of the teleportation feature
  116094. */
  116095. static TELEPORTATION: string;
  116096. }
  116097. /**
  116098. * Defining the constructor of a feature. Used to register the modules.
  116099. */
  116100. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116101. /**
  116102. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116103. * It is mainly used in AR sessions.
  116104. *
  116105. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116106. */
  116107. export class WebXRFeaturesManager implements IDisposable {
  116108. private _xrSessionManager;
  116109. private static readonly _AvailableFeatures;
  116110. private _features;
  116111. /**
  116112. * constructs a new features manages.
  116113. *
  116114. * @param _xrSessionManager an instance of WebXRSessionManager
  116115. */
  116116. constructor(_xrSessionManager: WebXRSessionManager);
  116117. /**
  116118. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116119. * Mainly used internally.
  116120. *
  116121. * @param featureName the name of the feature to register
  116122. * @param constructorFunction the function used to construct the module
  116123. * @param version the (babylon) version of the module
  116124. * @param stable is that a stable version of this module
  116125. */
  116126. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116127. /**
  116128. * Returns a constructor of a specific feature.
  116129. *
  116130. * @param featureName the name of the feature to construct
  116131. * @param version the version of the feature to load
  116132. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116133. * @param options optional options provided to the module.
  116134. * @returns a function that, when called, will return a new instance of this feature
  116135. */
  116136. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116137. /**
  116138. * Can be used to return the list of features currently registered
  116139. *
  116140. * @returns an Array of available features
  116141. */
  116142. static GetAvailableFeatures(): string[];
  116143. /**
  116144. * Gets the versions available for a specific feature
  116145. * @param featureName the name of the feature
  116146. * @returns an array with the available versions
  116147. */
  116148. static GetAvailableVersions(featureName: string): string[];
  116149. /**
  116150. * Return the latest unstable version of this feature
  116151. * @param featureName the name of the feature to search
  116152. * @returns the version number. if not found will return -1
  116153. */
  116154. static GetLatestVersionOfFeature(featureName: string): number;
  116155. /**
  116156. * Return the latest stable version of this feature
  116157. * @param featureName the name of the feature to search
  116158. * @returns the version number. if not found will return -1
  116159. */
  116160. static GetStableVersionOfFeature(featureName: string): number;
  116161. /**
  116162. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116163. * Can be used during a session to start a feature
  116164. * @param featureName the name of feature to attach
  116165. */
  116166. attachFeature(featureName: string): void;
  116167. /**
  116168. * Can be used inside a session or when the session ends to detach a specific feature
  116169. * @param featureName the name of the feature to detach
  116170. */
  116171. detachFeature(featureName: string): void;
  116172. /**
  116173. * Used to disable an already-enabled feature
  116174. * The feature will be disposed and will be recreated once enabled.
  116175. * @param featureName the feature to disable
  116176. * @returns true if disable was successful
  116177. */
  116178. disableFeature(featureName: string | {
  116179. Name: string;
  116180. }): boolean;
  116181. /**
  116182. * dispose this features manager
  116183. */
  116184. dispose(): void;
  116185. /**
  116186. * 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.
  116187. * 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.
  116188. *
  116189. * @param featureName the name of the feature to load or the class of the feature
  116190. * @param version optional version to load. if not provided the latest version will be enabled
  116191. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116192. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116193. * @returns a new constructed feature or throws an error if feature not found.
  116194. */
  116195. enableFeature(featureName: string | {
  116196. Name: string;
  116197. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116198. /**
  116199. * get the implementation of an enabled feature.
  116200. * @param featureName the name of the feature to load
  116201. * @returns the feature class, if found
  116202. */
  116203. getEnabledFeature(featureName: string): IWebXRFeature;
  116204. /**
  116205. * Get the list of enabled features
  116206. * @returns an array of enabled features
  116207. */
  116208. getEnabledFeatures(): string[];
  116209. }
  116210. }
  116211. declare module BABYLON {
  116212. /**
  116213. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116214. * @see https://doc.babylonjs.com/how_to/webxr
  116215. */
  116216. export class WebXRExperienceHelper implements IDisposable {
  116217. private scene;
  116218. private _nonVRCamera;
  116219. private _originalSceneAutoClear;
  116220. private _supported;
  116221. /**
  116222. * Camera used to render xr content
  116223. */
  116224. camera: WebXRCamera;
  116225. /** A features manager for this xr session */
  116226. featuresManager: WebXRFeaturesManager;
  116227. /**
  116228. * Observers registered here will be triggered after the camera's initial transformation is set
  116229. * This can be used to set a different ground level or an extra rotation.
  116230. *
  116231. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116232. * to the position set after this observable is done executing.
  116233. */
  116234. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116235. /**
  116236. * Fires when the state of the experience helper has changed
  116237. */
  116238. onStateChangedObservable: Observable<WebXRState>;
  116239. /** Session manager used to keep track of xr session */
  116240. sessionManager: WebXRSessionManager;
  116241. /**
  116242. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116243. */
  116244. state: WebXRState;
  116245. /**
  116246. * Creates a WebXRExperienceHelper
  116247. * @param scene The scene the helper should be created in
  116248. */
  116249. private constructor();
  116250. /**
  116251. * Creates the experience helper
  116252. * @param scene the scene to attach the experience helper to
  116253. * @returns a promise for the experience helper
  116254. */
  116255. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116256. /**
  116257. * Disposes of the experience helper
  116258. */
  116259. dispose(): void;
  116260. /**
  116261. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116262. * @param sessionMode options for the XR session
  116263. * @param referenceSpaceType frame of reference of the XR session
  116264. * @param renderTarget the output canvas that will be used to enter XR mode
  116265. * @returns promise that resolves after xr mode has entered
  116266. */
  116267. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116268. /**
  116269. * Exits XR mode and returns the scene to its original state
  116270. * @returns promise that resolves after xr mode has exited
  116271. */
  116272. exitXRAsync(): Promise<void>;
  116273. private _nonXRToXRCamera;
  116274. private _setState;
  116275. }
  116276. }
  116277. declare module BABYLON {
  116278. /**
  116279. * X-Y values for axes in WebXR
  116280. */
  116281. export interface IWebXRMotionControllerAxesValue {
  116282. /**
  116283. * The value of the x axis
  116284. */
  116285. x: number;
  116286. /**
  116287. * The value of the y-axis
  116288. */
  116289. y: number;
  116290. }
  116291. /**
  116292. * changed / previous values for the values of this component
  116293. */
  116294. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116295. /**
  116296. * current (this frame) value
  116297. */
  116298. current: T;
  116299. /**
  116300. * previous (last change) value
  116301. */
  116302. previous: T;
  116303. }
  116304. /**
  116305. * Represents changes in the component between current frame and last values recorded
  116306. */
  116307. export interface IWebXRMotionControllerComponentChanges {
  116308. /**
  116309. * will be populated with previous and current values if axes changed
  116310. */
  116311. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116312. /**
  116313. * will be populated with previous and current values if pressed changed
  116314. */
  116315. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116316. /**
  116317. * will be populated with previous and current values if touched changed
  116318. */
  116319. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116320. /**
  116321. * will be populated with previous and current values if value changed
  116322. */
  116323. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116324. }
  116325. /**
  116326. * This class represents a single component (for example button or thumbstick) of a motion controller
  116327. */
  116328. export class WebXRControllerComponent implements IDisposable {
  116329. /**
  116330. * the id of this component
  116331. */
  116332. id: string;
  116333. /**
  116334. * the type of the component
  116335. */
  116336. type: MotionControllerComponentType;
  116337. private _buttonIndex;
  116338. private _axesIndices;
  116339. private _axes;
  116340. private _changes;
  116341. private _currentValue;
  116342. private _hasChanges;
  116343. private _pressed;
  116344. private _touched;
  116345. /**
  116346. * button component type
  116347. */
  116348. static BUTTON_TYPE: MotionControllerComponentType;
  116349. /**
  116350. * squeeze component type
  116351. */
  116352. static SQUEEZE_TYPE: MotionControllerComponentType;
  116353. /**
  116354. * Thumbstick component type
  116355. */
  116356. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116357. /**
  116358. * Touchpad component type
  116359. */
  116360. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116361. /**
  116362. * trigger component type
  116363. */
  116364. static TRIGGER_TYPE: MotionControllerComponentType;
  116365. /**
  116366. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116367. * the axes data changes
  116368. */
  116369. onAxisValueChangedObservable: Observable<{
  116370. x: number;
  116371. y: number;
  116372. }>;
  116373. /**
  116374. * Observers registered here will be triggered when the state of a button changes
  116375. * State change is either pressed / touched / value
  116376. */
  116377. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116378. /**
  116379. * Creates a new component for a motion controller.
  116380. * It is created by the motion controller itself
  116381. *
  116382. * @param id the id of this component
  116383. * @param type the type of the component
  116384. * @param _buttonIndex index in the buttons array of the gamepad
  116385. * @param _axesIndices indices of the values in the axes array of the gamepad
  116386. */
  116387. constructor(
  116388. /**
  116389. * the id of this component
  116390. */
  116391. id: string,
  116392. /**
  116393. * the type of the component
  116394. */
  116395. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116396. /**
  116397. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116398. */
  116399. get axes(): IWebXRMotionControllerAxesValue;
  116400. /**
  116401. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116402. */
  116403. get changes(): IWebXRMotionControllerComponentChanges;
  116404. /**
  116405. * Return whether or not the component changed the last frame
  116406. */
  116407. get hasChanges(): boolean;
  116408. /**
  116409. * is the button currently pressed
  116410. */
  116411. get pressed(): boolean;
  116412. /**
  116413. * is the button currently touched
  116414. */
  116415. get touched(): boolean;
  116416. /**
  116417. * Get the current value of this component
  116418. */
  116419. get value(): number;
  116420. /**
  116421. * Dispose this component
  116422. */
  116423. dispose(): void;
  116424. /**
  116425. * Are there axes correlating to this component
  116426. * @return true is axes data is available
  116427. */
  116428. isAxes(): boolean;
  116429. /**
  116430. * Is this component a button (hence - pressable)
  116431. * @returns true if can be pressed
  116432. */
  116433. isButton(): boolean;
  116434. /**
  116435. * update this component using the gamepad object it is in. Called on every frame
  116436. * @param nativeController the native gamepad controller object
  116437. */
  116438. update(nativeController: IMinimalMotionControllerObject): void;
  116439. }
  116440. }
  116441. declare module BABYLON {
  116442. /**
  116443. * Class used to represent data loading progression
  116444. */
  116445. export class SceneLoaderProgressEvent {
  116446. /** defines if data length to load can be evaluated */
  116447. readonly lengthComputable: boolean;
  116448. /** defines the loaded data length */
  116449. readonly loaded: number;
  116450. /** defines the data length to load */
  116451. readonly total: number;
  116452. /**
  116453. * Create a new progress event
  116454. * @param lengthComputable defines if data length to load can be evaluated
  116455. * @param loaded defines the loaded data length
  116456. * @param total defines the data length to load
  116457. */
  116458. constructor(
  116459. /** defines if data length to load can be evaluated */
  116460. lengthComputable: boolean,
  116461. /** defines the loaded data length */
  116462. loaded: number,
  116463. /** defines the data length to load */
  116464. total: number);
  116465. /**
  116466. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116467. * @param event defines the source event
  116468. * @returns a new SceneLoaderProgressEvent
  116469. */
  116470. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116471. }
  116472. /**
  116473. * Interface used by SceneLoader plugins to define supported file extensions
  116474. */
  116475. export interface ISceneLoaderPluginExtensions {
  116476. /**
  116477. * Defines the list of supported extensions
  116478. */
  116479. [extension: string]: {
  116480. isBinary: boolean;
  116481. };
  116482. }
  116483. /**
  116484. * Interface used by SceneLoader plugin factory
  116485. */
  116486. export interface ISceneLoaderPluginFactory {
  116487. /**
  116488. * Defines the name of the factory
  116489. */
  116490. name: string;
  116491. /**
  116492. * Function called to create a new plugin
  116493. * @return the new plugin
  116494. */
  116495. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116496. /**
  116497. * The callback that returns true if the data can be directly loaded.
  116498. * @param data string containing the file data
  116499. * @returns if the data can be loaded directly
  116500. */
  116501. canDirectLoad?(data: string): boolean;
  116502. }
  116503. /**
  116504. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116505. */
  116506. export interface ISceneLoaderPluginBase {
  116507. /**
  116508. * The friendly name of this plugin.
  116509. */
  116510. name: string;
  116511. /**
  116512. * The file extensions supported by this plugin.
  116513. */
  116514. extensions: string | ISceneLoaderPluginExtensions;
  116515. /**
  116516. * The callback called when loading from a url.
  116517. * @param scene scene loading this url
  116518. * @param url url to load
  116519. * @param onSuccess callback called when the file successfully loads
  116520. * @param onProgress callback called while file is loading (if the server supports this mode)
  116521. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116522. * @param onError callback called when the file fails to load
  116523. * @returns a file request object
  116524. */
  116525. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116526. /**
  116527. * The callback called when loading from a file object.
  116528. * @param scene scene loading this file
  116529. * @param file defines the file to load
  116530. * @param onSuccess defines the callback to call when data is loaded
  116531. * @param onProgress defines the callback to call during loading process
  116532. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116533. * @param onError defines the callback to call when an error occurs
  116534. * @returns a file request object
  116535. */
  116536. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116537. /**
  116538. * The callback that returns true if the data can be directly loaded.
  116539. * @param data string containing the file data
  116540. * @returns if the data can be loaded directly
  116541. */
  116542. canDirectLoad?(data: string): boolean;
  116543. /**
  116544. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116545. * @param scene scene loading this data
  116546. * @param data string containing the data
  116547. * @returns data to pass to the plugin
  116548. */
  116549. directLoad?(scene: Scene, data: string): any;
  116550. /**
  116551. * The callback that allows custom handling of the root url based on the response url.
  116552. * @param rootUrl the original root url
  116553. * @param responseURL the response url if available
  116554. * @returns the new root url
  116555. */
  116556. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116557. }
  116558. /**
  116559. * Interface used to define a SceneLoader plugin
  116560. */
  116561. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116562. /**
  116563. * Import meshes into a scene.
  116564. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116565. * @param scene The scene to import into
  116566. * @param data The data to import
  116567. * @param rootUrl The root url for scene and resources
  116568. * @param meshes The meshes array to import into
  116569. * @param particleSystems The particle systems array to import into
  116570. * @param skeletons The skeletons array to import into
  116571. * @param onError The callback when import fails
  116572. * @returns True if successful or false otherwise
  116573. */
  116574. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116575. /**
  116576. * Load into a scene.
  116577. * @param scene The scene to load into
  116578. * @param data The data to import
  116579. * @param rootUrl The root url for scene and resources
  116580. * @param onError The callback when import fails
  116581. * @returns True if successful or false otherwise
  116582. */
  116583. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116584. /**
  116585. * Load into an asset container.
  116586. * @param scene The scene to load into
  116587. * @param data The data to import
  116588. * @param rootUrl The root url for scene and resources
  116589. * @param onError The callback when import fails
  116590. * @returns The loaded asset container
  116591. */
  116592. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116593. }
  116594. /**
  116595. * Interface used to define an async SceneLoader plugin
  116596. */
  116597. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116598. /**
  116599. * Import meshes into a scene.
  116600. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116601. * @param scene The scene to import into
  116602. * @param data The data to import
  116603. * @param rootUrl The root url for scene and resources
  116604. * @param onProgress The callback when the load progresses
  116605. * @param fileName Defines the name of the file to load
  116606. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116607. */
  116608. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116609. meshes: AbstractMesh[];
  116610. particleSystems: IParticleSystem[];
  116611. skeletons: Skeleton[];
  116612. animationGroups: AnimationGroup[];
  116613. }>;
  116614. /**
  116615. * Load into a scene.
  116616. * @param scene The scene to load into
  116617. * @param data The data to import
  116618. * @param rootUrl The root url for scene and resources
  116619. * @param onProgress The callback when the load progresses
  116620. * @param fileName Defines the name of the file to load
  116621. * @returns Nothing
  116622. */
  116623. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116624. /**
  116625. * Load into an asset container.
  116626. * @param scene The scene to load into
  116627. * @param data The data to import
  116628. * @param rootUrl The root url for scene and resources
  116629. * @param onProgress The callback when the load progresses
  116630. * @param fileName Defines the name of the file to load
  116631. * @returns The loaded asset container
  116632. */
  116633. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116634. }
  116635. /**
  116636. * Mode that determines how to handle old animation groups before loading new ones.
  116637. */
  116638. export enum SceneLoaderAnimationGroupLoadingMode {
  116639. /**
  116640. * Reset all old animations to initial state then dispose them.
  116641. */
  116642. Clean = 0,
  116643. /**
  116644. * Stop all old animations.
  116645. */
  116646. Stop = 1,
  116647. /**
  116648. * Restart old animations from first frame.
  116649. */
  116650. Sync = 2,
  116651. /**
  116652. * Old animations remains untouched.
  116653. */
  116654. NoSync = 3
  116655. }
  116656. /**
  116657. * Class used to load scene from various file formats using registered plugins
  116658. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116659. */
  116660. export class SceneLoader {
  116661. /**
  116662. * No logging while loading
  116663. */
  116664. static readonly NO_LOGGING: number;
  116665. /**
  116666. * Minimal logging while loading
  116667. */
  116668. static readonly MINIMAL_LOGGING: number;
  116669. /**
  116670. * Summary logging while loading
  116671. */
  116672. static readonly SUMMARY_LOGGING: number;
  116673. /**
  116674. * Detailled logging while loading
  116675. */
  116676. static readonly DETAILED_LOGGING: number;
  116677. /**
  116678. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116679. */
  116680. static get ForceFullSceneLoadingForIncremental(): boolean;
  116681. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116682. /**
  116683. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116684. */
  116685. static get ShowLoadingScreen(): boolean;
  116686. static set ShowLoadingScreen(value: boolean);
  116687. /**
  116688. * Defines the current logging level (while loading the scene)
  116689. * @ignorenaming
  116690. */
  116691. static get loggingLevel(): number;
  116692. static set loggingLevel(value: number);
  116693. /**
  116694. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116695. */
  116696. static get CleanBoneMatrixWeights(): boolean;
  116697. static set CleanBoneMatrixWeights(value: boolean);
  116698. /**
  116699. * Event raised when a plugin is used to load a scene
  116700. */
  116701. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116702. private static _registeredPlugins;
  116703. private static _getDefaultPlugin;
  116704. private static _getPluginForExtension;
  116705. private static _getPluginForDirectLoad;
  116706. private static _getPluginForFilename;
  116707. private static _getDirectLoad;
  116708. private static _loadData;
  116709. private static _getFileInfo;
  116710. /**
  116711. * Gets a plugin that can load the given extension
  116712. * @param extension defines the extension to load
  116713. * @returns a plugin or null if none works
  116714. */
  116715. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116716. /**
  116717. * Gets a boolean indicating that the given extension can be loaded
  116718. * @param extension defines the extension to load
  116719. * @returns true if the extension is supported
  116720. */
  116721. static IsPluginForExtensionAvailable(extension: string): boolean;
  116722. /**
  116723. * Adds a new plugin to the list of registered plugins
  116724. * @param plugin defines the plugin to add
  116725. */
  116726. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116727. /**
  116728. * Import meshes into a scene
  116729. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116730. * @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)
  116731. * @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)
  116732. * @param scene the instance of BABYLON.Scene to append to
  116733. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116734. * @param onProgress a callback with a progress event for each file being loaded
  116735. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116736. * @param pluginExtension the extension used to determine the plugin
  116737. * @returns The loaded plugin
  116738. */
  116739. 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>;
  116740. /**
  116741. * Import meshes into a scene
  116742. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116743. * @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)
  116744. * @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)
  116745. * @param scene the instance of BABYLON.Scene to append to
  116746. * @param onProgress a callback with a progress event for each file being loaded
  116747. * @param pluginExtension the extension used to determine the plugin
  116748. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116749. */
  116750. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116751. meshes: AbstractMesh[];
  116752. particleSystems: IParticleSystem[];
  116753. skeletons: Skeleton[];
  116754. animationGroups: AnimationGroup[];
  116755. }>;
  116756. /**
  116757. * Load a scene
  116758. * @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)
  116759. * @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)
  116760. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116761. * @param onSuccess a callback with the scene when import succeeds
  116762. * @param onProgress a callback with a progress event for each file being loaded
  116763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116764. * @param pluginExtension the extension used to determine the plugin
  116765. * @returns The loaded plugin
  116766. */
  116767. 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>;
  116768. /**
  116769. * Load a scene
  116770. * @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)
  116771. * @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)
  116772. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116773. * @param onProgress a callback with a progress event for each file being loaded
  116774. * @param pluginExtension the extension used to determine the plugin
  116775. * @returns The loaded scene
  116776. */
  116777. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116778. /**
  116779. * Append a scene
  116780. * @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)
  116781. * @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)
  116782. * @param scene is the instance of BABYLON.Scene to append to
  116783. * @param onSuccess a callback with the scene when import succeeds
  116784. * @param onProgress a callback with a progress event for each file being loaded
  116785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116786. * @param pluginExtension the extension used to determine the plugin
  116787. * @returns The loaded plugin
  116788. */
  116789. 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>;
  116790. /**
  116791. * Append a scene
  116792. * @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)
  116793. * @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)
  116794. * @param scene is the instance of BABYLON.Scene to append to
  116795. * @param onProgress a callback with a progress event for each file being loaded
  116796. * @param pluginExtension the extension used to determine the plugin
  116797. * @returns The given scene
  116798. */
  116799. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116800. /**
  116801. * Load a scene into an asset container
  116802. * @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)
  116803. * @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)
  116804. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116805. * @param onSuccess a callback with the scene when import succeeds
  116806. * @param onProgress a callback with a progress event for each file being loaded
  116807. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116808. * @param pluginExtension the extension used to determine the plugin
  116809. * @returns The loaded plugin
  116810. */
  116811. 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>;
  116812. /**
  116813. * Load a scene into an asset container
  116814. * @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)
  116815. * @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)
  116816. * @param scene is the instance of Scene to append to
  116817. * @param onProgress a callback with a progress event for each file being loaded
  116818. * @param pluginExtension the extension used to determine the plugin
  116819. * @returns The loaded asset container
  116820. */
  116821. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116822. /**
  116823. * Import animations from a file into a scene
  116824. * @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)
  116825. * @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)
  116826. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116827. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116828. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116829. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116830. * @param onSuccess a callback with the scene when import succeeds
  116831. * @param onProgress a callback with a progress event for each file being loaded
  116832. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116833. */
  116834. 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;
  116835. /**
  116836. * Import animations from a file into a scene
  116837. * @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)
  116838. * @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)
  116839. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116840. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116841. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116842. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116843. * @param onSuccess a callback with the scene when import succeeds
  116844. * @param onProgress a callback with a progress event for each file being loaded
  116845. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116846. * @returns the updated scene with imported animations
  116847. */
  116848. 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>;
  116849. }
  116850. }
  116851. declare module BABYLON {
  116852. /**
  116853. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116854. */
  116855. export type MotionControllerHandness = "none" | "left" | "right";
  116856. /**
  116857. * The type of components available in motion controllers.
  116858. * This is not the name of the component.
  116859. */
  116860. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116861. /**
  116862. * The state of a controller component
  116863. */
  116864. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116865. /**
  116866. * The schema of motion controller layout.
  116867. * No object will be initialized using this interface
  116868. * This is used just to define the profile.
  116869. */
  116870. export interface IMotionControllerLayout {
  116871. /**
  116872. * Path to load the assets. Usually relative to the base path
  116873. */
  116874. assetPath: string;
  116875. /**
  116876. * Available components (unsorted)
  116877. */
  116878. components: {
  116879. /**
  116880. * A map of component Ids
  116881. */
  116882. [componentId: string]: {
  116883. /**
  116884. * The type of input the component outputs
  116885. */
  116886. type: MotionControllerComponentType;
  116887. /**
  116888. * The indices of this component in the gamepad object
  116889. */
  116890. gamepadIndices: {
  116891. /**
  116892. * Index of button
  116893. */
  116894. button?: number;
  116895. /**
  116896. * If available, index of x-axis
  116897. */
  116898. xAxis?: number;
  116899. /**
  116900. * If available, index of y-axis
  116901. */
  116902. yAxis?: number;
  116903. };
  116904. /**
  116905. * The mesh's root node name
  116906. */
  116907. rootNodeName: string;
  116908. /**
  116909. * Animation definitions for this model
  116910. */
  116911. visualResponses: {
  116912. [stateKey: string]: {
  116913. /**
  116914. * What property will be animated
  116915. */
  116916. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116917. /**
  116918. * What states influence this visual response
  116919. */
  116920. states: MotionControllerComponentStateType[];
  116921. /**
  116922. * Type of animation - movement or visibility
  116923. */
  116924. valueNodeProperty: "transform" | "visibility";
  116925. /**
  116926. * Base node name to move. Its position will be calculated according to the min and max nodes
  116927. */
  116928. valueNodeName?: string;
  116929. /**
  116930. * Minimum movement node
  116931. */
  116932. minNodeName?: string;
  116933. /**
  116934. * Max movement node
  116935. */
  116936. maxNodeName?: string;
  116937. };
  116938. };
  116939. /**
  116940. * If touch enabled, what is the name of node to display user feedback
  116941. */
  116942. touchPointNodeName?: string;
  116943. };
  116944. };
  116945. /**
  116946. * Is it xr standard mapping or not
  116947. */
  116948. gamepadMapping: "" | "xr-standard";
  116949. /**
  116950. * Base root node of this entire model
  116951. */
  116952. rootNodeName: string;
  116953. /**
  116954. * Defines the main button component id
  116955. */
  116956. selectComponentId: string;
  116957. }
  116958. /**
  116959. * A definition for the layout map in the input profile
  116960. */
  116961. export interface IMotionControllerLayoutMap {
  116962. /**
  116963. * Layouts with handness type as a key
  116964. */
  116965. [handness: string]: IMotionControllerLayout;
  116966. }
  116967. /**
  116968. * The XR Input profile schema
  116969. * Profiles can be found here:
  116970. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116971. */
  116972. export interface IMotionControllerProfile {
  116973. /**
  116974. * fallback profiles for this profileId
  116975. */
  116976. fallbackProfileIds: string[];
  116977. /**
  116978. * The layout map, with handness as key
  116979. */
  116980. layouts: IMotionControllerLayoutMap;
  116981. /**
  116982. * The id of this profile
  116983. * correlates to the profile(s) in the xrInput.profiles array
  116984. */
  116985. profileId: string;
  116986. }
  116987. /**
  116988. * A helper-interface for the 3 meshes needed for controller button animation
  116989. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116990. */
  116991. export interface IMotionControllerButtonMeshMap {
  116992. /**
  116993. * the mesh that defines the pressed value mesh position.
  116994. * This is used to find the max-position of this button
  116995. */
  116996. pressedMesh: AbstractMesh;
  116997. /**
  116998. * the mesh that defines the unpressed value mesh position.
  116999. * This is used to find the min (or initial) position of this button
  117000. */
  117001. unpressedMesh: AbstractMesh;
  117002. /**
  117003. * The mesh that will be changed when value changes
  117004. */
  117005. valueMesh: AbstractMesh;
  117006. }
  117007. /**
  117008. * A helper-interface for the 3 meshes needed for controller axis animation.
  117009. * This will be expanded when touchpad animations are fully supported
  117010. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117011. */
  117012. export interface IMotionControllerMeshMap {
  117013. /**
  117014. * the mesh that defines the maximum value mesh position.
  117015. */
  117016. maxMesh?: AbstractMesh;
  117017. /**
  117018. * the mesh that defines the minimum value mesh position.
  117019. */
  117020. minMesh?: AbstractMesh;
  117021. /**
  117022. * The mesh that will be changed when axis value changes
  117023. */
  117024. valueMesh: AbstractMesh;
  117025. }
  117026. /**
  117027. * The elements needed for change-detection of the gamepad objects in motion controllers
  117028. */
  117029. export interface IMinimalMotionControllerObject {
  117030. /**
  117031. * Available axes of this controller
  117032. */
  117033. axes: number[];
  117034. /**
  117035. * An array of available buttons
  117036. */
  117037. buttons: Array<{
  117038. /**
  117039. * Value of the button/trigger
  117040. */
  117041. value: number;
  117042. /**
  117043. * If the button/trigger is currently touched
  117044. */
  117045. touched: boolean;
  117046. /**
  117047. * If the button/trigger is currently pressed
  117048. */
  117049. pressed: boolean;
  117050. }>;
  117051. }
  117052. /**
  117053. * An Abstract Motion controller
  117054. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117055. * Each component has an observable to check for changes in value and state
  117056. */
  117057. export abstract class WebXRAbstractMotionController implements IDisposable {
  117058. protected scene: Scene;
  117059. protected layout: IMotionControllerLayout;
  117060. /**
  117061. * The gamepad object correlating to this controller
  117062. */
  117063. gamepadObject: IMinimalMotionControllerObject;
  117064. /**
  117065. * handness (left/right/none) of this controller
  117066. */
  117067. handness: MotionControllerHandness;
  117068. private _initComponent;
  117069. private _modelReady;
  117070. /**
  117071. * A map of components (WebXRControllerComponent) in this motion controller
  117072. * Components have a ComponentType and can also have both button and axis definitions
  117073. */
  117074. readonly components: {
  117075. [id: string]: WebXRControllerComponent;
  117076. };
  117077. /**
  117078. * Disable the model's animation. Can be set at any time.
  117079. */
  117080. disableAnimation: boolean;
  117081. /**
  117082. * Observers registered here will be triggered when the model of this controller is done loading
  117083. */
  117084. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117085. /**
  117086. * The profile id of this motion controller
  117087. */
  117088. abstract profileId: string;
  117089. /**
  117090. * The root mesh of the model. It is null if the model was not yet initialized
  117091. */
  117092. rootMesh: Nullable<AbstractMesh>;
  117093. /**
  117094. * constructs a new abstract motion controller
  117095. * @param scene the scene to which the model of the controller will be added
  117096. * @param layout The profile layout to load
  117097. * @param gamepadObject The gamepad object correlating to this controller
  117098. * @param handness handness (left/right/none) of this controller
  117099. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117100. */
  117101. constructor(scene: Scene, layout: IMotionControllerLayout,
  117102. /**
  117103. * The gamepad object correlating to this controller
  117104. */
  117105. gamepadObject: IMinimalMotionControllerObject,
  117106. /**
  117107. * handness (left/right/none) of this controller
  117108. */
  117109. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117110. /**
  117111. * Dispose this controller, the model mesh and all its components
  117112. */
  117113. dispose(): void;
  117114. /**
  117115. * Returns all components of specific type
  117116. * @param type the type to search for
  117117. * @return an array of components with this type
  117118. */
  117119. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117120. /**
  117121. * get a component based an its component id as defined in layout.components
  117122. * @param id the id of the component
  117123. * @returns the component correlates to the id or undefined if not found
  117124. */
  117125. getComponent(id: string): WebXRControllerComponent;
  117126. /**
  117127. * Get the list of components available in this motion controller
  117128. * @returns an array of strings correlating to available components
  117129. */
  117130. getComponentIds(): string[];
  117131. /**
  117132. * Get the first component of specific type
  117133. * @param type type of component to find
  117134. * @return a controller component or null if not found
  117135. */
  117136. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117137. /**
  117138. * Get the main (Select) component of this controller as defined in the layout
  117139. * @returns the main component of this controller
  117140. */
  117141. getMainComponent(): WebXRControllerComponent;
  117142. /**
  117143. * Loads the model correlating to this controller
  117144. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117145. * @returns A promise fulfilled with the result of the model loading
  117146. */
  117147. loadModel(): Promise<boolean>;
  117148. /**
  117149. * Update this model using the current XRFrame
  117150. * @param xrFrame the current xr frame to use and update the model
  117151. */
  117152. updateFromXRFrame(xrFrame: XRFrame): void;
  117153. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117154. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117155. /**
  117156. * Moves the axis on the controller mesh based on its current state
  117157. * @param axis the index of the axis
  117158. * @param axisValue the value of the axis which determines the meshes new position
  117159. * @hidden
  117160. */
  117161. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117162. /**
  117163. * Update the model itself with the current frame data
  117164. * @param xrFrame the frame to use for updating the model mesh
  117165. */
  117166. protected updateModel(xrFrame: XRFrame): void;
  117167. /**
  117168. * Get the filename and path for this controller's model
  117169. * @returns a map of filename and path
  117170. */
  117171. protected abstract _getFilenameAndPath(): {
  117172. filename: string;
  117173. path: string;
  117174. };
  117175. /**
  117176. * This function is called before the mesh is loaded. It checks for loading constraints.
  117177. * For example, this function can check if the GLB loader is available
  117178. * If this function returns false, the generic controller will be loaded instead
  117179. * @returns Is the client ready to load the mesh
  117180. */
  117181. protected abstract _getModelLoadingConstraints(): boolean;
  117182. /**
  117183. * This function will be called after the model was successfully loaded and can be used
  117184. * for mesh transformations before it is available for the user
  117185. * @param meshes the loaded meshes
  117186. */
  117187. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117188. /**
  117189. * Set the root mesh for this controller. Important for the WebXR controller class
  117190. * @param meshes the loaded meshes
  117191. */
  117192. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117193. /**
  117194. * A function executed each frame that updates the mesh (if needed)
  117195. * @param xrFrame the current xrFrame
  117196. */
  117197. protected abstract _updateModel(xrFrame: XRFrame): void;
  117198. private _getGenericFilenameAndPath;
  117199. private _getGenericParentMesh;
  117200. }
  117201. }
  117202. declare module BABYLON {
  117203. /**
  117204. * A generic trigger-only motion controller for WebXR
  117205. */
  117206. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117207. /**
  117208. * Static version of the profile id of this controller
  117209. */
  117210. static ProfileId: string;
  117211. profileId: string;
  117212. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117213. protected _getFilenameAndPath(): {
  117214. filename: string;
  117215. path: string;
  117216. };
  117217. protected _getModelLoadingConstraints(): boolean;
  117218. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117219. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117220. protected _updateModel(): void;
  117221. }
  117222. }
  117223. declare module BABYLON {
  117224. /**
  117225. * Class containing static functions to help procedurally build meshes
  117226. */
  117227. export class SphereBuilder {
  117228. /**
  117229. * Creates a sphere mesh
  117230. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117231. * * 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`)
  117232. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117233. * * 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
  117234. * * 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)
  117235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117238. * @param name defines the name of the mesh
  117239. * @param options defines the options used to create the mesh
  117240. * @param scene defines the hosting scene
  117241. * @returns the sphere mesh
  117242. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117243. */
  117244. static CreateSphere(name: string, options: {
  117245. segments?: number;
  117246. diameter?: number;
  117247. diameterX?: number;
  117248. diameterY?: number;
  117249. diameterZ?: number;
  117250. arc?: number;
  117251. slice?: number;
  117252. sideOrientation?: number;
  117253. frontUVs?: Vector4;
  117254. backUVs?: Vector4;
  117255. updatable?: boolean;
  117256. }, scene?: Nullable<Scene>): Mesh;
  117257. }
  117258. }
  117259. declare module BABYLON {
  117260. /**
  117261. * A profiled motion controller has its profile loaded from an online repository.
  117262. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117263. */
  117264. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117265. private _repositoryUrl;
  117266. private _buttonMeshMapping;
  117267. private _touchDots;
  117268. /**
  117269. * The profile ID of this controller. Will be populated when the controller initializes.
  117270. */
  117271. profileId: string;
  117272. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117273. dispose(): void;
  117274. protected _getFilenameAndPath(): {
  117275. filename: string;
  117276. path: string;
  117277. };
  117278. protected _getModelLoadingConstraints(): boolean;
  117279. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117280. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117281. protected _updateModel(_xrFrame: XRFrame): void;
  117282. }
  117283. }
  117284. declare module BABYLON {
  117285. /**
  117286. * A construction function type to create a new controller based on an xrInput object
  117287. */
  117288. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117289. /**
  117290. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117291. *
  117292. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117293. * it should be replaced with auto-loaded controllers.
  117294. *
  117295. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117296. */
  117297. export class WebXRMotionControllerManager {
  117298. private static _AvailableControllers;
  117299. private static _Fallbacks;
  117300. private static _ProfileLoadingPromises;
  117301. private static _ProfilesList;
  117302. /**
  117303. * The base URL of the online controller repository. Can be changed at any time.
  117304. */
  117305. static BaseRepositoryUrl: string;
  117306. /**
  117307. * Which repository gets priority - local or online
  117308. */
  117309. static PrioritizeOnlineRepository: boolean;
  117310. /**
  117311. * Use the online repository, or use only locally-defined controllers
  117312. */
  117313. static UseOnlineRepository: boolean;
  117314. /**
  117315. * Clear the cache used for profile loading and reload when requested again
  117316. */
  117317. static ClearProfilesCache(): void;
  117318. /**
  117319. * Register the default fallbacks.
  117320. * This function is called automatically when this file is imported.
  117321. */
  117322. static DefaultFallbacks(): void;
  117323. /**
  117324. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117325. * @param profileId the profile to which a fallback needs to be found
  117326. * @return an array with corresponding fallback profiles
  117327. */
  117328. static FindFallbackWithProfileId(profileId: string): string[];
  117329. /**
  117330. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117331. * The order of search:
  117332. *
  117333. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117334. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117335. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117336. * 4) return the generic trigger controller if none were found
  117337. *
  117338. * @param xrInput the xrInput to which a new controller is initialized
  117339. * @param scene the scene to which the model will be added
  117340. * @param forceProfile force a certain profile for this controller
  117341. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117342. */
  117343. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117344. /**
  117345. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117346. *
  117347. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117348. *
  117349. * @param type the profile type to register
  117350. * @param constructFunction the function to be called when loading this profile
  117351. */
  117352. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117353. /**
  117354. * Register a fallback to a specific profile.
  117355. * @param profileId the profileId that will receive the fallbacks
  117356. * @param fallbacks A list of fallback profiles
  117357. */
  117358. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117359. /**
  117360. * Will update the list of profiles available in the repository
  117361. * @return a promise that resolves to a map of profiles available online
  117362. */
  117363. static UpdateProfilesList(): Promise<{
  117364. [profile: string]: string;
  117365. }>;
  117366. private static _LoadProfileFromRepository;
  117367. private static _LoadProfilesFromAvailableControllers;
  117368. }
  117369. }
  117370. declare module BABYLON {
  117371. /**
  117372. * Configuration options for the WebXR controller creation
  117373. */
  117374. export interface IWebXRControllerOptions {
  117375. /**
  117376. * Should the controller mesh be animated when a user interacts with it
  117377. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117378. */
  117379. disableMotionControllerAnimation?: boolean;
  117380. /**
  117381. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117382. */
  117383. doNotLoadControllerMesh?: boolean;
  117384. /**
  117385. * Force a specific controller type for this controller.
  117386. * This can be used when creating your own profile or when testing different controllers
  117387. */
  117388. forceControllerProfile?: string;
  117389. }
  117390. /**
  117391. * Represents an XR controller
  117392. */
  117393. export class WebXRInputSource {
  117394. private _scene;
  117395. /** The underlying input source for the controller */
  117396. inputSource: XRInputSource;
  117397. private _options;
  117398. private _tmpQuaternion;
  117399. private _tmpVector;
  117400. private _uniqueId;
  117401. /**
  117402. * 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
  117403. */
  117404. grip?: AbstractMesh;
  117405. /**
  117406. * If available, this is the gamepad object related to this controller.
  117407. * Using this object it is possible to get click events and trackpad changes of the
  117408. * webxr controller that is currently being used.
  117409. */
  117410. motionController?: WebXRAbstractMotionController;
  117411. /**
  117412. * Event that fires when the controller is removed/disposed.
  117413. * The object provided as event data is this controller, after associated assets were disposed.
  117414. * uniqueId is still available.
  117415. */
  117416. onDisposeObservable: Observable<WebXRInputSource>;
  117417. /**
  117418. * Will be triggered when the mesh associated with the motion controller is done loading.
  117419. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117420. * A shortened version of controller -> motion controller -> on mesh loaded.
  117421. */
  117422. onMeshLoadedObservable: Observable<AbstractMesh>;
  117423. /**
  117424. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117425. */
  117426. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117427. /**
  117428. * Pointer which can be used to select objects or attach a visible laser to
  117429. */
  117430. pointer: AbstractMesh;
  117431. /**
  117432. * Creates the controller
  117433. * @see https://doc.babylonjs.com/how_to/webxr
  117434. * @param _scene the scene which the controller should be associated to
  117435. * @param inputSource the underlying input source for the controller
  117436. * @param _options options for this controller creation
  117437. */
  117438. constructor(_scene: Scene,
  117439. /** The underlying input source for the controller */
  117440. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117441. /**
  117442. * Get this controllers unique id
  117443. */
  117444. get uniqueId(): string;
  117445. /**
  117446. * Disposes of the object
  117447. */
  117448. dispose(): void;
  117449. /**
  117450. * Gets a world space ray coming from the pointer or grip
  117451. * @param result the resulting ray
  117452. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117453. */
  117454. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117455. /**
  117456. * Updates the controller pose based on the given XRFrame
  117457. * @param xrFrame xr frame to update the pose with
  117458. * @param referenceSpace reference space to use
  117459. */
  117460. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117461. }
  117462. }
  117463. declare module BABYLON {
  117464. /**
  117465. * The schema for initialization options of the XR Input class
  117466. */
  117467. export interface IWebXRInputOptions {
  117468. /**
  117469. * If set to true no model will be automatically loaded
  117470. */
  117471. doNotLoadControllerMeshes?: boolean;
  117472. /**
  117473. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117474. * If not found, the xr input profile data will be used.
  117475. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117476. */
  117477. forceInputProfile?: string;
  117478. /**
  117479. * Do not send a request to the controller repository to load the profile.
  117480. *
  117481. * Instead, use the controllers available in babylon itself.
  117482. */
  117483. disableOnlineControllerRepository?: boolean;
  117484. /**
  117485. * A custom URL for the controllers repository
  117486. */
  117487. customControllersRepositoryURL?: string;
  117488. /**
  117489. * Should the controller model's components not move according to the user input
  117490. */
  117491. disableControllerAnimation?: boolean;
  117492. }
  117493. /**
  117494. * XR input used to track XR inputs such as controllers/rays
  117495. */
  117496. export class WebXRInput implements IDisposable {
  117497. /**
  117498. * the xr session manager for this session
  117499. */
  117500. xrSessionManager: WebXRSessionManager;
  117501. /**
  117502. * the WebXR camera for this session. Mainly used for teleportation
  117503. */
  117504. xrCamera: WebXRCamera;
  117505. private readonly options;
  117506. /**
  117507. * XR controllers being tracked
  117508. */
  117509. controllers: Array<WebXRInputSource>;
  117510. private _frameObserver;
  117511. private _sessionEndedObserver;
  117512. private _sessionInitObserver;
  117513. /**
  117514. * Event when a controller has been connected/added
  117515. */
  117516. onControllerAddedObservable: Observable<WebXRInputSource>;
  117517. /**
  117518. * Event when a controller has been removed/disconnected
  117519. */
  117520. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117521. /**
  117522. * Initializes the WebXRInput
  117523. * @param xrSessionManager the xr session manager for this session
  117524. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117525. * @param options = initialization options for this xr input
  117526. */
  117527. constructor(
  117528. /**
  117529. * the xr session manager for this session
  117530. */
  117531. xrSessionManager: WebXRSessionManager,
  117532. /**
  117533. * the WebXR camera for this session. Mainly used for teleportation
  117534. */
  117535. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117536. private _onInputSourcesChange;
  117537. private _addAndRemoveControllers;
  117538. /**
  117539. * Disposes of the object
  117540. */
  117541. dispose(): void;
  117542. }
  117543. }
  117544. declare module BABYLON {
  117545. /**
  117546. * This is the base class for all WebXR features.
  117547. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117548. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117549. */
  117550. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117551. protected _xrSessionManager: WebXRSessionManager;
  117552. private _attached;
  117553. private _removeOnDetach;
  117554. /**
  117555. * Should auto-attach be disabled?
  117556. */
  117557. disableAutoAttach: boolean;
  117558. /**
  117559. * Construct a new (abstract) WebXR feature
  117560. * @param _xrSessionManager the xr session manager for this feature
  117561. */
  117562. constructor(_xrSessionManager: WebXRSessionManager);
  117563. /**
  117564. * Is this feature attached
  117565. */
  117566. get attached(): boolean;
  117567. /**
  117568. * attach this feature
  117569. *
  117570. * @param force should attachment be forced (even when already attached)
  117571. * @returns true if successful, false is failed or already attached
  117572. */
  117573. attach(force?: boolean): boolean;
  117574. /**
  117575. * detach this feature.
  117576. *
  117577. * @returns true if successful, false if failed or already detached
  117578. */
  117579. detach(): boolean;
  117580. /**
  117581. * Dispose this feature and all of the resources attached
  117582. */
  117583. dispose(): void;
  117584. /**
  117585. * This is used to register callbacks that will automatically be removed when detach is called.
  117586. * @param observable the observable to which the observer will be attached
  117587. * @param callback the callback to register
  117588. */
  117589. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117590. /**
  117591. * Code in this function will be executed on each xrFrame received from the browser.
  117592. * This function will not execute after the feature is detached.
  117593. * @param _xrFrame the current frame
  117594. */
  117595. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117596. }
  117597. }
  117598. declare module BABYLON {
  117599. /**
  117600. * Renders a layer on top of an existing scene
  117601. */
  117602. export class UtilityLayerRenderer implements IDisposable {
  117603. /** the original scene that will be rendered on top of */
  117604. originalScene: Scene;
  117605. private _pointerCaptures;
  117606. private _lastPointerEvents;
  117607. private static _DefaultUtilityLayer;
  117608. private static _DefaultKeepDepthUtilityLayer;
  117609. private _sharedGizmoLight;
  117610. private _renderCamera;
  117611. /**
  117612. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117613. * @returns the camera that is used when rendering the utility layer
  117614. */
  117615. getRenderCamera(): Camera;
  117616. /**
  117617. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117618. * @param cam the camera that should be used when rendering the utility layer
  117619. */
  117620. setRenderCamera(cam: Nullable<Camera>): void;
  117621. /**
  117622. * @hidden
  117623. * Light which used by gizmos to get light shading
  117624. */
  117625. _getSharedGizmoLight(): HemisphericLight;
  117626. /**
  117627. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117628. */
  117629. pickUtilitySceneFirst: boolean;
  117630. /**
  117631. * 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)
  117632. */
  117633. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117634. /**
  117635. * 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)
  117636. */
  117637. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117638. /**
  117639. * The scene that is rendered on top of the original scene
  117640. */
  117641. utilityLayerScene: Scene;
  117642. /**
  117643. * If the utility layer should automatically be rendered on top of existing scene
  117644. */
  117645. shouldRender: boolean;
  117646. /**
  117647. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117648. */
  117649. onlyCheckPointerDownEvents: boolean;
  117650. /**
  117651. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117652. */
  117653. processAllEvents: boolean;
  117654. /**
  117655. * Observable raised when the pointer move from the utility layer scene to the main scene
  117656. */
  117657. onPointerOutObservable: Observable<number>;
  117658. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117659. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117660. private _afterRenderObserver;
  117661. private _sceneDisposeObserver;
  117662. private _originalPointerObserver;
  117663. /**
  117664. * Instantiates a UtilityLayerRenderer
  117665. * @param originalScene the original scene that will be rendered on top of
  117666. * @param handleEvents boolean indicating if the utility layer should handle events
  117667. */
  117668. constructor(
  117669. /** the original scene that will be rendered on top of */
  117670. originalScene: Scene, handleEvents?: boolean);
  117671. private _notifyObservers;
  117672. /**
  117673. * Renders the utility layers scene on top of the original scene
  117674. */
  117675. render(): void;
  117676. /**
  117677. * Disposes of the renderer
  117678. */
  117679. dispose(): void;
  117680. private _updateCamera;
  117681. }
  117682. }
  117683. declare module BABYLON {
  117684. /**
  117685. * Options interface for the pointer selection module
  117686. */
  117687. export interface IWebXRControllerPointerSelectionOptions {
  117688. /**
  117689. * if provided, this scene will be used to render meshes.
  117690. */
  117691. customUtilityLayerScene?: Scene;
  117692. /**
  117693. * 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)
  117694. * If not disabled, the last picked point will be used to execute a pointer up event
  117695. * If disabled, pointer up event will be triggered right after the pointer down event.
  117696. * Used in screen and gaze target ray mode only
  117697. */
  117698. disablePointerUpOnTouchOut: boolean;
  117699. /**
  117700. * For gaze mode (time to select instead of press)
  117701. */
  117702. forceGazeMode: boolean;
  117703. /**
  117704. * 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
  117705. * to start a new countdown to the pointer down event.
  117706. * Defaults to 1.
  117707. */
  117708. gazeModePointerMovedFactor?: number;
  117709. /**
  117710. * Different button type to use instead of the main component
  117711. */
  117712. overrideButtonId?: string;
  117713. /**
  117714. * use this rendering group id for the meshes (optional)
  117715. */
  117716. renderingGroupId?: number;
  117717. /**
  117718. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117719. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117720. * 3000 means 3 seconds between pointing at something and selecting it
  117721. */
  117722. timeToSelect?: number;
  117723. /**
  117724. * Should meshes created here be added to a utility layer or the main scene
  117725. */
  117726. useUtilityLayer?: boolean;
  117727. /**
  117728. * the xr input to use with this pointer selection
  117729. */
  117730. xrInput: WebXRInput;
  117731. }
  117732. /**
  117733. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117734. */
  117735. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117736. private readonly _options;
  117737. private static _idCounter;
  117738. private _attachController;
  117739. private _controllers;
  117740. private _scene;
  117741. private _tmpVectorForPickCompare;
  117742. /**
  117743. * The module's name
  117744. */
  117745. static readonly Name: string;
  117746. /**
  117747. * The (Babylon) version of this module.
  117748. * This is an integer representing the implementation version.
  117749. * This number does not correspond to the WebXR specs version
  117750. */
  117751. static readonly Version: number;
  117752. /**
  117753. * Disable lighting on the laser pointer (so it will always be visible)
  117754. */
  117755. disablePointerLighting: boolean;
  117756. /**
  117757. * Disable lighting on the selection mesh (so it will always be visible)
  117758. */
  117759. disableSelectionMeshLighting: boolean;
  117760. /**
  117761. * Should the laser pointer be displayed
  117762. */
  117763. displayLaserPointer: boolean;
  117764. /**
  117765. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117766. */
  117767. displaySelectionMesh: boolean;
  117768. /**
  117769. * This color will be set to the laser pointer when selection is triggered
  117770. */
  117771. laserPointerPickedColor: Color3;
  117772. /**
  117773. * Default color of the laser pointer
  117774. */
  117775. lasterPointerDefaultColor: Color3;
  117776. /**
  117777. * default color of the selection ring
  117778. */
  117779. selectionMeshDefaultColor: Color3;
  117780. /**
  117781. * This color will be applied to the selection ring when selection is triggered
  117782. */
  117783. selectionMeshPickedColor: Color3;
  117784. /**
  117785. * constructs a new background remover module
  117786. * @param _xrSessionManager the session manager for this module
  117787. * @param _options read-only options to be used in this module
  117788. */
  117789. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117790. /**
  117791. * attach this feature
  117792. * Will usually be called by the features manager
  117793. *
  117794. * @returns true if successful.
  117795. */
  117796. attach(): boolean;
  117797. /**
  117798. * detach this feature.
  117799. * Will usually be called by the features manager
  117800. *
  117801. * @returns true if successful.
  117802. */
  117803. detach(): boolean;
  117804. /**
  117805. * Will get the mesh under a specific pointer.
  117806. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117807. * @param controllerId the controllerId to check
  117808. * @returns The mesh under pointer or null if no mesh is under the pointer
  117809. */
  117810. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117811. /**
  117812. * Get the xr controller that correlates to the pointer id in the pointer event
  117813. *
  117814. * @param id the pointer id to search for
  117815. * @returns the controller that correlates to this id or null if not found
  117816. */
  117817. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117818. protected _onXRFrame(_xrFrame: XRFrame): void;
  117819. private _attachGazeMode;
  117820. private _attachScreenRayMode;
  117821. private _attachTrackedPointerRayMode;
  117822. private _convertNormalToDirectionOfRay;
  117823. private _detachController;
  117824. private _generateNewMeshPair;
  117825. private _pickingMoved;
  117826. private _updatePointerDistance;
  117827. }
  117828. }
  117829. declare module BABYLON {
  117830. /**
  117831. * Button which can be used to enter a different mode of XR
  117832. */
  117833. export class WebXREnterExitUIButton {
  117834. /** button element */
  117835. element: HTMLElement;
  117836. /** XR initialization options for the button */
  117837. sessionMode: XRSessionMode;
  117838. /** Reference space type */
  117839. referenceSpaceType: XRReferenceSpaceType;
  117840. /**
  117841. * Creates a WebXREnterExitUIButton
  117842. * @param element button element
  117843. * @param sessionMode XR initialization session mode
  117844. * @param referenceSpaceType the type of reference space to be used
  117845. */
  117846. constructor(
  117847. /** button element */
  117848. element: HTMLElement,
  117849. /** XR initialization options for the button */
  117850. sessionMode: XRSessionMode,
  117851. /** Reference space type */
  117852. referenceSpaceType: XRReferenceSpaceType);
  117853. /**
  117854. * Extendable function which can be used to update the button's visuals when the state changes
  117855. * @param activeButton the current active button in the UI
  117856. */
  117857. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117858. }
  117859. /**
  117860. * Options to create the webXR UI
  117861. */
  117862. export class WebXREnterExitUIOptions {
  117863. /**
  117864. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117865. */
  117866. customButtons?: Array<WebXREnterExitUIButton>;
  117867. /**
  117868. * A reference space type to use when creating the default button.
  117869. * Default is local-floor
  117870. */
  117871. referenceSpaceType?: XRReferenceSpaceType;
  117872. /**
  117873. * Context to enter xr with
  117874. */
  117875. renderTarget?: Nullable<WebXRRenderTarget>;
  117876. /**
  117877. * A session mode to use when creating the default button.
  117878. * Default is immersive-vr
  117879. */
  117880. sessionMode?: XRSessionMode;
  117881. }
  117882. /**
  117883. * UI to allow the user to enter/exit XR mode
  117884. */
  117885. export class WebXREnterExitUI implements IDisposable {
  117886. private scene;
  117887. /** version of the options passed to this UI */
  117888. options: WebXREnterExitUIOptions;
  117889. private _activeButton;
  117890. private _buttons;
  117891. private _overlay;
  117892. /**
  117893. * Fired every time the active button is changed.
  117894. *
  117895. * When xr is entered via a button that launches xr that button will be the callback parameter
  117896. *
  117897. * When exiting xr the callback parameter will be null)
  117898. */
  117899. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117900. /**
  117901. *
  117902. * @param scene babylon scene object to use
  117903. * @param options (read-only) version of the options passed to this UI
  117904. */
  117905. private constructor();
  117906. /**
  117907. * Creates UI to allow the user to enter/exit XR mode
  117908. * @param scene the scene to add the ui to
  117909. * @param helper the xr experience helper to enter/exit xr with
  117910. * @param options options to configure the UI
  117911. * @returns the created ui
  117912. */
  117913. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117914. /**
  117915. * Disposes of the XR UI component
  117916. */
  117917. dispose(): void;
  117918. private _updateButtons;
  117919. }
  117920. }
  117921. declare module BABYLON {
  117922. /**
  117923. * Class containing static functions to help procedurally build meshes
  117924. */
  117925. export class LinesBuilder {
  117926. /**
  117927. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117928. * * 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
  117929. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117930. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117931. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117932. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117933. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117934. * * 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
  117935. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117938. * @param name defines the name of the new line system
  117939. * @param options defines the options used to create the line system
  117940. * @param scene defines the hosting scene
  117941. * @returns a new line system mesh
  117942. */
  117943. static CreateLineSystem(name: string, options: {
  117944. lines: Vector3[][];
  117945. updatable?: boolean;
  117946. instance?: Nullable<LinesMesh>;
  117947. colors?: Nullable<Color4[][]>;
  117948. useVertexAlpha?: boolean;
  117949. }, scene: Nullable<Scene>): LinesMesh;
  117950. /**
  117951. * Creates a line mesh
  117952. * 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
  117953. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117954. * * The parameter `points` is an array successive Vector3
  117955. * * 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
  117956. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117957. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117958. * * When updating an instance, remember that only point positions can change, not the number of points
  117959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117960. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117961. * @param name defines the name of the new line system
  117962. * @param options defines the options used to create the line system
  117963. * @param scene defines the hosting scene
  117964. * @returns a new line mesh
  117965. */
  117966. static CreateLines(name: string, options: {
  117967. points: Vector3[];
  117968. updatable?: boolean;
  117969. instance?: Nullable<LinesMesh>;
  117970. colors?: Color4[];
  117971. useVertexAlpha?: boolean;
  117972. }, scene?: Nullable<Scene>): LinesMesh;
  117973. /**
  117974. * Creates a dashed line mesh
  117975. * * 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
  117976. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117977. * * The parameter `points` is an array successive Vector3
  117978. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117979. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117980. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117981. * * 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
  117982. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117983. * * When updating an instance, remember that only point positions can change, not the number of points
  117984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117985. * @param name defines the name of the mesh
  117986. * @param options defines the options used to create the mesh
  117987. * @param scene defines the hosting scene
  117988. * @returns the dashed line mesh
  117989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117990. */
  117991. static CreateDashedLines(name: string, options: {
  117992. points: Vector3[];
  117993. dashSize?: number;
  117994. gapSize?: number;
  117995. dashNb?: number;
  117996. updatable?: boolean;
  117997. instance?: LinesMesh;
  117998. useVertexAlpha?: boolean;
  117999. }, scene?: Nullable<Scene>): LinesMesh;
  118000. }
  118001. }
  118002. declare module BABYLON {
  118003. /**
  118004. * The options container for the teleportation module
  118005. */
  118006. export interface IWebXRTeleportationOptions {
  118007. /**
  118008. * if provided, this scene will be used to render meshes.
  118009. */
  118010. customUtilityLayerScene?: Scene;
  118011. /**
  118012. * Values to configure the default target mesh
  118013. */
  118014. defaultTargetMeshOptions?: {
  118015. /**
  118016. * Fill color of the teleportation area
  118017. */
  118018. teleportationFillColor?: string;
  118019. /**
  118020. * Border color for the teleportation area
  118021. */
  118022. teleportationBorderColor?: string;
  118023. /**
  118024. * Disable the mesh's animation sequence
  118025. */
  118026. disableAnimation?: boolean;
  118027. /**
  118028. * Disable lighting on the material or the ring and arrow
  118029. */
  118030. disableLighting?: boolean;
  118031. /**
  118032. * Override the default material of the torus and arrow
  118033. */
  118034. torusArrowMaterial?: Material;
  118035. };
  118036. /**
  118037. * A list of meshes to use as floor meshes.
  118038. * Meshes can be added and removed after initializing the feature using the
  118039. * addFloorMesh and removeFloorMesh functions
  118040. * If empty, rotation will still work
  118041. */
  118042. floorMeshes?: AbstractMesh[];
  118043. /**
  118044. * use this rendering group id for the meshes (optional)
  118045. */
  118046. renderingGroupId?: number;
  118047. /**
  118048. * Should teleportation move only to snap points
  118049. */
  118050. snapPointsOnly?: boolean;
  118051. /**
  118052. * An array of points to which the teleportation will snap to.
  118053. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118054. */
  118055. snapPositions?: Vector3[];
  118056. /**
  118057. * How close should the teleportation ray be in order to snap to position.
  118058. * Default to 0.8 units (meters)
  118059. */
  118060. snapToPositionRadius?: number;
  118061. /**
  118062. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118063. * If you want to support rotation, make sure your mesh has a direction indicator.
  118064. *
  118065. * When left untouched, the default mesh will be initialized.
  118066. */
  118067. teleportationTargetMesh?: AbstractMesh;
  118068. /**
  118069. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  118070. */
  118071. timeToTeleport?: number;
  118072. /**
  118073. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  118074. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  118075. */
  118076. useMainComponentOnly?: boolean;
  118077. /**
  118078. * Should meshes created here be added to a utility layer or the main scene
  118079. */
  118080. useUtilityLayer?: boolean;
  118081. /**
  118082. * Babylon XR Input class for controller
  118083. */
  118084. xrInput: WebXRInput;
  118085. }
  118086. /**
  118087. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118088. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118089. * the input of the attached controllers.
  118090. */
  118091. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118092. private _options;
  118093. private _controllers;
  118094. private _currentTeleportationControllerId;
  118095. private _floorMeshes;
  118096. private _quadraticBezierCurve;
  118097. private _selectionFeature;
  118098. private _snapToPositions;
  118099. private _snappedToPoint;
  118100. private _teleportationRingMaterial?;
  118101. private _tmpRay;
  118102. private _tmpVector;
  118103. /**
  118104. * The module's name
  118105. */
  118106. static readonly Name: string;
  118107. /**
  118108. * The (Babylon) version of this module.
  118109. * This is an integer representing the implementation version.
  118110. * This number does not correspond to the webxr specs version
  118111. */
  118112. static readonly Version: number;
  118113. /**
  118114. * Is movement backwards enabled
  118115. */
  118116. backwardsMovementEnabled: boolean;
  118117. /**
  118118. * Distance to travel when moving backwards
  118119. */
  118120. backwardsTeleportationDistance: number;
  118121. /**
  118122. * The distance from the user to the inspection point in the direction of the controller
  118123. * A higher number will allow the user to move further
  118124. * defaults to 5 (meters, in xr units)
  118125. */
  118126. parabolicCheckRadius: number;
  118127. /**
  118128. * Should the module support parabolic ray on top of direct ray
  118129. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118130. * Very helpful when moving between floors / different heights
  118131. */
  118132. parabolicRayEnabled: boolean;
  118133. /**
  118134. * How much rotation should be applied when rotating right and left
  118135. */
  118136. rotationAngle: number;
  118137. /**
  118138. * Is rotation enabled when moving forward?
  118139. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118140. */
  118141. rotationEnabled: boolean;
  118142. /**
  118143. * constructs a new anchor system
  118144. * @param _xrSessionManager an instance of WebXRSessionManager
  118145. * @param _options configuration object for this feature
  118146. */
  118147. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118148. /**
  118149. * Get the snapPointsOnly flag
  118150. */
  118151. get snapPointsOnly(): boolean;
  118152. /**
  118153. * Sets the snapPointsOnly flag
  118154. * @param snapToPoints should teleportation be exclusively to snap points
  118155. */
  118156. set snapPointsOnly(snapToPoints: boolean);
  118157. /**
  118158. * Add a new mesh to the floor meshes array
  118159. * @param mesh the mesh to use as floor mesh
  118160. */
  118161. addFloorMesh(mesh: AbstractMesh): void;
  118162. /**
  118163. * Add a new snap-to point to fix teleportation to this position
  118164. * @param newSnapPoint The new Snap-To point
  118165. */
  118166. addSnapPoint(newSnapPoint: Vector3): void;
  118167. attach(): boolean;
  118168. detach(): boolean;
  118169. dispose(): void;
  118170. /**
  118171. * Remove a mesh from the floor meshes array
  118172. * @param mesh the mesh to remove
  118173. */
  118174. removeFloorMesh(mesh: AbstractMesh): void;
  118175. /**
  118176. * Remove a mesh from the floor meshes array using its name
  118177. * @param name the mesh name to remove
  118178. */
  118179. removeFloorMeshByName(name: string): void;
  118180. /**
  118181. * 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
  118182. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118183. * @returns was the point found and removed or not
  118184. */
  118185. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118186. /**
  118187. * This function sets a selection feature that will be disabled when
  118188. * the forward ray is shown and will be reattached when hidden.
  118189. * This is used to remove the selection rays when moving.
  118190. * @param selectionFeature the feature to disable when forward movement is enabled
  118191. */
  118192. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118193. protected _onXRFrame(_xrFrame: XRFrame): void;
  118194. private _attachController;
  118195. private _createDefaultTargetMesh;
  118196. private _detachController;
  118197. private _findClosestSnapPointWithRadius;
  118198. private _setTargetMeshPosition;
  118199. private _setTargetMeshVisibility;
  118200. private _showParabolicPath;
  118201. private _teleportForward;
  118202. }
  118203. }
  118204. declare module BABYLON {
  118205. /**
  118206. * Options for the default xr helper
  118207. */
  118208. export class WebXRDefaultExperienceOptions {
  118209. /**
  118210. * Enable or disable default UI to enter XR
  118211. */
  118212. disableDefaultUI?: boolean;
  118213. /**
  118214. * Should teleportation not initialize. defaults to false.
  118215. */
  118216. disableTeleportation?: boolean;
  118217. /**
  118218. * Floor meshes that will be used for teleport
  118219. */
  118220. floorMeshes?: Array<AbstractMesh>;
  118221. /**
  118222. * If set to true, the first frame will not be used to reset position
  118223. * The first frame is mainly used when copying transformation from the old camera
  118224. * Mainly used in AR
  118225. */
  118226. ignoreNativeCameraTransformation?: boolean;
  118227. /**
  118228. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118229. */
  118230. inputOptions?: IWebXRInputOptions;
  118231. /**
  118232. * optional configuration for the output canvas
  118233. */
  118234. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118235. /**
  118236. * optional UI options. This can be used among other to change session mode and reference space type
  118237. */
  118238. uiOptions?: WebXREnterExitUIOptions;
  118239. /**
  118240. * When loading teleportation and pointer select, use stable versions instead of latest.
  118241. */
  118242. useStablePlugins?: boolean;
  118243. }
  118244. /**
  118245. * Default experience which provides a similar setup to the previous webVRExperience
  118246. */
  118247. export class WebXRDefaultExperience {
  118248. /**
  118249. * Base experience
  118250. */
  118251. baseExperience: WebXRExperienceHelper;
  118252. /**
  118253. * Enables ui for entering/exiting xr
  118254. */
  118255. enterExitUI: WebXREnterExitUI;
  118256. /**
  118257. * Input experience extension
  118258. */
  118259. input: WebXRInput;
  118260. /**
  118261. * Enables laser pointer and selection
  118262. */
  118263. pointerSelection: WebXRControllerPointerSelection;
  118264. /**
  118265. * Default target xr should render to
  118266. */
  118267. renderTarget: WebXRRenderTarget;
  118268. /**
  118269. * Enables teleportation
  118270. */
  118271. teleportation: WebXRMotionControllerTeleportation;
  118272. private constructor();
  118273. /**
  118274. * Creates the default xr experience
  118275. * @param scene scene
  118276. * @param options options for basic configuration
  118277. * @returns resulting WebXRDefaultExperience
  118278. */
  118279. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118280. /**
  118281. * DIsposes of the experience helper
  118282. */
  118283. dispose(): void;
  118284. }
  118285. }
  118286. declare module BABYLON {
  118287. /**
  118288. * Options to modify the vr teleportation behavior.
  118289. */
  118290. export interface VRTeleportationOptions {
  118291. /**
  118292. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118293. */
  118294. floorMeshName?: string;
  118295. /**
  118296. * A list of meshes to be used as the teleportation floor. (default: empty)
  118297. */
  118298. floorMeshes?: Mesh[];
  118299. /**
  118300. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118301. */
  118302. teleportationMode?: number;
  118303. /**
  118304. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118305. */
  118306. teleportationTime?: number;
  118307. /**
  118308. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118309. */
  118310. teleportationSpeed?: number;
  118311. /**
  118312. * The easing function used in the animation or null for Linear. (default CircleEase)
  118313. */
  118314. easingFunction?: EasingFunction;
  118315. }
  118316. /**
  118317. * Options to modify the vr experience helper's behavior.
  118318. */
  118319. export interface VRExperienceHelperOptions extends WebVROptions {
  118320. /**
  118321. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118322. */
  118323. createDeviceOrientationCamera?: boolean;
  118324. /**
  118325. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118326. */
  118327. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118328. /**
  118329. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118330. */
  118331. laserToggle?: boolean;
  118332. /**
  118333. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118334. */
  118335. floorMeshes?: Mesh[];
  118336. /**
  118337. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118338. */
  118339. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118340. /**
  118341. * Defines if WebXR should be used instead of WebVR (if available)
  118342. */
  118343. useXR?: boolean;
  118344. }
  118345. /**
  118346. * Event containing information after VR has been entered
  118347. */
  118348. export class OnAfterEnteringVRObservableEvent {
  118349. /**
  118350. * If entering vr was successful
  118351. */
  118352. success: boolean;
  118353. }
  118354. /**
  118355. * Helps to quickly add VR support to an existing scene.
  118356. * See http://doc.babylonjs.com/how_to/webvr_helper
  118357. */
  118358. export class VRExperienceHelper {
  118359. /** Options to modify the vr experience helper's behavior. */
  118360. webVROptions: VRExperienceHelperOptions;
  118361. private _scene;
  118362. private _position;
  118363. private _btnVR;
  118364. private _btnVRDisplayed;
  118365. private _webVRsupported;
  118366. private _webVRready;
  118367. private _webVRrequesting;
  118368. private _webVRpresenting;
  118369. private _hasEnteredVR;
  118370. private _fullscreenVRpresenting;
  118371. private _inputElement;
  118372. private _webVRCamera;
  118373. private _vrDeviceOrientationCamera;
  118374. private _deviceOrientationCamera;
  118375. private _existingCamera;
  118376. private _onKeyDown;
  118377. private _onVrDisplayPresentChange;
  118378. private _onVRDisplayChanged;
  118379. private _onVRRequestPresentStart;
  118380. private _onVRRequestPresentComplete;
  118381. /**
  118382. * 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)
  118383. */
  118384. enableGazeEvenWhenNoPointerLock: boolean;
  118385. /**
  118386. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118387. */
  118388. exitVROnDoubleTap: boolean;
  118389. /**
  118390. * Observable raised right before entering VR.
  118391. */
  118392. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118393. /**
  118394. * Observable raised when entering VR has completed.
  118395. */
  118396. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118397. /**
  118398. * Observable raised when exiting VR.
  118399. */
  118400. onExitingVRObservable: Observable<VRExperienceHelper>;
  118401. /**
  118402. * Observable raised when controller mesh is loaded.
  118403. */
  118404. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118405. /** Return this.onEnteringVRObservable
  118406. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118407. */
  118408. get onEnteringVR(): Observable<VRExperienceHelper>;
  118409. /** Return this.onExitingVRObservable
  118410. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118411. */
  118412. get onExitingVR(): Observable<VRExperienceHelper>;
  118413. /** Return this.onControllerMeshLoadedObservable
  118414. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118415. */
  118416. get onControllerMeshLoaded(): Observable<WebVRController>;
  118417. private _rayLength;
  118418. private _useCustomVRButton;
  118419. private _teleportationRequested;
  118420. private _teleportActive;
  118421. private _floorMeshName;
  118422. private _floorMeshesCollection;
  118423. private _teleportationMode;
  118424. private _teleportationTime;
  118425. private _teleportationSpeed;
  118426. private _teleportationEasing;
  118427. private _rotationAllowed;
  118428. private _teleportBackwardsVector;
  118429. private _teleportationTarget;
  118430. private _isDefaultTeleportationTarget;
  118431. private _postProcessMove;
  118432. private _teleportationFillColor;
  118433. private _teleportationBorderColor;
  118434. private _rotationAngle;
  118435. private _haloCenter;
  118436. private _cameraGazer;
  118437. private _padSensibilityUp;
  118438. private _padSensibilityDown;
  118439. private _leftController;
  118440. private _rightController;
  118441. private _gazeColor;
  118442. private _laserColor;
  118443. private _pickedLaserColor;
  118444. private _pickedGazeColor;
  118445. /**
  118446. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118447. */
  118448. onNewMeshSelected: Observable<AbstractMesh>;
  118449. /**
  118450. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118451. * This observable will provide the mesh and the controller used to select the mesh
  118452. */
  118453. onMeshSelectedWithController: Observable<{
  118454. mesh: AbstractMesh;
  118455. controller: WebVRController;
  118456. }>;
  118457. /**
  118458. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118459. */
  118460. onNewMeshPicked: Observable<PickingInfo>;
  118461. private _circleEase;
  118462. /**
  118463. * Observable raised before camera teleportation
  118464. */
  118465. onBeforeCameraTeleport: Observable<Vector3>;
  118466. /**
  118467. * Observable raised after camera teleportation
  118468. */
  118469. onAfterCameraTeleport: Observable<Vector3>;
  118470. /**
  118471. * Observable raised when current selected mesh gets unselected
  118472. */
  118473. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118474. private _raySelectionPredicate;
  118475. /**
  118476. * To be optionaly changed by user to define custom ray selection
  118477. */
  118478. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118479. /**
  118480. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118481. */
  118482. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118483. /**
  118484. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118485. */
  118486. teleportationEnabled: boolean;
  118487. private _defaultHeight;
  118488. private _teleportationInitialized;
  118489. private _interactionsEnabled;
  118490. private _interactionsRequested;
  118491. private _displayGaze;
  118492. private _displayLaserPointer;
  118493. /**
  118494. * The mesh used to display where the user is going to teleport.
  118495. */
  118496. get teleportationTarget(): Mesh;
  118497. /**
  118498. * Sets the mesh to be used to display where the user is going to teleport.
  118499. */
  118500. set teleportationTarget(value: Mesh);
  118501. /**
  118502. * 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
  118503. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118504. * See http://doc.babylonjs.com/resources/baking_transformations
  118505. */
  118506. get gazeTrackerMesh(): Mesh;
  118507. set gazeTrackerMesh(value: Mesh);
  118508. /**
  118509. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118510. */
  118511. updateGazeTrackerScale: boolean;
  118512. /**
  118513. * If the gaze trackers color should be updated when selecting meshes
  118514. */
  118515. updateGazeTrackerColor: boolean;
  118516. /**
  118517. * If the controller laser color should be updated when selecting meshes
  118518. */
  118519. updateControllerLaserColor: boolean;
  118520. /**
  118521. * The gaze tracking mesh corresponding to the left controller
  118522. */
  118523. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118524. /**
  118525. * The gaze tracking mesh corresponding to the right controller
  118526. */
  118527. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118528. /**
  118529. * If the ray of the gaze should be displayed.
  118530. */
  118531. get displayGaze(): boolean;
  118532. /**
  118533. * Sets if the ray of the gaze should be displayed.
  118534. */
  118535. set displayGaze(value: boolean);
  118536. /**
  118537. * If the ray of the LaserPointer should be displayed.
  118538. */
  118539. get displayLaserPointer(): boolean;
  118540. /**
  118541. * Sets if the ray of the LaserPointer should be displayed.
  118542. */
  118543. set displayLaserPointer(value: boolean);
  118544. /**
  118545. * The deviceOrientationCamera used as the camera when not in VR.
  118546. */
  118547. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118548. /**
  118549. * Based on the current WebVR support, returns the current VR camera used.
  118550. */
  118551. get currentVRCamera(): Nullable<Camera>;
  118552. /**
  118553. * The webVRCamera which is used when in VR.
  118554. */
  118555. get webVRCamera(): WebVRFreeCamera;
  118556. /**
  118557. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118558. */
  118559. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118560. /**
  118561. * The html button that is used to trigger entering into VR.
  118562. */
  118563. get vrButton(): Nullable<HTMLButtonElement>;
  118564. private get _teleportationRequestInitiated();
  118565. /**
  118566. * Defines whether or not Pointer lock should be requested when switching to
  118567. * full screen.
  118568. */
  118569. requestPointerLockOnFullScreen: boolean;
  118570. /**
  118571. * If asking to force XR, this will be populated with the default xr experience
  118572. */
  118573. xr: WebXRDefaultExperience;
  118574. /**
  118575. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118576. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118577. */
  118578. xrTestDone: boolean;
  118579. /**
  118580. * Instantiates a VRExperienceHelper.
  118581. * Helps to quickly add VR support to an existing scene.
  118582. * @param scene The scene the VRExperienceHelper belongs to.
  118583. * @param webVROptions Options to modify the vr experience helper's behavior.
  118584. */
  118585. constructor(scene: Scene,
  118586. /** Options to modify the vr experience helper's behavior. */
  118587. webVROptions?: VRExperienceHelperOptions);
  118588. private completeVRInit;
  118589. private _onDefaultMeshLoaded;
  118590. private _onResize;
  118591. private _onFullscreenChange;
  118592. /**
  118593. * Gets a value indicating if we are currently in VR mode.
  118594. */
  118595. get isInVRMode(): boolean;
  118596. private onVrDisplayPresentChange;
  118597. private onVRDisplayChanged;
  118598. private moveButtonToBottomRight;
  118599. private displayVRButton;
  118600. private updateButtonVisibility;
  118601. private _cachedAngularSensibility;
  118602. /**
  118603. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118604. * Otherwise, will use the fullscreen API.
  118605. */
  118606. enterVR(): void;
  118607. /**
  118608. * Attempt to exit VR, or fullscreen.
  118609. */
  118610. exitVR(): void;
  118611. /**
  118612. * The position of the vr experience helper.
  118613. */
  118614. get position(): Vector3;
  118615. /**
  118616. * Sets the position of the vr experience helper.
  118617. */
  118618. set position(value: Vector3);
  118619. /**
  118620. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118621. */
  118622. enableInteractions(): void;
  118623. private get _noControllerIsActive();
  118624. private beforeRender;
  118625. private _isTeleportationFloor;
  118626. /**
  118627. * Adds a floor mesh to be used for teleportation.
  118628. * @param floorMesh the mesh to be used for teleportation.
  118629. */
  118630. addFloorMesh(floorMesh: Mesh): void;
  118631. /**
  118632. * Removes a floor mesh from being used for teleportation.
  118633. * @param floorMesh the mesh to be removed.
  118634. */
  118635. removeFloorMesh(floorMesh: Mesh): void;
  118636. /**
  118637. * Enables interactions and teleportation using the VR controllers and gaze.
  118638. * @param vrTeleportationOptions options to modify teleportation behavior.
  118639. */
  118640. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118641. private _onNewGamepadConnected;
  118642. private _tryEnableInteractionOnController;
  118643. private _onNewGamepadDisconnected;
  118644. private _enableInteractionOnController;
  118645. private _checkTeleportWithRay;
  118646. private _checkRotate;
  118647. private _checkTeleportBackwards;
  118648. private _enableTeleportationOnController;
  118649. private _createTeleportationCircles;
  118650. private _displayTeleportationTarget;
  118651. private _hideTeleportationTarget;
  118652. private _rotateCamera;
  118653. private _moveTeleportationSelectorTo;
  118654. private _workingVector;
  118655. private _workingQuaternion;
  118656. private _workingMatrix;
  118657. /**
  118658. * Time Constant Teleportation Mode
  118659. */
  118660. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118661. /**
  118662. * Speed Constant Teleportation Mode
  118663. */
  118664. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118665. /**
  118666. * Teleports the users feet to the desired location
  118667. * @param location The location where the user's feet should be placed
  118668. */
  118669. teleportCamera(location: Vector3): void;
  118670. private _convertNormalToDirectionOfRay;
  118671. private _castRayAndSelectObject;
  118672. private _notifySelectedMeshUnselected;
  118673. /**
  118674. * Permanently set new colors for the laser pointer
  118675. * @param color the new laser color
  118676. * @param pickedColor the new laser color when picked mesh detected
  118677. */
  118678. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118679. /**
  118680. * Set lighting enabled / disabled on the laser pointer of both controllers
  118681. * @param enabled should the lighting be enabled on the laser pointer
  118682. */
  118683. setLaserLightingState(enabled?: boolean): void;
  118684. /**
  118685. * Permanently set new colors for the gaze pointer
  118686. * @param color the new gaze color
  118687. * @param pickedColor the new gaze color when picked mesh detected
  118688. */
  118689. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118690. /**
  118691. * Sets the color of the laser ray from the vr controllers.
  118692. * @param color new color for the ray.
  118693. */
  118694. changeLaserColor(color: Color3): void;
  118695. /**
  118696. * Sets the color of the ray from the vr headsets gaze.
  118697. * @param color new color for the ray.
  118698. */
  118699. changeGazeColor(color: Color3): void;
  118700. /**
  118701. * Exits VR and disposes of the vr experience helper
  118702. */
  118703. dispose(): void;
  118704. /**
  118705. * Gets the name of the VRExperienceHelper class
  118706. * @returns "VRExperienceHelper"
  118707. */
  118708. getClassName(): string;
  118709. }
  118710. }
  118711. declare module BABYLON {
  118712. /**
  118713. * Contains an array of blocks representing the octree
  118714. */
  118715. export interface IOctreeContainer<T> {
  118716. /**
  118717. * Blocks within the octree
  118718. */
  118719. blocks: Array<OctreeBlock<T>>;
  118720. }
  118721. /**
  118722. * Class used to store a cell in an octree
  118723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118724. */
  118725. export class OctreeBlock<T> {
  118726. /**
  118727. * Gets the content of the current block
  118728. */
  118729. entries: T[];
  118730. /**
  118731. * Gets the list of block children
  118732. */
  118733. blocks: Array<OctreeBlock<T>>;
  118734. private _depth;
  118735. private _maxDepth;
  118736. private _capacity;
  118737. private _minPoint;
  118738. private _maxPoint;
  118739. private _boundingVectors;
  118740. private _creationFunc;
  118741. /**
  118742. * Creates a new block
  118743. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118744. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118745. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118746. * @param depth defines the current depth of this block in the octree
  118747. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118748. * @param creationFunc defines a callback to call when an element is added to the block
  118749. */
  118750. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118751. /**
  118752. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118753. */
  118754. get capacity(): number;
  118755. /**
  118756. * Gets the minimum vector (in world space) of the block's bounding box
  118757. */
  118758. get minPoint(): Vector3;
  118759. /**
  118760. * Gets the maximum vector (in world space) of the block's bounding box
  118761. */
  118762. get maxPoint(): Vector3;
  118763. /**
  118764. * Add a new element to this block
  118765. * @param entry defines the element to add
  118766. */
  118767. addEntry(entry: T): void;
  118768. /**
  118769. * Remove an element from this block
  118770. * @param entry defines the element to remove
  118771. */
  118772. removeEntry(entry: T): void;
  118773. /**
  118774. * Add an array of elements to this block
  118775. * @param entries defines the array of elements to add
  118776. */
  118777. addEntries(entries: T[]): void;
  118778. /**
  118779. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118780. * @param frustumPlanes defines the frustum planes to test
  118781. * @param selection defines the array to store current content if selection is positive
  118782. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118783. */
  118784. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118785. /**
  118786. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118787. * @param sphereCenter defines the bounding sphere center
  118788. * @param sphereRadius defines the bounding sphere radius
  118789. * @param selection defines the array to store current content if selection is positive
  118790. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118791. */
  118792. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118793. /**
  118794. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118795. * @param ray defines the ray to test with
  118796. * @param selection defines the array to store current content if selection is positive
  118797. */
  118798. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118799. /**
  118800. * Subdivide the content into child blocks (this block will then be empty)
  118801. */
  118802. createInnerBlocks(): void;
  118803. /**
  118804. * @hidden
  118805. */
  118806. 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;
  118807. }
  118808. }
  118809. declare module BABYLON {
  118810. /**
  118811. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118813. */
  118814. export class Octree<T> {
  118815. /** 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.) */
  118816. maxDepth: number;
  118817. /**
  118818. * Blocks within the octree containing objects
  118819. */
  118820. blocks: Array<OctreeBlock<T>>;
  118821. /**
  118822. * Content stored in the octree
  118823. */
  118824. dynamicContent: T[];
  118825. private _maxBlockCapacity;
  118826. private _selectionContent;
  118827. private _creationFunc;
  118828. /**
  118829. * Creates a octree
  118830. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118831. * @param creationFunc function to be used to instatiate the octree
  118832. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118833. * @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.)
  118834. */
  118835. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118836. /** 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.) */
  118837. maxDepth?: number);
  118838. /**
  118839. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118840. * @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);
  118841. * @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);
  118842. * @param entries meshes to be added to the octree blocks
  118843. */
  118844. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118845. /**
  118846. * Adds a mesh to the octree
  118847. * @param entry Mesh to add to the octree
  118848. */
  118849. addMesh(entry: T): void;
  118850. /**
  118851. * Remove an element from the octree
  118852. * @param entry defines the element to remove
  118853. */
  118854. removeMesh(entry: T): void;
  118855. /**
  118856. * Selects an array of meshes within the frustum
  118857. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118858. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118859. * @returns array of meshes within the frustum
  118860. */
  118861. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118862. /**
  118863. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118864. * @param sphereCenter defines the bounding sphere center
  118865. * @param sphereRadius defines the bounding sphere radius
  118866. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118867. * @returns an array of objects that intersect the sphere
  118868. */
  118869. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118870. /**
  118871. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118872. * @param ray defines the ray to test with
  118873. * @returns array of intersected objects
  118874. */
  118875. intersectsRay(ray: Ray): SmartArray<T>;
  118876. /**
  118877. * Adds a mesh into the octree block if it intersects the block
  118878. */
  118879. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118880. /**
  118881. * Adds a submesh into the octree block if it intersects the block
  118882. */
  118883. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118884. }
  118885. }
  118886. declare module BABYLON {
  118887. interface Scene {
  118888. /**
  118889. * @hidden
  118890. * Backing Filed
  118891. */
  118892. _selectionOctree: Octree<AbstractMesh>;
  118893. /**
  118894. * Gets the octree used to boost mesh selection (picking)
  118895. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118896. */
  118897. selectionOctree: Octree<AbstractMesh>;
  118898. /**
  118899. * Creates or updates the octree used to boost selection (picking)
  118900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118901. * @param maxCapacity defines the maximum capacity per leaf
  118902. * @param maxDepth defines the maximum depth of the octree
  118903. * @returns an octree of AbstractMesh
  118904. */
  118905. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118906. }
  118907. interface AbstractMesh {
  118908. /**
  118909. * @hidden
  118910. * Backing Field
  118911. */
  118912. _submeshesOctree: Octree<SubMesh>;
  118913. /**
  118914. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118915. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118916. * @param maxCapacity defines the maximum size of each block (64 by default)
  118917. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118918. * @returns the new octree
  118919. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118921. */
  118922. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118923. }
  118924. /**
  118925. * Defines the octree scene component responsible to manage any octrees
  118926. * in a given scene.
  118927. */
  118928. export class OctreeSceneComponent {
  118929. /**
  118930. * The component name help to identify the component in the list of scene components.
  118931. */
  118932. readonly name: string;
  118933. /**
  118934. * The scene the component belongs to.
  118935. */
  118936. scene: Scene;
  118937. /**
  118938. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118939. */
  118940. readonly checksIsEnabled: boolean;
  118941. /**
  118942. * Creates a new instance of the component for the given scene
  118943. * @param scene Defines the scene to register the component in
  118944. */
  118945. constructor(scene: Scene);
  118946. /**
  118947. * Registers the component in a given scene
  118948. */
  118949. register(): void;
  118950. /**
  118951. * Return the list of active meshes
  118952. * @returns the list of active meshes
  118953. */
  118954. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118955. /**
  118956. * Return the list of active sub meshes
  118957. * @param mesh The mesh to get the candidates sub meshes from
  118958. * @returns the list of active sub meshes
  118959. */
  118960. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118961. private _tempRay;
  118962. /**
  118963. * Return the list of sub meshes intersecting with a given local ray
  118964. * @param mesh defines the mesh to find the submesh for
  118965. * @param localRay defines the ray in local space
  118966. * @returns the list of intersecting sub meshes
  118967. */
  118968. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118969. /**
  118970. * Return the list of sub meshes colliding with a collider
  118971. * @param mesh defines the mesh to find the submesh for
  118972. * @param collider defines the collider to evaluate the collision against
  118973. * @returns the list of colliding sub meshes
  118974. */
  118975. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118976. /**
  118977. * Rebuilds the elements related to this component in case of
  118978. * context lost for instance.
  118979. */
  118980. rebuild(): void;
  118981. /**
  118982. * Disposes the component and the associated ressources.
  118983. */
  118984. dispose(): void;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118990. */
  118991. export class Gizmo implements IDisposable {
  118992. /** The utility layer the gizmo will be added to */
  118993. gizmoLayer: UtilityLayerRenderer;
  118994. /**
  118995. * The root mesh of the gizmo
  118996. */
  118997. _rootMesh: Mesh;
  118998. private _attachedMesh;
  118999. /**
  119000. * Ratio for the scale of the gizmo (Default: 1)
  119001. */
  119002. scaleRatio: number;
  119003. /**
  119004. * If a custom mesh has been set (Default: false)
  119005. */
  119006. protected _customMeshSet: boolean;
  119007. /**
  119008. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119009. * * When set, interactions will be enabled
  119010. */
  119011. get attachedMesh(): Nullable<AbstractMesh>;
  119012. set attachedMesh(value: Nullable<AbstractMesh>);
  119013. /**
  119014. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119015. * @param mesh The mesh to replace the default mesh of the gizmo
  119016. */
  119017. setCustomMesh(mesh: Mesh): void;
  119018. /**
  119019. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119020. */
  119021. updateGizmoRotationToMatchAttachedMesh: boolean;
  119022. /**
  119023. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119024. */
  119025. updateGizmoPositionToMatchAttachedMesh: boolean;
  119026. /**
  119027. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119028. */
  119029. updateScale: boolean;
  119030. protected _interactionsEnabled: boolean;
  119031. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119032. private _beforeRenderObserver;
  119033. private _tempVector;
  119034. /**
  119035. * Creates a gizmo
  119036. * @param gizmoLayer The utility layer the gizmo will be added to
  119037. */
  119038. constructor(
  119039. /** The utility layer the gizmo will be added to */
  119040. gizmoLayer?: UtilityLayerRenderer);
  119041. /**
  119042. * Updates the gizmo to match the attached mesh's position/rotation
  119043. */
  119044. protected _update(): void;
  119045. /**
  119046. * Disposes of the gizmo
  119047. */
  119048. dispose(): void;
  119049. }
  119050. }
  119051. declare module BABYLON {
  119052. /**
  119053. * Single plane drag gizmo
  119054. */
  119055. export class PlaneDragGizmo extends Gizmo {
  119056. /**
  119057. * Drag behavior responsible for the gizmos dragging interactions
  119058. */
  119059. dragBehavior: PointerDragBehavior;
  119060. private _pointerObserver;
  119061. /**
  119062. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119063. */
  119064. snapDistance: number;
  119065. /**
  119066. * Event that fires each time the gizmo snaps to a new location.
  119067. * * snapDistance is the the change in distance
  119068. */
  119069. onSnapObservable: Observable<{
  119070. snapDistance: number;
  119071. }>;
  119072. private _plane;
  119073. private _coloredMaterial;
  119074. private _hoverMaterial;
  119075. private _isEnabled;
  119076. private _parent;
  119077. /** @hidden */
  119078. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119079. /** @hidden */
  119080. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119081. /**
  119082. * Creates a PlaneDragGizmo
  119083. * @param gizmoLayer The utility layer the gizmo will be added to
  119084. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119085. * @param color The color of the gizmo
  119086. */
  119087. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119088. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119089. /**
  119090. * If the gizmo is enabled
  119091. */
  119092. set isEnabled(value: boolean);
  119093. get isEnabled(): boolean;
  119094. /**
  119095. * Disposes of the gizmo
  119096. */
  119097. dispose(): void;
  119098. }
  119099. }
  119100. declare module BABYLON {
  119101. /**
  119102. * Gizmo that enables dragging a mesh along 3 axis
  119103. */
  119104. export class PositionGizmo extends Gizmo {
  119105. /**
  119106. * Internal gizmo used for interactions on the x axis
  119107. */
  119108. xGizmo: AxisDragGizmo;
  119109. /**
  119110. * Internal gizmo used for interactions on the y axis
  119111. */
  119112. yGizmo: AxisDragGizmo;
  119113. /**
  119114. * Internal gizmo used for interactions on the z axis
  119115. */
  119116. zGizmo: AxisDragGizmo;
  119117. /**
  119118. * Internal gizmo used for interactions on the yz plane
  119119. */
  119120. xPlaneGizmo: PlaneDragGizmo;
  119121. /**
  119122. * Internal gizmo used for interactions on the xz plane
  119123. */
  119124. yPlaneGizmo: PlaneDragGizmo;
  119125. /**
  119126. * Internal gizmo used for interactions on the xy plane
  119127. */
  119128. zPlaneGizmo: PlaneDragGizmo;
  119129. /**
  119130. * private variables
  119131. */
  119132. private _meshAttached;
  119133. private _updateGizmoRotationToMatchAttachedMesh;
  119134. private _snapDistance;
  119135. private _scaleRatio;
  119136. /** Fires an event when any of it's sub gizmos are dragged */
  119137. onDragStartObservable: Observable<unknown>;
  119138. /** Fires an event when any of it's sub gizmos are released from dragging */
  119139. onDragEndObservable: Observable<unknown>;
  119140. /**
  119141. * If set to true, planar drag is enabled
  119142. */
  119143. private _planarGizmoEnabled;
  119144. get attachedMesh(): Nullable<AbstractMesh>;
  119145. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119146. /**
  119147. * Creates a PositionGizmo
  119148. * @param gizmoLayer The utility layer the gizmo will be added to
  119149. */
  119150. constructor(gizmoLayer?: UtilityLayerRenderer);
  119151. /**
  119152. * If the planar drag gizmo is enabled
  119153. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119154. */
  119155. set planarGizmoEnabled(value: boolean);
  119156. get planarGizmoEnabled(): boolean;
  119157. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119158. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119159. /**
  119160. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119161. */
  119162. set snapDistance(value: number);
  119163. get snapDistance(): number;
  119164. /**
  119165. * Ratio for the scale of the gizmo (Default: 1)
  119166. */
  119167. set scaleRatio(value: number);
  119168. get scaleRatio(): number;
  119169. /**
  119170. * Disposes of the gizmo
  119171. */
  119172. dispose(): void;
  119173. /**
  119174. * CustomMeshes are not supported by this gizmo
  119175. * @param mesh The mesh to replace the default mesh of the gizmo
  119176. */
  119177. setCustomMesh(mesh: Mesh): void;
  119178. }
  119179. }
  119180. declare module BABYLON {
  119181. /**
  119182. * Single axis drag gizmo
  119183. */
  119184. export class AxisDragGizmo extends Gizmo {
  119185. /**
  119186. * Drag behavior responsible for the gizmos dragging interactions
  119187. */
  119188. dragBehavior: PointerDragBehavior;
  119189. private _pointerObserver;
  119190. /**
  119191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119192. */
  119193. snapDistance: number;
  119194. /**
  119195. * Event that fires each time the gizmo snaps to a new location.
  119196. * * snapDistance is the the change in distance
  119197. */
  119198. onSnapObservable: Observable<{
  119199. snapDistance: number;
  119200. }>;
  119201. private _isEnabled;
  119202. private _parent;
  119203. private _arrow;
  119204. private _coloredMaterial;
  119205. private _hoverMaterial;
  119206. /** @hidden */
  119207. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119208. /** @hidden */
  119209. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119210. /**
  119211. * Creates an AxisDragGizmo
  119212. * @param gizmoLayer The utility layer the gizmo will be added to
  119213. * @param dragAxis The axis which the gizmo will be able to drag on
  119214. * @param color The color of the gizmo
  119215. */
  119216. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119217. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119218. /**
  119219. * If the gizmo is enabled
  119220. */
  119221. set isEnabled(value: boolean);
  119222. get isEnabled(): boolean;
  119223. /**
  119224. * Disposes of the gizmo
  119225. */
  119226. dispose(): void;
  119227. }
  119228. }
  119229. declare module BABYLON.Debug {
  119230. /**
  119231. * The Axes viewer will show 3 axes in a specific point in space
  119232. */
  119233. export class AxesViewer {
  119234. private _xAxis;
  119235. private _yAxis;
  119236. private _zAxis;
  119237. private _scaleLinesFactor;
  119238. private _instanced;
  119239. /**
  119240. * Gets the hosting scene
  119241. */
  119242. scene: Scene;
  119243. /**
  119244. * Gets or sets a number used to scale line length
  119245. */
  119246. scaleLines: number;
  119247. /** Gets the node hierarchy used to render x-axis */
  119248. get xAxis(): TransformNode;
  119249. /** Gets the node hierarchy used to render y-axis */
  119250. get yAxis(): TransformNode;
  119251. /** Gets the node hierarchy used to render z-axis */
  119252. get zAxis(): TransformNode;
  119253. /**
  119254. * Creates a new AxesViewer
  119255. * @param scene defines the hosting scene
  119256. * @param scaleLines defines a number used to scale line length (1 by default)
  119257. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119258. * @param xAxis defines the node hierarchy used to render the x-axis
  119259. * @param yAxis defines the node hierarchy used to render the y-axis
  119260. * @param zAxis defines the node hierarchy used to render the z-axis
  119261. */
  119262. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119263. /**
  119264. * Force the viewer to update
  119265. * @param position defines the position of the viewer
  119266. * @param xaxis defines the x axis of the viewer
  119267. * @param yaxis defines the y axis of the viewer
  119268. * @param zaxis defines the z axis of the viewer
  119269. */
  119270. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119271. /**
  119272. * Creates an instance of this axes viewer.
  119273. * @returns a new axes viewer with instanced meshes
  119274. */
  119275. createInstance(): AxesViewer;
  119276. /** Releases resources */
  119277. dispose(): void;
  119278. private static _SetRenderingGroupId;
  119279. }
  119280. }
  119281. declare module BABYLON.Debug {
  119282. /**
  119283. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119284. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119285. */
  119286. export class BoneAxesViewer extends AxesViewer {
  119287. /**
  119288. * Gets or sets the target mesh where to display the axes viewer
  119289. */
  119290. mesh: Nullable<Mesh>;
  119291. /**
  119292. * Gets or sets the target bone where to display the axes viewer
  119293. */
  119294. bone: Nullable<Bone>;
  119295. /** Gets current position */
  119296. pos: Vector3;
  119297. /** Gets direction of X axis */
  119298. xaxis: Vector3;
  119299. /** Gets direction of Y axis */
  119300. yaxis: Vector3;
  119301. /** Gets direction of Z axis */
  119302. zaxis: Vector3;
  119303. /**
  119304. * Creates a new BoneAxesViewer
  119305. * @param scene defines the hosting scene
  119306. * @param bone defines the target bone
  119307. * @param mesh defines the target mesh
  119308. * @param scaleLines defines a scaling factor for line length (1 by default)
  119309. */
  119310. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119311. /**
  119312. * Force the viewer to update
  119313. */
  119314. update(): void;
  119315. /** Releases resources */
  119316. dispose(): void;
  119317. }
  119318. }
  119319. declare module BABYLON {
  119320. /**
  119321. * Interface used to define scene explorer extensibility option
  119322. */
  119323. export interface IExplorerExtensibilityOption {
  119324. /**
  119325. * Define the option label
  119326. */
  119327. label: string;
  119328. /**
  119329. * Defines the action to execute on click
  119330. */
  119331. action: (entity: any) => void;
  119332. }
  119333. /**
  119334. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119335. */
  119336. export interface IExplorerExtensibilityGroup {
  119337. /**
  119338. * Defines a predicate to test if a given type mut be extended
  119339. */
  119340. predicate: (entity: any) => boolean;
  119341. /**
  119342. * Gets the list of options added to a type
  119343. */
  119344. entries: IExplorerExtensibilityOption[];
  119345. }
  119346. /**
  119347. * Interface used to define the options to use to create the Inspector
  119348. */
  119349. export interface IInspectorOptions {
  119350. /**
  119351. * Display in overlay mode (default: false)
  119352. */
  119353. overlay?: boolean;
  119354. /**
  119355. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119356. */
  119357. globalRoot?: HTMLElement;
  119358. /**
  119359. * Display the Scene explorer
  119360. */
  119361. showExplorer?: boolean;
  119362. /**
  119363. * Display the property inspector
  119364. */
  119365. showInspector?: boolean;
  119366. /**
  119367. * Display in embed mode (both panes on the right)
  119368. */
  119369. embedMode?: boolean;
  119370. /**
  119371. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119372. */
  119373. handleResize?: boolean;
  119374. /**
  119375. * Allow the panes to popup (default: true)
  119376. */
  119377. enablePopup?: boolean;
  119378. /**
  119379. * Allow the panes to be closed by users (default: true)
  119380. */
  119381. enableClose?: boolean;
  119382. /**
  119383. * Optional list of extensibility entries
  119384. */
  119385. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119386. /**
  119387. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119388. */
  119389. inspectorURL?: string;
  119390. /**
  119391. * Optional initial tab (default to DebugLayerTab.Properties)
  119392. */
  119393. initialTab?: DebugLayerTab;
  119394. }
  119395. interface Scene {
  119396. /**
  119397. * @hidden
  119398. * Backing field
  119399. */
  119400. _debugLayer: DebugLayer;
  119401. /**
  119402. * Gets the debug layer (aka Inspector) associated with the scene
  119403. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119404. */
  119405. debugLayer: DebugLayer;
  119406. }
  119407. /**
  119408. * Enum of inspector action tab
  119409. */
  119410. export enum DebugLayerTab {
  119411. /**
  119412. * Properties tag (default)
  119413. */
  119414. Properties = 0,
  119415. /**
  119416. * Debug tab
  119417. */
  119418. Debug = 1,
  119419. /**
  119420. * Statistics tab
  119421. */
  119422. Statistics = 2,
  119423. /**
  119424. * Tools tab
  119425. */
  119426. Tools = 3,
  119427. /**
  119428. * Settings tab
  119429. */
  119430. Settings = 4
  119431. }
  119432. /**
  119433. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119434. * what is happening in your scene
  119435. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119436. */
  119437. export class DebugLayer {
  119438. /**
  119439. * Define the url to get the inspector script from.
  119440. * By default it uses the babylonjs CDN.
  119441. * @ignoreNaming
  119442. */
  119443. static InspectorURL: string;
  119444. private _scene;
  119445. private BJSINSPECTOR;
  119446. private _onPropertyChangedObservable?;
  119447. /**
  119448. * Observable triggered when a property is changed through the inspector.
  119449. */
  119450. get onPropertyChangedObservable(): any;
  119451. /**
  119452. * Instantiates a new debug layer.
  119453. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119454. * what is happening in your scene
  119455. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119456. * @param scene Defines the scene to inspect
  119457. */
  119458. constructor(scene: Scene);
  119459. /** Creates the inspector window. */
  119460. private _createInspector;
  119461. /**
  119462. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119463. * @param entity defines the entity to select
  119464. * @param lineContainerTitle defines the specific block to highlight
  119465. */
  119466. select(entity: any, lineContainerTitle?: string): void;
  119467. /** Get the inspector from bundle or global */
  119468. private _getGlobalInspector;
  119469. /**
  119470. * Get if the inspector is visible or not.
  119471. * @returns true if visible otherwise, false
  119472. */
  119473. isVisible(): boolean;
  119474. /**
  119475. * Hide the inspector and close its window.
  119476. */
  119477. hide(): void;
  119478. /**
  119479. * Launch the debugLayer.
  119480. * @param config Define the configuration of the inspector
  119481. * @return a promise fulfilled when the debug layer is visible
  119482. */
  119483. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119484. }
  119485. }
  119486. declare module BABYLON {
  119487. /**
  119488. * Class containing static functions to help procedurally build meshes
  119489. */
  119490. export class BoxBuilder {
  119491. /**
  119492. * Creates a box mesh
  119493. * * The parameter `size` sets the size (float) of each box side (default 1)
  119494. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119495. * * 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)
  119496. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119500. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119501. * @param name defines the name of the mesh
  119502. * @param options defines the options used to create the mesh
  119503. * @param scene defines the hosting scene
  119504. * @returns the box mesh
  119505. */
  119506. static CreateBox(name: string, options: {
  119507. size?: number;
  119508. width?: number;
  119509. height?: number;
  119510. depth?: number;
  119511. faceUV?: Vector4[];
  119512. faceColors?: Color4[];
  119513. sideOrientation?: number;
  119514. frontUVs?: Vector4;
  119515. backUVs?: Vector4;
  119516. wrap?: boolean;
  119517. topBaseAt?: number;
  119518. bottomBaseAt?: number;
  119519. updatable?: boolean;
  119520. }, scene?: Nullable<Scene>): Mesh;
  119521. }
  119522. }
  119523. declare module BABYLON.Debug {
  119524. /**
  119525. * Used to show the physics impostor around the specific mesh
  119526. */
  119527. export class PhysicsViewer {
  119528. /** @hidden */
  119529. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119530. /** @hidden */
  119531. protected _meshes: Array<Nullable<AbstractMesh>>;
  119532. /** @hidden */
  119533. protected _scene: Nullable<Scene>;
  119534. /** @hidden */
  119535. protected _numMeshes: number;
  119536. /** @hidden */
  119537. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119538. private _renderFunction;
  119539. private _utilityLayer;
  119540. private _debugBoxMesh;
  119541. private _debugSphereMesh;
  119542. private _debugCylinderMesh;
  119543. private _debugMaterial;
  119544. private _debugMeshMeshes;
  119545. /**
  119546. * Creates a new PhysicsViewer
  119547. * @param scene defines the hosting scene
  119548. */
  119549. constructor(scene: Scene);
  119550. /** @hidden */
  119551. protected _updateDebugMeshes(): void;
  119552. /**
  119553. * Renders a specified physic impostor
  119554. * @param impostor defines the impostor to render
  119555. * @param targetMesh defines the mesh represented by the impostor
  119556. * @returns the new debug mesh used to render the impostor
  119557. */
  119558. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119559. /**
  119560. * Hides a specified physic impostor
  119561. * @param impostor defines the impostor to hide
  119562. */
  119563. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119564. private _getDebugMaterial;
  119565. private _getDebugBoxMesh;
  119566. private _getDebugSphereMesh;
  119567. private _getDebugCylinderMesh;
  119568. private _getDebugMeshMesh;
  119569. private _getDebugMesh;
  119570. /** Releases all resources */
  119571. dispose(): void;
  119572. }
  119573. }
  119574. declare module BABYLON {
  119575. /**
  119576. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119577. * in order to better appreciate the issue one might have.
  119578. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119579. */
  119580. export class RayHelper {
  119581. /**
  119582. * Defines the ray we are currently tryin to visualize.
  119583. */
  119584. ray: Nullable<Ray>;
  119585. private _renderPoints;
  119586. private _renderLine;
  119587. private _renderFunction;
  119588. private _scene;
  119589. private _updateToMeshFunction;
  119590. private _attachedToMesh;
  119591. private _meshSpaceDirection;
  119592. private _meshSpaceOrigin;
  119593. /**
  119594. * Helper function to create a colored helper in a scene in one line.
  119595. * @param ray Defines the ray we are currently tryin to visualize
  119596. * @param scene Defines the scene the ray is used in
  119597. * @param color Defines the color we want to see the ray in
  119598. * @returns The newly created ray helper.
  119599. */
  119600. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119601. /**
  119602. * Instantiate a new ray helper.
  119603. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119604. * in order to better appreciate the issue one might have.
  119605. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119606. * @param ray Defines the ray we are currently tryin to visualize
  119607. */
  119608. constructor(ray: Ray);
  119609. /**
  119610. * Shows the ray we are willing to debug.
  119611. * @param scene Defines the scene the ray needs to be rendered in
  119612. * @param color Defines the color the ray needs to be rendered in
  119613. */
  119614. show(scene: Scene, color?: Color3): void;
  119615. /**
  119616. * Hides the ray we are debugging.
  119617. */
  119618. hide(): void;
  119619. private _render;
  119620. /**
  119621. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119622. * @param mesh Defines the mesh we want the helper attached to
  119623. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119624. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119625. * @param length Defines the length of the ray
  119626. */
  119627. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119628. /**
  119629. * Detach the ray helper from the mesh it has previously been attached to.
  119630. */
  119631. detachFromMesh(): void;
  119632. private _updateToMesh;
  119633. /**
  119634. * Dispose the helper and release its associated resources.
  119635. */
  119636. dispose(): void;
  119637. }
  119638. }
  119639. declare module BABYLON.Debug {
  119640. /**
  119641. * Class used to render a debug view of a given skeleton
  119642. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119643. */
  119644. export class SkeletonViewer {
  119645. /** defines the skeleton to render */
  119646. skeleton: Skeleton;
  119647. /** defines the mesh attached to the skeleton */
  119648. mesh: AbstractMesh;
  119649. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119650. autoUpdateBonesMatrices: boolean;
  119651. /** defines the rendering group id to use with the viewer */
  119652. renderingGroupId: number;
  119653. /** Gets or sets the color used to render the skeleton */
  119654. color: Color3;
  119655. private _scene;
  119656. private _debugLines;
  119657. private _debugMesh;
  119658. private _isEnabled;
  119659. private _renderFunction;
  119660. private _utilityLayer;
  119661. /**
  119662. * Returns the mesh used to render the bones
  119663. */
  119664. get debugMesh(): Nullable<LinesMesh>;
  119665. /**
  119666. * Creates a new SkeletonViewer
  119667. * @param skeleton defines the skeleton to render
  119668. * @param mesh defines the mesh attached to the skeleton
  119669. * @param scene defines the hosting scene
  119670. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119671. * @param renderingGroupId defines the rendering group id to use with the viewer
  119672. */
  119673. constructor(
  119674. /** defines the skeleton to render */
  119675. skeleton: Skeleton,
  119676. /** defines the mesh attached to the skeleton */
  119677. mesh: AbstractMesh, scene: Scene,
  119678. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119679. autoUpdateBonesMatrices?: boolean,
  119680. /** defines the rendering group id to use with the viewer */
  119681. renderingGroupId?: number);
  119682. /** Gets or sets a boolean indicating if the viewer is enabled */
  119683. set isEnabled(value: boolean);
  119684. get isEnabled(): boolean;
  119685. private _getBonePosition;
  119686. private _getLinesForBonesWithLength;
  119687. private _getLinesForBonesNoLength;
  119688. /** Update the viewer to sync with current skeleton state */
  119689. update(): void;
  119690. /** Release associated resources */
  119691. dispose(): void;
  119692. }
  119693. }
  119694. declare module BABYLON {
  119695. /**
  119696. * Options to create the null engine
  119697. */
  119698. export class NullEngineOptions {
  119699. /**
  119700. * Render width (Default: 512)
  119701. */
  119702. renderWidth: number;
  119703. /**
  119704. * Render height (Default: 256)
  119705. */
  119706. renderHeight: number;
  119707. /**
  119708. * Texture size (Default: 512)
  119709. */
  119710. textureSize: number;
  119711. /**
  119712. * If delta time between frames should be constant
  119713. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119714. */
  119715. deterministicLockstep: boolean;
  119716. /**
  119717. * Maximum about of steps between frames (Default: 4)
  119718. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119719. */
  119720. lockstepMaxSteps: number;
  119721. }
  119722. /**
  119723. * The null engine class provides support for headless version of babylon.js.
  119724. * This can be used in server side scenario or for testing purposes
  119725. */
  119726. export class NullEngine extends Engine {
  119727. private _options;
  119728. /**
  119729. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119731. * @returns true if engine is in deterministic lock step mode
  119732. */
  119733. isDeterministicLockStep(): boolean;
  119734. /**
  119735. * Gets the max steps when engine is running in deterministic lock step
  119736. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119737. * @returns the max steps
  119738. */
  119739. getLockstepMaxSteps(): number;
  119740. /**
  119741. * Gets the current hardware scaling level.
  119742. * By default the hardware scaling level is computed from the window device ratio.
  119743. * 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.
  119744. * @returns a number indicating the current hardware scaling level
  119745. */
  119746. getHardwareScalingLevel(): number;
  119747. constructor(options?: NullEngineOptions);
  119748. /**
  119749. * Creates a vertex buffer
  119750. * @param vertices the data for the vertex buffer
  119751. * @returns the new WebGL static buffer
  119752. */
  119753. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119754. /**
  119755. * Creates a new index buffer
  119756. * @param indices defines the content of the index buffer
  119757. * @param updatable defines if the index buffer must be updatable
  119758. * @returns a new webGL buffer
  119759. */
  119760. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119761. /**
  119762. * Clear the current render buffer or the current render target (if any is set up)
  119763. * @param color defines the color to use
  119764. * @param backBuffer defines if the back buffer must be cleared
  119765. * @param depth defines if the depth buffer must be cleared
  119766. * @param stencil defines if the stencil buffer must be cleared
  119767. */
  119768. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119769. /**
  119770. * Gets the current render width
  119771. * @param useScreen defines if screen size must be used (or the current render target if any)
  119772. * @returns a number defining the current render width
  119773. */
  119774. getRenderWidth(useScreen?: boolean): number;
  119775. /**
  119776. * Gets the current render height
  119777. * @param useScreen defines if screen size must be used (or the current render target if any)
  119778. * @returns a number defining the current render height
  119779. */
  119780. getRenderHeight(useScreen?: boolean): number;
  119781. /**
  119782. * Set the WebGL's viewport
  119783. * @param viewport defines the viewport element to be used
  119784. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119785. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119786. */
  119787. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119788. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119789. /**
  119790. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119791. * @param pipelineContext defines the pipeline context to use
  119792. * @param uniformsNames defines the list of uniform names
  119793. * @returns an array of webGL uniform locations
  119794. */
  119795. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119796. /**
  119797. * Gets the lsit of active attributes for a given webGL program
  119798. * @param pipelineContext defines the pipeline context to use
  119799. * @param attributesNames defines the list of attribute names to get
  119800. * @returns an array of indices indicating the offset of each attribute
  119801. */
  119802. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119803. /**
  119804. * Binds an effect to the webGL context
  119805. * @param effect defines the effect to bind
  119806. */
  119807. bindSamplers(effect: Effect): void;
  119808. /**
  119809. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119810. * @param effect defines the effect to activate
  119811. */
  119812. enableEffect(effect: Effect): void;
  119813. /**
  119814. * Set various states to the webGL context
  119815. * @param culling defines backface culling state
  119816. * @param zOffset defines the value to apply to zOffset (0 by default)
  119817. * @param force defines if states must be applied even if cache is up to date
  119818. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119819. */
  119820. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119821. /**
  119822. * Set the value of an uniform to an array of int32
  119823. * @param uniform defines the webGL uniform location where to store the value
  119824. * @param array defines the array of int32 to store
  119825. */
  119826. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119827. /**
  119828. * Set the value of an uniform to an array of int32 (stored as vec2)
  119829. * @param uniform defines the webGL uniform location where to store the value
  119830. * @param array defines the array of int32 to store
  119831. */
  119832. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119833. /**
  119834. * Set the value of an uniform to an array of int32 (stored as vec3)
  119835. * @param uniform defines the webGL uniform location where to store the value
  119836. * @param array defines the array of int32 to store
  119837. */
  119838. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119839. /**
  119840. * Set the value of an uniform to an array of int32 (stored as vec4)
  119841. * @param uniform defines the webGL uniform location where to store the value
  119842. * @param array defines the array of int32 to store
  119843. */
  119844. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119845. /**
  119846. * Set the value of an uniform to an array of float32
  119847. * @param uniform defines the webGL uniform location where to store the value
  119848. * @param array defines the array of float32 to store
  119849. */
  119850. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119851. /**
  119852. * Set the value of an uniform to an array of float32 (stored as vec2)
  119853. * @param uniform defines the webGL uniform location where to store the value
  119854. * @param array defines the array of float32 to store
  119855. */
  119856. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119857. /**
  119858. * Set the value of an uniform to an array of float32 (stored as vec3)
  119859. * @param uniform defines the webGL uniform location where to store the value
  119860. * @param array defines the array of float32 to store
  119861. */
  119862. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119863. /**
  119864. * Set the value of an uniform to an array of float32 (stored as vec4)
  119865. * @param uniform defines the webGL uniform location where to store the value
  119866. * @param array defines the array of float32 to store
  119867. */
  119868. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119869. /**
  119870. * Set the value of an uniform to an array of number
  119871. * @param uniform defines the webGL uniform location where to store the value
  119872. * @param array defines the array of number to store
  119873. */
  119874. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119875. /**
  119876. * Set the value of an uniform to an array of number (stored as vec2)
  119877. * @param uniform defines the webGL uniform location where to store the value
  119878. * @param array defines the array of number to store
  119879. */
  119880. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119881. /**
  119882. * Set the value of an uniform to an array of number (stored as vec3)
  119883. * @param uniform defines the webGL uniform location where to store the value
  119884. * @param array defines the array of number to store
  119885. */
  119886. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119887. /**
  119888. * Set the value of an uniform to an array of number (stored as vec4)
  119889. * @param uniform defines the webGL uniform location where to store the value
  119890. * @param array defines the array of number to store
  119891. */
  119892. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119893. /**
  119894. * Set the value of an uniform to an array of float32 (stored as matrices)
  119895. * @param uniform defines the webGL uniform location where to store the value
  119896. * @param matrices defines the array of float32 to store
  119897. */
  119898. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119899. /**
  119900. * Set the value of an uniform to a matrix (3x3)
  119901. * @param uniform defines the webGL uniform location where to store the value
  119902. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119903. */
  119904. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119905. /**
  119906. * Set the value of an uniform to a matrix (2x2)
  119907. * @param uniform defines the webGL uniform location where to store the value
  119908. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119909. */
  119910. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119911. /**
  119912. * Set the value of an uniform to a number (float)
  119913. * @param uniform defines the webGL uniform location where to store the value
  119914. * @param value defines the float number to store
  119915. */
  119916. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119917. /**
  119918. * Set the value of an uniform to a vec2
  119919. * @param uniform defines the webGL uniform location where to store the value
  119920. * @param x defines the 1st component of the value
  119921. * @param y defines the 2nd component of the value
  119922. */
  119923. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119924. /**
  119925. * Set the value of an uniform to a vec3
  119926. * @param uniform defines the webGL uniform location where to store the value
  119927. * @param x defines the 1st component of the value
  119928. * @param y defines the 2nd component of the value
  119929. * @param z defines the 3rd component of the value
  119930. */
  119931. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119932. /**
  119933. * Set the value of an uniform to a boolean
  119934. * @param uniform defines the webGL uniform location where to store the value
  119935. * @param bool defines the boolean to store
  119936. */
  119937. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119938. /**
  119939. * Set the value of an uniform to a vec4
  119940. * @param uniform defines the webGL uniform location where to store the value
  119941. * @param x defines the 1st component of the value
  119942. * @param y defines the 2nd component of the value
  119943. * @param z defines the 3rd component of the value
  119944. * @param w defines the 4th component of the value
  119945. */
  119946. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119947. /**
  119948. * Sets the current alpha mode
  119949. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119950. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119952. */
  119953. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119954. /**
  119955. * Bind webGl buffers directly to the webGL context
  119956. * @param vertexBuffers defines the vertex buffer to bind
  119957. * @param indexBuffer defines the index buffer to bind
  119958. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119959. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119960. * @param effect defines the effect associated with the vertex buffer
  119961. */
  119962. bindBuffers(vertexBuffers: {
  119963. [key: string]: VertexBuffer;
  119964. }, indexBuffer: DataBuffer, effect: Effect): void;
  119965. /**
  119966. * Force the entire cache to be cleared
  119967. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119968. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119969. */
  119970. wipeCaches(bruteForce?: boolean): void;
  119971. /**
  119972. * Send a draw order
  119973. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119974. * @param indexStart defines the starting index
  119975. * @param indexCount defines the number of index to draw
  119976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119977. */
  119978. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119979. /**
  119980. * Draw a list of indexed primitives
  119981. * @param fillMode defines the primitive to use
  119982. * @param indexStart defines the starting index
  119983. * @param indexCount defines the number of index to draw
  119984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119985. */
  119986. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119987. /**
  119988. * Draw a list of unindexed primitives
  119989. * @param fillMode defines the primitive to use
  119990. * @param verticesStart defines the index of first vertex to draw
  119991. * @param verticesCount defines the count of vertices to draw
  119992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119993. */
  119994. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119995. /** @hidden */
  119996. _createTexture(): WebGLTexture;
  119997. /** @hidden */
  119998. _releaseTexture(texture: InternalTexture): void;
  119999. /**
  120000. * Usually called from Texture.ts.
  120001. * Passed information to create a WebGLTexture
  120002. * @param urlArg defines a value which contains one of the following:
  120003. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120004. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120005. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120006. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120007. * @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)
  120008. * @param scene needed for loading to the correct scene
  120009. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120010. * @param onLoad optional callback to be called upon successful completion
  120011. * @param onError optional callback to be called upon failure
  120012. * @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
  120013. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120014. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120015. * @param forcedExtension defines the extension to use to pick the right loader
  120016. * @param mimeType defines an optional mime type
  120017. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120018. */
  120019. 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;
  120020. /**
  120021. * Creates a new render target texture
  120022. * @param size defines the size of the texture
  120023. * @param options defines the options used to create the texture
  120024. * @returns a new render target texture stored in an InternalTexture
  120025. */
  120026. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120027. /**
  120028. * Update the sampling mode of a given texture
  120029. * @param samplingMode defines the required sampling mode
  120030. * @param texture defines the texture to update
  120031. */
  120032. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120033. /**
  120034. * Binds the frame buffer to the specified texture.
  120035. * @param texture The texture to render to or null for the default canvas
  120036. * @param faceIndex The face of the texture to render to in case of cube texture
  120037. * @param requiredWidth The width of the target to render to
  120038. * @param requiredHeight The height of the target to render to
  120039. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120040. * @param lodLevel defines le lod level to bind to the frame buffer
  120041. */
  120042. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120043. /**
  120044. * Unbind the current render target texture from the webGL context
  120045. * @param texture defines the render target texture to unbind
  120046. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120047. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120048. */
  120049. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120050. /**
  120051. * Creates a dynamic vertex buffer
  120052. * @param vertices the data for the dynamic vertex buffer
  120053. * @returns the new WebGL dynamic buffer
  120054. */
  120055. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120056. /**
  120057. * Update the content of a dynamic texture
  120058. * @param texture defines the texture to update
  120059. * @param canvas defines the canvas containing the source
  120060. * @param invertY defines if data must be stored with Y axis inverted
  120061. * @param premulAlpha defines if alpha is stored as premultiplied
  120062. * @param format defines the format of the data
  120063. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120064. */
  120065. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120066. /**
  120067. * Gets a boolean indicating if all created effects are ready
  120068. * @returns true if all effects are ready
  120069. */
  120070. areAllEffectsReady(): boolean;
  120071. /**
  120072. * @hidden
  120073. * Get the current error code of the webGL context
  120074. * @returns the error code
  120075. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120076. */
  120077. getError(): number;
  120078. /** @hidden */
  120079. _getUnpackAlignement(): number;
  120080. /** @hidden */
  120081. _unpackFlipY(value: boolean): void;
  120082. /**
  120083. * Update a dynamic index buffer
  120084. * @param indexBuffer defines the target index buffer
  120085. * @param indices defines the data to update
  120086. * @param offset defines the offset in the target index buffer where update should start
  120087. */
  120088. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120089. /**
  120090. * Updates a dynamic vertex buffer.
  120091. * @param vertexBuffer the vertex buffer to update
  120092. * @param vertices the data used to update the vertex buffer
  120093. * @param byteOffset the byte offset of the data (optional)
  120094. * @param byteLength the byte length of the data (optional)
  120095. */
  120096. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120097. /** @hidden */
  120098. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120099. /** @hidden */
  120100. _bindTexture(channel: number, texture: InternalTexture): void;
  120101. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120102. /**
  120103. * 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
  120104. */
  120105. releaseEffects(): void;
  120106. displayLoadingUI(): void;
  120107. hideLoadingUI(): void;
  120108. /** @hidden */
  120109. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120110. /** @hidden */
  120111. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120112. /** @hidden */
  120113. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120114. /** @hidden */
  120115. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120116. }
  120117. }
  120118. declare module BABYLON {
  120119. /**
  120120. * @hidden
  120121. **/
  120122. export class _TimeToken {
  120123. _startTimeQuery: Nullable<WebGLQuery>;
  120124. _endTimeQuery: Nullable<WebGLQuery>;
  120125. _timeElapsedQuery: Nullable<WebGLQuery>;
  120126. _timeElapsedQueryEnded: boolean;
  120127. }
  120128. }
  120129. declare module BABYLON {
  120130. /** @hidden */
  120131. export class _OcclusionDataStorage {
  120132. /** @hidden */
  120133. occlusionInternalRetryCounter: number;
  120134. /** @hidden */
  120135. isOcclusionQueryInProgress: boolean;
  120136. /** @hidden */
  120137. isOccluded: boolean;
  120138. /** @hidden */
  120139. occlusionRetryCount: number;
  120140. /** @hidden */
  120141. occlusionType: number;
  120142. /** @hidden */
  120143. occlusionQueryAlgorithmType: number;
  120144. }
  120145. interface Engine {
  120146. /**
  120147. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120148. * @return the new query
  120149. */
  120150. createQuery(): WebGLQuery;
  120151. /**
  120152. * Delete and release a webGL query
  120153. * @param query defines the query to delete
  120154. * @return the current engine
  120155. */
  120156. deleteQuery(query: WebGLQuery): Engine;
  120157. /**
  120158. * Check if a given query has resolved and got its value
  120159. * @param query defines the query to check
  120160. * @returns true if the query got its value
  120161. */
  120162. isQueryResultAvailable(query: WebGLQuery): boolean;
  120163. /**
  120164. * Gets the value of a given query
  120165. * @param query defines the query to check
  120166. * @returns the value of the query
  120167. */
  120168. getQueryResult(query: WebGLQuery): number;
  120169. /**
  120170. * Initiates an occlusion query
  120171. * @param algorithmType defines the algorithm to use
  120172. * @param query defines the query to use
  120173. * @returns the current engine
  120174. * @see http://doc.babylonjs.com/features/occlusionquery
  120175. */
  120176. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120177. /**
  120178. * Ends an occlusion query
  120179. * @see http://doc.babylonjs.com/features/occlusionquery
  120180. * @param algorithmType defines the algorithm to use
  120181. * @returns the current engine
  120182. */
  120183. endOcclusionQuery(algorithmType: number): Engine;
  120184. /**
  120185. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120186. * Please note that only one query can be issued at a time
  120187. * @returns a time token used to track the time span
  120188. */
  120189. startTimeQuery(): Nullable<_TimeToken>;
  120190. /**
  120191. * Ends a time query
  120192. * @param token defines the token used to measure the time span
  120193. * @returns the time spent (in ns)
  120194. */
  120195. endTimeQuery(token: _TimeToken): int;
  120196. /** @hidden */
  120197. _currentNonTimestampToken: Nullable<_TimeToken>;
  120198. /** @hidden */
  120199. _createTimeQuery(): WebGLQuery;
  120200. /** @hidden */
  120201. _deleteTimeQuery(query: WebGLQuery): void;
  120202. /** @hidden */
  120203. _getGlAlgorithmType(algorithmType: number): number;
  120204. /** @hidden */
  120205. _getTimeQueryResult(query: WebGLQuery): any;
  120206. /** @hidden */
  120207. _getTimeQueryAvailability(query: WebGLQuery): any;
  120208. }
  120209. interface AbstractMesh {
  120210. /**
  120211. * Backing filed
  120212. * @hidden
  120213. */
  120214. __occlusionDataStorage: _OcclusionDataStorage;
  120215. /**
  120216. * Access property
  120217. * @hidden
  120218. */
  120219. _occlusionDataStorage: _OcclusionDataStorage;
  120220. /**
  120221. * 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.
  120222. * The default value is -1 which means don't break the query and wait till the result
  120223. * @see http://doc.babylonjs.com/features/occlusionquery
  120224. */
  120225. occlusionRetryCount: number;
  120226. /**
  120227. * 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:
  120228. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120229. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120230. * * 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.
  120231. * @see http://doc.babylonjs.com/features/occlusionquery
  120232. */
  120233. occlusionType: number;
  120234. /**
  120235. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120236. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120237. * * 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.
  120238. * @see http://doc.babylonjs.com/features/occlusionquery
  120239. */
  120240. occlusionQueryAlgorithmType: number;
  120241. /**
  120242. * 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
  120243. * @see http://doc.babylonjs.com/features/occlusionquery
  120244. */
  120245. isOccluded: boolean;
  120246. /**
  120247. * Flag to check the progress status of the query
  120248. * @see http://doc.babylonjs.com/features/occlusionquery
  120249. */
  120250. isOcclusionQueryInProgress: boolean;
  120251. }
  120252. }
  120253. declare module BABYLON {
  120254. /** @hidden */
  120255. export var _forceTransformFeedbackToBundle: boolean;
  120256. interface Engine {
  120257. /**
  120258. * Creates a webGL transform feedback object
  120259. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120260. * @returns the webGL transform feedback object
  120261. */
  120262. createTransformFeedback(): WebGLTransformFeedback;
  120263. /**
  120264. * Delete a webGL transform feedback object
  120265. * @param value defines the webGL transform feedback object to delete
  120266. */
  120267. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120268. /**
  120269. * Bind a webGL transform feedback object to the webgl context
  120270. * @param value defines the webGL transform feedback object to bind
  120271. */
  120272. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120273. /**
  120274. * Begins a transform feedback operation
  120275. * @param usePoints defines if points or triangles must be used
  120276. */
  120277. beginTransformFeedback(usePoints: boolean): void;
  120278. /**
  120279. * Ends a transform feedback operation
  120280. */
  120281. endTransformFeedback(): void;
  120282. /**
  120283. * Specify the varyings to use with transform feedback
  120284. * @param program defines the associated webGL program
  120285. * @param value defines the list of strings representing the varying names
  120286. */
  120287. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120288. /**
  120289. * Bind a webGL buffer for a transform feedback operation
  120290. * @param value defines the webGL buffer to bind
  120291. */
  120292. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120293. }
  120294. }
  120295. declare module BABYLON {
  120296. /**
  120297. * Creation options of the multi render target texture.
  120298. */
  120299. export interface IMultiRenderTargetOptions {
  120300. /**
  120301. * Define if the texture needs to create mip maps after render.
  120302. */
  120303. generateMipMaps?: boolean;
  120304. /**
  120305. * Define the types of all the draw buffers we want to create
  120306. */
  120307. types?: number[];
  120308. /**
  120309. * Define the sampling modes of all the draw buffers we want to create
  120310. */
  120311. samplingModes?: number[];
  120312. /**
  120313. * Define if a depth buffer is required
  120314. */
  120315. generateDepthBuffer?: boolean;
  120316. /**
  120317. * Define if a stencil buffer is required
  120318. */
  120319. generateStencilBuffer?: boolean;
  120320. /**
  120321. * Define if a depth texture is required instead of a depth buffer
  120322. */
  120323. generateDepthTexture?: boolean;
  120324. /**
  120325. * Define the number of desired draw buffers
  120326. */
  120327. textureCount?: number;
  120328. /**
  120329. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120330. */
  120331. doNotChangeAspectRatio?: boolean;
  120332. /**
  120333. * Define the default type of the buffers we are creating
  120334. */
  120335. defaultType?: number;
  120336. }
  120337. /**
  120338. * A multi render target, like a render target provides the ability to render to a texture.
  120339. * Unlike the render target, it can render to several draw buffers in one draw.
  120340. * This is specially interesting in deferred rendering or for any effects requiring more than
  120341. * just one color from a single pass.
  120342. */
  120343. export class MultiRenderTarget extends RenderTargetTexture {
  120344. private _internalTextures;
  120345. private _textures;
  120346. private _multiRenderTargetOptions;
  120347. /**
  120348. * Get if draw buffers are currently supported by the used hardware and browser.
  120349. */
  120350. get isSupported(): boolean;
  120351. /**
  120352. * Get the list of textures generated by the multi render target.
  120353. */
  120354. get textures(): Texture[];
  120355. /**
  120356. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120357. */
  120358. get depthTexture(): Texture;
  120359. /**
  120360. * Set the wrapping mode on U of all the textures we are rendering to.
  120361. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120362. */
  120363. set wrapU(wrap: number);
  120364. /**
  120365. * Set the wrapping mode on V of all the textures we are rendering to.
  120366. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120367. */
  120368. set wrapV(wrap: number);
  120369. /**
  120370. * Instantiate a new multi render target texture.
  120371. * A multi render target, like a render target provides the ability to render to a texture.
  120372. * Unlike the render target, it can render to several draw buffers in one draw.
  120373. * This is specially interesting in deferred rendering or for any effects requiring more than
  120374. * just one color from a single pass.
  120375. * @param name Define the name of the texture
  120376. * @param size Define the size of the buffers to render to
  120377. * @param count Define the number of target we are rendering into
  120378. * @param scene Define the scene the texture belongs to
  120379. * @param options Define the options used to create the multi render target
  120380. */
  120381. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120382. /** @hidden */
  120383. _rebuild(): void;
  120384. private _createInternalTextures;
  120385. private _createTextures;
  120386. /**
  120387. * Define the number of samples used if MSAA is enabled.
  120388. */
  120389. get samples(): number;
  120390. set samples(value: number);
  120391. /**
  120392. * Resize all the textures in the multi render target.
  120393. * Be carrefull as it will recreate all the data in the new texture.
  120394. * @param size Define the new size
  120395. */
  120396. resize(size: any): void;
  120397. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120398. /**
  120399. * Dispose the render targets and their associated resources
  120400. */
  120401. dispose(): void;
  120402. /**
  120403. * Release all the underlying texture used as draw buffers.
  120404. */
  120405. releaseInternalTextures(): void;
  120406. }
  120407. }
  120408. declare module BABYLON {
  120409. interface ThinEngine {
  120410. /**
  120411. * Unbind a list of render target textures from the webGL context
  120412. * This is used only when drawBuffer extension or webGL2 are active
  120413. * @param textures defines the render target textures to unbind
  120414. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120415. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120416. */
  120417. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120418. /**
  120419. * Create a multi render target texture
  120420. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120421. * @param size defines the size of the texture
  120422. * @param options defines the creation options
  120423. * @returns the cube texture as an InternalTexture
  120424. */
  120425. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120426. /**
  120427. * Update the sample count for a given multiple render target texture
  120428. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120429. * @param textures defines the textures to update
  120430. * @param samples defines the sample count to set
  120431. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120432. */
  120433. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120434. }
  120435. }
  120436. declare module BABYLON {
  120437. /**
  120438. * Class used to define an additional view for the engine
  120439. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120440. */
  120441. export class EngineView {
  120442. /** Defines the canvas where to render the view */
  120443. target: HTMLCanvasElement;
  120444. /** Defines an optional camera used to render the view (will use active camera else) */
  120445. camera?: Camera;
  120446. }
  120447. interface Engine {
  120448. /**
  120449. * Gets or sets the HTML element to use for attaching events
  120450. */
  120451. inputElement: Nullable<HTMLElement>;
  120452. /**
  120453. * Gets the current engine view
  120454. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120455. */
  120456. activeView: Nullable<EngineView>;
  120457. /** Gets or sets the list of views */
  120458. views: EngineView[];
  120459. /**
  120460. * Register a new child canvas
  120461. * @param canvas defines the canvas to register
  120462. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120463. * @returns the associated view
  120464. */
  120465. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120466. /**
  120467. * Remove a registered child canvas
  120468. * @param canvas defines the canvas to remove
  120469. * @returns the current engine
  120470. */
  120471. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120472. }
  120473. }
  120474. declare module BABYLON {
  120475. /**
  120476. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120477. */
  120478. export interface CubeMapInfo {
  120479. /**
  120480. * The pixel array for the front face.
  120481. * This is stored in format, left to right, up to down format.
  120482. */
  120483. front: Nullable<ArrayBufferView>;
  120484. /**
  120485. * The pixel array for the back face.
  120486. * This is stored in format, left to right, up to down format.
  120487. */
  120488. back: Nullable<ArrayBufferView>;
  120489. /**
  120490. * The pixel array for the left face.
  120491. * This is stored in format, left to right, up to down format.
  120492. */
  120493. left: Nullable<ArrayBufferView>;
  120494. /**
  120495. * The pixel array for the right face.
  120496. * This is stored in format, left to right, up to down format.
  120497. */
  120498. right: Nullable<ArrayBufferView>;
  120499. /**
  120500. * The pixel array for the up face.
  120501. * This is stored in format, left to right, up to down format.
  120502. */
  120503. up: Nullable<ArrayBufferView>;
  120504. /**
  120505. * The pixel array for the down face.
  120506. * This is stored in format, left to right, up to down format.
  120507. */
  120508. down: Nullable<ArrayBufferView>;
  120509. /**
  120510. * The size of the cubemap stored.
  120511. *
  120512. * Each faces will be size * size pixels.
  120513. */
  120514. size: number;
  120515. /**
  120516. * The format of the texture.
  120517. *
  120518. * RGBA, RGB.
  120519. */
  120520. format: number;
  120521. /**
  120522. * The type of the texture data.
  120523. *
  120524. * UNSIGNED_INT, FLOAT.
  120525. */
  120526. type: number;
  120527. /**
  120528. * Specifies whether the texture is in gamma space.
  120529. */
  120530. gammaSpace: boolean;
  120531. }
  120532. /**
  120533. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120534. */
  120535. export class PanoramaToCubeMapTools {
  120536. private static FACE_FRONT;
  120537. private static FACE_BACK;
  120538. private static FACE_RIGHT;
  120539. private static FACE_LEFT;
  120540. private static FACE_DOWN;
  120541. private static FACE_UP;
  120542. /**
  120543. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120544. *
  120545. * @param float32Array The source data.
  120546. * @param inputWidth The width of the input panorama.
  120547. * @param inputHeight The height of the input panorama.
  120548. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120549. * @return The cubemap data
  120550. */
  120551. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120552. private static CreateCubemapTexture;
  120553. private static CalcProjectionSpherical;
  120554. }
  120555. }
  120556. declare module BABYLON {
  120557. /**
  120558. * Helper class dealing with the extraction of spherical polynomial dataArray
  120559. * from a cube map.
  120560. */
  120561. export class CubeMapToSphericalPolynomialTools {
  120562. private static FileFaces;
  120563. /**
  120564. * Converts a texture to the according Spherical Polynomial data.
  120565. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120566. *
  120567. * @param texture The texture to extract the information from.
  120568. * @return The Spherical Polynomial data.
  120569. */
  120570. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120571. /**
  120572. * Converts a cubemap to the according Spherical Polynomial data.
  120573. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120574. *
  120575. * @param cubeInfo The Cube map to extract the information from.
  120576. * @return The Spherical Polynomial data.
  120577. */
  120578. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120579. }
  120580. }
  120581. declare module BABYLON {
  120582. interface BaseTexture {
  120583. /**
  120584. * Get the polynomial representation of the texture data.
  120585. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120586. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120587. */
  120588. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120589. }
  120590. }
  120591. declare module BABYLON {
  120592. /** @hidden */
  120593. export var rgbdEncodePixelShader: {
  120594. name: string;
  120595. shader: string;
  120596. };
  120597. }
  120598. declare module BABYLON {
  120599. /** @hidden */
  120600. export var rgbdDecodePixelShader: {
  120601. name: string;
  120602. shader: string;
  120603. };
  120604. }
  120605. declare module BABYLON {
  120606. /**
  120607. * Raw texture data and descriptor sufficient for WebGL texture upload
  120608. */
  120609. export interface EnvironmentTextureInfo {
  120610. /**
  120611. * Version of the environment map
  120612. */
  120613. version: number;
  120614. /**
  120615. * Width of image
  120616. */
  120617. width: number;
  120618. /**
  120619. * Irradiance information stored in the file.
  120620. */
  120621. irradiance: any;
  120622. /**
  120623. * Specular information stored in the file.
  120624. */
  120625. specular: any;
  120626. }
  120627. /**
  120628. * Defines One Image in the file. It requires only the position in the file
  120629. * as well as the length.
  120630. */
  120631. interface BufferImageData {
  120632. /**
  120633. * Length of the image data.
  120634. */
  120635. length: number;
  120636. /**
  120637. * Position of the data from the null terminator delimiting the end of the JSON.
  120638. */
  120639. position: number;
  120640. }
  120641. /**
  120642. * Defines the specular data enclosed in the file.
  120643. * This corresponds to the version 1 of the data.
  120644. */
  120645. export interface EnvironmentTextureSpecularInfoV1 {
  120646. /**
  120647. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120648. */
  120649. specularDataPosition?: number;
  120650. /**
  120651. * This contains all the images data needed to reconstruct the cubemap.
  120652. */
  120653. mipmaps: Array<BufferImageData>;
  120654. /**
  120655. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120656. */
  120657. lodGenerationScale: number;
  120658. }
  120659. /**
  120660. * Sets of helpers addressing the serialization and deserialization of environment texture
  120661. * stored in a BabylonJS env file.
  120662. * Those files are usually stored as .env files.
  120663. */
  120664. export class EnvironmentTextureTools {
  120665. /**
  120666. * Magic number identifying the env file.
  120667. */
  120668. private static _MagicBytes;
  120669. /**
  120670. * Gets the environment info from an env file.
  120671. * @param data The array buffer containing the .env bytes.
  120672. * @returns the environment file info (the json header) if successfully parsed.
  120673. */
  120674. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120675. /**
  120676. * Creates an environment texture from a loaded cube texture.
  120677. * @param texture defines the cube texture to convert in env file
  120678. * @return a promise containing the environment data if succesfull.
  120679. */
  120680. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120681. /**
  120682. * Creates a JSON representation of the spherical data.
  120683. * @param texture defines the texture containing the polynomials
  120684. * @return the JSON representation of the spherical info
  120685. */
  120686. private static _CreateEnvTextureIrradiance;
  120687. /**
  120688. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120689. * @param data the image data
  120690. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120691. * @return the views described by info providing access to the underlying buffer
  120692. */
  120693. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120694. /**
  120695. * Uploads the texture info contained in the env file to the GPU.
  120696. * @param texture defines the internal texture to upload to
  120697. * @param data defines the data to load
  120698. * @param info defines the texture info retrieved through the GetEnvInfo method
  120699. * @returns a promise
  120700. */
  120701. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120702. private static _OnImageReadyAsync;
  120703. /**
  120704. * Uploads the levels of image data to the GPU.
  120705. * @param texture defines the internal texture to upload to
  120706. * @param imageData defines the array buffer views of image data [mipmap][face]
  120707. * @returns a promise
  120708. */
  120709. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120710. /**
  120711. * Uploads spherical polynomials information to the texture.
  120712. * @param texture defines the texture we are trying to upload the information to
  120713. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120714. */
  120715. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120716. /** @hidden */
  120717. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120718. }
  120719. }
  120720. declare module BABYLON {
  120721. /**
  120722. * Contains position and normal vectors for a vertex
  120723. */
  120724. export class PositionNormalVertex {
  120725. /** the position of the vertex (defaut: 0,0,0) */
  120726. position: Vector3;
  120727. /** the normal of the vertex (defaut: 0,1,0) */
  120728. normal: Vector3;
  120729. /**
  120730. * Creates a PositionNormalVertex
  120731. * @param position the position of the vertex (defaut: 0,0,0)
  120732. * @param normal the normal of the vertex (defaut: 0,1,0)
  120733. */
  120734. constructor(
  120735. /** the position of the vertex (defaut: 0,0,0) */
  120736. position?: Vector3,
  120737. /** the normal of the vertex (defaut: 0,1,0) */
  120738. normal?: Vector3);
  120739. /**
  120740. * Clones the PositionNormalVertex
  120741. * @returns the cloned PositionNormalVertex
  120742. */
  120743. clone(): PositionNormalVertex;
  120744. }
  120745. /**
  120746. * Contains position, normal and uv vectors for a vertex
  120747. */
  120748. export class PositionNormalTextureVertex {
  120749. /** the position of the vertex (defaut: 0,0,0) */
  120750. position: Vector3;
  120751. /** the normal of the vertex (defaut: 0,1,0) */
  120752. normal: Vector3;
  120753. /** the uv of the vertex (default: 0,0) */
  120754. uv: Vector2;
  120755. /**
  120756. * Creates a PositionNormalTextureVertex
  120757. * @param position the position of the vertex (defaut: 0,0,0)
  120758. * @param normal the normal of the vertex (defaut: 0,1,0)
  120759. * @param uv the uv of the vertex (default: 0,0)
  120760. */
  120761. constructor(
  120762. /** the position of the vertex (defaut: 0,0,0) */
  120763. position?: Vector3,
  120764. /** the normal of the vertex (defaut: 0,1,0) */
  120765. normal?: Vector3,
  120766. /** the uv of the vertex (default: 0,0) */
  120767. uv?: Vector2);
  120768. /**
  120769. * Clones the PositionNormalTextureVertex
  120770. * @returns the cloned PositionNormalTextureVertex
  120771. */
  120772. clone(): PositionNormalTextureVertex;
  120773. }
  120774. }
  120775. declare module BABYLON {
  120776. /** @hidden */
  120777. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120778. private _genericAttributeLocation;
  120779. private _varyingLocationCount;
  120780. private _varyingLocationMap;
  120781. private _replacements;
  120782. private _textureCount;
  120783. private _uniforms;
  120784. lineProcessor(line: string): string;
  120785. attributeProcessor(attribute: string): string;
  120786. varyingProcessor(varying: string, isFragment: boolean): string;
  120787. uniformProcessor(uniform: string): string;
  120788. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120789. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120790. }
  120791. }
  120792. declare module BABYLON {
  120793. /**
  120794. * Container for accessors for natively-stored mesh data buffers.
  120795. */
  120796. class NativeDataBuffer extends DataBuffer {
  120797. /**
  120798. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120799. */
  120800. nativeIndexBuffer?: any;
  120801. /**
  120802. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120803. */
  120804. nativeVertexBuffer?: any;
  120805. }
  120806. /** @hidden */
  120807. class NativeTexture extends InternalTexture {
  120808. getInternalTexture(): InternalTexture;
  120809. getViewCount(): number;
  120810. }
  120811. /** @hidden */
  120812. export class NativeEngine extends Engine {
  120813. private readonly _native;
  120814. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120815. private readonly INVALID_HANDLE;
  120816. getHardwareScalingLevel(): number;
  120817. constructor();
  120818. /**
  120819. * Can be used to override the current requestAnimationFrame requester.
  120820. * @hidden
  120821. */
  120822. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120823. /**
  120824. * Override default engine behavior.
  120825. * @param color
  120826. * @param backBuffer
  120827. * @param depth
  120828. * @param stencil
  120829. */
  120830. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120831. /**
  120832. * Gets host document
  120833. * @returns the host document object
  120834. */
  120835. getHostDocument(): Nullable<Document>;
  120836. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120837. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120838. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120839. recordVertexArrayObject(vertexBuffers: {
  120840. [key: string]: VertexBuffer;
  120841. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120842. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120843. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120844. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120845. /**
  120846. * Draw a list of indexed primitives
  120847. * @param fillMode defines the primitive to use
  120848. * @param indexStart defines the starting index
  120849. * @param indexCount defines the number of index to draw
  120850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120851. */
  120852. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120853. /**
  120854. * Draw a list of unindexed primitives
  120855. * @param fillMode defines the primitive to use
  120856. * @param verticesStart defines the index of first vertex to draw
  120857. * @param verticesCount defines the count of vertices to draw
  120858. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120859. */
  120860. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120861. createPipelineContext(): IPipelineContext;
  120862. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120863. /** @hidden */
  120864. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120865. /** @hidden */
  120866. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120867. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120869. protected _setProgram(program: WebGLProgram): void;
  120870. _releaseEffect(effect: Effect): void;
  120871. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120872. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120873. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120874. bindSamplers(effect: Effect): void;
  120875. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120876. getRenderWidth(useScreen?: boolean): number;
  120877. getRenderHeight(useScreen?: boolean): number;
  120878. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120879. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120880. /**
  120881. * Set the z offset to apply to current rendering
  120882. * @param value defines the offset to apply
  120883. */
  120884. setZOffset(value: number): void;
  120885. /**
  120886. * Gets the current value of the zOffset
  120887. * @returns the current zOffset state
  120888. */
  120889. getZOffset(): number;
  120890. /**
  120891. * Enable or disable depth buffering
  120892. * @param enable defines the state to set
  120893. */
  120894. setDepthBuffer(enable: boolean): void;
  120895. /**
  120896. * Gets a boolean indicating if depth writing is enabled
  120897. * @returns the current depth writing state
  120898. */
  120899. getDepthWrite(): boolean;
  120900. /**
  120901. * Enable or disable depth writing
  120902. * @param enable defines the state to set
  120903. */
  120904. setDepthWrite(enable: boolean): void;
  120905. /**
  120906. * Enable or disable color writing
  120907. * @param enable defines the state to set
  120908. */
  120909. setColorWrite(enable: boolean): void;
  120910. /**
  120911. * Gets a boolean indicating if color writing is enabled
  120912. * @returns the current color writing state
  120913. */
  120914. getColorWrite(): boolean;
  120915. /**
  120916. * Sets alpha constants used by some alpha blending modes
  120917. * @param r defines the red component
  120918. * @param g defines the green component
  120919. * @param b defines the blue component
  120920. * @param a defines the alpha component
  120921. */
  120922. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120923. /**
  120924. * Sets the current alpha mode
  120925. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120926. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120928. */
  120929. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120930. /**
  120931. * Gets the current alpha mode
  120932. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120933. * @returns the current alpha mode
  120934. */
  120935. getAlphaMode(): number;
  120936. setInt(uniform: WebGLUniformLocation, int: number): void;
  120937. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120938. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120939. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120940. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120941. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120942. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120943. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120944. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120945. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120946. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120947. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120948. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120949. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120950. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120951. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120952. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120953. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120954. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120955. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120956. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120957. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120958. wipeCaches(bruteForce?: boolean): void;
  120959. _createTexture(): WebGLTexture;
  120960. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120961. /**
  120962. * Usually called from Texture.ts.
  120963. * Passed information to create a WebGLTexture
  120964. * @param urlArg defines a value which contains one of the following:
  120965. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120966. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120967. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120968. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120969. * @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)
  120970. * @param scene needed for loading to the correct scene
  120971. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120972. * @param onLoad optional callback to be called upon successful completion
  120973. * @param onError optional callback to be called upon failure
  120974. * @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
  120975. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120976. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120977. * @param forcedExtension defines the extension to use to pick the right loader
  120978. * @param mimeType defines an optional mime type
  120979. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120980. */
  120981. 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;
  120982. /**
  120983. * Creates a cube texture
  120984. * @param rootUrl defines the url where the files to load is located
  120985. * @param scene defines the current scene
  120986. * @param files defines the list of files to load (1 per face)
  120987. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120988. * @param onLoad defines an optional callback raised when the texture is loaded
  120989. * @param onError defines an optional callback raised if there is an issue to load the texture
  120990. * @param format defines the format of the data
  120991. * @param forcedExtension defines the extension to use to pick the right loader
  120992. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120993. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120994. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120995. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120996. * @returns the cube texture as an InternalTexture
  120997. */
  120998. 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;
  120999. private _getSamplingFilter;
  121000. private static _GetNativeTextureFormat;
  121001. createRenderTargetTexture(size: number | {
  121002. width: number;
  121003. height: number;
  121004. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121005. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121006. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121007. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121008. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121009. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121010. /**
  121011. * Updates a dynamic vertex buffer.
  121012. * @param vertexBuffer the vertex buffer to update
  121013. * @param data the data used to update the vertex buffer
  121014. * @param byteOffset the byte offset of the data (optional)
  121015. * @param byteLength the byte length of the data (optional)
  121016. */
  121017. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121018. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121019. private _updateAnisotropicLevel;
  121020. private _getAddressMode;
  121021. /** @hidden */
  121022. _bindTexture(channel: number, texture: InternalTexture): void;
  121023. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121024. releaseEffects(): void;
  121025. /** @hidden */
  121026. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121027. /** @hidden */
  121028. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121029. /** @hidden */
  121030. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121031. /** @hidden */
  121032. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121033. }
  121034. }
  121035. declare module BABYLON {
  121036. /**
  121037. * Gather the list of clipboard event types as constants.
  121038. */
  121039. export class ClipboardEventTypes {
  121040. /**
  121041. * The clipboard event is fired when a copy command is active (pressed).
  121042. */
  121043. static readonly COPY: number;
  121044. /**
  121045. * The clipboard event is fired when a cut command is active (pressed).
  121046. */
  121047. static readonly CUT: number;
  121048. /**
  121049. * The clipboard event is fired when a paste command is active (pressed).
  121050. */
  121051. static readonly PASTE: number;
  121052. }
  121053. /**
  121054. * This class is used to store clipboard related info for the onClipboardObservable event.
  121055. */
  121056. export class ClipboardInfo {
  121057. /**
  121058. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121059. */
  121060. type: number;
  121061. /**
  121062. * Defines the related dom event
  121063. */
  121064. event: ClipboardEvent;
  121065. /**
  121066. *Creates an instance of ClipboardInfo.
  121067. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121068. * @param event Defines the related dom event
  121069. */
  121070. constructor(
  121071. /**
  121072. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121073. */
  121074. type: number,
  121075. /**
  121076. * Defines the related dom event
  121077. */
  121078. event: ClipboardEvent);
  121079. /**
  121080. * Get the clipboard event's type from the keycode.
  121081. * @param keyCode Defines the keyCode for the current keyboard event.
  121082. * @return {number}
  121083. */
  121084. static GetTypeFromCharacter(keyCode: number): number;
  121085. }
  121086. }
  121087. declare module BABYLON {
  121088. /**
  121089. * Google Daydream controller
  121090. */
  121091. export class DaydreamController extends WebVRController {
  121092. /**
  121093. * Base Url for the controller model.
  121094. */
  121095. static MODEL_BASE_URL: string;
  121096. /**
  121097. * File name for the controller model.
  121098. */
  121099. static MODEL_FILENAME: string;
  121100. /**
  121101. * Gamepad Id prefix used to identify Daydream Controller.
  121102. */
  121103. static readonly GAMEPAD_ID_PREFIX: string;
  121104. /**
  121105. * Creates a new DaydreamController from a gamepad
  121106. * @param vrGamepad the gamepad that the controller should be created from
  121107. */
  121108. constructor(vrGamepad: any);
  121109. /**
  121110. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121111. * @param scene scene in which to add meshes
  121112. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121113. */
  121114. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121115. /**
  121116. * Called once for each button that changed state since the last frame
  121117. * @param buttonIdx Which button index changed
  121118. * @param state New state of the button
  121119. * @param changes Which properties on the state changed since last frame
  121120. */
  121121. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121122. }
  121123. }
  121124. declare module BABYLON {
  121125. /**
  121126. * Gear VR Controller
  121127. */
  121128. export class GearVRController extends WebVRController {
  121129. /**
  121130. * Base Url for the controller model.
  121131. */
  121132. static MODEL_BASE_URL: string;
  121133. /**
  121134. * File name for the controller model.
  121135. */
  121136. static MODEL_FILENAME: string;
  121137. /**
  121138. * Gamepad Id prefix used to identify this controller.
  121139. */
  121140. static readonly GAMEPAD_ID_PREFIX: string;
  121141. private readonly _buttonIndexToObservableNameMap;
  121142. /**
  121143. * Creates a new GearVRController from a gamepad
  121144. * @param vrGamepad the gamepad that the controller should be created from
  121145. */
  121146. constructor(vrGamepad: any);
  121147. /**
  121148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121149. * @param scene scene in which to add meshes
  121150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121151. */
  121152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121153. /**
  121154. * Called once for each button that changed state since the last frame
  121155. * @param buttonIdx Which button index changed
  121156. * @param state New state of the button
  121157. * @param changes Which properties on the state changed since last frame
  121158. */
  121159. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121160. }
  121161. }
  121162. declare module BABYLON {
  121163. /**
  121164. * Generic Controller
  121165. */
  121166. export class GenericController extends WebVRController {
  121167. /**
  121168. * Base Url for the controller model.
  121169. */
  121170. static readonly MODEL_BASE_URL: string;
  121171. /**
  121172. * File name for the controller model.
  121173. */
  121174. static readonly MODEL_FILENAME: string;
  121175. /**
  121176. * Creates a new GenericController from a gamepad
  121177. * @param vrGamepad the gamepad that the controller should be created from
  121178. */
  121179. constructor(vrGamepad: any);
  121180. /**
  121181. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121182. * @param scene scene in which to add meshes
  121183. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121184. */
  121185. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121186. /**
  121187. * Called once for each button that changed state since the last frame
  121188. * @param buttonIdx Which button index changed
  121189. * @param state New state of the button
  121190. * @param changes Which properties on the state changed since last frame
  121191. */
  121192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121193. }
  121194. }
  121195. declare module BABYLON {
  121196. /**
  121197. * Oculus Touch Controller
  121198. */
  121199. export class OculusTouchController extends WebVRController {
  121200. /**
  121201. * Base Url for the controller model.
  121202. */
  121203. static MODEL_BASE_URL: string;
  121204. /**
  121205. * File name for the left controller model.
  121206. */
  121207. static MODEL_LEFT_FILENAME: string;
  121208. /**
  121209. * File name for the right controller model.
  121210. */
  121211. static MODEL_RIGHT_FILENAME: string;
  121212. /**
  121213. * Base Url for the Quest controller model.
  121214. */
  121215. static QUEST_MODEL_BASE_URL: string;
  121216. /**
  121217. * @hidden
  121218. * If the controllers are running on a device that needs the updated Quest controller models
  121219. */
  121220. static _IsQuest: boolean;
  121221. /**
  121222. * Fired when the secondary trigger on this controller is modified
  121223. */
  121224. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121225. /**
  121226. * Fired when the thumb rest on this controller is modified
  121227. */
  121228. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121229. /**
  121230. * Creates a new OculusTouchController from a gamepad
  121231. * @param vrGamepad the gamepad that the controller should be created from
  121232. */
  121233. constructor(vrGamepad: any);
  121234. /**
  121235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121236. * @param scene scene in which to add meshes
  121237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121238. */
  121239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121240. /**
  121241. * Fired when the A button on this controller is modified
  121242. */
  121243. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121244. /**
  121245. * Fired when the B button on this controller is modified
  121246. */
  121247. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121248. /**
  121249. * Fired when the X button on this controller is modified
  121250. */
  121251. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121252. /**
  121253. * Fired when the Y button on this controller is modified
  121254. */
  121255. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121256. /**
  121257. * Called once for each button that changed state since the last frame
  121258. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121259. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121260. * 2) secondary trigger (same)
  121261. * 3) A (right) X (left), touch, pressed = value
  121262. * 4) B / Y
  121263. * 5) thumb rest
  121264. * @param buttonIdx Which button index changed
  121265. * @param state New state of the button
  121266. * @param changes Which properties on the state changed since last frame
  121267. */
  121268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121269. }
  121270. }
  121271. declare module BABYLON {
  121272. /**
  121273. * Vive Controller
  121274. */
  121275. export class ViveController extends WebVRController {
  121276. /**
  121277. * Base Url for the controller model.
  121278. */
  121279. static MODEL_BASE_URL: string;
  121280. /**
  121281. * File name for the controller model.
  121282. */
  121283. static MODEL_FILENAME: string;
  121284. /**
  121285. * Creates a new ViveController from a gamepad
  121286. * @param vrGamepad the gamepad that the controller should be created from
  121287. */
  121288. constructor(vrGamepad: any);
  121289. /**
  121290. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121291. * @param scene scene in which to add meshes
  121292. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121293. */
  121294. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121295. /**
  121296. * Fired when the left button on this controller is modified
  121297. */
  121298. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121299. /**
  121300. * Fired when the right button on this controller is modified
  121301. */
  121302. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121303. /**
  121304. * Fired when the menu button on this controller is modified
  121305. */
  121306. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121307. /**
  121308. * Called once for each button that changed state since the last frame
  121309. * Vive mapping:
  121310. * 0: touchpad
  121311. * 1: trigger
  121312. * 2: left AND right buttons
  121313. * 3: menu button
  121314. * @param buttonIdx Which button index changed
  121315. * @param state New state of the button
  121316. * @param changes Which properties on the state changed since last frame
  121317. */
  121318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121319. }
  121320. }
  121321. declare module BABYLON {
  121322. /**
  121323. * Defines the WindowsMotionController object that the state of the windows motion controller
  121324. */
  121325. export class WindowsMotionController extends WebVRController {
  121326. /**
  121327. * The base url used to load the left and right controller models
  121328. */
  121329. static MODEL_BASE_URL: string;
  121330. /**
  121331. * The name of the left controller model file
  121332. */
  121333. static MODEL_LEFT_FILENAME: string;
  121334. /**
  121335. * The name of the right controller model file
  121336. */
  121337. static MODEL_RIGHT_FILENAME: string;
  121338. /**
  121339. * The controller name prefix for this controller type
  121340. */
  121341. static readonly GAMEPAD_ID_PREFIX: string;
  121342. /**
  121343. * The controller id pattern for this controller type
  121344. */
  121345. private static readonly GAMEPAD_ID_PATTERN;
  121346. private _loadedMeshInfo;
  121347. protected readonly _mapping: {
  121348. buttons: string[];
  121349. buttonMeshNames: {
  121350. 'trigger': string;
  121351. 'menu': string;
  121352. 'grip': string;
  121353. 'thumbstick': string;
  121354. 'trackpad': string;
  121355. };
  121356. buttonObservableNames: {
  121357. 'trigger': string;
  121358. 'menu': string;
  121359. 'grip': string;
  121360. 'thumbstick': string;
  121361. 'trackpad': string;
  121362. };
  121363. axisMeshNames: string[];
  121364. pointingPoseMeshName: string;
  121365. };
  121366. /**
  121367. * Fired when the trackpad on this controller is clicked
  121368. */
  121369. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121370. /**
  121371. * Fired when the trackpad on this controller is modified
  121372. */
  121373. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121374. /**
  121375. * The current x and y values of this controller's trackpad
  121376. */
  121377. trackpad: StickValues;
  121378. /**
  121379. * Creates a new WindowsMotionController from a gamepad
  121380. * @param vrGamepad the gamepad that the controller should be created from
  121381. */
  121382. constructor(vrGamepad: any);
  121383. /**
  121384. * Fired when the trigger on this controller is modified
  121385. */
  121386. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121387. /**
  121388. * Fired when the menu button on this controller is modified
  121389. */
  121390. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121391. /**
  121392. * Fired when the grip button on this controller is modified
  121393. */
  121394. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121395. /**
  121396. * Fired when the thumbstick button on this controller is modified
  121397. */
  121398. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121399. /**
  121400. * Fired when the touchpad button on this controller is modified
  121401. */
  121402. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121403. /**
  121404. * Fired when the touchpad values on this controller are modified
  121405. */
  121406. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121407. protected _updateTrackpad(): void;
  121408. /**
  121409. * Called once per frame by the engine.
  121410. */
  121411. update(): void;
  121412. /**
  121413. * Called once for each button that changed state since the last frame
  121414. * @param buttonIdx Which button index changed
  121415. * @param state New state of the button
  121416. * @param changes Which properties on the state changed since last frame
  121417. */
  121418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121419. /**
  121420. * Moves the buttons on the controller mesh based on their current state
  121421. * @param buttonName the name of the button to move
  121422. * @param buttonValue the value of the button which determines the buttons new position
  121423. */
  121424. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121425. /**
  121426. * Moves the axis on the controller mesh based on its current state
  121427. * @param axis the index of the axis
  121428. * @param axisValue the value of the axis which determines the meshes new position
  121429. * @hidden
  121430. */
  121431. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121432. /**
  121433. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121434. * @param scene scene in which to add meshes
  121435. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121436. */
  121437. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121438. /**
  121439. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121440. * can be transformed by button presses and axes values, based on this._mapping.
  121441. *
  121442. * @param scene scene in which the meshes exist
  121443. * @param meshes list of meshes that make up the controller model to process
  121444. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121445. */
  121446. private processModel;
  121447. private createMeshInfo;
  121448. /**
  121449. * Gets the ray of the controller in the direction the controller is pointing
  121450. * @param length the length the resulting ray should be
  121451. * @returns a ray in the direction the controller is pointing
  121452. */
  121453. getForwardRay(length?: number): Ray;
  121454. /**
  121455. * Disposes of the controller
  121456. */
  121457. dispose(): void;
  121458. }
  121459. /**
  121460. * This class represents a new windows motion controller in XR.
  121461. */
  121462. export class XRWindowsMotionController extends WindowsMotionController {
  121463. /**
  121464. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121465. */
  121466. protected readonly _mapping: {
  121467. buttons: string[];
  121468. buttonMeshNames: {
  121469. 'trigger': string;
  121470. 'menu': string;
  121471. 'grip': string;
  121472. 'thumbstick': string;
  121473. 'trackpad': string;
  121474. };
  121475. buttonObservableNames: {
  121476. 'trigger': string;
  121477. 'menu': string;
  121478. 'grip': string;
  121479. 'thumbstick': string;
  121480. 'trackpad': string;
  121481. };
  121482. axisMeshNames: string[];
  121483. pointingPoseMeshName: string;
  121484. };
  121485. /**
  121486. * Construct a new XR-Based windows motion controller
  121487. *
  121488. * @param gamepadInfo the gamepad object from the browser
  121489. */
  121490. constructor(gamepadInfo: any);
  121491. /**
  121492. * holds the thumbstick values (X,Y)
  121493. */
  121494. thumbstickValues: StickValues;
  121495. /**
  121496. * Fired when the thumbstick on this controller is clicked
  121497. */
  121498. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121499. /**
  121500. * Fired when the thumbstick on this controller is modified
  121501. */
  121502. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121503. /**
  121504. * Fired when the touchpad button on this controller is modified
  121505. */
  121506. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121507. /**
  121508. * Fired when the touchpad values on this controller are modified
  121509. */
  121510. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121511. /**
  121512. * Fired when the thumbstick button on this controller is modified
  121513. * here to prevent breaking changes
  121514. */
  121515. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121516. /**
  121517. * updating the thumbstick(!) and not the trackpad.
  121518. * This is named this way due to the difference between WebVR and XR and to avoid
  121519. * changing the parent class.
  121520. */
  121521. protected _updateTrackpad(): void;
  121522. /**
  121523. * Disposes the class with joy
  121524. */
  121525. dispose(): void;
  121526. }
  121527. }
  121528. declare module BABYLON {
  121529. /**
  121530. * Class containing static functions to help procedurally build meshes
  121531. */
  121532. export class PolyhedronBuilder {
  121533. /**
  121534. * Creates a polyhedron mesh
  121535. * * 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
  121536. * * The parameter `size` (positive float, default 1) sets the polygon size
  121537. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121538. * * 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`
  121539. * * 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
  121540. * * 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)`)
  121541. * * 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
  121542. * * 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
  121543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121546. * @param name defines the name of the mesh
  121547. * @param options defines the options used to create the mesh
  121548. * @param scene defines the hosting scene
  121549. * @returns the polyhedron mesh
  121550. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121551. */
  121552. static CreatePolyhedron(name: string, options: {
  121553. type?: number;
  121554. size?: number;
  121555. sizeX?: number;
  121556. sizeY?: number;
  121557. sizeZ?: number;
  121558. custom?: any;
  121559. faceUV?: Vector4[];
  121560. faceColors?: Color4[];
  121561. flat?: boolean;
  121562. updatable?: boolean;
  121563. sideOrientation?: number;
  121564. frontUVs?: Vector4;
  121565. backUVs?: Vector4;
  121566. }, scene?: Nullable<Scene>): Mesh;
  121567. }
  121568. }
  121569. declare module BABYLON {
  121570. /**
  121571. * Gizmo that enables scaling a mesh along 3 axis
  121572. */
  121573. export class ScaleGizmo extends Gizmo {
  121574. /**
  121575. * Internal gizmo used for interactions on the x axis
  121576. */
  121577. xGizmo: AxisScaleGizmo;
  121578. /**
  121579. * Internal gizmo used for interactions on the y axis
  121580. */
  121581. yGizmo: AxisScaleGizmo;
  121582. /**
  121583. * Internal gizmo used for interactions on the z axis
  121584. */
  121585. zGizmo: AxisScaleGizmo;
  121586. /**
  121587. * Internal gizmo used to scale all axis equally
  121588. */
  121589. uniformScaleGizmo: AxisScaleGizmo;
  121590. private _meshAttached;
  121591. private _updateGizmoRotationToMatchAttachedMesh;
  121592. private _snapDistance;
  121593. private _scaleRatio;
  121594. private _uniformScalingMesh;
  121595. private _octahedron;
  121596. private _sensitivity;
  121597. /** Fires an event when any of it's sub gizmos are dragged */
  121598. onDragStartObservable: Observable<unknown>;
  121599. /** Fires an event when any of it's sub gizmos are released from dragging */
  121600. onDragEndObservable: Observable<unknown>;
  121601. get attachedMesh(): Nullable<AbstractMesh>;
  121602. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121603. /**
  121604. * Creates a ScaleGizmo
  121605. * @param gizmoLayer The utility layer the gizmo will be added to
  121606. */
  121607. constructor(gizmoLayer?: UtilityLayerRenderer);
  121608. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121609. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121610. /**
  121611. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121612. */
  121613. set snapDistance(value: number);
  121614. get snapDistance(): number;
  121615. /**
  121616. * Ratio for the scale of the gizmo (Default: 1)
  121617. */
  121618. set scaleRatio(value: number);
  121619. get scaleRatio(): number;
  121620. /**
  121621. * Sensitivity factor for dragging (Default: 1)
  121622. */
  121623. set sensitivity(value: number);
  121624. get sensitivity(): number;
  121625. /**
  121626. * Disposes of the gizmo
  121627. */
  121628. dispose(): void;
  121629. }
  121630. }
  121631. declare module BABYLON {
  121632. /**
  121633. * Single axis scale gizmo
  121634. */
  121635. export class AxisScaleGizmo extends Gizmo {
  121636. /**
  121637. * Drag behavior responsible for the gizmos dragging interactions
  121638. */
  121639. dragBehavior: PointerDragBehavior;
  121640. private _pointerObserver;
  121641. /**
  121642. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121643. */
  121644. snapDistance: number;
  121645. /**
  121646. * Event that fires each time the gizmo snaps to a new location.
  121647. * * snapDistance is the the change in distance
  121648. */
  121649. onSnapObservable: Observable<{
  121650. snapDistance: number;
  121651. }>;
  121652. /**
  121653. * If the scaling operation should be done on all axis (default: false)
  121654. */
  121655. uniformScaling: boolean;
  121656. /**
  121657. * Custom sensitivity value for the drag strength
  121658. */
  121659. sensitivity: number;
  121660. private _isEnabled;
  121661. private _parent;
  121662. private _arrow;
  121663. private _coloredMaterial;
  121664. private _hoverMaterial;
  121665. /**
  121666. * Creates an AxisScaleGizmo
  121667. * @param gizmoLayer The utility layer the gizmo will be added to
  121668. * @param dragAxis The axis which the gizmo will be able to scale on
  121669. * @param color The color of the gizmo
  121670. */
  121671. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121672. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121673. /**
  121674. * If the gizmo is enabled
  121675. */
  121676. set isEnabled(value: boolean);
  121677. get isEnabled(): boolean;
  121678. /**
  121679. * Disposes of the gizmo
  121680. */
  121681. dispose(): void;
  121682. /**
  121683. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121684. * @param mesh The mesh to replace the default mesh of the gizmo
  121685. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121686. */
  121687. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121688. }
  121689. }
  121690. declare module BABYLON {
  121691. /**
  121692. * Bounding box gizmo
  121693. */
  121694. export class BoundingBoxGizmo extends Gizmo {
  121695. private _lineBoundingBox;
  121696. private _rotateSpheresParent;
  121697. private _scaleBoxesParent;
  121698. private _boundingDimensions;
  121699. private _renderObserver;
  121700. private _pointerObserver;
  121701. private _scaleDragSpeed;
  121702. private _tmpQuaternion;
  121703. private _tmpVector;
  121704. private _tmpRotationMatrix;
  121705. /**
  121706. * 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)
  121707. */
  121708. ignoreChildren: boolean;
  121709. /**
  121710. * 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)
  121711. */
  121712. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121713. /**
  121714. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121715. */
  121716. rotationSphereSize: number;
  121717. /**
  121718. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121719. */
  121720. scaleBoxSize: number;
  121721. /**
  121722. * 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)
  121723. */
  121724. fixedDragMeshScreenSize: boolean;
  121725. /**
  121726. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121727. */
  121728. fixedDragMeshScreenSizeDistanceFactor: number;
  121729. /**
  121730. * Fired when a rotation sphere or scale box is dragged
  121731. */
  121732. onDragStartObservable: Observable<{}>;
  121733. /**
  121734. * Fired when a scale box is dragged
  121735. */
  121736. onScaleBoxDragObservable: Observable<{}>;
  121737. /**
  121738. * Fired when a scale box drag is ended
  121739. */
  121740. onScaleBoxDragEndObservable: Observable<{}>;
  121741. /**
  121742. * Fired when a rotation sphere is dragged
  121743. */
  121744. onRotationSphereDragObservable: Observable<{}>;
  121745. /**
  121746. * Fired when a rotation sphere drag is ended
  121747. */
  121748. onRotationSphereDragEndObservable: Observable<{}>;
  121749. /**
  121750. * 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)
  121751. */
  121752. scalePivot: Nullable<Vector3>;
  121753. /**
  121754. * Mesh used as a pivot to rotate the attached mesh
  121755. */
  121756. private _anchorMesh;
  121757. private _existingMeshScale;
  121758. private _dragMesh;
  121759. private pointerDragBehavior;
  121760. private coloredMaterial;
  121761. private hoverColoredMaterial;
  121762. /**
  121763. * Sets the color of the bounding box gizmo
  121764. * @param color the color to set
  121765. */
  121766. setColor(color: Color3): void;
  121767. /**
  121768. * Creates an BoundingBoxGizmo
  121769. * @param gizmoLayer The utility layer the gizmo will be added to
  121770. * @param color The color of the gizmo
  121771. */
  121772. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121773. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121774. private _selectNode;
  121775. /**
  121776. * Updates the bounding box information for the Gizmo
  121777. */
  121778. updateBoundingBox(): void;
  121779. private _updateRotationSpheres;
  121780. private _updateScaleBoxes;
  121781. /**
  121782. * Enables rotation on the specified axis and disables rotation on the others
  121783. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121784. */
  121785. setEnabledRotationAxis(axis: string): void;
  121786. /**
  121787. * Enables/disables scaling
  121788. * @param enable if scaling should be enabled
  121789. */
  121790. setEnabledScaling(enable: boolean): void;
  121791. private _updateDummy;
  121792. /**
  121793. * Enables a pointer drag behavior on the bounding box of the gizmo
  121794. */
  121795. enableDragBehavior(): void;
  121796. /**
  121797. * Disposes of the gizmo
  121798. */
  121799. dispose(): void;
  121800. /**
  121801. * 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)
  121802. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121803. * @returns the bounding box mesh with the passed in mesh as a child
  121804. */
  121805. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121806. /**
  121807. * CustomMeshes are not supported by this gizmo
  121808. * @param mesh The mesh to replace the default mesh of the gizmo
  121809. */
  121810. setCustomMesh(mesh: Mesh): void;
  121811. }
  121812. }
  121813. declare module BABYLON {
  121814. /**
  121815. * Single plane rotation gizmo
  121816. */
  121817. export class PlaneRotationGizmo extends Gizmo {
  121818. /**
  121819. * Drag behavior responsible for the gizmos dragging interactions
  121820. */
  121821. dragBehavior: PointerDragBehavior;
  121822. private _pointerObserver;
  121823. /**
  121824. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121825. */
  121826. snapDistance: number;
  121827. /**
  121828. * Event that fires each time the gizmo snaps to a new location.
  121829. * * snapDistance is the the change in distance
  121830. */
  121831. onSnapObservable: Observable<{
  121832. snapDistance: number;
  121833. }>;
  121834. private _isEnabled;
  121835. private _parent;
  121836. /**
  121837. * Creates a PlaneRotationGizmo
  121838. * @param gizmoLayer The utility layer the gizmo will be added to
  121839. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121840. * @param color The color of the gizmo
  121841. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121842. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121843. */
  121844. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121846. /**
  121847. * If the gizmo is enabled
  121848. */
  121849. set isEnabled(value: boolean);
  121850. get isEnabled(): boolean;
  121851. /**
  121852. * Disposes of the gizmo
  121853. */
  121854. dispose(): void;
  121855. }
  121856. }
  121857. declare module BABYLON {
  121858. /**
  121859. * Gizmo that enables rotating a mesh along 3 axis
  121860. */
  121861. export class RotationGizmo extends Gizmo {
  121862. /**
  121863. * Internal gizmo used for interactions on the x axis
  121864. */
  121865. xGizmo: PlaneRotationGizmo;
  121866. /**
  121867. * Internal gizmo used for interactions on the y axis
  121868. */
  121869. yGizmo: PlaneRotationGizmo;
  121870. /**
  121871. * Internal gizmo used for interactions on the z axis
  121872. */
  121873. zGizmo: PlaneRotationGizmo;
  121874. /** Fires an event when any of it's sub gizmos are dragged */
  121875. onDragStartObservable: Observable<unknown>;
  121876. /** Fires an event when any of it's sub gizmos are released from dragging */
  121877. onDragEndObservable: Observable<unknown>;
  121878. private _meshAttached;
  121879. get attachedMesh(): Nullable<AbstractMesh>;
  121880. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121881. /**
  121882. * Creates a RotationGizmo
  121883. * @param gizmoLayer The utility layer the gizmo will be added to
  121884. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121885. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121886. */
  121887. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121888. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121889. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121890. /**
  121891. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121892. */
  121893. set snapDistance(value: number);
  121894. get snapDistance(): number;
  121895. /**
  121896. * Ratio for the scale of the gizmo (Default: 1)
  121897. */
  121898. set scaleRatio(value: number);
  121899. get scaleRatio(): number;
  121900. /**
  121901. * Disposes of the gizmo
  121902. */
  121903. dispose(): void;
  121904. /**
  121905. * CustomMeshes are not supported by this gizmo
  121906. * @param mesh The mesh to replace the default mesh of the gizmo
  121907. */
  121908. setCustomMesh(mesh: Mesh): void;
  121909. }
  121910. }
  121911. declare module BABYLON {
  121912. /**
  121913. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121914. */
  121915. export class GizmoManager implements IDisposable {
  121916. private scene;
  121917. /**
  121918. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121919. */
  121920. gizmos: {
  121921. positionGizmo: Nullable<PositionGizmo>;
  121922. rotationGizmo: Nullable<RotationGizmo>;
  121923. scaleGizmo: Nullable<ScaleGizmo>;
  121924. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121925. };
  121926. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121927. clearGizmoOnEmptyPointerEvent: boolean;
  121928. /** Fires an event when the manager is attached to a mesh */
  121929. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121930. private _gizmosEnabled;
  121931. private _pointerObserver;
  121932. private _attachedMesh;
  121933. private _boundingBoxColor;
  121934. private _defaultUtilityLayer;
  121935. private _defaultKeepDepthUtilityLayer;
  121936. /**
  121937. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121938. */
  121939. boundingBoxDragBehavior: SixDofDragBehavior;
  121940. /**
  121941. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121942. */
  121943. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121944. /**
  121945. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121946. */
  121947. usePointerToAttachGizmos: boolean;
  121948. /**
  121949. * Utility layer that the bounding box gizmo belongs to
  121950. */
  121951. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121952. /**
  121953. * Utility layer that all gizmos besides bounding box belong to
  121954. */
  121955. get utilityLayer(): UtilityLayerRenderer;
  121956. /**
  121957. * Instatiates a gizmo manager
  121958. * @param scene the scene to overlay the gizmos on top of
  121959. */
  121960. constructor(scene: Scene);
  121961. /**
  121962. * Attaches a set of gizmos to the specified mesh
  121963. * @param mesh The mesh the gizmo's should be attached to
  121964. */
  121965. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121966. /**
  121967. * If the position gizmo is enabled
  121968. */
  121969. set positionGizmoEnabled(value: boolean);
  121970. get positionGizmoEnabled(): boolean;
  121971. /**
  121972. * If the rotation gizmo is enabled
  121973. */
  121974. set rotationGizmoEnabled(value: boolean);
  121975. get rotationGizmoEnabled(): boolean;
  121976. /**
  121977. * If the scale gizmo is enabled
  121978. */
  121979. set scaleGizmoEnabled(value: boolean);
  121980. get scaleGizmoEnabled(): boolean;
  121981. /**
  121982. * If the boundingBox gizmo is enabled
  121983. */
  121984. set boundingBoxGizmoEnabled(value: boolean);
  121985. get boundingBoxGizmoEnabled(): boolean;
  121986. /**
  121987. * Disposes of the gizmo manager
  121988. */
  121989. dispose(): void;
  121990. }
  121991. }
  121992. declare module BABYLON {
  121993. /**
  121994. * A directional light is defined by a direction (what a surprise!).
  121995. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121996. * 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.
  121997. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121998. */
  121999. export class DirectionalLight extends ShadowLight {
  122000. private _shadowFrustumSize;
  122001. /**
  122002. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122003. */
  122004. get shadowFrustumSize(): number;
  122005. /**
  122006. * Specifies a fix frustum size for the shadow generation.
  122007. */
  122008. set shadowFrustumSize(value: number);
  122009. private _shadowOrthoScale;
  122010. /**
  122011. * Gets the shadow projection scale against the optimal computed one.
  122012. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122013. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122014. */
  122015. get shadowOrthoScale(): number;
  122016. /**
  122017. * Sets the shadow projection scale against the optimal computed one.
  122018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122020. */
  122021. set shadowOrthoScale(value: number);
  122022. /**
  122023. * Automatically compute the projection matrix to best fit (including all the casters)
  122024. * on each frame.
  122025. */
  122026. autoUpdateExtends: boolean;
  122027. /**
  122028. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122029. * on each frame. autoUpdateExtends must be set to true for this to work
  122030. */
  122031. autoCalcShadowZBounds: boolean;
  122032. private _orthoLeft;
  122033. private _orthoRight;
  122034. private _orthoTop;
  122035. private _orthoBottom;
  122036. /**
  122037. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122038. * The directional light is emitted from everywhere in the given direction.
  122039. * It can cast shadows.
  122040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122041. * @param name The friendly name of the light
  122042. * @param direction The direction of the light
  122043. * @param scene The scene the light belongs to
  122044. */
  122045. constructor(name: string, direction: Vector3, scene: Scene);
  122046. /**
  122047. * Returns the string "DirectionalLight".
  122048. * @return The class name
  122049. */
  122050. getClassName(): string;
  122051. /**
  122052. * Returns the integer 1.
  122053. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122054. */
  122055. getTypeID(): number;
  122056. /**
  122057. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122058. * Returns the DirectionalLight Shadow projection matrix.
  122059. */
  122060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122061. /**
  122062. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122063. * Returns the DirectionalLight Shadow projection matrix.
  122064. */
  122065. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122066. /**
  122067. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122068. * Returns the DirectionalLight Shadow projection matrix.
  122069. */
  122070. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122071. protected _buildUniformLayout(): void;
  122072. /**
  122073. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122074. * @param effect The effect to update
  122075. * @param lightIndex The index of the light in the effect to update
  122076. * @returns The directional light
  122077. */
  122078. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122079. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122080. /**
  122081. * Gets the minZ used for shadow according to both the scene and the light.
  122082. *
  122083. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122084. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122085. * @param activeCamera The camera we are returning the min for
  122086. * @returns the depth min z
  122087. */
  122088. getDepthMinZ(activeCamera: Camera): number;
  122089. /**
  122090. * Gets the maxZ used for shadow according to both the scene and the light.
  122091. *
  122092. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122093. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122094. * @param activeCamera The camera we are returning the max for
  122095. * @returns the depth max z
  122096. */
  122097. getDepthMaxZ(activeCamera: Camera): number;
  122098. /**
  122099. * Prepares the list of defines specific to the light type.
  122100. * @param defines the list of defines
  122101. * @param lightIndex defines the index of the light for the effect
  122102. */
  122103. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122104. }
  122105. }
  122106. declare module BABYLON {
  122107. /**
  122108. * Class containing static functions to help procedurally build meshes
  122109. */
  122110. export class HemisphereBuilder {
  122111. /**
  122112. * Creates a hemisphere mesh
  122113. * @param name defines the name of the mesh
  122114. * @param options defines the options used to create the mesh
  122115. * @param scene defines the hosting scene
  122116. * @returns the hemisphere mesh
  122117. */
  122118. static CreateHemisphere(name: string, options: {
  122119. segments?: number;
  122120. diameter?: number;
  122121. sideOrientation?: number;
  122122. }, scene: any): Mesh;
  122123. }
  122124. }
  122125. declare module BABYLON {
  122126. /**
  122127. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122128. * These values define a cone of light starting from the position, emitting toward the direction.
  122129. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122130. * and the exponent defines the speed of the decay of the light with distance (reach).
  122131. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122132. */
  122133. export class SpotLight extends ShadowLight {
  122134. private _angle;
  122135. private _innerAngle;
  122136. private _cosHalfAngle;
  122137. private _lightAngleScale;
  122138. private _lightAngleOffset;
  122139. /**
  122140. * Gets the cone angle of the spot light in Radians.
  122141. */
  122142. get angle(): number;
  122143. /**
  122144. * Sets the cone angle of the spot light in Radians.
  122145. */
  122146. set angle(value: number);
  122147. /**
  122148. * Only used in gltf falloff mode, this defines the angle where
  122149. * the directional falloff will start before cutting at angle which could be seen
  122150. * as outer angle.
  122151. */
  122152. get innerAngle(): number;
  122153. /**
  122154. * Only used in gltf falloff mode, this defines the angle where
  122155. * the directional falloff will start before cutting at angle which could be seen
  122156. * as outer angle.
  122157. */
  122158. set innerAngle(value: number);
  122159. private _shadowAngleScale;
  122160. /**
  122161. * Allows scaling the angle of the light for shadow generation only.
  122162. */
  122163. get shadowAngleScale(): number;
  122164. /**
  122165. * Allows scaling the angle of the light for shadow generation only.
  122166. */
  122167. set shadowAngleScale(value: number);
  122168. /**
  122169. * The light decay speed with the distance from the emission spot.
  122170. */
  122171. exponent: number;
  122172. private _projectionTextureMatrix;
  122173. /**
  122174. * Allows reading the projecton texture
  122175. */
  122176. get projectionTextureMatrix(): Matrix;
  122177. protected _projectionTextureLightNear: number;
  122178. /**
  122179. * Gets the near clip of the Spotlight for texture projection.
  122180. */
  122181. get projectionTextureLightNear(): number;
  122182. /**
  122183. * Sets the near clip of the Spotlight for texture projection.
  122184. */
  122185. set projectionTextureLightNear(value: number);
  122186. protected _projectionTextureLightFar: number;
  122187. /**
  122188. * Gets the far clip of the Spotlight for texture projection.
  122189. */
  122190. get projectionTextureLightFar(): number;
  122191. /**
  122192. * Sets the far clip of the Spotlight for texture projection.
  122193. */
  122194. set projectionTextureLightFar(value: number);
  122195. protected _projectionTextureUpDirection: Vector3;
  122196. /**
  122197. * Gets the Up vector of the Spotlight for texture projection.
  122198. */
  122199. get projectionTextureUpDirection(): Vector3;
  122200. /**
  122201. * Sets the Up vector of the Spotlight for texture projection.
  122202. */
  122203. set projectionTextureUpDirection(value: Vector3);
  122204. private _projectionTexture;
  122205. /**
  122206. * Gets the projection texture of the light.
  122207. */
  122208. get projectionTexture(): Nullable<BaseTexture>;
  122209. /**
  122210. * Sets the projection texture of the light.
  122211. */
  122212. set projectionTexture(value: Nullable<BaseTexture>);
  122213. private _projectionTextureViewLightDirty;
  122214. private _projectionTextureProjectionLightDirty;
  122215. private _projectionTextureDirty;
  122216. private _projectionTextureViewTargetVector;
  122217. private _projectionTextureViewLightMatrix;
  122218. private _projectionTextureProjectionLightMatrix;
  122219. private _projectionTextureScalingMatrix;
  122220. /**
  122221. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122222. * It can cast shadows.
  122223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122224. * @param name The light friendly name
  122225. * @param position The position of the spot light in the scene
  122226. * @param direction The direction of the light in the scene
  122227. * @param angle The cone angle of the light in Radians
  122228. * @param exponent The light decay speed with the distance from the emission spot
  122229. * @param scene The scene the lights belongs to
  122230. */
  122231. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122232. /**
  122233. * Returns the string "SpotLight".
  122234. * @returns the class name
  122235. */
  122236. getClassName(): string;
  122237. /**
  122238. * Returns the integer 2.
  122239. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122240. */
  122241. getTypeID(): number;
  122242. /**
  122243. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122244. */
  122245. protected _setDirection(value: Vector3): void;
  122246. /**
  122247. * Overrides the position setter to recompute the projection texture view light Matrix.
  122248. */
  122249. protected _setPosition(value: Vector3): void;
  122250. /**
  122251. * 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.
  122252. * Returns the SpotLight.
  122253. */
  122254. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122255. protected _computeProjectionTextureViewLightMatrix(): void;
  122256. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122257. /**
  122258. * Main function for light texture projection matrix computing.
  122259. */
  122260. protected _computeProjectionTextureMatrix(): void;
  122261. protected _buildUniformLayout(): void;
  122262. private _computeAngleValues;
  122263. /**
  122264. * Sets the passed Effect "effect" with the Light textures.
  122265. * @param effect The effect to update
  122266. * @param lightIndex The index of the light in the effect to update
  122267. * @returns The light
  122268. */
  122269. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122270. /**
  122271. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122272. * @param effect The effect to update
  122273. * @param lightIndex The index of the light in the effect to update
  122274. * @returns The spot light
  122275. */
  122276. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122277. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122278. /**
  122279. * Disposes the light and the associated resources.
  122280. */
  122281. dispose(): void;
  122282. /**
  122283. * Prepares the list of defines specific to the light type.
  122284. * @param defines the list of defines
  122285. * @param lightIndex defines the index of the light for the effect
  122286. */
  122287. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122288. }
  122289. }
  122290. declare module BABYLON {
  122291. /**
  122292. * Gizmo that enables viewing a light
  122293. */
  122294. export class LightGizmo extends Gizmo {
  122295. private _lightMesh;
  122296. private _material;
  122297. private _cachedPosition;
  122298. private _cachedForward;
  122299. private _attachedMeshParent;
  122300. /**
  122301. * Creates a LightGizmo
  122302. * @param gizmoLayer The utility layer the gizmo will be added to
  122303. */
  122304. constructor(gizmoLayer?: UtilityLayerRenderer);
  122305. private _light;
  122306. /**
  122307. * The light that the gizmo is attached to
  122308. */
  122309. set light(light: Nullable<Light>);
  122310. get light(): Nullable<Light>;
  122311. /**
  122312. * Gets the material used to render the light gizmo
  122313. */
  122314. get material(): StandardMaterial;
  122315. /**
  122316. * @hidden
  122317. * Updates the gizmo to match the attached mesh's position/rotation
  122318. */
  122319. protected _update(): void;
  122320. private static _Scale;
  122321. /**
  122322. * Creates the lines for a light mesh
  122323. */
  122324. private static _CreateLightLines;
  122325. /**
  122326. * Disposes of the light gizmo
  122327. */
  122328. dispose(): void;
  122329. private static _CreateHemisphericLightMesh;
  122330. private static _CreatePointLightMesh;
  122331. private static _CreateSpotLightMesh;
  122332. private static _CreateDirectionalLightMesh;
  122333. }
  122334. }
  122335. declare module BABYLON {
  122336. /** @hidden */
  122337. export var backgroundFragmentDeclaration: {
  122338. name: string;
  122339. shader: string;
  122340. };
  122341. }
  122342. declare module BABYLON {
  122343. /** @hidden */
  122344. export var backgroundUboDeclaration: {
  122345. name: string;
  122346. shader: string;
  122347. };
  122348. }
  122349. declare module BABYLON {
  122350. /** @hidden */
  122351. export var backgroundPixelShader: {
  122352. name: string;
  122353. shader: string;
  122354. };
  122355. }
  122356. declare module BABYLON {
  122357. /** @hidden */
  122358. export var backgroundVertexDeclaration: {
  122359. name: string;
  122360. shader: string;
  122361. };
  122362. }
  122363. declare module BABYLON {
  122364. /** @hidden */
  122365. export var backgroundVertexShader: {
  122366. name: string;
  122367. shader: string;
  122368. };
  122369. }
  122370. declare module BABYLON {
  122371. /**
  122372. * Background material used to create an efficient environement around your scene.
  122373. */
  122374. export class BackgroundMaterial extends PushMaterial {
  122375. /**
  122376. * Standard reflectance value at parallel view angle.
  122377. */
  122378. static StandardReflectance0: number;
  122379. /**
  122380. * Standard reflectance value at grazing angle.
  122381. */
  122382. static StandardReflectance90: number;
  122383. protected _primaryColor: Color3;
  122384. /**
  122385. * Key light Color (multiply against the environement texture)
  122386. */
  122387. primaryColor: Color3;
  122388. protected __perceptualColor: Nullable<Color3>;
  122389. /**
  122390. * Experimental Internal Use Only.
  122391. *
  122392. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122393. * This acts as a helper to set the primary color to a more "human friendly" value.
  122394. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122395. * output color as close as possible from the chosen value.
  122396. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122397. * part of lighting setup.)
  122398. */
  122399. get _perceptualColor(): Nullable<Color3>;
  122400. set _perceptualColor(value: Nullable<Color3>);
  122401. protected _primaryColorShadowLevel: float;
  122402. /**
  122403. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122404. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122405. */
  122406. get primaryColorShadowLevel(): float;
  122407. set primaryColorShadowLevel(value: float);
  122408. protected _primaryColorHighlightLevel: float;
  122409. /**
  122410. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122411. * The primary color is used at the level chosen to define what the white area would look.
  122412. */
  122413. get primaryColorHighlightLevel(): float;
  122414. set primaryColorHighlightLevel(value: float);
  122415. protected _reflectionTexture: Nullable<BaseTexture>;
  122416. /**
  122417. * Reflection Texture used in the material.
  122418. * Should be author in a specific way for the best result (refer to the documentation).
  122419. */
  122420. reflectionTexture: Nullable<BaseTexture>;
  122421. protected _reflectionBlur: float;
  122422. /**
  122423. * Reflection Texture level of blur.
  122424. *
  122425. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122426. * texture twice.
  122427. */
  122428. reflectionBlur: float;
  122429. protected _diffuseTexture: Nullable<BaseTexture>;
  122430. /**
  122431. * Diffuse Texture used in the material.
  122432. * Should be author in a specific way for the best result (refer to the documentation).
  122433. */
  122434. diffuseTexture: Nullable<BaseTexture>;
  122435. protected _shadowLights: Nullable<IShadowLight[]>;
  122436. /**
  122437. * Specify the list of lights casting shadow on the material.
  122438. * All scene shadow lights will be included if null.
  122439. */
  122440. shadowLights: Nullable<IShadowLight[]>;
  122441. protected _shadowLevel: float;
  122442. /**
  122443. * Helps adjusting the shadow to a softer level if required.
  122444. * 0 means black shadows and 1 means no shadows.
  122445. */
  122446. shadowLevel: float;
  122447. protected _sceneCenter: Vector3;
  122448. /**
  122449. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122450. * It is usually zero but might be interesting to modify according to your setup.
  122451. */
  122452. sceneCenter: Vector3;
  122453. protected _opacityFresnel: boolean;
  122454. /**
  122455. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122456. * This helps ensuring a nice transition when the camera goes under the ground.
  122457. */
  122458. opacityFresnel: boolean;
  122459. protected _reflectionFresnel: boolean;
  122460. /**
  122461. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122462. * This helps adding a mirror texture on the ground.
  122463. */
  122464. reflectionFresnel: boolean;
  122465. protected _reflectionFalloffDistance: number;
  122466. /**
  122467. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122468. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122469. */
  122470. reflectionFalloffDistance: number;
  122471. protected _reflectionAmount: number;
  122472. /**
  122473. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122474. */
  122475. reflectionAmount: number;
  122476. protected _reflectionReflectance0: number;
  122477. /**
  122478. * This specifies the weight of the reflection at grazing angle.
  122479. */
  122480. reflectionReflectance0: number;
  122481. protected _reflectionReflectance90: number;
  122482. /**
  122483. * This specifies the weight of the reflection at a perpendicular point of view.
  122484. */
  122485. reflectionReflectance90: number;
  122486. /**
  122487. * Sets the reflection reflectance fresnel values according to the default standard
  122488. * empirically know to work well :-)
  122489. */
  122490. set reflectionStandardFresnelWeight(value: number);
  122491. protected _useRGBColor: boolean;
  122492. /**
  122493. * Helps to directly use the maps channels instead of their level.
  122494. */
  122495. useRGBColor: boolean;
  122496. protected _enableNoise: boolean;
  122497. /**
  122498. * This helps reducing the banding effect that could occur on the background.
  122499. */
  122500. enableNoise: boolean;
  122501. /**
  122502. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122503. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122504. * Recommended to be keep at 1.0 except for special cases.
  122505. */
  122506. get fovMultiplier(): number;
  122507. set fovMultiplier(value: number);
  122508. private _fovMultiplier;
  122509. /**
  122510. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122511. */
  122512. useEquirectangularFOV: boolean;
  122513. private _maxSimultaneousLights;
  122514. /**
  122515. * Number of Simultaneous lights allowed on the material.
  122516. */
  122517. maxSimultaneousLights: int;
  122518. /**
  122519. * Default configuration related to image processing available in the Background Material.
  122520. */
  122521. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122522. /**
  122523. * Keep track of the image processing observer to allow dispose and replace.
  122524. */
  122525. private _imageProcessingObserver;
  122526. /**
  122527. * Attaches a new image processing configuration to the PBR Material.
  122528. * @param configuration (if null the scene configuration will be use)
  122529. */
  122530. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122531. /**
  122532. * Gets the image processing configuration used either in this material.
  122533. */
  122534. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122535. /**
  122536. * Sets the Default image processing configuration used either in the this material.
  122537. *
  122538. * If sets to null, the scene one is in use.
  122539. */
  122540. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122541. /**
  122542. * Gets wether the color curves effect is enabled.
  122543. */
  122544. get cameraColorCurvesEnabled(): boolean;
  122545. /**
  122546. * Sets wether the color curves effect is enabled.
  122547. */
  122548. set cameraColorCurvesEnabled(value: boolean);
  122549. /**
  122550. * Gets wether the color grading effect is enabled.
  122551. */
  122552. get cameraColorGradingEnabled(): boolean;
  122553. /**
  122554. * Gets wether the color grading effect is enabled.
  122555. */
  122556. set cameraColorGradingEnabled(value: boolean);
  122557. /**
  122558. * Gets wether tonemapping is enabled or not.
  122559. */
  122560. get cameraToneMappingEnabled(): boolean;
  122561. /**
  122562. * Sets wether tonemapping is enabled or not
  122563. */
  122564. set cameraToneMappingEnabled(value: boolean);
  122565. /**
  122566. * The camera exposure used on this material.
  122567. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122568. * This corresponds to a photographic exposure.
  122569. */
  122570. get cameraExposure(): float;
  122571. /**
  122572. * The camera exposure used on this material.
  122573. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122574. * This corresponds to a photographic exposure.
  122575. */
  122576. set cameraExposure(value: float);
  122577. /**
  122578. * Gets The camera contrast used on this material.
  122579. */
  122580. get cameraContrast(): float;
  122581. /**
  122582. * Sets The camera contrast used on this material.
  122583. */
  122584. set cameraContrast(value: float);
  122585. /**
  122586. * Gets the Color Grading 2D Lookup Texture.
  122587. */
  122588. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122589. /**
  122590. * Sets the Color Grading 2D Lookup Texture.
  122591. */
  122592. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122593. /**
  122594. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122595. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122596. * 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;
  122597. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122598. */
  122599. get cameraColorCurves(): Nullable<ColorCurves>;
  122600. /**
  122601. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122602. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122603. * 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;
  122604. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122605. */
  122606. set cameraColorCurves(value: Nullable<ColorCurves>);
  122607. /**
  122608. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122609. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122610. */
  122611. switchToBGR: boolean;
  122612. private _renderTargets;
  122613. private _reflectionControls;
  122614. private _white;
  122615. private _primaryShadowColor;
  122616. private _primaryHighlightColor;
  122617. /**
  122618. * Instantiates a Background Material in the given scene
  122619. * @param name The friendly name of the material
  122620. * @param scene The scene to add the material to
  122621. */
  122622. constructor(name: string, scene: Scene);
  122623. /**
  122624. * Gets a boolean indicating that current material needs to register RTT
  122625. */
  122626. get hasRenderTargetTextures(): boolean;
  122627. /**
  122628. * The entire material has been created in order to prevent overdraw.
  122629. * @returns false
  122630. */
  122631. needAlphaTesting(): boolean;
  122632. /**
  122633. * The entire material has been created in order to prevent overdraw.
  122634. * @returns true if blending is enable
  122635. */
  122636. needAlphaBlending(): boolean;
  122637. /**
  122638. * Checks wether the material is ready to be rendered for a given mesh.
  122639. * @param mesh The mesh to render
  122640. * @param subMesh The submesh to check against
  122641. * @param useInstances Specify wether or not the material is used with instances
  122642. * @returns true if all the dependencies are ready (Textures, Effects...)
  122643. */
  122644. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122645. /**
  122646. * Compute the primary color according to the chosen perceptual color.
  122647. */
  122648. private _computePrimaryColorFromPerceptualColor;
  122649. /**
  122650. * Compute the highlights and shadow colors according to their chosen levels.
  122651. */
  122652. private _computePrimaryColors;
  122653. /**
  122654. * Build the uniform buffer used in the material.
  122655. */
  122656. buildUniformLayout(): void;
  122657. /**
  122658. * Unbind the material.
  122659. */
  122660. unbind(): void;
  122661. /**
  122662. * Bind only the world matrix to the material.
  122663. * @param world The world matrix to bind.
  122664. */
  122665. bindOnlyWorldMatrix(world: Matrix): void;
  122666. /**
  122667. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122668. * @param world The world matrix to bind.
  122669. * @param subMesh The submesh to bind for.
  122670. */
  122671. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122672. /**
  122673. * Checks to see if a texture is used in the material.
  122674. * @param texture - Base texture to use.
  122675. * @returns - Boolean specifying if a texture is used in the material.
  122676. */
  122677. hasTexture(texture: BaseTexture): boolean;
  122678. /**
  122679. * Dispose the material.
  122680. * @param forceDisposeEffect Force disposal of the associated effect.
  122681. * @param forceDisposeTextures Force disposal of the associated textures.
  122682. */
  122683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122684. /**
  122685. * Clones the material.
  122686. * @param name The cloned name.
  122687. * @returns The cloned material.
  122688. */
  122689. clone(name: string): BackgroundMaterial;
  122690. /**
  122691. * Serializes the current material to its JSON representation.
  122692. * @returns The JSON representation.
  122693. */
  122694. serialize(): any;
  122695. /**
  122696. * Gets the class name of the material
  122697. * @returns "BackgroundMaterial"
  122698. */
  122699. getClassName(): string;
  122700. /**
  122701. * Parse a JSON input to create back a background material.
  122702. * @param source The JSON data to parse
  122703. * @param scene The scene to create the parsed material in
  122704. * @param rootUrl The root url of the assets the material depends upon
  122705. * @returns the instantiated BackgroundMaterial.
  122706. */
  122707. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122708. }
  122709. }
  122710. declare module BABYLON {
  122711. /**
  122712. * Represents the different options available during the creation of
  122713. * a Environment helper.
  122714. *
  122715. * This can control the default ground, skybox and image processing setup of your scene.
  122716. */
  122717. export interface IEnvironmentHelperOptions {
  122718. /**
  122719. * Specifies whether or not to create a ground.
  122720. * True by default.
  122721. */
  122722. createGround: boolean;
  122723. /**
  122724. * Specifies the ground size.
  122725. * 15 by default.
  122726. */
  122727. groundSize: number;
  122728. /**
  122729. * The texture used on the ground for the main color.
  122730. * Comes from the BabylonJS CDN by default.
  122731. *
  122732. * Remarks: Can be either a texture or a url.
  122733. */
  122734. groundTexture: string | BaseTexture;
  122735. /**
  122736. * The color mixed in the ground texture by default.
  122737. * BabylonJS clearColor by default.
  122738. */
  122739. groundColor: Color3;
  122740. /**
  122741. * Specifies the ground opacity.
  122742. * 1 by default.
  122743. */
  122744. groundOpacity: number;
  122745. /**
  122746. * Enables the ground to receive shadows.
  122747. * True by default.
  122748. */
  122749. enableGroundShadow: boolean;
  122750. /**
  122751. * Helps preventing the shadow to be fully black on the ground.
  122752. * 0.5 by default.
  122753. */
  122754. groundShadowLevel: number;
  122755. /**
  122756. * Creates a mirror texture attach to the ground.
  122757. * false by default.
  122758. */
  122759. enableGroundMirror: boolean;
  122760. /**
  122761. * Specifies the ground mirror size ratio.
  122762. * 0.3 by default as the default kernel is 64.
  122763. */
  122764. groundMirrorSizeRatio: number;
  122765. /**
  122766. * Specifies the ground mirror blur kernel size.
  122767. * 64 by default.
  122768. */
  122769. groundMirrorBlurKernel: number;
  122770. /**
  122771. * Specifies the ground mirror visibility amount.
  122772. * 1 by default
  122773. */
  122774. groundMirrorAmount: number;
  122775. /**
  122776. * Specifies the ground mirror reflectance weight.
  122777. * This uses the standard weight of the background material to setup the fresnel effect
  122778. * of the mirror.
  122779. * 1 by default.
  122780. */
  122781. groundMirrorFresnelWeight: number;
  122782. /**
  122783. * Specifies the ground mirror Falloff distance.
  122784. * This can helps reducing the size of the reflection.
  122785. * 0 by Default.
  122786. */
  122787. groundMirrorFallOffDistance: number;
  122788. /**
  122789. * Specifies the ground mirror texture type.
  122790. * Unsigned Int by Default.
  122791. */
  122792. groundMirrorTextureType: number;
  122793. /**
  122794. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122795. * the shown objects.
  122796. */
  122797. groundYBias: number;
  122798. /**
  122799. * Specifies whether or not to create a skybox.
  122800. * True by default.
  122801. */
  122802. createSkybox: boolean;
  122803. /**
  122804. * Specifies the skybox size.
  122805. * 20 by default.
  122806. */
  122807. skyboxSize: number;
  122808. /**
  122809. * The texture used on the skybox for the main color.
  122810. * Comes from the BabylonJS CDN by default.
  122811. *
  122812. * Remarks: Can be either a texture or a url.
  122813. */
  122814. skyboxTexture: string | BaseTexture;
  122815. /**
  122816. * The color mixed in the skybox texture by default.
  122817. * BabylonJS clearColor by default.
  122818. */
  122819. skyboxColor: Color3;
  122820. /**
  122821. * The background rotation around the Y axis of the scene.
  122822. * This helps aligning the key lights of your scene with the background.
  122823. * 0 by default.
  122824. */
  122825. backgroundYRotation: number;
  122826. /**
  122827. * Compute automatically the size of the elements to best fit with the scene.
  122828. */
  122829. sizeAuto: boolean;
  122830. /**
  122831. * Default position of the rootMesh if autoSize is not true.
  122832. */
  122833. rootPosition: Vector3;
  122834. /**
  122835. * Sets up the image processing in the scene.
  122836. * true by default.
  122837. */
  122838. setupImageProcessing: boolean;
  122839. /**
  122840. * The texture used as your environment texture in the scene.
  122841. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122842. *
  122843. * Remarks: Can be either a texture or a url.
  122844. */
  122845. environmentTexture: string | BaseTexture;
  122846. /**
  122847. * The value of the exposure to apply to the scene.
  122848. * 0.6 by default if setupImageProcessing is true.
  122849. */
  122850. cameraExposure: number;
  122851. /**
  122852. * The value of the contrast to apply to the scene.
  122853. * 1.6 by default if setupImageProcessing is true.
  122854. */
  122855. cameraContrast: number;
  122856. /**
  122857. * Specifies whether or not tonemapping should be enabled in the scene.
  122858. * true by default if setupImageProcessing is true.
  122859. */
  122860. toneMappingEnabled: boolean;
  122861. }
  122862. /**
  122863. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122864. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122865. * It also helps with the default setup of your imageProcessing configuration.
  122866. */
  122867. export class EnvironmentHelper {
  122868. /**
  122869. * Default ground texture URL.
  122870. */
  122871. private static _groundTextureCDNUrl;
  122872. /**
  122873. * Default skybox texture URL.
  122874. */
  122875. private static _skyboxTextureCDNUrl;
  122876. /**
  122877. * Default environment texture URL.
  122878. */
  122879. private static _environmentTextureCDNUrl;
  122880. /**
  122881. * Creates the default options for the helper.
  122882. */
  122883. private static _getDefaultOptions;
  122884. private _rootMesh;
  122885. /**
  122886. * Gets the root mesh created by the helper.
  122887. */
  122888. get rootMesh(): Mesh;
  122889. private _skybox;
  122890. /**
  122891. * Gets the skybox created by the helper.
  122892. */
  122893. get skybox(): Nullable<Mesh>;
  122894. private _skyboxTexture;
  122895. /**
  122896. * Gets the skybox texture created by the helper.
  122897. */
  122898. get skyboxTexture(): Nullable<BaseTexture>;
  122899. private _skyboxMaterial;
  122900. /**
  122901. * Gets the skybox material created by the helper.
  122902. */
  122903. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122904. private _ground;
  122905. /**
  122906. * Gets the ground mesh created by the helper.
  122907. */
  122908. get ground(): Nullable<Mesh>;
  122909. private _groundTexture;
  122910. /**
  122911. * Gets the ground texture created by the helper.
  122912. */
  122913. get groundTexture(): Nullable<BaseTexture>;
  122914. private _groundMirror;
  122915. /**
  122916. * Gets the ground mirror created by the helper.
  122917. */
  122918. get groundMirror(): Nullable<MirrorTexture>;
  122919. /**
  122920. * Gets the ground mirror render list to helps pushing the meshes
  122921. * you wish in the ground reflection.
  122922. */
  122923. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122924. private _groundMaterial;
  122925. /**
  122926. * Gets the ground material created by the helper.
  122927. */
  122928. get groundMaterial(): Nullable<BackgroundMaterial>;
  122929. /**
  122930. * Stores the creation options.
  122931. */
  122932. private readonly _scene;
  122933. private _options;
  122934. /**
  122935. * This observable will be notified with any error during the creation of the environment,
  122936. * mainly texture creation errors.
  122937. */
  122938. onErrorObservable: Observable<{
  122939. message?: string;
  122940. exception?: any;
  122941. }>;
  122942. /**
  122943. * constructor
  122944. * @param options Defines the options we want to customize the helper
  122945. * @param scene The scene to add the material to
  122946. */
  122947. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122948. /**
  122949. * Updates the background according to the new options
  122950. * @param options
  122951. */
  122952. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122953. /**
  122954. * Sets the primary color of all the available elements.
  122955. * @param color the main color to affect to the ground and the background
  122956. */
  122957. setMainColor(color: Color3): void;
  122958. /**
  122959. * Setup the image processing according to the specified options.
  122960. */
  122961. private _setupImageProcessing;
  122962. /**
  122963. * Setup the environment texture according to the specified options.
  122964. */
  122965. private _setupEnvironmentTexture;
  122966. /**
  122967. * Setup the background according to the specified options.
  122968. */
  122969. private _setupBackground;
  122970. /**
  122971. * Get the scene sizes according to the setup.
  122972. */
  122973. private _getSceneSize;
  122974. /**
  122975. * Setup the ground according to the specified options.
  122976. */
  122977. private _setupGround;
  122978. /**
  122979. * Setup the ground material according to the specified options.
  122980. */
  122981. private _setupGroundMaterial;
  122982. /**
  122983. * Setup the ground diffuse texture according to the specified options.
  122984. */
  122985. private _setupGroundDiffuseTexture;
  122986. /**
  122987. * Setup the ground mirror texture according to the specified options.
  122988. */
  122989. private _setupGroundMirrorTexture;
  122990. /**
  122991. * Setup the ground to receive the mirror texture.
  122992. */
  122993. private _setupMirrorInGroundMaterial;
  122994. /**
  122995. * Setup the skybox according to the specified options.
  122996. */
  122997. private _setupSkybox;
  122998. /**
  122999. * Setup the skybox material according to the specified options.
  123000. */
  123001. private _setupSkyboxMaterial;
  123002. /**
  123003. * Setup the skybox reflection texture according to the specified options.
  123004. */
  123005. private _setupSkyboxReflectionTexture;
  123006. private _errorHandler;
  123007. /**
  123008. * Dispose all the elements created by the Helper.
  123009. */
  123010. dispose(): void;
  123011. }
  123012. }
  123013. declare module BABYLON {
  123014. /**
  123015. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123016. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123017. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123018. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123019. */
  123020. export class PhotoDome extends TransformNode {
  123021. /**
  123022. * Define the image as a Monoscopic panoramic 360 image.
  123023. */
  123024. static readonly MODE_MONOSCOPIC: number;
  123025. /**
  123026. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123027. */
  123028. static readonly MODE_TOPBOTTOM: number;
  123029. /**
  123030. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123031. */
  123032. static readonly MODE_SIDEBYSIDE: number;
  123033. private _useDirectMapping;
  123034. /**
  123035. * The texture being displayed on the sphere
  123036. */
  123037. protected _photoTexture: Texture;
  123038. /**
  123039. * Gets or sets the texture being displayed on the sphere
  123040. */
  123041. get photoTexture(): Texture;
  123042. set photoTexture(value: Texture);
  123043. /**
  123044. * Observable raised when an error occured while loading the 360 image
  123045. */
  123046. onLoadErrorObservable: Observable<string>;
  123047. /**
  123048. * The skybox material
  123049. */
  123050. protected _material: BackgroundMaterial;
  123051. /**
  123052. * The surface used for the skybox
  123053. */
  123054. protected _mesh: Mesh;
  123055. /**
  123056. * Gets the mesh used for the skybox.
  123057. */
  123058. get mesh(): Mesh;
  123059. /**
  123060. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123061. * Also see the options.resolution property.
  123062. */
  123063. get fovMultiplier(): number;
  123064. set fovMultiplier(value: number);
  123065. private _imageMode;
  123066. /**
  123067. * Gets or set the current video mode for the video. It can be:
  123068. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123069. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123070. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123071. */
  123072. get imageMode(): number;
  123073. set imageMode(value: number);
  123074. /**
  123075. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123076. * @param name Element's name, child elements will append suffixes for their own names.
  123077. * @param urlsOfPhoto defines the url of the photo to display
  123078. * @param options defines an object containing optional or exposed sub element properties
  123079. * @param onError defines a callback called when an error occured while loading the texture
  123080. */
  123081. constructor(name: string, urlOfPhoto: string, options: {
  123082. resolution?: number;
  123083. size?: number;
  123084. useDirectMapping?: boolean;
  123085. faceForward?: boolean;
  123086. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123087. private _onBeforeCameraRenderObserver;
  123088. private _changeImageMode;
  123089. /**
  123090. * Releases resources associated with this node.
  123091. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123092. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123093. */
  123094. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123095. }
  123096. }
  123097. declare module BABYLON {
  123098. /**
  123099. * Class used to host RGBD texture specific utilities
  123100. */
  123101. export class RGBDTextureTools {
  123102. /**
  123103. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123104. * @param texture the texture to expand.
  123105. */
  123106. static ExpandRGBDTexture(texture: Texture): void;
  123107. }
  123108. }
  123109. declare module BABYLON {
  123110. /**
  123111. * Class used to host texture specific utilities
  123112. */
  123113. export class BRDFTextureTools {
  123114. /**
  123115. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123116. * @param scene defines the hosting scene
  123117. * @returns the environment BRDF texture
  123118. */
  123119. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123120. private static _environmentBRDFBase64Texture;
  123121. }
  123122. }
  123123. declare module BABYLON {
  123124. /**
  123125. * @hidden
  123126. */
  123127. export interface IMaterialClearCoatDefines {
  123128. CLEARCOAT: boolean;
  123129. CLEARCOAT_DEFAULTIOR: boolean;
  123130. CLEARCOAT_TEXTURE: boolean;
  123131. CLEARCOAT_TEXTUREDIRECTUV: number;
  123132. CLEARCOAT_BUMP: boolean;
  123133. CLEARCOAT_BUMPDIRECTUV: number;
  123134. CLEARCOAT_TINT: boolean;
  123135. CLEARCOAT_TINT_TEXTURE: boolean;
  123136. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123137. /** @hidden */
  123138. _areTexturesDirty: boolean;
  123139. }
  123140. /**
  123141. * Define the code related to the clear coat parameters of the pbr material.
  123142. */
  123143. export class PBRClearCoatConfiguration {
  123144. /**
  123145. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123146. * The default fits with a polyurethane material.
  123147. */
  123148. private static readonly _DefaultIndexOfRefraction;
  123149. private _isEnabled;
  123150. /**
  123151. * Defines if the clear coat is enabled in the material.
  123152. */
  123153. isEnabled: boolean;
  123154. /**
  123155. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123156. */
  123157. intensity: number;
  123158. /**
  123159. * Defines the clear coat layer roughness.
  123160. */
  123161. roughness: number;
  123162. private _indexOfRefraction;
  123163. /**
  123164. * Defines the index of refraction of the clear coat.
  123165. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123166. * The default fits with a polyurethane material.
  123167. * Changing the default value is more performance intensive.
  123168. */
  123169. indexOfRefraction: number;
  123170. private _texture;
  123171. /**
  123172. * Stores the clear coat values in a texture.
  123173. */
  123174. texture: Nullable<BaseTexture>;
  123175. private _bumpTexture;
  123176. /**
  123177. * Define the clear coat specific bump texture.
  123178. */
  123179. bumpTexture: Nullable<BaseTexture>;
  123180. private _isTintEnabled;
  123181. /**
  123182. * Defines if the clear coat tint is enabled in the material.
  123183. */
  123184. isTintEnabled: boolean;
  123185. /**
  123186. * Defines the clear coat tint of the material.
  123187. * This is only use if tint is enabled
  123188. */
  123189. tintColor: Color3;
  123190. /**
  123191. * Defines the distance at which the tint color should be found in the
  123192. * clear coat media.
  123193. * This is only use if tint is enabled
  123194. */
  123195. tintColorAtDistance: number;
  123196. /**
  123197. * Defines the clear coat layer thickness.
  123198. * This is only use if tint is enabled
  123199. */
  123200. tintThickness: number;
  123201. private _tintTexture;
  123202. /**
  123203. * Stores the clear tint values in a texture.
  123204. * rgb is tint
  123205. * a is a thickness factor
  123206. */
  123207. tintTexture: Nullable<BaseTexture>;
  123208. /** @hidden */
  123209. private _internalMarkAllSubMeshesAsTexturesDirty;
  123210. /** @hidden */
  123211. _markAllSubMeshesAsTexturesDirty(): void;
  123212. /**
  123213. * Instantiate a new istance of clear coat configuration.
  123214. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123215. */
  123216. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123217. /**
  123218. * Gets wehter the submesh is ready to be used or not.
  123219. * @param defines the list of "defines" to update.
  123220. * @param scene defines the scene the material belongs to.
  123221. * @param engine defines the engine the material belongs to.
  123222. * @param disableBumpMap defines wether the material disables bump or not.
  123223. * @returns - boolean indicating that the submesh is ready or not.
  123224. */
  123225. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123226. /**
  123227. * Checks to see if a texture is used in the material.
  123228. * @param defines the list of "defines" to update.
  123229. * @param scene defines the scene to the material belongs to.
  123230. */
  123231. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123232. /**
  123233. * Binds the material data.
  123234. * @param uniformBuffer defines the Uniform buffer to fill in.
  123235. * @param scene defines the scene the material belongs to.
  123236. * @param engine defines the engine the material belongs to.
  123237. * @param disableBumpMap defines wether the material disables bump or not.
  123238. * @param isFrozen defines wether the material is frozen or not.
  123239. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123240. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123241. */
  123242. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123243. /**
  123244. * Checks to see if a texture is used in the material.
  123245. * @param texture - Base texture to use.
  123246. * @returns - Boolean specifying if a texture is used in the material.
  123247. */
  123248. hasTexture(texture: BaseTexture): boolean;
  123249. /**
  123250. * Returns an array of the actively used textures.
  123251. * @param activeTextures Array of BaseTextures
  123252. */
  123253. getActiveTextures(activeTextures: BaseTexture[]): void;
  123254. /**
  123255. * Returns the animatable textures.
  123256. * @param animatables Array of animatable textures.
  123257. */
  123258. getAnimatables(animatables: IAnimatable[]): void;
  123259. /**
  123260. * Disposes the resources of the material.
  123261. * @param forceDisposeTextures - Forces the disposal of all textures.
  123262. */
  123263. dispose(forceDisposeTextures?: boolean): void;
  123264. /**
  123265. * Get the current class name of the texture useful for serialization or dynamic coding.
  123266. * @returns "PBRClearCoatConfiguration"
  123267. */
  123268. getClassName(): string;
  123269. /**
  123270. * Add fallbacks to the effect fallbacks list.
  123271. * @param defines defines the Base texture to use.
  123272. * @param fallbacks defines the current fallback list.
  123273. * @param currentRank defines the current fallback rank.
  123274. * @returns the new fallback rank.
  123275. */
  123276. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123277. /**
  123278. * Add the required uniforms to the current list.
  123279. * @param uniforms defines the current uniform list.
  123280. */
  123281. static AddUniforms(uniforms: string[]): void;
  123282. /**
  123283. * Add the required samplers to the current list.
  123284. * @param samplers defines the current sampler list.
  123285. */
  123286. static AddSamplers(samplers: string[]): void;
  123287. /**
  123288. * Add the required uniforms to the current buffer.
  123289. * @param uniformBuffer defines the current uniform buffer.
  123290. */
  123291. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123292. /**
  123293. * Makes a duplicate of the current configuration into another one.
  123294. * @param clearCoatConfiguration define the config where to copy the info
  123295. */
  123296. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123297. /**
  123298. * Serializes this clear coat configuration.
  123299. * @returns - An object with the serialized config.
  123300. */
  123301. serialize(): any;
  123302. /**
  123303. * Parses a anisotropy Configuration from a serialized object.
  123304. * @param source - Serialized object.
  123305. * @param scene Defines the scene we are parsing for
  123306. * @param rootUrl Defines the rootUrl to load from
  123307. */
  123308. parse(source: any, scene: Scene, rootUrl: string): void;
  123309. }
  123310. }
  123311. declare module BABYLON {
  123312. /**
  123313. * @hidden
  123314. */
  123315. export interface IMaterialAnisotropicDefines {
  123316. ANISOTROPIC: boolean;
  123317. ANISOTROPIC_TEXTURE: boolean;
  123318. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123319. MAINUV1: boolean;
  123320. _areTexturesDirty: boolean;
  123321. _needUVs: boolean;
  123322. }
  123323. /**
  123324. * Define the code related to the anisotropic parameters of the pbr material.
  123325. */
  123326. export class PBRAnisotropicConfiguration {
  123327. private _isEnabled;
  123328. /**
  123329. * Defines if the anisotropy is enabled in the material.
  123330. */
  123331. isEnabled: boolean;
  123332. /**
  123333. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123334. */
  123335. intensity: number;
  123336. /**
  123337. * Defines if the effect is along the tangents, bitangents or in between.
  123338. * By default, the effect is "strectching" the highlights along the tangents.
  123339. */
  123340. direction: Vector2;
  123341. private _texture;
  123342. /**
  123343. * Stores the anisotropy values in a texture.
  123344. * rg is direction (like normal from -1 to 1)
  123345. * b is a intensity
  123346. */
  123347. texture: Nullable<BaseTexture>;
  123348. /** @hidden */
  123349. private _internalMarkAllSubMeshesAsTexturesDirty;
  123350. /** @hidden */
  123351. _markAllSubMeshesAsTexturesDirty(): void;
  123352. /**
  123353. * Instantiate a new istance of anisotropy configuration.
  123354. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123355. */
  123356. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123357. /**
  123358. * Specifies that the submesh is ready to be used.
  123359. * @param defines the list of "defines" to update.
  123360. * @param scene defines the scene the material belongs to.
  123361. * @returns - boolean indicating that the submesh is ready or not.
  123362. */
  123363. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123364. /**
  123365. * Checks to see if a texture is used in the material.
  123366. * @param defines the list of "defines" to update.
  123367. * @param mesh the mesh we are preparing the defines for.
  123368. * @param scene defines the scene the material belongs to.
  123369. */
  123370. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123371. /**
  123372. * Binds the material data.
  123373. * @param uniformBuffer defines the Uniform buffer to fill in.
  123374. * @param scene defines the scene the material belongs to.
  123375. * @param isFrozen defines wether the material is frozen or not.
  123376. */
  123377. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123378. /**
  123379. * Checks to see if a texture is used in the material.
  123380. * @param texture - Base texture to use.
  123381. * @returns - Boolean specifying if a texture is used in the material.
  123382. */
  123383. hasTexture(texture: BaseTexture): boolean;
  123384. /**
  123385. * Returns an array of the actively used textures.
  123386. * @param activeTextures Array of BaseTextures
  123387. */
  123388. getActiveTextures(activeTextures: BaseTexture[]): void;
  123389. /**
  123390. * Returns the animatable textures.
  123391. * @param animatables Array of animatable textures.
  123392. */
  123393. getAnimatables(animatables: IAnimatable[]): void;
  123394. /**
  123395. * Disposes the resources of the material.
  123396. * @param forceDisposeTextures - Forces the disposal of all textures.
  123397. */
  123398. dispose(forceDisposeTextures?: boolean): void;
  123399. /**
  123400. * Get the current class name of the texture useful for serialization or dynamic coding.
  123401. * @returns "PBRAnisotropicConfiguration"
  123402. */
  123403. getClassName(): string;
  123404. /**
  123405. * Add fallbacks to the effect fallbacks list.
  123406. * @param defines defines the Base texture to use.
  123407. * @param fallbacks defines the current fallback list.
  123408. * @param currentRank defines the current fallback rank.
  123409. * @returns the new fallback rank.
  123410. */
  123411. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123412. /**
  123413. * Add the required uniforms to the current list.
  123414. * @param uniforms defines the current uniform list.
  123415. */
  123416. static AddUniforms(uniforms: string[]): void;
  123417. /**
  123418. * Add the required uniforms to the current buffer.
  123419. * @param uniformBuffer defines the current uniform buffer.
  123420. */
  123421. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123422. /**
  123423. * Add the required samplers to the current list.
  123424. * @param samplers defines the current sampler list.
  123425. */
  123426. static AddSamplers(samplers: string[]): void;
  123427. /**
  123428. * Makes a duplicate of the current configuration into another one.
  123429. * @param anisotropicConfiguration define the config where to copy the info
  123430. */
  123431. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123432. /**
  123433. * Serializes this anisotropy configuration.
  123434. * @returns - An object with the serialized config.
  123435. */
  123436. serialize(): any;
  123437. /**
  123438. * Parses a anisotropy Configuration from a serialized object.
  123439. * @param source - Serialized object.
  123440. * @param scene Defines the scene we are parsing for
  123441. * @param rootUrl Defines the rootUrl to load from
  123442. */
  123443. parse(source: any, scene: Scene, rootUrl: string): void;
  123444. }
  123445. }
  123446. declare module BABYLON {
  123447. /**
  123448. * @hidden
  123449. */
  123450. export interface IMaterialBRDFDefines {
  123451. BRDF_V_HEIGHT_CORRELATED: boolean;
  123452. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123453. SPHERICAL_HARMONICS: boolean;
  123454. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123455. /** @hidden */
  123456. _areMiscDirty: boolean;
  123457. }
  123458. /**
  123459. * Define the code related to the BRDF parameters of the pbr material.
  123460. */
  123461. export class PBRBRDFConfiguration {
  123462. /**
  123463. * Default value used for the energy conservation.
  123464. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123465. */
  123466. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123467. /**
  123468. * Default value used for the Smith Visibility Height Correlated mode.
  123469. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123470. */
  123471. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123472. /**
  123473. * Default value used for the IBL diffuse part.
  123474. * This can help switching back to the polynomials mode globally which is a tiny bit
  123475. * less GPU intensive at the drawback of a lower quality.
  123476. */
  123477. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123478. /**
  123479. * Default value used for activating energy conservation for the specular workflow.
  123480. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123481. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123482. */
  123483. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123484. private _useEnergyConservation;
  123485. /**
  123486. * Defines if the material uses energy conservation.
  123487. */
  123488. useEnergyConservation: boolean;
  123489. private _useSmithVisibilityHeightCorrelated;
  123490. /**
  123491. * LEGACY Mode set to false
  123492. * Defines if the material uses height smith correlated visibility term.
  123493. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123494. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123495. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123496. * Not relying on height correlated will also disable energy conservation.
  123497. */
  123498. useSmithVisibilityHeightCorrelated: boolean;
  123499. private _useSphericalHarmonics;
  123500. /**
  123501. * LEGACY Mode set to false
  123502. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123503. * diffuse part of the IBL.
  123504. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123505. * to the ground truth.
  123506. */
  123507. useSphericalHarmonics: boolean;
  123508. private _useSpecularGlossinessInputEnergyConservation;
  123509. /**
  123510. * Defines if the material uses energy conservation, when the specular workflow is active.
  123511. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123512. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123513. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123514. */
  123515. useSpecularGlossinessInputEnergyConservation: boolean;
  123516. /** @hidden */
  123517. private _internalMarkAllSubMeshesAsMiscDirty;
  123518. /** @hidden */
  123519. _markAllSubMeshesAsMiscDirty(): void;
  123520. /**
  123521. * Instantiate a new istance of clear coat configuration.
  123522. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123523. */
  123524. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123525. /**
  123526. * Checks to see if a texture is used in the material.
  123527. * @param defines the list of "defines" to update.
  123528. */
  123529. prepareDefines(defines: IMaterialBRDFDefines): void;
  123530. /**
  123531. * Get the current class name of the texture useful for serialization or dynamic coding.
  123532. * @returns "PBRClearCoatConfiguration"
  123533. */
  123534. getClassName(): string;
  123535. /**
  123536. * Makes a duplicate of the current configuration into another one.
  123537. * @param brdfConfiguration define the config where to copy the info
  123538. */
  123539. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123540. /**
  123541. * Serializes this BRDF configuration.
  123542. * @returns - An object with the serialized config.
  123543. */
  123544. serialize(): any;
  123545. /**
  123546. * Parses a anisotropy Configuration from a serialized object.
  123547. * @param source - Serialized object.
  123548. * @param scene Defines the scene we are parsing for
  123549. * @param rootUrl Defines the rootUrl to load from
  123550. */
  123551. parse(source: any, scene: Scene, rootUrl: string): void;
  123552. }
  123553. }
  123554. declare module BABYLON {
  123555. /**
  123556. * @hidden
  123557. */
  123558. export interface IMaterialSheenDefines {
  123559. SHEEN: boolean;
  123560. SHEEN_TEXTURE: boolean;
  123561. SHEEN_TEXTUREDIRECTUV: number;
  123562. SHEEN_LINKWITHALBEDO: boolean;
  123563. /** @hidden */
  123564. _areTexturesDirty: boolean;
  123565. }
  123566. /**
  123567. * Define the code related to the Sheen parameters of the pbr material.
  123568. */
  123569. export class PBRSheenConfiguration {
  123570. private _isEnabled;
  123571. /**
  123572. * Defines if the material uses sheen.
  123573. */
  123574. isEnabled: boolean;
  123575. private _linkSheenWithAlbedo;
  123576. /**
  123577. * Defines if the sheen is linked to the sheen color.
  123578. */
  123579. linkSheenWithAlbedo: boolean;
  123580. /**
  123581. * Defines the sheen intensity.
  123582. */
  123583. intensity: number;
  123584. /**
  123585. * Defines the sheen color.
  123586. */
  123587. color: Color3;
  123588. private _texture;
  123589. /**
  123590. * Stores the sheen tint values in a texture.
  123591. * rgb is tint
  123592. * a is a intensity
  123593. */
  123594. texture: Nullable<BaseTexture>;
  123595. /** @hidden */
  123596. private _internalMarkAllSubMeshesAsTexturesDirty;
  123597. /** @hidden */
  123598. _markAllSubMeshesAsTexturesDirty(): void;
  123599. /**
  123600. * Instantiate a new istance of clear coat configuration.
  123601. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123602. */
  123603. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123604. /**
  123605. * Specifies that the submesh is ready to be used.
  123606. * @param defines the list of "defines" to update.
  123607. * @param scene defines the scene the material belongs to.
  123608. * @returns - boolean indicating that the submesh is ready or not.
  123609. */
  123610. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123611. /**
  123612. * Checks to see if a texture is used in the material.
  123613. * @param defines the list of "defines" to update.
  123614. * @param scene defines the scene the material belongs to.
  123615. */
  123616. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123617. /**
  123618. * Binds the material data.
  123619. * @param uniformBuffer defines the Uniform buffer to fill in.
  123620. * @param scene defines the scene the material belongs to.
  123621. * @param isFrozen defines wether the material is frozen or not.
  123622. */
  123623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123624. /**
  123625. * Checks to see if a texture is used in the material.
  123626. * @param texture - Base texture to use.
  123627. * @returns - Boolean specifying if a texture is used in the material.
  123628. */
  123629. hasTexture(texture: BaseTexture): boolean;
  123630. /**
  123631. * Returns an array of the actively used textures.
  123632. * @param activeTextures Array of BaseTextures
  123633. */
  123634. getActiveTextures(activeTextures: BaseTexture[]): void;
  123635. /**
  123636. * Returns the animatable textures.
  123637. * @param animatables Array of animatable textures.
  123638. */
  123639. getAnimatables(animatables: IAnimatable[]): void;
  123640. /**
  123641. * Disposes the resources of the material.
  123642. * @param forceDisposeTextures - Forces the disposal of all textures.
  123643. */
  123644. dispose(forceDisposeTextures?: boolean): void;
  123645. /**
  123646. * Get the current class name of the texture useful for serialization or dynamic coding.
  123647. * @returns "PBRSheenConfiguration"
  123648. */
  123649. getClassName(): string;
  123650. /**
  123651. * Add fallbacks to the effect fallbacks list.
  123652. * @param defines defines the Base texture to use.
  123653. * @param fallbacks defines the current fallback list.
  123654. * @param currentRank defines the current fallback rank.
  123655. * @returns the new fallback rank.
  123656. */
  123657. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123658. /**
  123659. * Add the required uniforms to the current list.
  123660. * @param uniforms defines the current uniform list.
  123661. */
  123662. static AddUniforms(uniforms: string[]): void;
  123663. /**
  123664. * Add the required uniforms to the current buffer.
  123665. * @param uniformBuffer defines the current uniform buffer.
  123666. */
  123667. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123668. /**
  123669. * Add the required samplers to the current list.
  123670. * @param samplers defines the current sampler list.
  123671. */
  123672. static AddSamplers(samplers: string[]): void;
  123673. /**
  123674. * Makes a duplicate of the current configuration into another one.
  123675. * @param sheenConfiguration define the config where to copy the info
  123676. */
  123677. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123678. /**
  123679. * Serializes this BRDF configuration.
  123680. * @returns - An object with the serialized config.
  123681. */
  123682. serialize(): any;
  123683. /**
  123684. * Parses a anisotropy Configuration from a serialized object.
  123685. * @param source - Serialized object.
  123686. * @param scene Defines the scene we are parsing for
  123687. * @param rootUrl Defines the rootUrl to load from
  123688. */
  123689. parse(source: any, scene: Scene, rootUrl: string): void;
  123690. }
  123691. }
  123692. declare module BABYLON {
  123693. /**
  123694. * @hidden
  123695. */
  123696. export interface IMaterialSubSurfaceDefines {
  123697. SUBSURFACE: boolean;
  123698. SS_REFRACTION: boolean;
  123699. SS_TRANSLUCENCY: boolean;
  123700. SS_SCATERRING: boolean;
  123701. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123702. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123703. SS_REFRACTIONMAP_3D: boolean;
  123704. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123705. SS_LODINREFRACTIONALPHA: boolean;
  123706. SS_GAMMAREFRACTION: boolean;
  123707. SS_RGBDREFRACTION: boolean;
  123708. SS_LINEARSPECULARREFRACTION: boolean;
  123709. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123710. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123711. /** @hidden */
  123712. _areTexturesDirty: boolean;
  123713. }
  123714. /**
  123715. * Define the code related to the sub surface parameters of the pbr material.
  123716. */
  123717. export class PBRSubSurfaceConfiguration {
  123718. private _isRefractionEnabled;
  123719. /**
  123720. * Defines if the refraction is enabled in the material.
  123721. */
  123722. isRefractionEnabled: boolean;
  123723. private _isTranslucencyEnabled;
  123724. /**
  123725. * Defines if the translucency is enabled in the material.
  123726. */
  123727. isTranslucencyEnabled: boolean;
  123728. private _isScatteringEnabled;
  123729. /**
  123730. * Defines the refraction intensity of the material.
  123731. * The refraction when enabled replaces the Diffuse part of the material.
  123732. * The intensity helps transitionning between diffuse and refraction.
  123733. */
  123734. refractionIntensity: number;
  123735. /**
  123736. * Defines the translucency intensity of the material.
  123737. * When translucency has been enabled, this defines how much of the "translucency"
  123738. * is addded to the diffuse part of the material.
  123739. */
  123740. translucencyIntensity: number;
  123741. /**
  123742. * Defines the scattering intensity of the material.
  123743. * When scattering has been enabled, this defines how much of the "scattered light"
  123744. * is addded to the diffuse part of the material.
  123745. */
  123746. scatteringIntensity: number;
  123747. private _thicknessTexture;
  123748. /**
  123749. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123750. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123751. * 0 would mean minimumThickness
  123752. * 1 would mean maximumThickness
  123753. * The other channels might be use as a mask to vary the different effects intensity.
  123754. */
  123755. thicknessTexture: Nullable<BaseTexture>;
  123756. private _refractionTexture;
  123757. /**
  123758. * Defines the texture to use for refraction.
  123759. */
  123760. refractionTexture: Nullable<BaseTexture>;
  123761. private _indexOfRefraction;
  123762. /**
  123763. * Defines the index of refraction used in the material.
  123764. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123765. */
  123766. indexOfRefraction: number;
  123767. private _invertRefractionY;
  123768. /**
  123769. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123770. */
  123771. invertRefractionY: boolean;
  123772. private _linkRefractionWithTransparency;
  123773. /**
  123774. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123775. * Materials half opaque for instance using refraction could benefit from this control.
  123776. */
  123777. linkRefractionWithTransparency: boolean;
  123778. /**
  123779. * Defines the minimum thickness stored in the thickness map.
  123780. * If no thickness map is defined, this value will be used to simulate thickness.
  123781. */
  123782. minimumThickness: number;
  123783. /**
  123784. * Defines the maximum thickness stored in the thickness map.
  123785. */
  123786. maximumThickness: number;
  123787. /**
  123788. * Defines the volume tint of the material.
  123789. * This is used for both translucency and scattering.
  123790. */
  123791. tintColor: Color3;
  123792. /**
  123793. * Defines the distance at which the tint color should be found in the media.
  123794. * This is used for refraction only.
  123795. */
  123796. tintColorAtDistance: number;
  123797. /**
  123798. * Defines how far each channel transmit through the media.
  123799. * It is defined as a color to simplify it selection.
  123800. */
  123801. diffusionDistance: Color3;
  123802. private _useMaskFromThicknessTexture;
  123803. /**
  123804. * Stores the intensity of the different subsurface effects in the thickness texture.
  123805. * * the green channel is the translucency intensity.
  123806. * * the blue channel is the scattering intensity.
  123807. * * the alpha channel is the refraction intensity.
  123808. */
  123809. useMaskFromThicknessTexture: boolean;
  123810. /** @hidden */
  123811. private _internalMarkAllSubMeshesAsTexturesDirty;
  123812. /** @hidden */
  123813. _markAllSubMeshesAsTexturesDirty(): void;
  123814. /**
  123815. * Instantiate a new istance of sub surface configuration.
  123816. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123817. */
  123818. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123819. /**
  123820. * Gets wehter the submesh is ready to be used or not.
  123821. * @param defines the list of "defines" to update.
  123822. * @param scene defines the scene the material belongs to.
  123823. * @returns - boolean indicating that the submesh is ready or not.
  123824. */
  123825. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123826. /**
  123827. * Checks to see if a texture is used in the material.
  123828. * @param defines the list of "defines" to update.
  123829. * @param scene defines the scene to the material belongs to.
  123830. */
  123831. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123832. /**
  123833. * Binds the material data.
  123834. * @param uniformBuffer defines the Uniform buffer to fill in.
  123835. * @param scene defines the scene the material belongs to.
  123836. * @param engine defines the engine the material belongs to.
  123837. * @param isFrozen defines wether the material is frozen or not.
  123838. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123839. */
  123840. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123841. /**
  123842. * Unbinds the material from the mesh.
  123843. * @param activeEffect defines the effect that should be unbound from.
  123844. * @returns true if unbound, otherwise false
  123845. */
  123846. unbind(activeEffect: Effect): boolean;
  123847. /**
  123848. * Returns the texture used for refraction or null if none is used.
  123849. * @param scene defines the scene the material belongs to.
  123850. * @returns - Refraction texture if present. If no refraction texture and refraction
  123851. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123852. */
  123853. private _getRefractionTexture;
  123854. /**
  123855. * Returns true if alpha blending should be disabled.
  123856. */
  123857. get disableAlphaBlending(): boolean;
  123858. /**
  123859. * Fills the list of render target textures.
  123860. * @param renderTargets the list of render targets to update
  123861. */
  123862. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123863. /**
  123864. * Checks to see if a texture is used in the material.
  123865. * @param texture - Base texture to use.
  123866. * @returns - Boolean specifying if a texture is used in the material.
  123867. */
  123868. hasTexture(texture: BaseTexture): boolean;
  123869. /**
  123870. * Gets a boolean indicating that current material needs to register RTT
  123871. * @returns true if this uses a render target otherwise false.
  123872. */
  123873. hasRenderTargetTextures(): boolean;
  123874. /**
  123875. * Returns an array of the actively used textures.
  123876. * @param activeTextures Array of BaseTextures
  123877. */
  123878. getActiveTextures(activeTextures: BaseTexture[]): void;
  123879. /**
  123880. * Returns the animatable textures.
  123881. * @param animatables Array of animatable textures.
  123882. */
  123883. getAnimatables(animatables: IAnimatable[]): void;
  123884. /**
  123885. * Disposes the resources of the material.
  123886. * @param forceDisposeTextures - Forces the disposal of all textures.
  123887. */
  123888. dispose(forceDisposeTextures?: boolean): void;
  123889. /**
  123890. * Get the current class name of the texture useful for serialization or dynamic coding.
  123891. * @returns "PBRSubSurfaceConfiguration"
  123892. */
  123893. getClassName(): string;
  123894. /**
  123895. * Add fallbacks to the effect fallbacks list.
  123896. * @param defines defines the Base texture to use.
  123897. * @param fallbacks defines the current fallback list.
  123898. * @param currentRank defines the current fallback rank.
  123899. * @returns the new fallback rank.
  123900. */
  123901. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123902. /**
  123903. * Add the required uniforms to the current list.
  123904. * @param uniforms defines the current uniform list.
  123905. */
  123906. static AddUniforms(uniforms: string[]): void;
  123907. /**
  123908. * Add the required samplers to the current list.
  123909. * @param samplers defines the current sampler list.
  123910. */
  123911. static AddSamplers(samplers: string[]): void;
  123912. /**
  123913. * Add the required uniforms to the current buffer.
  123914. * @param uniformBuffer defines the current uniform buffer.
  123915. */
  123916. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123917. /**
  123918. * Makes a duplicate of the current configuration into another one.
  123919. * @param configuration define the config where to copy the info
  123920. */
  123921. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123922. /**
  123923. * Serializes this Sub Surface configuration.
  123924. * @returns - An object with the serialized config.
  123925. */
  123926. serialize(): any;
  123927. /**
  123928. * Parses a anisotropy Configuration from a serialized object.
  123929. * @param source - Serialized object.
  123930. * @param scene Defines the scene we are parsing for
  123931. * @param rootUrl Defines the rootUrl to load from
  123932. */
  123933. parse(source: any, scene: Scene, rootUrl: string): void;
  123934. }
  123935. }
  123936. declare module BABYLON {
  123937. /** @hidden */
  123938. export var pbrFragmentDeclaration: {
  123939. name: string;
  123940. shader: string;
  123941. };
  123942. }
  123943. declare module BABYLON {
  123944. /** @hidden */
  123945. export var pbrUboDeclaration: {
  123946. name: string;
  123947. shader: string;
  123948. };
  123949. }
  123950. declare module BABYLON {
  123951. /** @hidden */
  123952. export var pbrFragmentExtraDeclaration: {
  123953. name: string;
  123954. shader: string;
  123955. };
  123956. }
  123957. declare module BABYLON {
  123958. /** @hidden */
  123959. export var pbrFragmentSamplersDeclaration: {
  123960. name: string;
  123961. shader: string;
  123962. };
  123963. }
  123964. declare module BABYLON {
  123965. /** @hidden */
  123966. export var pbrHelperFunctions: {
  123967. name: string;
  123968. shader: string;
  123969. };
  123970. }
  123971. declare module BABYLON {
  123972. /** @hidden */
  123973. export var harmonicsFunctions: {
  123974. name: string;
  123975. shader: string;
  123976. };
  123977. }
  123978. declare module BABYLON {
  123979. /** @hidden */
  123980. export var pbrDirectLightingSetupFunctions: {
  123981. name: string;
  123982. shader: string;
  123983. };
  123984. }
  123985. declare module BABYLON {
  123986. /** @hidden */
  123987. export var pbrDirectLightingFalloffFunctions: {
  123988. name: string;
  123989. shader: string;
  123990. };
  123991. }
  123992. declare module BABYLON {
  123993. /** @hidden */
  123994. export var pbrBRDFFunctions: {
  123995. name: string;
  123996. shader: string;
  123997. };
  123998. }
  123999. declare module BABYLON {
  124000. /** @hidden */
  124001. export var pbrDirectLightingFunctions: {
  124002. name: string;
  124003. shader: string;
  124004. };
  124005. }
  124006. declare module BABYLON {
  124007. /** @hidden */
  124008. export var pbrIBLFunctions: {
  124009. name: string;
  124010. shader: string;
  124011. };
  124012. }
  124013. declare module BABYLON {
  124014. /** @hidden */
  124015. export var pbrDebug: {
  124016. name: string;
  124017. shader: string;
  124018. };
  124019. }
  124020. declare module BABYLON {
  124021. /** @hidden */
  124022. export var pbrPixelShader: {
  124023. name: string;
  124024. shader: string;
  124025. };
  124026. }
  124027. declare module BABYLON {
  124028. /** @hidden */
  124029. export var pbrVertexDeclaration: {
  124030. name: string;
  124031. shader: string;
  124032. };
  124033. }
  124034. declare module BABYLON {
  124035. /** @hidden */
  124036. export var pbrVertexShader: {
  124037. name: string;
  124038. shader: string;
  124039. };
  124040. }
  124041. declare module BABYLON {
  124042. /**
  124043. * Manages the defines for the PBR Material.
  124044. * @hidden
  124045. */
  124046. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124047. PBR: boolean;
  124048. MAINUV1: boolean;
  124049. MAINUV2: boolean;
  124050. UV1: boolean;
  124051. UV2: boolean;
  124052. ALBEDO: boolean;
  124053. GAMMAALBEDO: boolean;
  124054. ALBEDODIRECTUV: number;
  124055. VERTEXCOLOR: boolean;
  124056. AMBIENT: boolean;
  124057. AMBIENTDIRECTUV: number;
  124058. AMBIENTINGRAYSCALE: boolean;
  124059. OPACITY: boolean;
  124060. VERTEXALPHA: boolean;
  124061. OPACITYDIRECTUV: number;
  124062. OPACITYRGB: boolean;
  124063. ALPHATEST: boolean;
  124064. DEPTHPREPASS: boolean;
  124065. ALPHABLEND: boolean;
  124066. ALPHAFROMALBEDO: boolean;
  124067. ALPHATESTVALUE: string;
  124068. SPECULAROVERALPHA: boolean;
  124069. RADIANCEOVERALPHA: boolean;
  124070. ALPHAFRESNEL: boolean;
  124071. LINEARALPHAFRESNEL: boolean;
  124072. PREMULTIPLYALPHA: boolean;
  124073. EMISSIVE: boolean;
  124074. EMISSIVEDIRECTUV: number;
  124075. REFLECTIVITY: boolean;
  124076. REFLECTIVITYDIRECTUV: number;
  124077. SPECULARTERM: boolean;
  124078. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124079. MICROSURFACEAUTOMATIC: boolean;
  124080. LODBASEDMICROSFURACE: boolean;
  124081. MICROSURFACEMAP: boolean;
  124082. MICROSURFACEMAPDIRECTUV: number;
  124083. METALLICWORKFLOW: boolean;
  124084. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124085. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124086. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124087. AOSTOREINMETALMAPRED: boolean;
  124088. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124089. ENVIRONMENTBRDF: boolean;
  124090. ENVIRONMENTBRDF_RGBD: boolean;
  124091. NORMAL: boolean;
  124092. TANGENT: boolean;
  124093. BUMP: boolean;
  124094. BUMPDIRECTUV: number;
  124095. OBJECTSPACE_NORMALMAP: boolean;
  124096. PARALLAX: boolean;
  124097. PARALLAXOCCLUSION: boolean;
  124098. NORMALXYSCALE: boolean;
  124099. LIGHTMAP: boolean;
  124100. LIGHTMAPDIRECTUV: number;
  124101. USELIGHTMAPASSHADOWMAP: boolean;
  124102. GAMMALIGHTMAP: boolean;
  124103. RGBDLIGHTMAP: boolean;
  124104. REFLECTION: boolean;
  124105. REFLECTIONMAP_3D: boolean;
  124106. REFLECTIONMAP_SPHERICAL: boolean;
  124107. REFLECTIONMAP_PLANAR: boolean;
  124108. REFLECTIONMAP_CUBIC: boolean;
  124109. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124110. REFLECTIONMAP_PROJECTION: boolean;
  124111. REFLECTIONMAP_SKYBOX: boolean;
  124112. REFLECTIONMAP_EXPLICIT: boolean;
  124113. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124114. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124115. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124116. INVERTCUBICMAP: boolean;
  124117. USESPHERICALFROMREFLECTIONMAP: boolean;
  124118. USEIRRADIANCEMAP: boolean;
  124119. SPHERICAL_HARMONICS: boolean;
  124120. USESPHERICALINVERTEX: boolean;
  124121. REFLECTIONMAP_OPPOSITEZ: boolean;
  124122. LODINREFLECTIONALPHA: boolean;
  124123. GAMMAREFLECTION: boolean;
  124124. RGBDREFLECTION: boolean;
  124125. LINEARSPECULARREFLECTION: boolean;
  124126. RADIANCEOCCLUSION: boolean;
  124127. HORIZONOCCLUSION: boolean;
  124128. INSTANCES: boolean;
  124129. NUM_BONE_INFLUENCERS: number;
  124130. BonesPerMesh: number;
  124131. BONETEXTURE: boolean;
  124132. NONUNIFORMSCALING: boolean;
  124133. MORPHTARGETS: boolean;
  124134. MORPHTARGETS_NORMAL: boolean;
  124135. MORPHTARGETS_TANGENT: boolean;
  124136. MORPHTARGETS_UV: boolean;
  124137. NUM_MORPH_INFLUENCERS: number;
  124138. IMAGEPROCESSING: boolean;
  124139. VIGNETTE: boolean;
  124140. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124141. VIGNETTEBLENDMODEOPAQUE: boolean;
  124142. TONEMAPPING: boolean;
  124143. TONEMAPPING_ACES: boolean;
  124144. CONTRAST: boolean;
  124145. COLORCURVES: boolean;
  124146. COLORGRADING: boolean;
  124147. COLORGRADING3D: boolean;
  124148. SAMPLER3DGREENDEPTH: boolean;
  124149. SAMPLER3DBGRMAP: boolean;
  124150. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124151. EXPOSURE: boolean;
  124152. MULTIVIEW: boolean;
  124153. USEPHYSICALLIGHTFALLOFF: boolean;
  124154. USEGLTFLIGHTFALLOFF: boolean;
  124155. TWOSIDEDLIGHTING: boolean;
  124156. SHADOWFLOAT: boolean;
  124157. CLIPPLANE: boolean;
  124158. CLIPPLANE2: boolean;
  124159. CLIPPLANE3: boolean;
  124160. CLIPPLANE4: boolean;
  124161. CLIPPLANE5: boolean;
  124162. CLIPPLANE6: boolean;
  124163. POINTSIZE: boolean;
  124164. FOG: boolean;
  124165. LOGARITHMICDEPTH: boolean;
  124166. FORCENORMALFORWARD: boolean;
  124167. SPECULARAA: boolean;
  124168. CLEARCOAT: boolean;
  124169. CLEARCOAT_DEFAULTIOR: boolean;
  124170. CLEARCOAT_TEXTURE: boolean;
  124171. CLEARCOAT_TEXTUREDIRECTUV: number;
  124172. CLEARCOAT_BUMP: boolean;
  124173. CLEARCOAT_BUMPDIRECTUV: number;
  124174. CLEARCOAT_TINT: boolean;
  124175. CLEARCOAT_TINT_TEXTURE: boolean;
  124176. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124177. ANISOTROPIC: boolean;
  124178. ANISOTROPIC_TEXTURE: boolean;
  124179. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124180. BRDF_V_HEIGHT_CORRELATED: boolean;
  124181. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124182. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124183. SHEEN: boolean;
  124184. SHEEN_TEXTURE: boolean;
  124185. SHEEN_TEXTUREDIRECTUV: number;
  124186. SHEEN_LINKWITHALBEDO: boolean;
  124187. SUBSURFACE: boolean;
  124188. SS_REFRACTION: boolean;
  124189. SS_TRANSLUCENCY: boolean;
  124190. SS_SCATERRING: boolean;
  124191. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124192. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124193. SS_REFRACTIONMAP_3D: boolean;
  124194. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124195. SS_LODINREFRACTIONALPHA: boolean;
  124196. SS_GAMMAREFRACTION: boolean;
  124197. SS_RGBDREFRACTION: boolean;
  124198. SS_LINEARSPECULARREFRACTION: boolean;
  124199. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124200. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124201. UNLIT: boolean;
  124202. DEBUGMODE: number;
  124203. /**
  124204. * Initializes the PBR Material defines.
  124205. */
  124206. constructor();
  124207. /**
  124208. * Resets the PBR Material defines.
  124209. */
  124210. reset(): void;
  124211. }
  124212. /**
  124213. * The Physically based material base class of BJS.
  124214. *
  124215. * This offers the main features of a standard PBR material.
  124216. * For more information, please refer to the documentation :
  124217. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124218. */
  124219. export abstract class PBRBaseMaterial extends PushMaterial {
  124220. /**
  124221. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124222. */
  124223. static readonly PBRMATERIAL_OPAQUE: number;
  124224. /**
  124225. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124226. */
  124227. static readonly PBRMATERIAL_ALPHATEST: number;
  124228. /**
  124229. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124230. */
  124231. static readonly PBRMATERIAL_ALPHABLEND: number;
  124232. /**
  124233. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124234. * They are also discarded below the alpha cutoff threshold to improve performances.
  124235. */
  124236. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124237. /**
  124238. * Defines the default value of how much AO map is occluding the analytical lights
  124239. * (point spot...).
  124240. */
  124241. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124242. /**
  124243. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124244. */
  124245. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124246. /**
  124247. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124248. * to enhance interoperability with other engines.
  124249. */
  124250. static readonly LIGHTFALLOFF_GLTF: number;
  124251. /**
  124252. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124253. * to enhance interoperability with other materials.
  124254. */
  124255. static readonly LIGHTFALLOFF_STANDARD: number;
  124256. /**
  124257. * Intensity of the direct lights e.g. the four lights available in your scene.
  124258. * This impacts both the direct diffuse and specular highlights.
  124259. */
  124260. protected _directIntensity: number;
  124261. /**
  124262. * Intensity of the emissive part of the material.
  124263. * This helps controlling the emissive effect without modifying the emissive color.
  124264. */
  124265. protected _emissiveIntensity: number;
  124266. /**
  124267. * Intensity of the environment e.g. how much the environment will light the object
  124268. * either through harmonics for rough material or through the refelction for shiny ones.
  124269. */
  124270. protected _environmentIntensity: number;
  124271. /**
  124272. * This is a special control allowing the reduction of the specular highlights coming from the
  124273. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124274. */
  124275. protected _specularIntensity: number;
  124276. /**
  124277. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124278. */
  124279. private _lightingInfos;
  124280. /**
  124281. * Debug Control allowing disabling the bump map on this material.
  124282. */
  124283. protected _disableBumpMap: boolean;
  124284. /**
  124285. * AKA Diffuse Texture in standard nomenclature.
  124286. */
  124287. protected _albedoTexture: Nullable<BaseTexture>;
  124288. /**
  124289. * AKA Occlusion Texture in other nomenclature.
  124290. */
  124291. protected _ambientTexture: Nullable<BaseTexture>;
  124292. /**
  124293. * AKA Occlusion Texture Intensity in other nomenclature.
  124294. */
  124295. protected _ambientTextureStrength: number;
  124296. /**
  124297. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124298. * 1 means it completely occludes it
  124299. * 0 mean it has no impact
  124300. */
  124301. protected _ambientTextureImpactOnAnalyticalLights: number;
  124302. /**
  124303. * Stores the alpha values in a texture.
  124304. */
  124305. protected _opacityTexture: Nullable<BaseTexture>;
  124306. /**
  124307. * Stores the reflection values in a texture.
  124308. */
  124309. protected _reflectionTexture: Nullable<BaseTexture>;
  124310. /**
  124311. * Stores the emissive values in a texture.
  124312. */
  124313. protected _emissiveTexture: Nullable<BaseTexture>;
  124314. /**
  124315. * AKA Specular texture in other nomenclature.
  124316. */
  124317. protected _reflectivityTexture: Nullable<BaseTexture>;
  124318. /**
  124319. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124320. */
  124321. protected _metallicTexture: Nullable<BaseTexture>;
  124322. /**
  124323. * Specifies the metallic scalar of the metallic/roughness workflow.
  124324. * Can also be used to scale the metalness values of the metallic texture.
  124325. */
  124326. protected _metallic: Nullable<number>;
  124327. /**
  124328. * Specifies the roughness scalar of the metallic/roughness workflow.
  124329. * Can also be used to scale the roughness values of the metallic texture.
  124330. */
  124331. protected _roughness: Nullable<number>;
  124332. /**
  124333. * Specifies the an F0 factor to help configuring the material F0.
  124334. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124335. * to 0.5 the previously hard coded value stays the same.
  124336. * Can also be used to scale the F0 values of the metallic texture.
  124337. */
  124338. protected _metallicF0Factor: number;
  124339. /**
  124340. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124341. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124342. * your expectation as it multiplies with the texture data.
  124343. */
  124344. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124345. /**
  124346. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124347. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124348. */
  124349. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124350. /**
  124351. * Stores surface normal data used to displace a mesh in a texture.
  124352. */
  124353. protected _bumpTexture: Nullable<BaseTexture>;
  124354. /**
  124355. * Stores the pre-calculated light information of a mesh in a texture.
  124356. */
  124357. protected _lightmapTexture: Nullable<BaseTexture>;
  124358. /**
  124359. * The color of a material in ambient lighting.
  124360. */
  124361. protected _ambientColor: Color3;
  124362. /**
  124363. * AKA Diffuse Color in other nomenclature.
  124364. */
  124365. protected _albedoColor: Color3;
  124366. /**
  124367. * AKA Specular Color in other nomenclature.
  124368. */
  124369. protected _reflectivityColor: Color3;
  124370. /**
  124371. * The color applied when light is reflected from a material.
  124372. */
  124373. protected _reflectionColor: Color3;
  124374. /**
  124375. * The color applied when light is emitted from a material.
  124376. */
  124377. protected _emissiveColor: Color3;
  124378. /**
  124379. * AKA Glossiness in other nomenclature.
  124380. */
  124381. protected _microSurface: number;
  124382. /**
  124383. * Specifies that the material will use the light map as a show map.
  124384. */
  124385. protected _useLightmapAsShadowmap: boolean;
  124386. /**
  124387. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124388. * makes the reflect vector face the model (under horizon).
  124389. */
  124390. protected _useHorizonOcclusion: boolean;
  124391. /**
  124392. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124393. * too much the area relying on ambient texture to define their ambient occlusion.
  124394. */
  124395. protected _useRadianceOcclusion: boolean;
  124396. /**
  124397. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124398. */
  124399. protected _useAlphaFromAlbedoTexture: boolean;
  124400. /**
  124401. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124402. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124403. */
  124404. protected _useSpecularOverAlpha: boolean;
  124405. /**
  124406. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124407. */
  124408. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124409. /**
  124410. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124411. */
  124412. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124413. /**
  124414. * Specifies if the metallic texture contains the roughness information in its green channel.
  124415. */
  124416. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124417. /**
  124418. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124419. */
  124420. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124421. /**
  124422. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124423. */
  124424. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124425. /**
  124426. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124427. */
  124428. protected _useAmbientInGrayScale: boolean;
  124429. /**
  124430. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124431. * The material will try to infer what glossiness each pixel should be.
  124432. */
  124433. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124434. /**
  124435. * Defines the falloff type used in this material.
  124436. * It by default is Physical.
  124437. */
  124438. protected _lightFalloff: number;
  124439. /**
  124440. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124441. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124442. */
  124443. protected _useRadianceOverAlpha: boolean;
  124444. /**
  124445. * Allows using an object space normal map (instead of tangent space).
  124446. */
  124447. protected _useObjectSpaceNormalMap: boolean;
  124448. /**
  124449. * Allows using the bump map in parallax mode.
  124450. */
  124451. protected _useParallax: boolean;
  124452. /**
  124453. * Allows using the bump map in parallax occlusion mode.
  124454. */
  124455. protected _useParallaxOcclusion: boolean;
  124456. /**
  124457. * Controls the scale bias of the parallax mode.
  124458. */
  124459. protected _parallaxScaleBias: number;
  124460. /**
  124461. * If sets to true, disables all the lights affecting the material.
  124462. */
  124463. protected _disableLighting: boolean;
  124464. /**
  124465. * Number of Simultaneous lights allowed on the material.
  124466. */
  124467. protected _maxSimultaneousLights: number;
  124468. /**
  124469. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124470. */
  124471. protected _invertNormalMapX: boolean;
  124472. /**
  124473. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124474. */
  124475. protected _invertNormalMapY: boolean;
  124476. /**
  124477. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124478. */
  124479. protected _twoSidedLighting: boolean;
  124480. /**
  124481. * Defines the alpha limits in alpha test mode.
  124482. */
  124483. protected _alphaCutOff: number;
  124484. /**
  124485. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124486. */
  124487. protected _forceAlphaTest: boolean;
  124488. /**
  124489. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124490. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124491. */
  124492. protected _useAlphaFresnel: boolean;
  124493. /**
  124494. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124495. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124496. */
  124497. protected _useLinearAlphaFresnel: boolean;
  124498. /**
  124499. * The transparency mode of the material.
  124500. */
  124501. protected _transparencyMode: Nullable<number>;
  124502. /**
  124503. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124504. * from cos thetav and roughness:
  124505. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124506. */
  124507. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124508. /**
  124509. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124510. */
  124511. protected _forceIrradianceInFragment: boolean;
  124512. /**
  124513. * Force normal to face away from face.
  124514. */
  124515. protected _forceNormalForward: boolean;
  124516. /**
  124517. * Enables specular anti aliasing in the PBR shader.
  124518. * It will both interacts on the Geometry for analytical and IBL lighting.
  124519. * It also prefilter the roughness map based on the bump values.
  124520. */
  124521. protected _enableSpecularAntiAliasing: boolean;
  124522. /**
  124523. * Default configuration related to image processing available in the PBR Material.
  124524. */
  124525. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124526. /**
  124527. * Keep track of the image processing observer to allow dispose and replace.
  124528. */
  124529. private _imageProcessingObserver;
  124530. /**
  124531. * Attaches a new image processing configuration to the PBR Material.
  124532. * @param configuration
  124533. */
  124534. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124535. /**
  124536. * Stores the available render targets.
  124537. */
  124538. private _renderTargets;
  124539. /**
  124540. * Sets the global ambient color for the material used in lighting calculations.
  124541. */
  124542. private _globalAmbientColor;
  124543. /**
  124544. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124545. */
  124546. private _useLogarithmicDepth;
  124547. /**
  124548. * If set to true, no lighting calculations will be applied.
  124549. */
  124550. private _unlit;
  124551. private _debugMode;
  124552. /**
  124553. * @hidden
  124554. * This is reserved for the inspector.
  124555. * Defines the material debug mode.
  124556. * It helps seeing only some components of the material while troubleshooting.
  124557. */
  124558. debugMode: number;
  124559. /**
  124560. * @hidden
  124561. * This is reserved for the inspector.
  124562. * Specify from where on screen the debug mode should start.
  124563. * The value goes from -1 (full screen) to 1 (not visible)
  124564. * It helps with side by side comparison against the final render
  124565. * This defaults to -1
  124566. */
  124567. private debugLimit;
  124568. /**
  124569. * @hidden
  124570. * This is reserved for the inspector.
  124571. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124572. * You can use the factor to better multiply the final value.
  124573. */
  124574. private debugFactor;
  124575. /**
  124576. * Defines the clear coat layer parameters for the material.
  124577. */
  124578. readonly clearCoat: PBRClearCoatConfiguration;
  124579. /**
  124580. * Defines the anisotropic parameters for the material.
  124581. */
  124582. readonly anisotropy: PBRAnisotropicConfiguration;
  124583. /**
  124584. * Defines the BRDF parameters for the material.
  124585. */
  124586. readonly brdf: PBRBRDFConfiguration;
  124587. /**
  124588. * Defines the Sheen parameters for the material.
  124589. */
  124590. readonly sheen: PBRSheenConfiguration;
  124591. /**
  124592. * Defines the SubSurface parameters for the material.
  124593. */
  124594. readonly subSurface: PBRSubSurfaceConfiguration;
  124595. /**
  124596. * Custom callback helping to override the default shader used in the material.
  124597. */
  124598. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124599. protected _rebuildInParallel: boolean;
  124600. /**
  124601. * Instantiates a new PBRMaterial instance.
  124602. *
  124603. * @param name The material name
  124604. * @param scene The scene the material will be use in.
  124605. */
  124606. constructor(name: string, scene: Scene);
  124607. /**
  124608. * Gets a boolean indicating that current material needs to register RTT
  124609. */
  124610. get hasRenderTargetTextures(): boolean;
  124611. /**
  124612. * Gets the name of the material class.
  124613. */
  124614. getClassName(): string;
  124615. /**
  124616. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124617. */
  124618. get useLogarithmicDepth(): boolean;
  124619. /**
  124620. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124621. */
  124622. set useLogarithmicDepth(value: boolean);
  124623. /**
  124624. * Gets the current transparency mode.
  124625. */
  124626. get transparencyMode(): Nullable<number>;
  124627. /**
  124628. * Sets the transparency mode of the material.
  124629. *
  124630. * | Value | Type | Description |
  124631. * | ----- | ----------------------------------- | ----------- |
  124632. * | 0 | OPAQUE | |
  124633. * | 1 | ALPHATEST | |
  124634. * | 2 | ALPHABLEND | |
  124635. * | 3 | ALPHATESTANDBLEND | |
  124636. *
  124637. */
  124638. set transparencyMode(value: Nullable<number>);
  124639. /**
  124640. * Returns true if alpha blending should be disabled.
  124641. */
  124642. private get _disableAlphaBlending();
  124643. /**
  124644. * Specifies whether or not this material should be rendered in alpha blend mode.
  124645. */
  124646. needAlphaBlending(): boolean;
  124647. /**
  124648. * Specifies if the mesh will require alpha blending.
  124649. * @param mesh - BJS mesh.
  124650. */
  124651. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124652. /**
  124653. * Specifies whether or not this material should be rendered in alpha test mode.
  124654. */
  124655. needAlphaTesting(): boolean;
  124656. /**
  124657. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124658. */
  124659. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124660. /**
  124661. * Gets the texture used for the alpha test.
  124662. */
  124663. getAlphaTestTexture(): Nullable<BaseTexture>;
  124664. /**
  124665. * Specifies that the submesh is ready to be used.
  124666. * @param mesh - BJS mesh.
  124667. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124668. * @param useInstances - Specifies that instances should be used.
  124669. * @returns - boolean indicating that the submesh is ready or not.
  124670. */
  124671. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124672. /**
  124673. * Specifies if the material uses metallic roughness workflow.
  124674. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124675. */
  124676. isMetallicWorkflow(): boolean;
  124677. private _prepareEffect;
  124678. private _prepareDefines;
  124679. /**
  124680. * Force shader compilation
  124681. */
  124682. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124683. /**
  124684. * Initializes the uniform buffer layout for the shader.
  124685. */
  124686. buildUniformLayout(): void;
  124687. /**
  124688. * Unbinds the material from the mesh
  124689. */
  124690. unbind(): void;
  124691. /**
  124692. * Binds the submesh data.
  124693. * @param world - The world matrix.
  124694. * @param mesh - The BJS mesh.
  124695. * @param subMesh - A submesh of the BJS mesh.
  124696. */
  124697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124698. /**
  124699. * Returns the animatable textures.
  124700. * @returns - Array of animatable textures.
  124701. */
  124702. getAnimatables(): IAnimatable[];
  124703. /**
  124704. * Returns the texture used for reflections.
  124705. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124706. */
  124707. private _getReflectionTexture;
  124708. /**
  124709. * Returns an array of the actively used textures.
  124710. * @returns - Array of BaseTextures
  124711. */
  124712. getActiveTextures(): BaseTexture[];
  124713. /**
  124714. * Checks to see if a texture is used in the material.
  124715. * @param texture - Base texture to use.
  124716. * @returns - Boolean specifying if a texture is used in the material.
  124717. */
  124718. hasTexture(texture: BaseTexture): boolean;
  124719. /**
  124720. * Disposes the resources of the material.
  124721. * @param forceDisposeEffect - Forces the disposal of effects.
  124722. * @param forceDisposeTextures - Forces the disposal of all textures.
  124723. */
  124724. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124725. }
  124726. }
  124727. declare module BABYLON {
  124728. /**
  124729. * The Physically based material of BJS.
  124730. *
  124731. * This offers the main features of a standard PBR material.
  124732. * For more information, please refer to the documentation :
  124733. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124734. */
  124735. export class PBRMaterial extends PBRBaseMaterial {
  124736. /**
  124737. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124738. */
  124739. static readonly PBRMATERIAL_OPAQUE: number;
  124740. /**
  124741. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124742. */
  124743. static readonly PBRMATERIAL_ALPHATEST: number;
  124744. /**
  124745. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124746. */
  124747. static readonly PBRMATERIAL_ALPHABLEND: number;
  124748. /**
  124749. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124750. * They are also discarded below the alpha cutoff threshold to improve performances.
  124751. */
  124752. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124753. /**
  124754. * Defines the default value of how much AO map is occluding the analytical lights
  124755. * (point spot...).
  124756. */
  124757. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124758. /**
  124759. * Intensity of the direct lights e.g. the four lights available in your scene.
  124760. * This impacts both the direct diffuse and specular highlights.
  124761. */
  124762. directIntensity: number;
  124763. /**
  124764. * Intensity of the emissive part of the material.
  124765. * This helps controlling the emissive effect without modifying the emissive color.
  124766. */
  124767. emissiveIntensity: number;
  124768. /**
  124769. * Intensity of the environment e.g. how much the environment will light the object
  124770. * either through harmonics for rough material or through the refelction for shiny ones.
  124771. */
  124772. environmentIntensity: number;
  124773. /**
  124774. * This is a special control allowing the reduction of the specular highlights coming from the
  124775. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124776. */
  124777. specularIntensity: number;
  124778. /**
  124779. * Debug Control allowing disabling the bump map on this material.
  124780. */
  124781. disableBumpMap: boolean;
  124782. /**
  124783. * AKA Diffuse Texture in standard nomenclature.
  124784. */
  124785. albedoTexture: BaseTexture;
  124786. /**
  124787. * AKA Occlusion Texture in other nomenclature.
  124788. */
  124789. ambientTexture: BaseTexture;
  124790. /**
  124791. * AKA Occlusion Texture Intensity in other nomenclature.
  124792. */
  124793. ambientTextureStrength: number;
  124794. /**
  124795. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124796. * 1 means it completely occludes it
  124797. * 0 mean it has no impact
  124798. */
  124799. ambientTextureImpactOnAnalyticalLights: number;
  124800. /**
  124801. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124802. */
  124803. opacityTexture: BaseTexture;
  124804. /**
  124805. * Stores the reflection values in a texture.
  124806. */
  124807. reflectionTexture: Nullable<BaseTexture>;
  124808. /**
  124809. * Stores the emissive values in a texture.
  124810. */
  124811. emissiveTexture: BaseTexture;
  124812. /**
  124813. * AKA Specular texture in other nomenclature.
  124814. */
  124815. reflectivityTexture: BaseTexture;
  124816. /**
  124817. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124818. */
  124819. metallicTexture: BaseTexture;
  124820. /**
  124821. * Specifies the metallic scalar of the metallic/roughness workflow.
  124822. * Can also be used to scale the metalness values of the metallic texture.
  124823. */
  124824. metallic: Nullable<number>;
  124825. /**
  124826. * Specifies the roughness scalar of the metallic/roughness workflow.
  124827. * Can also be used to scale the roughness values of the metallic texture.
  124828. */
  124829. roughness: Nullable<number>;
  124830. /**
  124831. * Specifies the an F0 factor to help configuring the material F0.
  124832. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124833. * to 0.5 the previously hard coded value stays the same.
  124834. * Can also be used to scale the F0 values of the metallic texture.
  124835. */
  124836. metallicF0Factor: number;
  124837. /**
  124838. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124839. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124840. * your expectation as it multiplies with the texture data.
  124841. */
  124842. useMetallicF0FactorFromMetallicTexture: boolean;
  124843. /**
  124844. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124845. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124846. */
  124847. microSurfaceTexture: BaseTexture;
  124848. /**
  124849. * Stores surface normal data used to displace a mesh in a texture.
  124850. */
  124851. bumpTexture: BaseTexture;
  124852. /**
  124853. * Stores the pre-calculated light information of a mesh in a texture.
  124854. */
  124855. lightmapTexture: BaseTexture;
  124856. /**
  124857. * Stores the refracted light information in a texture.
  124858. */
  124859. get refractionTexture(): Nullable<BaseTexture>;
  124860. set refractionTexture(value: Nullable<BaseTexture>);
  124861. /**
  124862. * The color of a material in ambient lighting.
  124863. */
  124864. ambientColor: Color3;
  124865. /**
  124866. * AKA Diffuse Color in other nomenclature.
  124867. */
  124868. albedoColor: Color3;
  124869. /**
  124870. * AKA Specular Color in other nomenclature.
  124871. */
  124872. reflectivityColor: Color3;
  124873. /**
  124874. * The color reflected from the material.
  124875. */
  124876. reflectionColor: Color3;
  124877. /**
  124878. * The color emitted from the material.
  124879. */
  124880. emissiveColor: Color3;
  124881. /**
  124882. * AKA Glossiness in other nomenclature.
  124883. */
  124884. microSurface: number;
  124885. /**
  124886. * source material index of refraction (IOR)' / 'destination material IOR.
  124887. */
  124888. get indexOfRefraction(): number;
  124889. set indexOfRefraction(value: number);
  124890. /**
  124891. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124892. */
  124893. get invertRefractionY(): boolean;
  124894. set invertRefractionY(value: boolean);
  124895. /**
  124896. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124897. * Materials half opaque for instance using refraction could benefit from this control.
  124898. */
  124899. get linkRefractionWithTransparency(): boolean;
  124900. set linkRefractionWithTransparency(value: boolean);
  124901. /**
  124902. * If true, the light map contains occlusion information instead of lighting info.
  124903. */
  124904. useLightmapAsShadowmap: boolean;
  124905. /**
  124906. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124907. */
  124908. useAlphaFromAlbedoTexture: boolean;
  124909. /**
  124910. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124911. */
  124912. forceAlphaTest: boolean;
  124913. /**
  124914. * Defines the alpha limits in alpha test mode.
  124915. */
  124916. alphaCutOff: number;
  124917. /**
  124918. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124919. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124920. */
  124921. useSpecularOverAlpha: boolean;
  124922. /**
  124923. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124924. */
  124925. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124926. /**
  124927. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124928. */
  124929. useRoughnessFromMetallicTextureAlpha: boolean;
  124930. /**
  124931. * Specifies if the metallic texture contains the roughness information in its green channel.
  124932. */
  124933. useRoughnessFromMetallicTextureGreen: boolean;
  124934. /**
  124935. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124936. */
  124937. useMetallnessFromMetallicTextureBlue: boolean;
  124938. /**
  124939. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124940. */
  124941. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124942. /**
  124943. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124944. */
  124945. useAmbientInGrayScale: boolean;
  124946. /**
  124947. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124948. * The material will try to infer what glossiness each pixel should be.
  124949. */
  124950. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124951. /**
  124952. * BJS is using an harcoded light falloff based on a manually sets up range.
  124953. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124954. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124955. */
  124956. get usePhysicalLightFalloff(): boolean;
  124957. /**
  124958. * BJS is using an harcoded light falloff based on a manually sets up range.
  124959. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124960. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124961. */
  124962. set usePhysicalLightFalloff(value: boolean);
  124963. /**
  124964. * In order to support the falloff compatibility with gltf, a special mode has been added
  124965. * to reproduce the gltf light falloff.
  124966. */
  124967. get useGLTFLightFalloff(): boolean;
  124968. /**
  124969. * In order to support the falloff compatibility with gltf, a special mode has been added
  124970. * to reproduce the gltf light falloff.
  124971. */
  124972. set useGLTFLightFalloff(value: boolean);
  124973. /**
  124974. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124975. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124976. */
  124977. useRadianceOverAlpha: boolean;
  124978. /**
  124979. * Allows using an object space normal map (instead of tangent space).
  124980. */
  124981. useObjectSpaceNormalMap: boolean;
  124982. /**
  124983. * Allows using the bump map in parallax mode.
  124984. */
  124985. useParallax: boolean;
  124986. /**
  124987. * Allows using the bump map in parallax occlusion mode.
  124988. */
  124989. useParallaxOcclusion: boolean;
  124990. /**
  124991. * Controls the scale bias of the parallax mode.
  124992. */
  124993. parallaxScaleBias: number;
  124994. /**
  124995. * If sets to true, disables all the lights affecting the material.
  124996. */
  124997. disableLighting: boolean;
  124998. /**
  124999. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125000. */
  125001. forceIrradianceInFragment: boolean;
  125002. /**
  125003. * Number of Simultaneous lights allowed on the material.
  125004. */
  125005. maxSimultaneousLights: number;
  125006. /**
  125007. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125008. */
  125009. invertNormalMapX: boolean;
  125010. /**
  125011. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125012. */
  125013. invertNormalMapY: boolean;
  125014. /**
  125015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125016. */
  125017. twoSidedLighting: boolean;
  125018. /**
  125019. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125020. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125021. */
  125022. useAlphaFresnel: boolean;
  125023. /**
  125024. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125025. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125026. */
  125027. useLinearAlphaFresnel: boolean;
  125028. /**
  125029. * Let user defines the brdf lookup texture used for IBL.
  125030. * A default 8bit version is embedded but you could point at :
  125031. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125032. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125033. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125034. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125035. */
  125036. environmentBRDFTexture: Nullable<BaseTexture>;
  125037. /**
  125038. * Force normal to face away from face.
  125039. */
  125040. forceNormalForward: boolean;
  125041. /**
  125042. * Enables specular anti aliasing in the PBR shader.
  125043. * It will both interacts on the Geometry for analytical and IBL lighting.
  125044. * It also prefilter the roughness map based on the bump values.
  125045. */
  125046. enableSpecularAntiAliasing: boolean;
  125047. /**
  125048. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125049. * makes the reflect vector face the model (under horizon).
  125050. */
  125051. useHorizonOcclusion: boolean;
  125052. /**
  125053. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125054. * too much the area relying on ambient texture to define their ambient occlusion.
  125055. */
  125056. useRadianceOcclusion: boolean;
  125057. /**
  125058. * If set to true, no lighting calculations will be applied.
  125059. */
  125060. unlit: boolean;
  125061. /**
  125062. * Gets the image processing configuration used either in this material.
  125063. */
  125064. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125065. /**
  125066. * Sets the Default image processing configuration used either in the this material.
  125067. *
  125068. * If sets to null, the scene one is in use.
  125069. */
  125070. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125071. /**
  125072. * Gets wether the color curves effect is enabled.
  125073. */
  125074. get cameraColorCurvesEnabled(): boolean;
  125075. /**
  125076. * Sets wether the color curves effect is enabled.
  125077. */
  125078. set cameraColorCurvesEnabled(value: boolean);
  125079. /**
  125080. * Gets wether the color grading effect is enabled.
  125081. */
  125082. get cameraColorGradingEnabled(): boolean;
  125083. /**
  125084. * Gets wether the color grading effect is enabled.
  125085. */
  125086. set cameraColorGradingEnabled(value: boolean);
  125087. /**
  125088. * Gets wether tonemapping is enabled or not.
  125089. */
  125090. get cameraToneMappingEnabled(): boolean;
  125091. /**
  125092. * Sets wether tonemapping is enabled or not
  125093. */
  125094. set cameraToneMappingEnabled(value: boolean);
  125095. /**
  125096. * The camera exposure used on this material.
  125097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125098. * This corresponds to a photographic exposure.
  125099. */
  125100. get cameraExposure(): number;
  125101. /**
  125102. * The camera exposure used on this material.
  125103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125104. * This corresponds to a photographic exposure.
  125105. */
  125106. set cameraExposure(value: number);
  125107. /**
  125108. * Gets The camera contrast used on this material.
  125109. */
  125110. get cameraContrast(): number;
  125111. /**
  125112. * Sets The camera contrast used on this material.
  125113. */
  125114. set cameraContrast(value: number);
  125115. /**
  125116. * Gets the Color Grading 2D Lookup Texture.
  125117. */
  125118. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125119. /**
  125120. * Sets the Color Grading 2D Lookup Texture.
  125121. */
  125122. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125123. /**
  125124. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125125. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125126. * 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;
  125127. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125128. */
  125129. get cameraColorCurves(): Nullable<ColorCurves>;
  125130. /**
  125131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125133. * 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;
  125134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125135. */
  125136. set cameraColorCurves(value: Nullable<ColorCurves>);
  125137. /**
  125138. * Instantiates a new PBRMaterial instance.
  125139. *
  125140. * @param name The material name
  125141. * @param scene The scene the material will be use in.
  125142. */
  125143. constructor(name: string, scene: Scene);
  125144. /**
  125145. * Returns the name of this material class.
  125146. */
  125147. getClassName(): string;
  125148. /**
  125149. * Makes a duplicate of the current material.
  125150. * @param name - name to use for the new material.
  125151. */
  125152. clone(name: string): PBRMaterial;
  125153. /**
  125154. * Serializes this PBR Material.
  125155. * @returns - An object with the serialized material.
  125156. */
  125157. serialize(): any;
  125158. /**
  125159. * Parses a PBR Material from a serialized object.
  125160. * @param source - Serialized object.
  125161. * @param scene - BJS scene instance.
  125162. * @param rootUrl - url for the scene object
  125163. * @returns - PBRMaterial
  125164. */
  125165. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125166. }
  125167. }
  125168. declare module BABYLON {
  125169. /**
  125170. * Direct draw surface info
  125171. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125172. */
  125173. export interface DDSInfo {
  125174. /**
  125175. * Width of the texture
  125176. */
  125177. width: number;
  125178. /**
  125179. * Width of the texture
  125180. */
  125181. height: number;
  125182. /**
  125183. * Number of Mipmaps for the texture
  125184. * @see https://en.wikipedia.org/wiki/Mipmap
  125185. */
  125186. mipmapCount: number;
  125187. /**
  125188. * If the textures format is a known fourCC format
  125189. * @see https://www.fourcc.org/
  125190. */
  125191. isFourCC: boolean;
  125192. /**
  125193. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125194. */
  125195. isRGB: boolean;
  125196. /**
  125197. * If the texture is a lumincance format
  125198. */
  125199. isLuminance: boolean;
  125200. /**
  125201. * If this is a cube texture
  125202. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125203. */
  125204. isCube: boolean;
  125205. /**
  125206. * If the texture is a compressed format eg. FOURCC_DXT1
  125207. */
  125208. isCompressed: boolean;
  125209. /**
  125210. * The dxgiFormat of the texture
  125211. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125212. */
  125213. dxgiFormat: number;
  125214. /**
  125215. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125216. */
  125217. textureType: number;
  125218. /**
  125219. * Sphericle polynomial created for the dds texture
  125220. */
  125221. sphericalPolynomial?: SphericalPolynomial;
  125222. }
  125223. /**
  125224. * Class used to provide DDS decompression tools
  125225. */
  125226. export class DDSTools {
  125227. /**
  125228. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125229. */
  125230. static StoreLODInAlphaChannel: boolean;
  125231. /**
  125232. * Gets DDS information from an array buffer
  125233. * @param data defines the array buffer view to read data from
  125234. * @returns the DDS information
  125235. */
  125236. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125237. private static _FloatView;
  125238. private static _Int32View;
  125239. private static _ToHalfFloat;
  125240. private static _FromHalfFloat;
  125241. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125242. private static _GetHalfFloatRGBAArrayBuffer;
  125243. private static _GetFloatRGBAArrayBuffer;
  125244. private static _GetFloatAsUIntRGBAArrayBuffer;
  125245. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125246. private static _GetRGBAArrayBuffer;
  125247. private static _ExtractLongWordOrder;
  125248. private static _GetRGBArrayBuffer;
  125249. private static _GetLuminanceArrayBuffer;
  125250. /**
  125251. * Uploads DDS Levels to a Babylon Texture
  125252. * @hidden
  125253. */
  125254. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125255. }
  125256. interface ThinEngine {
  125257. /**
  125258. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125259. * @param rootUrl defines the url where the file to load is located
  125260. * @param scene defines the current scene
  125261. * @param lodScale defines scale to apply to the mip map selection
  125262. * @param lodOffset defines offset to apply to the mip map selection
  125263. * @param onLoad defines an optional callback raised when the texture is loaded
  125264. * @param onError defines an optional callback raised if there is an issue to load the texture
  125265. * @param format defines the format of the data
  125266. * @param forcedExtension defines the extension to use to pick the right loader
  125267. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125268. * @returns the cube texture as an InternalTexture
  125269. */
  125270. 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;
  125271. }
  125272. }
  125273. declare module BABYLON {
  125274. /**
  125275. * Implementation of the DDS Texture Loader.
  125276. * @hidden
  125277. */
  125278. export class _DDSTextureLoader implements IInternalTextureLoader {
  125279. /**
  125280. * Defines wether the loader supports cascade loading the different faces.
  125281. */
  125282. readonly supportCascades: boolean;
  125283. /**
  125284. * This returns if the loader support the current file information.
  125285. * @param extension defines the file extension of the file being loaded
  125286. * @returns true if the loader can load the specified file
  125287. */
  125288. canLoad(extension: string): boolean;
  125289. /**
  125290. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125291. * @param data contains the texture data
  125292. * @param texture defines the BabylonJS internal texture
  125293. * @param createPolynomials will be true if polynomials have been requested
  125294. * @param onLoad defines the callback to trigger once the texture is ready
  125295. * @param onError defines the callback to trigger in case of error
  125296. */
  125297. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125298. /**
  125299. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125300. * @param data contains the texture data
  125301. * @param texture defines the BabylonJS internal texture
  125302. * @param callback defines the method to call once ready to upload
  125303. */
  125304. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125305. }
  125306. }
  125307. declare module BABYLON {
  125308. /**
  125309. * Implementation of the ENV Texture Loader.
  125310. * @hidden
  125311. */
  125312. export class _ENVTextureLoader implements IInternalTextureLoader {
  125313. /**
  125314. * Defines wether the loader supports cascade loading the different faces.
  125315. */
  125316. readonly supportCascades: boolean;
  125317. /**
  125318. * This returns if the loader support the current file information.
  125319. * @param extension defines the file extension of the file being loaded
  125320. * @returns true if the loader can load the specified file
  125321. */
  125322. canLoad(extension: string): boolean;
  125323. /**
  125324. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125325. * @param data contains the texture data
  125326. * @param texture defines the BabylonJS internal texture
  125327. * @param createPolynomials will be true if polynomials have been requested
  125328. * @param onLoad defines the callback to trigger once the texture is ready
  125329. * @param onError defines the callback to trigger in case of error
  125330. */
  125331. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125332. /**
  125333. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125334. * @param data contains the texture data
  125335. * @param texture defines the BabylonJS internal texture
  125336. * @param callback defines the method to call once ready to upload
  125337. */
  125338. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125339. }
  125340. }
  125341. declare module BABYLON {
  125342. /**
  125343. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125344. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125345. */
  125346. export class KhronosTextureContainer {
  125347. /** contents of the KTX container file */
  125348. data: ArrayBufferView;
  125349. private static HEADER_LEN;
  125350. private static COMPRESSED_2D;
  125351. private static COMPRESSED_3D;
  125352. private static TEX_2D;
  125353. private static TEX_3D;
  125354. /**
  125355. * Gets the openGL type
  125356. */
  125357. glType: number;
  125358. /**
  125359. * Gets the openGL type size
  125360. */
  125361. glTypeSize: number;
  125362. /**
  125363. * Gets the openGL format
  125364. */
  125365. glFormat: number;
  125366. /**
  125367. * Gets the openGL internal format
  125368. */
  125369. glInternalFormat: number;
  125370. /**
  125371. * Gets the base internal format
  125372. */
  125373. glBaseInternalFormat: number;
  125374. /**
  125375. * Gets image width in pixel
  125376. */
  125377. pixelWidth: number;
  125378. /**
  125379. * Gets image height in pixel
  125380. */
  125381. pixelHeight: number;
  125382. /**
  125383. * Gets image depth in pixels
  125384. */
  125385. pixelDepth: number;
  125386. /**
  125387. * Gets the number of array elements
  125388. */
  125389. numberOfArrayElements: number;
  125390. /**
  125391. * Gets the number of faces
  125392. */
  125393. numberOfFaces: number;
  125394. /**
  125395. * Gets the number of mipmap levels
  125396. */
  125397. numberOfMipmapLevels: number;
  125398. /**
  125399. * Gets the bytes of key value data
  125400. */
  125401. bytesOfKeyValueData: number;
  125402. /**
  125403. * Gets the load type
  125404. */
  125405. loadType: number;
  125406. /**
  125407. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125408. */
  125409. isInvalid: boolean;
  125410. /**
  125411. * Creates a new KhronosTextureContainer
  125412. * @param data contents of the KTX container file
  125413. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125414. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125415. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125416. */
  125417. constructor(
  125418. /** contents of the KTX container file */
  125419. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125420. /**
  125421. * Uploads KTX content to a Babylon Texture.
  125422. * It is assumed that the texture has already been created & is currently bound
  125423. * @hidden
  125424. */
  125425. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125426. private _upload2DCompressedLevels;
  125427. /**
  125428. * Checks if the given data starts with a KTX file identifier.
  125429. * @param data the data to check
  125430. * @returns true if the data is a KTX file or false otherwise
  125431. */
  125432. static IsValid(data: ArrayBufferView): boolean;
  125433. }
  125434. }
  125435. declare module BABYLON {
  125436. /**
  125437. * Class for loading KTX2 files
  125438. * !!! Experimental Extension Subject to Changes !!!
  125439. * @hidden
  125440. */
  125441. export class KhronosTextureContainer2 {
  125442. private static _ModulePromise;
  125443. private static _TranscodeFormat;
  125444. constructor(engine: ThinEngine);
  125445. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125446. private _determineTranscodeFormat;
  125447. /**
  125448. * Checks if the given data starts with a KTX2 file identifier.
  125449. * @param data the data to check
  125450. * @returns true if the data is a KTX2 file or false otherwise
  125451. */
  125452. static IsValid(data: ArrayBufferView): boolean;
  125453. }
  125454. }
  125455. declare module BABYLON {
  125456. /**
  125457. * Implementation of the KTX Texture Loader.
  125458. * @hidden
  125459. */
  125460. export class _KTXTextureLoader implements IInternalTextureLoader {
  125461. /**
  125462. * Defines wether the loader supports cascade loading the different faces.
  125463. */
  125464. readonly supportCascades: boolean;
  125465. /**
  125466. * This returns if the loader support the current file information.
  125467. * @param extension defines the file extension of the file being loaded
  125468. * @returns true if the loader can load the specified file
  125469. */
  125470. canLoad(extension: string): boolean;
  125471. /**
  125472. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125473. * @param data contains the texture data
  125474. * @param texture defines the BabylonJS internal texture
  125475. * @param createPolynomials will be true if polynomials have been requested
  125476. * @param onLoad defines the callback to trigger once the texture is ready
  125477. * @param onError defines the callback to trigger in case of error
  125478. */
  125479. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125480. /**
  125481. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125482. * @param data contains the texture data
  125483. * @param texture defines the BabylonJS internal texture
  125484. * @param callback defines the method to call once ready to upload
  125485. */
  125486. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125487. }
  125488. }
  125489. declare module BABYLON {
  125490. /** @hidden */
  125491. export var _forceSceneHelpersToBundle: boolean;
  125492. interface Scene {
  125493. /**
  125494. * Creates a default light for the scene.
  125495. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125496. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125497. */
  125498. createDefaultLight(replace?: boolean): void;
  125499. /**
  125500. * Creates a default camera for the scene.
  125501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125502. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125503. * @param replace has default false, when true replaces the active camera in the scene
  125504. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125505. */
  125506. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125507. /**
  125508. * Creates a default camera and a default light.
  125509. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125510. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125511. * @param replace has the default false, when true replaces the active camera/light in the scene
  125512. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125513. */
  125514. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125515. /**
  125516. * Creates a new sky box
  125517. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125518. * @param environmentTexture defines the texture to use as environment texture
  125519. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125520. * @param scale defines the overall scale of the skybox
  125521. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125522. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125523. * @returns a new mesh holding the sky box
  125524. */
  125525. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125526. /**
  125527. * Creates a new environment
  125528. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125529. * @param options defines the options you can use to configure the environment
  125530. * @returns the new EnvironmentHelper
  125531. */
  125532. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125533. /**
  125534. * Creates a new VREXperienceHelper
  125535. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125536. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125537. * @returns a new VREXperienceHelper
  125538. */
  125539. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125540. /**
  125541. * Creates a new WebXRDefaultExperience
  125542. * @see http://doc.babylonjs.com/how_to/webxr
  125543. * @param options experience options
  125544. * @returns a promise for a new WebXRDefaultExperience
  125545. */
  125546. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125547. }
  125548. }
  125549. declare module BABYLON {
  125550. /**
  125551. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125552. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125553. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125554. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125555. */
  125556. export class VideoDome extends TransformNode {
  125557. /**
  125558. * Define the video source as a Monoscopic panoramic 360 video.
  125559. */
  125560. static readonly MODE_MONOSCOPIC: number;
  125561. /**
  125562. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125563. */
  125564. static readonly MODE_TOPBOTTOM: number;
  125565. /**
  125566. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125567. */
  125568. static readonly MODE_SIDEBYSIDE: number;
  125569. private _halfDome;
  125570. private _useDirectMapping;
  125571. /**
  125572. * The video texture being displayed on the sphere
  125573. */
  125574. protected _videoTexture: VideoTexture;
  125575. /**
  125576. * Gets the video texture being displayed on the sphere
  125577. */
  125578. get videoTexture(): VideoTexture;
  125579. /**
  125580. * The skybox material
  125581. */
  125582. protected _material: BackgroundMaterial;
  125583. /**
  125584. * The surface used for the skybox
  125585. */
  125586. protected _mesh: Mesh;
  125587. /**
  125588. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125589. */
  125590. private _halfDomeMask;
  125591. /**
  125592. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125593. * Also see the options.resolution property.
  125594. */
  125595. get fovMultiplier(): number;
  125596. set fovMultiplier(value: number);
  125597. private _videoMode;
  125598. /**
  125599. * Gets or set the current video mode for the video. It can be:
  125600. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125601. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125602. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125603. */
  125604. get videoMode(): number;
  125605. set videoMode(value: number);
  125606. /**
  125607. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125608. *
  125609. */
  125610. get halfDome(): boolean;
  125611. /**
  125612. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125613. */
  125614. set halfDome(enabled: boolean);
  125615. /**
  125616. * Oberserver used in Stereoscopic VR Mode.
  125617. */
  125618. private _onBeforeCameraRenderObserver;
  125619. /**
  125620. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125621. * @param name Element's name, child elements will append suffixes for their own names.
  125622. * @param urlsOrVideo defines the url(s) or the video element to use
  125623. * @param options An object containing optional or exposed sub element properties
  125624. */
  125625. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125626. resolution?: number;
  125627. clickToPlay?: boolean;
  125628. autoPlay?: boolean;
  125629. loop?: boolean;
  125630. size?: number;
  125631. poster?: string;
  125632. faceForward?: boolean;
  125633. useDirectMapping?: boolean;
  125634. halfDomeMode?: boolean;
  125635. }, scene: Scene);
  125636. private _changeVideoMode;
  125637. /**
  125638. * Releases resources associated with this node.
  125639. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125640. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125641. */
  125642. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125643. }
  125644. }
  125645. declare module BABYLON {
  125646. /**
  125647. * This class can be used to get instrumentation data from a Babylon engine
  125648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125649. */
  125650. export class EngineInstrumentation implements IDisposable {
  125651. /**
  125652. * Define the instrumented engine.
  125653. */
  125654. engine: Engine;
  125655. private _captureGPUFrameTime;
  125656. private _gpuFrameTimeToken;
  125657. private _gpuFrameTime;
  125658. private _captureShaderCompilationTime;
  125659. private _shaderCompilationTime;
  125660. private _onBeginFrameObserver;
  125661. private _onEndFrameObserver;
  125662. private _onBeforeShaderCompilationObserver;
  125663. private _onAfterShaderCompilationObserver;
  125664. /**
  125665. * Gets the perf counter used for GPU frame time
  125666. */
  125667. get gpuFrameTimeCounter(): PerfCounter;
  125668. /**
  125669. * Gets the GPU frame time capture status
  125670. */
  125671. get captureGPUFrameTime(): boolean;
  125672. /**
  125673. * Enable or disable the GPU frame time capture
  125674. */
  125675. set captureGPUFrameTime(value: boolean);
  125676. /**
  125677. * Gets the perf counter used for shader compilation time
  125678. */
  125679. get shaderCompilationTimeCounter(): PerfCounter;
  125680. /**
  125681. * Gets the shader compilation time capture status
  125682. */
  125683. get captureShaderCompilationTime(): boolean;
  125684. /**
  125685. * Enable or disable the shader compilation time capture
  125686. */
  125687. set captureShaderCompilationTime(value: boolean);
  125688. /**
  125689. * Instantiates a new engine instrumentation.
  125690. * This class can be used to get instrumentation data from a Babylon engine
  125691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125692. * @param engine Defines the engine to instrument
  125693. */
  125694. constructor(
  125695. /**
  125696. * Define the instrumented engine.
  125697. */
  125698. engine: Engine);
  125699. /**
  125700. * Dispose and release associated resources.
  125701. */
  125702. dispose(): void;
  125703. }
  125704. }
  125705. declare module BABYLON {
  125706. /**
  125707. * This class can be used to get instrumentation data from a Babylon engine
  125708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125709. */
  125710. export class SceneInstrumentation implements IDisposable {
  125711. /**
  125712. * Defines the scene to instrument
  125713. */
  125714. scene: Scene;
  125715. private _captureActiveMeshesEvaluationTime;
  125716. private _activeMeshesEvaluationTime;
  125717. private _captureRenderTargetsRenderTime;
  125718. private _renderTargetsRenderTime;
  125719. private _captureFrameTime;
  125720. private _frameTime;
  125721. private _captureRenderTime;
  125722. private _renderTime;
  125723. private _captureInterFrameTime;
  125724. private _interFrameTime;
  125725. private _captureParticlesRenderTime;
  125726. private _particlesRenderTime;
  125727. private _captureSpritesRenderTime;
  125728. private _spritesRenderTime;
  125729. private _capturePhysicsTime;
  125730. private _physicsTime;
  125731. private _captureAnimationsTime;
  125732. private _animationsTime;
  125733. private _captureCameraRenderTime;
  125734. private _cameraRenderTime;
  125735. private _onBeforeActiveMeshesEvaluationObserver;
  125736. private _onAfterActiveMeshesEvaluationObserver;
  125737. private _onBeforeRenderTargetsRenderObserver;
  125738. private _onAfterRenderTargetsRenderObserver;
  125739. private _onAfterRenderObserver;
  125740. private _onBeforeDrawPhaseObserver;
  125741. private _onAfterDrawPhaseObserver;
  125742. private _onBeforeAnimationsObserver;
  125743. private _onBeforeParticlesRenderingObserver;
  125744. private _onAfterParticlesRenderingObserver;
  125745. private _onBeforeSpritesRenderingObserver;
  125746. private _onAfterSpritesRenderingObserver;
  125747. private _onBeforePhysicsObserver;
  125748. private _onAfterPhysicsObserver;
  125749. private _onAfterAnimationsObserver;
  125750. private _onBeforeCameraRenderObserver;
  125751. private _onAfterCameraRenderObserver;
  125752. /**
  125753. * Gets the perf counter used for active meshes evaluation time
  125754. */
  125755. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125756. /**
  125757. * Gets the active meshes evaluation time capture status
  125758. */
  125759. get captureActiveMeshesEvaluationTime(): boolean;
  125760. /**
  125761. * Enable or disable the active meshes evaluation time capture
  125762. */
  125763. set captureActiveMeshesEvaluationTime(value: boolean);
  125764. /**
  125765. * Gets the perf counter used for render targets render time
  125766. */
  125767. get renderTargetsRenderTimeCounter(): PerfCounter;
  125768. /**
  125769. * Gets the render targets render time capture status
  125770. */
  125771. get captureRenderTargetsRenderTime(): boolean;
  125772. /**
  125773. * Enable or disable the render targets render time capture
  125774. */
  125775. set captureRenderTargetsRenderTime(value: boolean);
  125776. /**
  125777. * Gets the perf counter used for particles render time
  125778. */
  125779. get particlesRenderTimeCounter(): PerfCounter;
  125780. /**
  125781. * Gets the particles render time capture status
  125782. */
  125783. get captureParticlesRenderTime(): boolean;
  125784. /**
  125785. * Enable or disable the particles render time capture
  125786. */
  125787. set captureParticlesRenderTime(value: boolean);
  125788. /**
  125789. * Gets the perf counter used for sprites render time
  125790. */
  125791. get spritesRenderTimeCounter(): PerfCounter;
  125792. /**
  125793. * Gets the sprites render time capture status
  125794. */
  125795. get captureSpritesRenderTime(): boolean;
  125796. /**
  125797. * Enable or disable the sprites render time capture
  125798. */
  125799. set captureSpritesRenderTime(value: boolean);
  125800. /**
  125801. * Gets the perf counter used for physics time
  125802. */
  125803. get physicsTimeCounter(): PerfCounter;
  125804. /**
  125805. * Gets the physics time capture status
  125806. */
  125807. get capturePhysicsTime(): boolean;
  125808. /**
  125809. * Enable or disable the physics time capture
  125810. */
  125811. set capturePhysicsTime(value: boolean);
  125812. /**
  125813. * Gets the perf counter used for animations time
  125814. */
  125815. get animationsTimeCounter(): PerfCounter;
  125816. /**
  125817. * Gets the animations time capture status
  125818. */
  125819. get captureAnimationsTime(): boolean;
  125820. /**
  125821. * Enable or disable the animations time capture
  125822. */
  125823. set captureAnimationsTime(value: boolean);
  125824. /**
  125825. * Gets the perf counter used for frame time capture
  125826. */
  125827. get frameTimeCounter(): PerfCounter;
  125828. /**
  125829. * Gets the frame time capture status
  125830. */
  125831. get captureFrameTime(): boolean;
  125832. /**
  125833. * Enable or disable the frame time capture
  125834. */
  125835. set captureFrameTime(value: boolean);
  125836. /**
  125837. * Gets the perf counter used for inter-frames time capture
  125838. */
  125839. get interFrameTimeCounter(): PerfCounter;
  125840. /**
  125841. * Gets the inter-frames time capture status
  125842. */
  125843. get captureInterFrameTime(): boolean;
  125844. /**
  125845. * Enable or disable the inter-frames time capture
  125846. */
  125847. set captureInterFrameTime(value: boolean);
  125848. /**
  125849. * Gets the perf counter used for render time capture
  125850. */
  125851. get renderTimeCounter(): PerfCounter;
  125852. /**
  125853. * Gets the render time capture status
  125854. */
  125855. get captureRenderTime(): boolean;
  125856. /**
  125857. * Enable or disable the render time capture
  125858. */
  125859. set captureRenderTime(value: boolean);
  125860. /**
  125861. * Gets the perf counter used for camera render time capture
  125862. */
  125863. get cameraRenderTimeCounter(): PerfCounter;
  125864. /**
  125865. * Gets the camera render time capture status
  125866. */
  125867. get captureCameraRenderTime(): boolean;
  125868. /**
  125869. * Enable or disable the camera render time capture
  125870. */
  125871. set captureCameraRenderTime(value: boolean);
  125872. /**
  125873. * Gets the perf counter used for draw calls
  125874. */
  125875. get drawCallsCounter(): PerfCounter;
  125876. /**
  125877. * Instantiates a new scene 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#sceneinstrumentation
  125880. * @param scene Defines the scene to instrument
  125881. */
  125882. constructor(
  125883. /**
  125884. * Defines the scene to instrument
  125885. */
  125886. scene: Scene);
  125887. /**
  125888. * Dispose and release associated resources.
  125889. */
  125890. dispose(): void;
  125891. }
  125892. }
  125893. declare module BABYLON {
  125894. /** @hidden */
  125895. export var glowMapGenerationPixelShader: {
  125896. name: string;
  125897. shader: string;
  125898. };
  125899. }
  125900. declare module BABYLON {
  125901. /** @hidden */
  125902. export var glowMapGenerationVertexShader: {
  125903. name: string;
  125904. shader: string;
  125905. };
  125906. }
  125907. declare module BABYLON {
  125908. /**
  125909. * Effect layer options. This helps customizing the behaviour
  125910. * of the effect layer.
  125911. */
  125912. export interface IEffectLayerOptions {
  125913. /**
  125914. * Multiplication factor apply to the canvas size to compute the render target size
  125915. * used to generated the objects (the smaller the faster).
  125916. */
  125917. mainTextureRatio: number;
  125918. /**
  125919. * Enforces a fixed size texture to ensure effect stability across devices.
  125920. */
  125921. mainTextureFixedSize?: number;
  125922. /**
  125923. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125924. */
  125925. alphaBlendingMode: number;
  125926. /**
  125927. * The camera attached to the layer.
  125928. */
  125929. camera: Nullable<Camera>;
  125930. /**
  125931. * The rendering group to draw the layer in.
  125932. */
  125933. renderingGroupId: number;
  125934. }
  125935. /**
  125936. * The effect layer Helps adding post process effect blended with the main pass.
  125937. *
  125938. * This can be for instance use to generate glow or higlight effects on the scene.
  125939. *
  125940. * The effect layer class can not be used directly and is intented to inherited from to be
  125941. * customized per effects.
  125942. */
  125943. export abstract class EffectLayer {
  125944. private _vertexBuffers;
  125945. private _indexBuffer;
  125946. private _cachedDefines;
  125947. private _effectLayerMapGenerationEffect;
  125948. private _effectLayerOptions;
  125949. private _mergeEffect;
  125950. protected _scene: Scene;
  125951. protected _engine: Engine;
  125952. protected _maxSize: number;
  125953. protected _mainTextureDesiredSize: ISize;
  125954. protected _mainTexture: RenderTargetTexture;
  125955. protected _shouldRender: boolean;
  125956. protected _postProcesses: PostProcess[];
  125957. protected _textures: BaseTexture[];
  125958. protected _emissiveTextureAndColor: {
  125959. texture: Nullable<BaseTexture>;
  125960. color: Color4;
  125961. };
  125962. /**
  125963. * The name of the layer
  125964. */
  125965. name: string;
  125966. /**
  125967. * The clear color of the texture used to generate the glow map.
  125968. */
  125969. neutralColor: Color4;
  125970. /**
  125971. * Specifies whether the highlight layer is enabled or not.
  125972. */
  125973. isEnabled: boolean;
  125974. /**
  125975. * Gets the camera attached to the layer.
  125976. */
  125977. get camera(): Nullable<Camera>;
  125978. /**
  125979. * Gets the rendering group id the layer should render in.
  125980. */
  125981. get renderingGroupId(): number;
  125982. set renderingGroupId(renderingGroupId: number);
  125983. /**
  125984. * An event triggered when the effect layer has been disposed.
  125985. */
  125986. onDisposeObservable: Observable<EffectLayer>;
  125987. /**
  125988. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125989. */
  125990. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125991. /**
  125992. * An event triggered when the generated texture is being merged in the scene.
  125993. */
  125994. onBeforeComposeObservable: Observable<EffectLayer>;
  125995. /**
  125996. * An event triggered when the mesh is rendered into the effect render target.
  125997. */
  125998. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125999. /**
  126000. * An event triggered after the mesh has been rendered into the effect render target.
  126001. */
  126002. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126003. /**
  126004. * An event triggered when the generated texture has been merged in the scene.
  126005. */
  126006. onAfterComposeObservable: Observable<EffectLayer>;
  126007. /**
  126008. * An event triggered when the efffect layer changes its size.
  126009. */
  126010. onSizeChangedObservable: Observable<EffectLayer>;
  126011. /** @hidden */
  126012. static _SceneComponentInitialization: (scene: Scene) => void;
  126013. /**
  126014. * Instantiates a new effect Layer and references it in the scene.
  126015. * @param name The name of the layer
  126016. * @param scene The scene to use the layer in
  126017. */
  126018. constructor(
  126019. /** The Friendly of the effect in the scene */
  126020. name: string, scene: Scene);
  126021. /**
  126022. * Get the effect name of the layer.
  126023. * @return The effect name
  126024. */
  126025. abstract getEffectName(): string;
  126026. /**
  126027. * Checks for the readiness of the element composing the layer.
  126028. * @param subMesh the mesh to check for
  126029. * @param useInstances specify whether or not to use instances to render the mesh
  126030. * @return true if ready otherwise, false
  126031. */
  126032. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126033. /**
  126034. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126035. * @returns true if the effect requires stencil during the main canvas render pass.
  126036. */
  126037. abstract needStencil(): boolean;
  126038. /**
  126039. * Create the merge effect. This is the shader use to blit the information back
  126040. * to the main canvas at the end of the scene rendering.
  126041. * @returns The effect containing the shader used to merge the effect on the main canvas
  126042. */
  126043. protected abstract _createMergeEffect(): Effect;
  126044. /**
  126045. * Creates the render target textures and post processes used in the effect layer.
  126046. */
  126047. protected abstract _createTextureAndPostProcesses(): void;
  126048. /**
  126049. * Implementation specific of rendering the generating effect on the main canvas.
  126050. * @param effect The effect used to render through
  126051. */
  126052. protected abstract _internalRender(effect: Effect): void;
  126053. /**
  126054. * Sets the required values for both the emissive texture and and the main color.
  126055. */
  126056. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126057. /**
  126058. * Free any resources and references associated to a mesh.
  126059. * Internal use
  126060. * @param mesh The mesh to free.
  126061. */
  126062. abstract _disposeMesh(mesh: Mesh): void;
  126063. /**
  126064. * Serializes this layer (Glow or Highlight for example)
  126065. * @returns a serialized layer object
  126066. */
  126067. abstract serialize?(): any;
  126068. /**
  126069. * Initializes the effect layer with the required options.
  126070. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126071. */
  126072. protected _init(options: Partial<IEffectLayerOptions>): void;
  126073. /**
  126074. * Generates the index buffer of the full screen quad blending to the main canvas.
  126075. */
  126076. private _generateIndexBuffer;
  126077. /**
  126078. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126079. */
  126080. private _generateVertexBuffer;
  126081. /**
  126082. * Sets the main texture desired size which is the closest power of two
  126083. * of the engine canvas size.
  126084. */
  126085. private _setMainTextureSize;
  126086. /**
  126087. * Creates the main texture for the effect layer.
  126088. */
  126089. protected _createMainTexture(): void;
  126090. /**
  126091. * Adds specific effects defines.
  126092. * @param defines The defines to add specifics to.
  126093. */
  126094. protected _addCustomEffectDefines(defines: string[]): void;
  126095. /**
  126096. * Checks for the readiness of the element composing the layer.
  126097. * @param subMesh the mesh to check for
  126098. * @param useInstances specify whether or not to use instances to render the mesh
  126099. * @param emissiveTexture the associated emissive texture used to generate the glow
  126100. * @return true if ready otherwise, false
  126101. */
  126102. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126103. /**
  126104. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126105. */
  126106. render(): void;
  126107. /**
  126108. * Determine if a given mesh will be used in the current effect.
  126109. * @param mesh mesh to test
  126110. * @returns true if the mesh will be used
  126111. */
  126112. hasMesh(mesh: AbstractMesh): boolean;
  126113. /**
  126114. * Returns true if the layer contains information to display, otherwise false.
  126115. * @returns true if the glow layer should be rendered
  126116. */
  126117. shouldRender(): boolean;
  126118. /**
  126119. * Returns true if the mesh should render, otherwise false.
  126120. * @param mesh The mesh to render
  126121. * @returns true if it should render otherwise false
  126122. */
  126123. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126124. /**
  126125. * Returns true if the mesh can be rendered, otherwise false.
  126126. * @param mesh The mesh to render
  126127. * @param material The material used on the mesh
  126128. * @returns true if it can be rendered otherwise false
  126129. */
  126130. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126131. /**
  126132. * Returns true if the mesh should render, otherwise false.
  126133. * @param mesh The mesh to render
  126134. * @returns true if it should render otherwise false
  126135. */
  126136. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126137. /**
  126138. * Renders the submesh passed in parameter to the generation map.
  126139. */
  126140. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126141. /**
  126142. * Defines whether the current material of the mesh should be use to render the effect.
  126143. * @param mesh defines the current mesh to render
  126144. */
  126145. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126146. /**
  126147. * Rebuild the required buffers.
  126148. * @hidden Internal use only.
  126149. */
  126150. _rebuild(): void;
  126151. /**
  126152. * Dispose only the render target textures and post process.
  126153. */
  126154. private _disposeTextureAndPostProcesses;
  126155. /**
  126156. * Dispose the highlight layer and free resources.
  126157. */
  126158. dispose(): void;
  126159. /**
  126160. * Gets the class name of the effect layer
  126161. * @returns the string with the class name of the effect layer
  126162. */
  126163. getClassName(): string;
  126164. /**
  126165. * Creates an effect layer from parsed effect layer data
  126166. * @param parsedEffectLayer defines effect layer data
  126167. * @param scene defines the current scene
  126168. * @param rootUrl defines the root URL containing the effect layer information
  126169. * @returns a parsed effect Layer
  126170. */
  126171. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. interface AbstractScene {
  126176. /**
  126177. * The list of effect layers (highlights/glow) added to the scene
  126178. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126179. * @see http://doc.babylonjs.com/how_to/glow_layer
  126180. */
  126181. effectLayers: Array<EffectLayer>;
  126182. /**
  126183. * Removes the given effect layer from this scene.
  126184. * @param toRemove defines the effect layer to remove
  126185. * @returns the index of the removed effect layer
  126186. */
  126187. removeEffectLayer(toRemove: EffectLayer): number;
  126188. /**
  126189. * Adds the given effect layer to this scene
  126190. * @param newEffectLayer defines the effect layer to add
  126191. */
  126192. addEffectLayer(newEffectLayer: EffectLayer): void;
  126193. }
  126194. /**
  126195. * Defines the layer scene component responsible to manage any effect layers
  126196. * in a given scene.
  126197. */
  126198. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126199. /**
  126200. * The component name helpfull to identify the component in the list of scene components.
  126201. */
  126202. readonly name: string;
  126203. /**
  126204. * The scene the component belongs to.
  126205. */
  126206. scene: Scene;
  126207. private _engine;
  126208. private _renderEffects;
  126209. private _needStencil;
  126210. private _previousStencilState;
  126211. /**
  126212. * Creates a new instance of the component for the given scene
  126213. * @param scene Defines the scene to register the component in
  126214. */
  126215. constructor(scene: Scene);
  126216. /**
  126217. * Registers the component in a given scene
  126218. */
  126219. register(): void;
  126220. /**
  126221. * Rebuilds the elements related to this component in case of
  126222. * context lost for instance.
  126223. */
  126224. rebuild(): void;
  126225. /**
  126226. * Serializes the component data to the specified json object
  126227. * @param serializationObject The object to serialize to
  126228. */
  126229. serialize(serializationObject: any): void;
  126230. /**
  126231. * Adds all the elements from the container to the scene
  126232. * @param container the container holding the elements
  126233. */
  126234. addFromContainer(container: AbstractScene): void;
  126235. /**
  126236. * Removes all the elements in the container from the scene
  126237. * @param container contains the elements to remove
  126238. * @param dispose if the removed element should be disposed (default: false)
  126239. */
  126240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126241. /**
  126242. * Disposes the component and the associated ressources.
  126243. */
  126244. dispose(): void;
  126245. private _isReadyForMesh;
  126246. private _renderMainTexture;
  126247. private _setStencil;
  126248. private _setStencilBack;
  126249. private _draw;
  126250. private _drawCamera;
  126251. private _drawRenderingGroup;
  126252. }
  126253. }
  126254. declare module BABYLON {
  126255. /** @hidden */
  126256. export var glowMapMergePixelShader: {
  126257. name: string;
  126258. shader: string;
  126259. };
  126260. }
  126261. declare module BABYLON {
  126262. /** @hidden */
  126263. export var glowMapMergeVertexShader: {
  126264. name: string;
  126265. shader: string;
  126266. };
  126267. }
  126268. declare module BABYLON {
  126269. interface AbstractScene {
  126270. /**
  126271. * Return a the first highlight layer of the scene with a given name.
  126272. * @param name The name of the highlight layer to look for.
  126273. * @return The highlight layer if found otherwise null.
  126274. */
  126275. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126276. }
  126277. /**
  126278. * Glow layer options. This helps customizing the behaviour
  126279. * of the glow layer.
  126280. */
  126281. export interface IGlowLayerOptions {
  126282. /**
  126283. * Multiplication factor apply to the canvas size to compute the render target size
  126284. * used to generated the glowing objects (the smaller the faster).
  126285. */
  126286. mainTextureRatio: number;
  126287. /**
  126288. * Enforces a fixed size texture to ensure resize independant blur.
  126289. */
  126290. mainTextureFixedSize?: number;
  126291. /**
  126292. * How big is the kernel of the blur texture.
  126293. */
  126294. blurKernelSize: number;
  126295. /**
  126296. * The camera attached to the layer.
  126297. */
  126298. camera: Nullable<Camera>;
  126299. /**
  126300. * Enable MSAA by chosing the number of samples.
  126301. */
  126302. mainTextureSamples?: number;
  126303. /**
  126304. * The rendering group to draw the layer in.
  126305. */
  126306. renderingGroupId: number;
  126307. }
  126308. /**
  126309. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126310. *
  126311. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126312. *
  126313. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126314. */
  126315. export class GlowLayer extends EffectLayer {
  126316. /**
  126317. * Effect Name of the layer.
  126318. */
  126319. static readonly EffectName: string;
  126320. /**
  126321. * The default blur kernel size used for the glow.
  126322. */
  126323. static DefaultBlurKernelSize: number;
  126324. /**
  126325. * The default texture size ratio used for the glow.
  126326. */
  126327. static DefaultTextureRatio: number;
  126328. /**
  126329. * Sets the kernel size of the blur.
  126330. */
  126331. set blurKernelSize(value: number);
  126332. /**
  126333. * Gets the kernel size of the blur.
  126334. */
  126335. get blurKernelSize(): number;
  126336. /**
  126337. * Sets the glow intensity.
  126338. */
  126339. set intensity(value: number);
  126340. /**
  126341. * Gets the glow intensity.
  126342. */
  126343. get intensity(): number;
  126344. private _options;
  126345. private _intensity;
  126346. private _horizontalBlurPostprocess1;
  126347. private _verticalBlurPostprocess1;
  126348. private _horizontalBlurPostprocess2;
  126349. private _verticalBlurPostprocess2;
  126350. private _blurTexture1;
  126351. private _blurTexture2;
  126352. private _postProcesses1;
  126353. private _postProcesses2;
  126354. private _includedOnlyMeshes;
  126355. private _excludedMeshes;
  126356. private _meshesUsingTheirOwnMaterials;
  126357. /**
  126358. * Callback used to let the user override the color selection on a per mesh basis
  126359. */
  126360. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126361. /**
  126362. * Callback used to let the user override the texture selection on a per mesh basis
  126363. */
  126364. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126365. /**
  126366. * Instantiates a new glow Layer and references it to the scene.
  126367. * @param name The name of the layer
  126368. * @param scene The scene to use the layer in
  126369. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126370. */
  126371. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126372. /**
  126373. * Get the effect name of the layer.
  126374. * @return The effect name
  126375. */
  126376. getEffectName(): string;
  126377. /**
  126378. * Create the merge effect. This is the shader use to blit the information back
  126379. * to the main canvas at the end of the scene rendering.
  126380. */
  126381. protected _createMergeEffect(): Effect;
  126382. /**
  126383. * Creates the render target textures and post processes used in the glow layer.
  126384. */
  126385. protected _createTextureAndPostProcesses(): void;
  126386. /**
  126387. * Checks for the readiness of the element composing the layer.
  126388. * @param subMesh the mesh to check for
  126389. * @param useInstances specify wether or not to use instances to render the mesh
  126390. * @param emissiveTexture the associated emissive texture used to generate the glow
  126391. * @return true if ready otherwise, false
  126392. */
  126393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126394. /**
  126395. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126396. */
  126397. needStencil(): boolean;
  126398. /**
  126399. * Returns true if the mesh can be rendered, otherwise false.
  126400. * @param mesh The mesh to render
  126401. * @param material The material used on the mesh
  126402. * @returns true if it can be rendered otherwise false
  126403. */
  126404. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126405. /**
  126406. * Implementation specific of rendering the generating effect on the main canvas.
  126407. * @param effect The effect used to render through
  126408. */
  126409. protected _internalRender(effect: Effect): void;
  126410. /**
  126411. * Sets the required values for both the emissive texture and and the main color.
  126412. */
  126413. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126414. /**
  126415. * Returns true if the mesh should render, otherwise false.
  126416. * @param mesh The mesh to render
  126417. * @returns true if it should render otherwise false
  126418. */
  126419. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126420. /**
  126421. * Adds specific effects defines.
  126422. * @param defines The defines to add specifics to.
  126423. */
  126424. protected _addCustomEffectDefines(defines: string[]): void;
  126425. /**
  126426. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126427. * @param mesh The mesh to exclude from the glow layer
  126428. */
  126429. addExcludedMesh(mesh: Mesh): void;
  126430. /**
  126431. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126432. * @param mesh The mesh to remove
  126433. */
  126434. removeExcludedMesh(mesh: Mesh): void;
  126435. /**
  126436. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126437. * @param mesh The mesh to include in the glow layer
  126438. */
  126439. addIncludedOnlyMesh(mesh: Mesh): void;
  126440. /**
  126441. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126442. * @param mesh The mesh to remove
  126443. */
  126444. removeIncludedOnlyMesh(mesh: Mesh): void;
  126445. /**
  126446. * Determine if a given mesh will be used in the glow layer
  126447. * @param mesh The mesh to test
  126448. * @returns true if the mesh will be highlighted by the current glow layer
  126449. */
  126450. hasMesh(mesh: AbstractMesh): boolean;
  126451. /**
  126452. * Defines whether the current material of the mesh should be use to render the effect.
  126453. * @param mesh defines the current mesh to render
  126454. */
  126455. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126456. /**
  126457. * Add a mesh to be rendered through its own material and not with emissive only.
  126458. * @param mesh The mesh for which we need to use its material
  126459. */
  126460. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126461. /**
  126462. * Remove a mesh from being rendered through its own material and not with emissive only.
  126463. * @param mesh The mesh for which we need to not use its material
  126464. */
  126465. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126466. /**
  126467. * Free any resources and references associated to a mesh.
  126468. * Internal use
  126469. * @param mesh The mesh to free.
  126470. * @hidden
  126471. */
  126472. _disposeMesh(mesh: Mesh): void;
  126473. /**
  126474. * Gets the class name of the effect layer
  126475. * @returns the string with the class name of the effect layer
  126476. */
  126477. getClassName(): string;
  126478. /**
  126479. * Serializes this glow layer
  126480. * @returns a serialized glow layer object
  126481. */
  126482. serialize(): any;
  126483. /**
  126484. * Creates a Glow Layer from parsed glow layer data
  126485. * @param parsedGlowLayer defines glow layer data
  126486. * @param scene defines the current scene
  126487. * @param rootUrl defines the root URL containing the glow layer information
  126488. * @returns a parsed Glow Layer
  126489. */
  126490. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126491. }
  126492. }
  126493. declare module BABYLON {
  126494. /** @hidden */
  126495. export var glowBlurPostProcessPixelShader: {
  126496. name: string;
  126497. shader: string;
  126498. };
  126499. }
  126500. declare module BABYLON {
  126501. interface AbstractScene {
  126502. /**
  126503. * Return a the first highlight layer of the scene with a given name.
  126504. * @param name The name of the highlight layer to look for.
  126505. * @return The highlight layer if found otherwise null.
  126506. */
  126507. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126508. }
  126509. /**
  126510. * Highlight layer options. This helps customizing the behaviour
  126511. * of the highlight layer.
  126512. */
  126513. export interface IHighlightLayerOptions {
  126514. /**
  126515. * Multiplication factor apply to the canvas size to compute the render target size
  126516. * used to generated the glowing objects (the smaller the faster).
  126517. */
  126518. mainTextureRatio: number;
  126519. /**
  126520. * Enforces a fixed size texture to ensure resize independant blur.
  126521. */
  126522. mainTextureFixedSize?: number;
  126523. /**
  126524. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126525. * of the picture to blur (the smaller the faster).
  126526. */
  126527. blurTextureSizeRatio: number;
  126528. /**
  126529. * How big in texel of the blur texture is the vertical blur.
  126530. */
  126531. blurVerticalSize: number;
  126532. /**
  126533. * How big in texel of the blur texture is the horizontal blur.
  126534. */
  126535. blurHorizontalSize: number;
  126536. /**
  126537. * Alpha blending mode used to apply the blur. Default is combine.
  126538. */
  126539. alphaBlendingMode: number;
  126540. /**
  126541. * The camera attached to the layer.
  126542. */
  126543. camera: Nullable<Camera>;
  126544. /**
  126545. * Should we display highlight as a solid stroke?
  126546. */
  126547. isStroke?: boolean;
  126548. /**
  126549. * The rendering group to draw the layer in.
  126550. */
  126551. renderingGroupId: number;
  126552. }
  126553. /**
  126554. * The highlight layer Helps adding a glow effect around a mesh.
  126555. *
  126556. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126557. * glowy meshes to your scene.
  126558. *
  126559. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126560. */
  126561. export class HighlightLayer extends EffectLayer {
  126562. name: string;
  126563. /**
  126564. * Effect Name of the highlight layer.
  126565. */
  126566. static readonly EffectName: string;
  126567. /**
  126568. * The neutral color used during the preparation of the glow effect.
  126569. * This is black by default as the blend operation is a blend operation.
  126570. */
  126571. static NeutralColor: Color4;
  126572. /**
  126573. * Stencil value used for glowing meshes.
  126574. */
  126575. static GlowingMeshStencilReference: number;
  126576. /**
  126577. * Stencil value used for the other meshes in the scene.
  126578. */
  126579. static NormalMeshStencilReference: number;
  126580. /**
  126581. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126582. */
  126583. innerGlow: boolean;
  126584. /**
  126585. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126586. */
  126587. outerGlow: boolean;
  126588. /**
  126589. * Specifies the horizontal size of the blur.
  126590. */
  126591. set blurHorizontalSize(value: number);
  126592. /**
  126593. * Specifies the vertical size of the blur.
  126594. */
  126595. set blurVerticalSize(value: number);
  126596. /**
  126597. * Gets the horizontal size of the blur.
  126598. */
  126599. get blurHorizontalSize(): number;
  126600. /**
  126601. * Gets the vertical size of the blur.
  126602. */
  126603. get blurVerticalSize(): number;
  126604. /**
  126605. * An event triggered when the highlight layer is being blurred.
  126606. */
  126607. onBeforeBlurObservable: Observable<HighlightLayer>;
  126608. /**
  126609. * An event triggered when the highlight layer has been blurred.
  126610. */
  126611. onAfterBlurObservable: Observable<HighlightLayer>;
  126612. private _instanceGlowingMeshStencilReference;
  126613. private _options;
  126614. private _downSamplePostprocess;
  126615. private _horizontalBlurPostprocess;
  126616. private _verticalBlurPostprocess;
  126617. private _blurTexture;
  126618. private _meshes;
  126619. private _excludedMeshes;
  126620. /**
  126621. * Instantiates a new highlight Layer and references it to the scene..
  126622. * @param name The name of the layer
  126623. * @param scene The scene to use the layer in
  126624. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126625. */
  126626. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126627. /**
  126628. * Get the effect name of the layer.
  126629. * @return The effect name
  126630. */
  126631. getEffectName(): string;
  126632. /**
  126633. * Create the merge effect. This is the shader use to blit the information back
  126634. * to the main canvas at the end of the scene rendering.
  126635. */
  126636. protected _createMergeEffect(): Effect;
  126637. /**
  126638. * Creates the render target textures and post processes used in the highlight layer.
  126639. */
  126640. protected _createTextureAndPostProcesses(): void;
  126641. /**
  126642. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126643. */
  126644. needStencil(): boolean;
  126645. /**
  126646. * Checks for the readiness of the element composing the layer.
  126647. * @param subMesh the mesh to check for
  126648. * @param useInstances specify wether or not to use instances to render the mesh
  126649. * @param emissiveTexture the associated emissive texture used to generate the glow
  126650. * @return true if ready otherwise, false
  126651. */
  126652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126653. /**
  126654. * Implementation specific of rendering the generating effect on the main canvas.
  126655. * @param effect The effect used to render through
  126656. */
  126657. protected _internalRender(effect: Effect): void;
  126658. /**
  126659. * Returns true if the layer contains information to display, otherwise false.
  126660. */
  126661. shouldRender(): boolean;
  126662. /**
  126663. * Returns true if the mesh should render, otherwise false.
  126664. * @param mesh The mesh to render
  126665. * @returns true if it should render otherwise false
  126666. */
  126667. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126668. /**
  126669. * Sets the required values for both the emissive texture and and the main color.
  126670. */
  126671. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126672. /**
  126673. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126674. * @param mesh The mesh to exclude from the highlight layer
  126675. */
  126676. addExcludedMesh(mesh: Mesh): void;
  126677. /**
  126678. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126679. * @param mesh The mesh to highlight
  126680. */
  126681. removeExcludedMesh(mesh: Mesh): void;
  126682. /**
  126683. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126684. * @param mesh mesh to test
  126685. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126686. */
  126687. hasMesh(mesh: AbstractMesh): boolean;
  126688. /**
  126689. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126690. * @param mesh The mesh to highlight
  126691. * @param color The color of the highlight
  126692. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126693. */
  126694. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126695. /**
  126696. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126697. * @param mesh The mesh to highlight
  126698. */
  126699. removeMesh(mesh: Mesh): void;
  126700. /**
  126701. * Remove all the meshes currently referenced in the highlight layer
  126702. */
  126703. removeAllMeshes(): void;
  126704. /**
  126705. * Force the stencil to the normal expected value for none glowing parts
  126706. */
  126707. private _defaultStencilReference;
  126708. /**
  126709. * Free any resources and references associated to a mesh.
  126710. * Internal use
  126711. * @param mesh The mesh to free.
  126712. * @hidden
  126713. */
  126714. _disposeMesh(mesh: Mesh): void;
  126715. /**
  126716. * Dispose the highlight layer and free resources.
  126717. */
  126718. dispose(): void;
  126719. /**
  126720. * Gets the class name of the effect layer
  126721. * @returns the string with the class name of the effect layer
  126722. */
  126723. getClassName(): string;
  126724. /**
  126725. * Serializes this Highlight layer
  126726. * @returns a serialized Highlight layer object
  126727. */
  126728. serialize(): any;
  126729. /**
  126730. * Creates a Highlight layer from parsed Highlight layer data
  126731. * @param parsedHightlightLayer defines the Highlight layer data
  126732. * @param scene defines the current scene
  126733. * @param rootUrl defines the root URL containing the Highlight layer information
  126734. * @returns a parsed Highlight layer
  126735. */
  126736. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126737. }
  126738. }
  126739. declare module BABYLON {
  126740. interface AbstractScene {
  126741. /**
  126742. * The list of layers (background and foreground) of the scene
  126743. */
  126744. layers: Array<Layer>;
  126745. }
  126746. /**
  126747. * Defines the layer scene component responsible to manage any layers
  126748. * in a given scene.
  126749. */
  126750. export class LayerSceneComponent implements ISceneComponent {
  126751. /**
  126752. * The component name helpfull to identify the component in the list of scene components.
  126753. */
  126754. readonly name: string;
  126755. /**
  126756. * The scene the component belongs to.
  126757. */
  126758. scene: Scene;
  126759. private _engine;
  126760. /**
  126761. * Creates a new instance of the component for the given scene
  126762. * @param scene Defines the scene to register the component in
  126763. */
  126764. constructor(scene: Scene);
  126765. /**
  126766. * Registers the component in a given scene
  126767. */
  126768. register(): void;
  126769. /**
  126770. * Rebuilds the elements related to this component in case of
  126771. * context lost for instance.
  126772. */
  126773. rebuild(): void;
  126774. /**
  126775. * Disposes the component and the associated ressources.
  126776. */
  126777. dispose(): void;
  126778. private _draw;
  126779. private _drawCameraPredicate;
  126780. private _drawCameraBackground;
  126781. private _drawCameraForeground;
  126782. private _drawRenderTargetPredicate;
  126783. private _drawRenderTargetBackground;
  126784. private _drawRenderTargetForeground;
  126785. /**
  126786. * Adds all the elements from the container to the scene
  126787. * @param container the container holding the elements
  126788. */
  126789. addFromContainer(container: AbstractScene): void;
  126790. /**
  126791. * Removes all the elements in the container from the scene
  126792. * @param container contains the elements to remove
  126793. * @param dispose if the removed element should be disposed (default: false)
  126794. */
  126795. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126796. }
  126797. }
  126798. declare module BABYLON {
  126799. /** @hidden */
  126800. export var layerPixelShader: {
  126801. name: string;
  126802. shader: string;
  126803. };
  126804. }
  126805. declare module BABYLON {
  126806. /** @hidden */
  126807. export var layerVertexShader: {
  126808. name: string;
  126809. shader: string;
  126810. };
  126811. }
  126812. declare module BABYLON {
  126813. /**
  126814. * This represents a full screen 2d layer.
  126815. * This can be useful to display a picture in the background of your scene for instance.
  126816. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126817. */
  126818. export class Layer {
  126819. /**
  126820. * Define the name of the layer.
  126821. */
  126822. name: string;
  126823. /**
  126824. * Define the texture the layer should display.
  126825. */
  126826. texture: Nullable<Texture>;
  126827. /**
  126828. * Is the layer in background or foreground.
  126829. */
  126830. isBackground: boolean;
  126831. /**
  126832. * Define the color of the layer (instead of texture).
  126833. */
  126834. color: Color4;
  126835. /**
  126836. * Define the scale of the layer in order to zoom in out of the texture.
  126837. */
  126838. scale: Vector2;
  126839. /**
  126840. * Define an offset for the layer in order to shift the texture.
  126841. */
  126842. offset: Vector2;
  126843. /**
  126844. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126845. */
  126846. alphaBlendingMode: number;
  126847. /**
  126848. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126849. * Alpha test will not mix with the background color in case of transparency.
  126850. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126851. */
  126852. alphaTest: boolean;
  126853. /**
  126854. * Define a mask to restrict the layer to only some of the scene cameras.
  126855. */
  126856. layerMask: number;
  126857. /**
  126858. * Define the list of render target the layer is visible into.
  126859. */
  126860. renderTargetTextures: RenderTargetTexture[];
  126861. /**
  126862. * Define if the layer is only used in renderTarget or if it also
  126863. * renders in the main frame buffer of the canvas.
  126864. */
  126865. renderOnlyInRenderTargetTextures: boolean;
  126866. private _scene;
  126867. private _vertexBuffers;
  126868. private _indexBuffer;
  126869. private _effect;
  126870. private _previousDefines;
  126871. /**
  126872. * An event triggered when the layer is disposed.
  126873. */
  126874. onDisposeObservable: Observable<Layer>;
  126875. private _onDisposeObserver;
  126876. /**
  126877. * Back compatibility with callback before the onDisposeObservable existed.
  126878. * The set callback will be triggered when the layer has been disposed.
  126879. */
  126880. set onDispose(callback: () => void);
  126881. /**
  126882. * An event triggered before rendering the scene
  126883. */
  126884. onBeforeRenderObservable: Observable<Layer>;
  126885. private _onBeforeRenderObserver;
  126886. /**
  126887. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126888. * The set callback will be triggered just before rendering the layer.
  126889. */
  126890. set onBeforeRender(callback: () => void);
  126891. /**
  126892. * An event triggered after rendering the scene
  126893. */
  126894. onAfterRenderObservable: Observable<Layer>;
  126895. private _onAfterRenderObserver;
  126896. /**
  126897. * Back compatibility with callback before the onAfterRenderObservable existed.
  126898. * The set callback will be triggered just after rendering the layer.
  126899. */
  126900. set onAfterRender(callback: () => void);
  126901. /**
  126902. * Instantiates a new layer.
  126903. * This represents a full screen 2d layer.
  126904. * This can be useful to display a picture in the background of your scene for instance.
  126905. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126906. * @param name Define the name of the layer in the scene
  126907. * @param imgUrl Define the url of the texture to display in the layer
  126908. * @param scene Define the scene the layer belongs to
  126909. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126910. * @param color Defines a color for the layer
  126911. */
  126912. constructor(
  126913. /**
  126914. * Define the name of the layer.
  126915. */
  126916. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126917. private _createIndexBuffer;
  126918. /** @hidden */
  126919. _rebuild(): void;
  126920. /**
  126921. * Renders the layer in the scene.
  126922. */
  126923. render(): void;
  126924. /**
  126925. * Disposes and releases the associated ressources.
  126926. */
  126927. dispose(): void;
  126928. }
  126929. }
  126930. declare module BABYLON {
  126931. /** @hidden */
  126932. export var lensFlarePixelShader: {
  126933. name: string;
  126934. shader: string;
  126935. };
  126936. }
  126937. declare module BABYLON {
  126938. /** @hidden */
  126939. export var lensFlareVertexShader: {
  126940. name: string;
  126941. shader: string;
  126942. };
  126943. }
  126944. declare module BABYLON {
  126945. /**
  126946. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126947. * It is usually composed of several `lensFlare`.
  126948. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126949. */
  126950. export class LensFlareSystem {
  126951. /**
  126952. * Define the name of the lens flare system
  126953. */
  126954. name: string;
  126955. /**
  126956. * List of lens flares used in this system.
  126957. */
  126958. lensFlares: LensFlare[];
  126959. /**
  126960. * Define a limit from the border the lens flare can be visible.
  126961. */
  126962. borderLimit: number;
  126963. /**
  126964. * Define a viewport border we do not want to see the lens flare in.
  126965. */
  126966. viewportBorder: number;
  126967. /**
  126968. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126969. */
  126970. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126971. /**
  126972. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126973. */
  126974. layerMask: number;
  126975. /**
  126976. * Define the id of the lens flare system in the scene.
  126977. * (equal to name by default)
  126978. */
  126979. id: string;
  126980. private _scene;
  126981. private _emitter;
  126982. private _vertexBuffers;
  126983. private _indexBuffer;
  126984. private _effect;
  126985. private _positionX;
  126986. private _positionY;
  126987. private _isEnabled;
  126988. /** @hidden */
  126989. static _SceneComponentInitialization: (scene: Scene) => void;
  126990. /**
  126991. * Instantiates a lens flare system.
  126992. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126993. * It is usually composed of several `lensFlare`.
  126994. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126995. * @param name Define the name of the lens flare system in the scene
  126996. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126997. * @param scene Define the scene the lens flare system belongs to
  126998. */
  126999. constructor(
  127000. /**
  127001. * Define the name of the lens flare system
  127002. */
  127003. name: string, emitter: any, scene: Scene);
  127004. /**
  127005. * Define if the lens flare system is enabled.
  127006. */
  127007. get isEnabled(): boolean;
  127008. set isEnabled(value: boolean);
  127009. /**
  127010. * Get the scene the effects belongs to.
  127011. * @returns the scene holding the lens flare system
  127012. */
  127013. getScene(): Scene;
  127014. /**
  127015. * Get the emitter of the lens flare system.
  127016. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127017. * @returns the emitter of the lens flare system
  127018. */
  127019. getEmitter(): any;
  127020. /**
  127021. * Set the emitter of the lens flare system.
  127022. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127023. * @param newEmitter Define the new emitter of the system
  127024. */
  127025. setEmitter(newEmitter: any): void;
  127026. /**
  127027. * Get the lens flare system emitter position.
  127028. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127029. * @returns the position
  127030. */
  127031. getEmitterPosition(): Vector3;
  127032. /**
  127033. * @hidden
  127034. */
  127035. computeEffectivePosition(globalViewport: Viewport): boolean;
  127036. /** @hidden */
  127037. _isVisible(): boolean;
  127038. /**
  127039. * @hidden
  127040. */
  127041. render(): boolean;
  127042. /**
  127043. * Dispose and release the lens flare with its associated resources.
  127044. */
  127045. dispose(): void;
  127046. /**
  127047. * Parse a lens flare system from a JSON repressentation
  127048. * @param parsedLensFlareSystem Define the JSON to parse
  127049. * @param scene Define the scene the parsed system should be instantiated in
  127050. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127051. * @returns the parsed system
  127052. */
  127053. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127054. /**
  127055. * Serialize the current Lens Flare System into a JSON representation.
  127056. * @returns the serialized JSON
  127057. */
  127058. serialize(): any;
  127059. }
  127060. }
  127061. declare module BABYLON {
  127062. /**
  127063. * This represents one of the lens effect in a `lensFlareSystem`.
  127064. * It controls one of the indiviual texture used in the effect.
  127065. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127066. */
  127067. export class LensFlare {
  127068. /**
  127069. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127070. */
  127071. size: number;
  127072. /**
  127073. * 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.
  127074. */
  127075. position: number;
  127076. /**
  127077. * Define the lens color.
  127078. */
  127079. color: Color3;
  127080. /**
  127081. * Define the lens texture.
  127082. */
  127083. texture: Nullable<Texture>;
  127084. /**
  127085. * Define the alpha mode to render this particular lens.
  127086. */
  127087. alphaMode: number;
  127088. private _system;
  127089. /**
  127090. * Creates a new Lens Flare.
  127091. * This represents one of the lens effect in a `lensFlareSystem`.
  127092. * It controls one of the indiviual texture used in the effect.
  127093. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127094. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127095. * @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.
  127096. * @param color Define the lens color
  127097. * @param imgUrl Define the lens texture url
  127098. * @param system Define the `lensFlareSystem` this flare is part of
  127099. * @returns The newly created Lens Flare
  127100. */
  127101. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127102. /**
  127103. * Instantiates a new Lens Flare.
  127104. * This represents one of the lens effect in a `lensFlareSystem`.
  127105. * It controls one of the indiviual texture used in the effect.
  127106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127107. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127108. * @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.
  127109. * @param color Define the lens color
  127110. * @param imgUrl Define the lens texture url
  127111. * @param system Define the `lensFlareSystem` this flare is part of
  127112. */
  127113. constructor(
  127114. /**
  127115. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127116. */
  127117. size: number,
  127118. /**
  127119. * 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.
  127120. */
  127121. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127122. /**
  127123. * Dispose and release the lens flare with its associated resources.
  127124. */
  127125. dispose(): void;
  127126. }
  127127. }
  127128. declare module BABYLON {
  127129. interface AbstractScene {
  127130. /**
  127131. * The list of lens flare system added to the scene
  127132. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127133. */
  127134. lensFlareSystems: Array<LensFlareSystem>;
  127135. /**
  127136. * Removes the given lens flare system from this scene.
  127137. * @param toRemove The lens flare system to remove
  127138. * @returns The index of the removed lens flare system
  127139. */
  127140. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127141. /**
  127142. * Adds the given lens flare system to this scene
  127143. * @param newLensFlareSystem The lens flare system to add
  127144. */
  127145. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127146. /**
  127147. * Gets a lens flare system using its name
  127148. * @param name defines the name to look for
  127149. * @returns the lens flare system or null if not found
  127150. */
  127151. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127152. /**
  127153. * Gets a lens flare system using its id
  127154. * @param id defines the id to look for
  127155. * @returns the lens flare system or null if not found
  127156. */
  127157. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127158. }
  127159. /**
  127160. * Defines the lens flare scene component responsible to manage any lens flares
  127161. * in a given scene.
  127162. */
  127163. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127164. /**
  127165. * The component name helpfull to identify the component in the list of scene components.
  127166. */
  127167. readonly name: string;
  127168. /**
  127169. * The scene the component belongs to.
  127170. */
  127171. scene: Scene;
  127172. /**
  127173. * Creates a new instance of the component for the given scene
  127174. * @param scene Defines the scene to register the component in
  127175. */
  127176. constructor(scene: Scene);
  127177. /**
  127178. * Registers the component in a given scene
  127179. */
  127180. register(): void;
  127181. /**
  127182. * Rebuilds the elements related to this component in case of
  127183. * context lost for instance.
  127184. */
  127185. rebuild(): void;
  127186. /**
  127187. * Adds all the elements from the container to the scene
  127188. * @param container the container holding the elements
  127189. */
  127190. addFromContainer(container: AbstractScene): void;
  127191. /**
  127192. * Removes all the elements in the container from the scene
  127193. * @param container contains the elements to remove
  127194. * @param dispose if the removed element should be disposed (default: false)
  127195. */
  127196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127197. /**
  127198. * Serializes the component data to the specified json object
  127199. * @param serializationObject The object to serialize to
  127200. */
  127201. serialize(serializationObject: any): void;
  127202. /**
  127203. * Disposes the component and the associated ressources.
  127204. */
  127205. dispose(): void;
  127206. private _draw;
  127207. }
  127208. }
  127209. declare module BABYLON {
  127210. /** @hidden */
  127211. export var depthPixelShader: {
  127212. name: string;
  127213. shader: string;
  127214. };
  127215. }
  127216. declare module BABYLON {
  127217. /** @hidden */
  127218. export var depthVertexShader: {
  127219. name: string;
  127220. shader: string;
  127221. };
  127222. }
  127223. declare module BABYLON {
  127224. /**
  127225. * This represents a depth renderer in Babylon.
  127226. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127227. */
  127228. export class DepthRenderer {
  127229. private _scene;
  127230. private _depthMap;
  127231. private _effect;
  127232. private readonly _storeNonLinearDepth;
  127233. private readonly _clearColor;
  127234. /** Get if the depth renderer is using packed depth or not */
  127235. readonly isPacked: boolean;
  127236. private _cachedDefines;
  127237. private _camera;
  127238. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127239. enabled: boolean;
  127240. /**
  127241. * Specifiess that the depth renderer will only be used within
  127242. * the camera it is created for.
  127243. * This can help forcing its rendering during the camera processing.
  127244. */
  127245. useOnlyInActiveCamera: boolean;
  127246. /** @hidden */
  127247. static _SceneComponentInitialization: (scene: Scene) => void;
  127248. /**
  127249. * Instantiates a depth renderer
  127250. * @param scene The scene the renderer belongs to
  127251. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127252. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127253. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127254. */
  127255. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127256. /**
  127257. * Creates the depth rendering effect and checks if the effect is ready.
  127258. * @param subMesh The submesh to be used to render the depth map of
  127259. * @param useInstances If multiple world instances should be used
  127260. * @returns if the depth renderer is ready to render the depth map
  127261. */
  127262. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127263. /**
  127264. * Gets the texture which the depth map will be written to.
  127265. * @returns The depth map texture
  127266. */
  127267. getDepthMap(): RenderTargetTexture;
  127268. /**
  127269. * Disposes of the depth renderer.
  127270. */
  127271. dispose(): void;
  127272. }
  127273. }
  127274. declare module BABYLON {
  127275. /** @hidden */
  127276. export var minmaxReduxPixelShader: {
  127277. name: string;
  127278. shader: string;
  127279. };
  127280. }
  127281. declare module BABYLON {
  127282. /**
  127283. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127284. * and maximum values from all values of the texture.
  127285. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127286. * The source values are read from the red channel of the texture.
  127287. */
  127288. export class MinMaxReducer {
  127289. /**
  127290. * Observable triggered when the computation has been performed
  127291. */
  127292. onAfterReductionPerformed: Observable<{
  127293. min: number;
  127294. max: number;
  127295. }>;
  127296. protected _camera: Camera;
  127297. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127298. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127299. protected _postProcessManager: PostProcessManager;
  127300. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127301. protected _forceFullscreenViewport: boolean;
  127302. /**
  127303. * Creates a min/max reducer
  127304. * @param camera The camera to use for the post processes
  127305. */
  127306. constructor(camera: Camera);
  127307. /**
  127308. * Gets the texture used to read the values from.
  127309. */
  127310. get sourceTexture(): Nullable<RenderTargetTexture>;
  127311. /**
  127312. * Sets the source texture to read the values from.
  127313. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127314. * because in such textures '1' value must not be taken into account to compute the maximum
  127315. * as this value is used to clear the texture.
  127316. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127317. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127318. * @param depthRedux Indicates if the texture is a depth texture or not
  127319. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127320. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127321. */
  127322. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127323. /**
  127324. * Defines the refresh rate of the computation.
  127325. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127326. */
  127327. get refreshRate(): number;
  127328. set refreshRate(value: number);
  127329. protected _activated: boolean;
  127330. /**
  127331. * Gets the activation status of the reducer
  127332. */
  127333. get activated(): boolean;
  127334. /**
  127335. * Activates the reduction computation.
  127336. * When activated, the observers registered in onAfterReductionPerformed are
  127337. * called after the compuation is performed
  127338. */
  127339. activate(): void;
  127340. /**
  127341. * Deactivates the reduction computation.
  127342. */
  127343. deactivate(): void;
  127344. /**
  127345. * Disposes the min/max reducer
  127346. * @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.
  127347. */
  127348. dispose(disposeAll?: boolean): void;
  127349. }
  127350. }
  127351. declare module BABYLON {
  127352. /**
  127353. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127354. */
  127355. export class DepthReducer extends MinMaxReducer {
  127356. private _depthRenderer;
  127357. private _depthRendererId;
  127358. /**
  127359. * Gets the depth renderer used for the computation.
  127360. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127361. */
  127362. get depthRenderer(): Nullable<DepthRenderer>;
  127363. /**
  127364. * Creates a depth reducer
  127365. * @param camera The camera used to render the depth texture
  127366. */
  127367. constructor(camera: Camera);
  127368. /**
  127369. * Sets the depth renderer to use to generate the depth map
  127370. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127371. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127372. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127373. */
  127374. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127375. /** @hidden */
  127376. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127377. /**
  127378. * Activates the reduction computation.
  127379. * When activated, the observers registered in onAfterReductionPerformed are
  127380. * called after the compuation is performed
  127381. */
  127382. activate(): void;
  127383. /**
  127384. * Deactivates the reduction computation.
  127385. */
  127386. deactivate(): void;
  127387. /**
  127388. * Disposes the depth reducer
  127389. * @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.
  127390. */
  127391. dispose(disposeAll?: boolean): void;
  127392. }
  127393. }
  127394. declare module BABYLON {
  127395. /**
  127396. * A CSM implementation allowing casting shadows on large scenes.
  127397. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127398. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127399. */
  127400. export class CascadedShadowGenerator extends ShadowGenerator {
  127401. private static readonly frustumCornersNDCSpace;
  127402. /**
  127403. * Name of the CSM class
  127404. */
  127405. static CLASSNAME: string;
  127406. /**
  127407. * Defines the default number of cascades used by the CSM.
  127408. */
  127409. static readonly DEFAULT_CASCADES_COUNT: number;
  127410. /**
  127411. * Defines the minimum number of cascades used by the CSM.
  127412. */
  127413. static readonly MIN_CASCADES_COUNT: number;
  127414. /**
  127415. * Defines the maximum number of cascades used by the CSM.
  127416. */
  127417. static readonly MAX_CASCADES_COUNT: number;
  127418. protected _validateFilter(filter: number): number;
  127419. /**
  127420. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127421. */
  127422. penumbraDarkness: number;
  127423. private _numCascades;
  127424. /**
  127425. * Gets or set the number of cascades used by the CSM.
  127426. */
  127427. get numCascades(): number;
  127428. set numCascades(value: number);
  127429. /**
  127430. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127431. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127432. */
  127433. stabilizeCascades: boolean;
  127434. private _freezeShadowCastersBoundingInfo;
  127435. private _freezeShadowCastersBoundingInfoObservable;
  127436. /**
  127437. * Enables or disables the shadow casters bounding info computation.
  127438. * If your shadow casters don't move, you can disable this feature.
  127439. * If it is enabled, the bounding box computation is done every frame.
  127440. */
  127441. get freezeShadowCastersBoundingInfo(): boolean;
  127442. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127443. private _scbiMin;
  127444. private _scbiMax;
  127445. protected _computeShadowCastersBoundingInfo(): void;
  127446. protected _shadowCastersBoundingInfo: BoundingInfo;
  127447. /**
  127448. * Gets or sets the shadow casters bounding info.
  127449. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127450. * so that the system won't overwrite the bounds you provide
  127451. */
  127452. get shadowCastersBoundingInfo(): BoundingInfo;
  127453. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127454. protected _breaksAreDirty: boolean;
  127455. protected _minDistance: number;
  127456. protected _maxDistance: number;
  127457. /**
  127458. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127459. *
  127460. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127461. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127462. * @param min minimal distance for the breaks (default to 0.)
  127463. * @param max maximal distance for the breaks (default to 1.)
  127464. */
  127465. setMinMaxDistance(min: number, max: number): void;
  127466. /** Gets the minimal distance used in the cascade break computation */
  127467. get minDistance(): number;
  127468. /** Gets the maximal distance used in the cascade break computation */
  127469. get maxDistance(): number;
  127470. /**
  127471. * Gets the class name of that object
  127472. * @returns "CascadedShadowGenerator"
  127473. */
  127474. getClassName(): string;
  127475. private _cascadeMinExtents;
  127476. private _cascadeMaxExtents;
  127477. /**
  127478. * Gets a cascade minimum extents
  127479. * @param cascadeIndex index of the cascade
  127480. * @returns the minimum cascade extents
  127481. */
  127482. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127483. /**
  127484. * Gets a cascade maximum extents
  127485. * @param cascadeIndex index of the cascade
  127486. * @returns the maximum cascade extents
  127487. */
  127488. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127489. private _cascades;
  127490. private _currentLayer;
  127491. private _viewSpaceFrustumsZ;
  127492. private _viewMatrices;
  127493. private _projectionMatrices;
  127494. private _transformMatrices;
  127495. private _transformMatricesAsArray;
  127496. private _frustumLengths;
  127497. private _lightSizeUVCorrection;
  127498. private _depthCorrection;
  127499. private _frustumCornersWorldSpace;
  127500. private _frustumCenter;
  127501. private _shadowCameraPos;
  127502. private _shadowMaxZ;
  127503. /**
  127504. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127505. * It defaults to camera.maxZ
  127506. */
  127507. get shadowMaxZ(): number;
  127508. /**
  127509. * Sets the shadow max z distance.
  127510. */
  127511. set shadowMaxZ(value: number);
  127512. protected _debug: boolean;
  127513. /**
  127514. * Gets or sets the debug flag.
  127515. * When enabled, the cascades are materialized by different colors on the screen.
  127516. */
  127517. get debug(): boolean;
  127518. set debug(dbg: boolean);
  127519. private _depthClamp;
  127520. /**
  127521. * Gets or sets the depth clamping value.
  127522. *
  127523. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127524. * to account for the shadow casters far away.
  127525. *
  127526. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127527. */
  127528. get depthClamp(): boolean;
  127529. set depthClamp(value: boolean);
  127530. private _cascadeBlendPercentage;
  127531. /**
  127532. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127533. * It defaults to 0.1 (10% blending).
  127534. */
  127535. get cascadeBlendPercentage(): number;
  127536. set cascadeBlendPercentage(value: number);
  127537. private _lambda;
  127538. /**
  127539. * Gets or set the lambda parameter.
  127540. * This parameter is used to split the camera frustum and create the cascades.
  127541. * 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.
  127542. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127543. */
  127544. get lambda(): number;
  127545. set lambda(value: number);
  127546. /**
  127547. * Gets the view matrix corresponding to a given cascade
  127548. * @param cascadeNum cascade to retrieve the view matrix from
  127549. * @returns the cascade view matrix
  127550. */
  127551. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127552. /**
  127553. * Gets the projection matrix corresponding to a given cascade
  127554. * @param cascadeNum cascade to retrieve the projection matrix from
  127555. * @returns the cascade projection matrix
  127556. */
  127557. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127558. /**
  127559. * Gets the transformation matrix corresponding to a given cascade
  127560. * @param cascadeNum cascade to retrieve the transformation matrix from
  127561. * @returns the cascade transformation matrix
  127562. */
  127563. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127564. private _depthRenderer;
  127565. /**
  127566. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127567. *
  127568. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127569. *
  127570. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127571. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127572. * @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
  127573. */
  127574. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127575. private _depthReducer;
  127576. private _autoCalcDepthBounds;
  127577. /**
  127578. * Gets or sets the autoCalcDepthBounds property.
  127579. *
  127580. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127581. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127582. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127583. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127584. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127585. */
  127586. get autoCalcDepthBounds(): boolean;
  127587. set autoCalcDepthBounds(value: boolean);
  127588. /**
  127589. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127590. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127591. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127592. * for setting the refresh rate on the renderer yourself!
  127593. */
  127594. get autoCalcDepthBoundsRefreshRate(): number;
  127595. set autoCalcDepthBoundsRefreshRate(value: number);
  127596. /**
  127597. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127598. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127599. * you change the camera near/far planes!
  127600. */
  127601. splitFrustum(): void;
  127602. private _splitFrustum;
  127603. private _computeMatrices;
  127604. private _computeFrustumInWorldSpace;
  127605. private _computeCascadeFrustum;
  127606. /** @hidden */
  127607. static _SceneComponentInitialization: (scene: Scene) => void;
  127608. /**
  127609. * Creates a Cascaded Shadow Generator object.
  127610. * A ShadowGenerator is the required tool to use the shadows.
  127611. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127612. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127613. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127614. * @param light The directional light object generating the shadows.
  127615. * @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.
  127616. */
  127617. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127618. protected _initializeGenerator(): void;
  127619. protected _createTargetRenderTexture(): void;
  127620. protected _initializeShadowMap(): void;
  127621. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127622. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127623. /**
  127624. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127625. * @param defines Defines of the material we want to update
  127626. * @param lightIndex Index of the light in the enabled light list of the material
  127627. */
  127628. prepareDefines(defines: any, lightIndex: number): void;
  127629. /**
  127630. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127631. * defined in the generator but impacting the effect).
  127632. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127633. * @param effect The effect we are binfing the information for
  127634. */
  127635. bindShadowLight(lightIndex: string, effect: Effect): void;
  127636. /**
  127637. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127638. * (eq to view projection * shadow projection matrices)
  127639. * @returns The transform matrix used to create the shadow map
  127640. */
  127641. getTransformMatrix(): Matrix;
  127642. /**
  127643. * Disposes the ShadowGenerator.
  127644. * Returns nothing.
  127645. */
  127646. dispose(): void;
  127647. /**
  127648. * Serializes the shadow generator setup to a json object.
  127649. * @returns The serialized JSON object
  127650. */
  127651. serialize(): any;
  127652. /**
  127653. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127654. * @param parsedShadowGenerator The JSON object to parse
  127655. * @param scene The scene to create the shadow map for
  127656. * @returns The parsed shadow generator
  127657. */
  127658. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127659. }
  127660. }
  127661. declare module BABYLON {
  127662. /**
  127663. * Defines the shadow generator component responsible to manage any shadow generators
  127664. * in a given scene.
  127665. */
  127666. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127667. /**
  127668. * The component name helpfull to identify the component in the list of scene components.
  127669. */
  127670. readonly name: string;
  127671. /**
  127672. * The scene the component belongs to.
  127673. */
  127674. scene: Scene;
  127675. /**
  127676. * Creates a new instance of the component for the given scene
  127677. * @param scene Defines the scene to register the component in
  127678. */
  127679. constructor(scene: Scene);
  127680. /**
  127681. * Registers the component in a given scene
  127682. */
  127683. register(): void;
  127684. /**
  127685. * Rebuilds the elements related to this component in case of
  127686. * context lost for instance.
  127687. */
  127688. rebuild(): void;
  127689. /**
  127690. * Serializes the component data to the specified json object
  127691. * @param serializationObject The object to serialize to
  127692. */
  127693. serialize(serializationObject: any): void;
  127694. /**
  127695. * Adds all the elements from the container to the scene
  127696. * @param container the container holding the elements
  127697. */
  127698. addFromContainer(container: AbstractScene): void;
  127699. /**
  127700. * Removes all the elements in the container from the scene
  127701. * @param container contains the elements to remove
  127702. * @param dispose if the removed element should be disposed (default: false)
  127703. */
  127704. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127705. /**
  127706. * Rebuilds the elements related to this component in case of
  127707. * context lost for instance.
  127708. */
  127709. dispose(): void;
  127710. private _gatherRenderTargets;
  127711. }
  127712. }
  127713. declare module BABYLON {
  127714. /**
  127715. * A point light is a light defined by an unique point in world space.
  127716. * The light is emitted in every direction from this point.
  127717. * A good example of a point light is a standard light bulb.
  127718. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127719. */
  127720. export class PointLight extends ShadowLight {
  127721. private _shadowAngle;
  127722. /**
  127723. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127724. * This specifies what angle the shadow will use to be created.
  127725. *
  127726. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127727. */
  127728. get shadowAngle(): number;
  127729. /**
  127730. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127731. * This specifies what angle the shadow will use to be created.
  127732. *
  127733. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127734. */
  127735. set shadowAngle(value: number);
  127736. /**
  127737. * Gets the direction if it has been set.
  127738. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127739. */
  127740. get direction(): Vector3;
  127741. /**
  127742. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127743. */
  127744. set direction(value: Vector3);
  127745. /**
  127746. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127747. * A PointLight emits the light in every direction.
  127748. * It can cast shadows.
  127749. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127750. * ```javascript
  127751. * var pointLight = new PointLight("pl", camera.position, scene);
  127752. * ```
  127753. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127754. * @param name The light friendly name
  127755. * @param position The position of the point light in the scene
  127756. * @param scene The scene the lights belongs to
  127757. */
  127758. constructor(name: string, position: Vector3, scene: Scene);
  127759. /**
  127760. * Returns the string "PointLight"
  127761. * @returns the class name
  127762. */
  127763. getClassName(): string;
  127764. /**
  127765. * Returns the integer 0.
  127766. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127767. */
  127768. getTypeID(): number;
  127769. /**
  127770. * Specifies wether or not the shadowmap should be a cube texture.
  127771. * @returns true if the shadowmap needs to be a cube texture.
  127772. */
  127773. needCube(): boolean;
  127774. /**
  127775. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127776. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127777. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127778. */
  127779. getShadowDirection(faceIndex?: number): Vector3;
  127780. /**
  127781. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127782. * - fov = PI / 2
  127783. * - aspect ratio : 1.0
  127784. * - z-near and far equal to the active camera minZ and maxZ.
  127785. * Returns the PointLight.
  127786. */
  127787. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127788. protected _buildUniformLayout(): void;
  127789. /**
  127790. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127791. * @param effect The effect to update
  127792. * @param lightIndex The index of the light in the effect to update
  127793. * @returns The point light
  127794. */
  127795. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127796. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127797. /**
  127798. * Prepares the list of defines specific to the light type.
  127799. * @param defines the list of defines
  127800. * @param lightIndex defines the index of the light for the effect
  127801. */
  127802. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127803. }
  127804. }
  127805. declare module BABYLON {
  127806. /**
  127807. * Header information of HDR texture files.
  127808. */
  127809. export interface HDRInfo {
  127810. /**
  127811. * The height of the texture in pixels.
  127812. */
  127813. height: number;
  127814. /**
  127815. * The width of the texture in pixels.
  127816. */
  127817. width: number;
  127818. /**
  127819. * The index of the beginning of the data in the binary file.
  127820. */
  127821. dataPosition: number;
  127822. }
  127823. /**
  127824. * This groups tools to convert HDR texture to native colors array.
  127825. */
  127826. export class HDRTools {
  127827. private static Ldexp;
  127828. private static Rgbe2float;
  127829. private static readStringLine;
  127830. /**
  127831. * Reads header information from an RGBE texture stored in a native array.
  127832. * More information on this format are available here:
  127833. * https://en.wikipedia.org/wiki/RGBE_image_format
  127834. *
  127835. * @param uint8array The binary file stored in native array.
  127836. * @return The header information.
  127837. */
  127838. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127839. /**
  127840. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127841. * This RGBE texture needs to store the information as a panorama.
  127842. *
  127843. * More information on this format are available here:
  127844. * https://en.wikipedia.org/wiki/RGBE_image_format
  127845. *
  127846. * @param buffer The binary file stored in an array buffer.
  127847. * @param size The expected size of the extracted cubemap.
  127848. * @return The Cube Map information.
  127849. */
  127850. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127851. /**
  127852. * Returns the pixels data extracted from an RGBE texture.
  127853. * This pixels will be stored left to right up to down in the R G B order in one array.
  127854. *
  127855. * More information on this format are available here:
  127856. * https://en.wikipedia.org/wiki/RGBE_image_format
  127857. *
  127858. * @param uint8array The binary file stored in an array buffer.
  127859. * @param hdrInfo The header information of the file.
  127860. * @return The pixels data in RGB right to left up to down order.
  127861. */
  127862. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127863. private static RGBE_ReadPixels_RLE;
  127864. }
  127865. }
  127866. declare module BABYLON {
  127867. /**
  127868. * This represents a texture coming from an HDR input.
  127869. *
  127870. * The only supported format is currently panorama picture stored in RGBE format.
  127871. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127872. */
  127873. export class HDRCubeTexture extends BaseTexture {
  127874. private static _facesMapping;
  127875. private _generateHarmonics;
  127876. private _noMipmap;
  127877. private _textureMatrix;
  127878. private _size;
  127879. private _onLoad;
  127880. private _onError;
  127881. /**
  127882. * The texture URL.
  127883. */
  127884. url: string;
  127885. /**
  127886. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127887. */
  127888. coordinatesMode: number;
  127889. protected _isBlocking: boolean;
  127890. /**
  127891. * Sets wether or not the texture is blocking during loading.
  127892. */
  127893. set isBlocking(value: boolean);
  127894. /**
  127895. * Gets wether or not the texture is blocking during loading.
  127896. */
  127897. get isBlocking(): boolean;
  127898. protected _rotationY: number;
  127899. /**
  127900. * Sets texture matrix rotation angle around Y axis in radians.
  127901. */
  127902. set rotationY(value: number);
  127903. /**
  127904. * Gets texture matrix rotation angle around Y axis radians.
  127905. */
  127906. get rotationY(): number;
  127907. /**
  127908. * Gets or sets the center of the bounding box associated with the cube texture
  127909. * It must define where the camera used to render the texture was set
  127910. */
  127911. boundingBoxPosition: Vector3;
  127912. private _boundingBoxSize;
  127913. /**
  127914. * Gets or sets the size of the bounding box associated with the cube texture
  127915. * When defined, the cubemap will switch to local mode
  127916. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127917. * @example https://www.babylonjs-playground.com/#RNASML
  127918. */
  127919. set boundingBoxSize(value: Vector3);
  127920. get boundingBoxSize(): Vector3;
  127921. /**
  127922. * Instantiates an HDRTexture from the following parameters.
  127923. *
  127924. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127925. * @param scene The scene the texture will be used in
  127926. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127927. * @param noMipmap Forces to not generate the mipmap if true
  127928. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127929. * @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)
  127930. * @param reserved Reserved flag for internal use.
  127931. */
  127932. 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>);
  127933. /**
  127934. * Get the current class name of the texture useful for serialization or dynamic coding.
  127935. * @returns "HDRCubeTexture"
  127936. */
  127937. getClassName(): string;
  127938. /**
  127939. * Occurs when the file is raw .hdr file.
  127940. */
  127941. private loadTexture;
  127942. clone(): HDRCubeTexture;
  127943. delayLoad(): void;
  127944. /**
  127945. * Get the texture reflection matrix used to rotate/transform the reflection.
  127946. * @returns the reflection matrix
  127947. */
  127948. getReflectionTextureMatrix(): Matrix;
  127949. /**
  127950. * Set the texture reflection matrix used to rotate/transform the reflection.
  127951. * @param value Define the reflection matrix to set
  127952. */
  127953. setReflectionTextureMatrix(value: Matrix): void;
  127954. /**
  127955. * Parses a JSON representation of an HDR Texture in order to create the texture
  127956. * @param parsedTexture Define the JSON representation
  127957. * @param scene Define the scene the texture should be created in
  127958. * @param rootUrl Define the root url in case we need to load relative dependencies
  127959. * @returns the newly created texture after parsing
  127960. */
  127961. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127962. serialize(): any;
  127963. }
  127964. }
  127965. declare module BABYLON {
  127966. /**
  127967. * Class used to control physics engine
  127968. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127969. */
  127970. export class PhysicsEngine implements IPhysicsEngine {
  127971. private _physicsPlugin;
  127972. /**
  127973. * Global value used to control the smallest number supported by the simulation
  127974. */
  127975. static Epsilon: number;
  127976. private _impostors;
  127977. private _joints;
  127978. private _subTimeStep;
  127979. /**
  127980. * Gets the gravity vector used by the simulation
  127981. */
  127982. gravity: Vector3;
  127983. /**
  127984. * Factory used to create the default physics plugin.
  127985. * @returns The default physics plugin
  127986. */
  127987. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127988. /**
  127989. * Creates a new Physics Engine
  127990. * @param gravity defines the gravity vector used by the simulation
  127991. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127992. */
  127993. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127994. /**
  127995. * Sets the gravity vector used by the simulation
  127996. * @param gravity defines the gravity vector to use
  127997. */
  127998. setGravity(gravity: Vector3): void;
  127999. /**
  128000. * Set the time step of the physics engine.
  128001. * Default is 1/60.
  128002. * To slow it down, enter 1/600 for example.
  128003. * To speed it up, 1/30
  128004. * @param newTimeStep defines the new timestep to apply to this world.
  128005. */
  128006. setTimeStep(newTimeStep?: number): void;
  128007. /**
  128008. * Get the time step of the physics engine.
  128009. * @returns the current time step
  128010. */
  128011. getTimeStep(): number;
  128012. /**
  128013. * Set the sub time step of the physics engine.
  128014. * Default is 0 meaning there is no sub steps
  128015. * To increase physics resolution precision, set a small value (like 1 ms)
  128016. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128017. */
  128018. setSubTimeStep(subTimeStep?: number): void;
  128019. /**
  128020. * Get the sub time step of the physics engine.
  128021. * @returns the current sub time step
  128022. */
  128023. getSubTimeStep(): number;
  128024. /**
  128025. * Release all resources
  128026. */
  128027. dispose(): void;
  128028. /**
  128029. * Gets the name of the current physics plugin
  128030. * @returns the name of the plugin
  128031. */
  128032. getPhysicsPluginName(): string;
  128033. /**
  128034. * Adding a new impostor for the impostor tracking.
  128035. * This will be done by the impostor itself.
  128036. * @param impostor the impostor to add
  128037. */
  128038. addImpostor(impostor: PhysicsImpostor): void;
  128039. /**
  128040. * Remove an impostor from the engine.
  128041. * This impostor and its mesh will not longer be updated by the physics engine.
  128042. * @param impostor the impostor to remove
  128043. */
  128044. removeImpostor(impostor: PhysicsImpostor): void;
  128045. /**
  128046. * Add a joint to the physics engine
  128047. * @param mainImpostor defines the main impostor to which the joint is added.
  128048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128049. * @param joint defines the joint that will connect both impostors.
  128050. */
  128051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128052. /**
  128053. * Removes a joint from the simulation
  128054. * @param mainImpostor defines the impostor used with the joint
  128055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128056. * @param joint defines the joint to remove
  128057. */
  128058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128059. /**
  128060. * Called by the scene. No need to call it.
  128061. * @param delta defines the timespam between frames
  128062. */
  128063. _step(delta: number): void;
  128064. /**
  128065. * Gets the current plugin used to run the simulation
  128066. * @returns current plugin
  128067. */
  128068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128069. /**
  128070. * Gets the list of physic impostors
  128071. * @returns an array of PhysicsImpostor
  128072. */
  128073. getImpostors(): Array<PhysicsImpostor>;
  128074. /**
  128075. * Gets the impostor for a physics enabled object
  128076. * @param object defines the object impersonated by the impostor
  128077. * @returns the PhysicsImpostor or null if not found
  128078. */
  128079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128080. /**
  128081. * Gets the impostor for a physics body object
  128082. * @param body defines physics body used by the impostor
  128083. * @returns the PhysicsImpostor or null if not found
  128084. */
  128085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128086. /**
  128087. * Does a raycast in the physics world
  128088. * @param from when should the ray start?
  128089. * @param to when should the ray end?
  128090. * @returns PhysicsRaycastResult
  128091. */
  128092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128093. }
  128094. }
  128095. declare module BABYLON {
  128096. /** @hidden */
  128097. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128098. private _useDeltaForWorldStep;
  128099. world: any;
  128100. name: string;
  128101. private _physicsMaterials;
  128102. private _fixedTimeStep;
  128103. private _cannonRaycastResult;
  128104. private _raycastResult;
  128105. private _physicsBodysToRemoveAfterStep;
  128106. BJSCANNON: any;
  128107. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128108. setGravity(gravity: Vector3): void;
  128109. setTimeStep(timeStep: number): void;
  128110. getTimeStep(): number;
  128111. executeStep(delta: number): void;
  128112. private _removeMarkedPhysicsBodiesFromWorld;
  128113. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128114. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128115. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128116. private _processChildMeshes;
  128117. removePhysicsBody(impostor: PhysicsImpostor): void;
  128118. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128119. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128120. private _addMaterial;
  128121. private _checkWithEpsilon;
  128122. private _createShape;
  128123. private _createHeightmap;
  128124. private _minus90X;
  128125. private _plus90X;
  128126. private _tmpPosition;
  128127. private _tmpDeltaPosition;
  128128. private _tmpUnityRotation;
  128129. private _updatePhysicsBodyTransformation;
  128130. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128131. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128132. isSupported(): boolean;
  128133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128134. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128138. getBodyMass(impostor: PhysicsImpostor): number;
  128139. getBodyFriction(impostor: PhysicsImpostor): number;
  128140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128141. getBodyRestitution(impostor: PhysicsImpostor): number;
  128142. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128143. sleepBody(impostor: PhysicsImpostor): void;
  128144. wakeUpBody(impostor: PhysicsImpostor): void;
  128145. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128146. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128147. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128149. getRadius(impostor: PhysicsImpostor): number;
  128150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128151. dispose(): void;
  128152. private _extendNamespace;
  128153. /**
  128154. * Does a raycast in the physics world
  128155. * @param from when should the ray start?
  128156. * @param to when should the ray end?
  128157. * @returns PhysicsRaycastResult
  128158. */
  128159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128160. }
  128161. }
  128162. declare module BABYLON {
  128163. /** @hidden */
  128164. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128165. world: any;
  128166. name: string;
  128167. BJSOIMO: any;
  128168. private _raycastResult;
  128169. constructor(iterations?: number, oimoInjection?: any);
  128170. setGravity(gravity: Vector3): void;
  128171. setTimeStep(timeStep: number): void;
  128172. getTimeStep(): number;
  128173. private _tmpImpostorsArray;
  128174. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128175. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128176. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128177. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128178. private _tmpPositionVector;
  128179. removePhysicsBody(impostor: PhysicsImpostor): void;
  128180. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128181. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128182. isSupported(): boolean;
  128183. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128184. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128185. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128186. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128187. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128188. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128189. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128190. getBodyMass(impostor: PhysicsImpostor): number;
  128191. getBodyFriction(impostor: PhysicsImpostor): number;
  128192. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128193. getBodyRestitution(impostor: PhysicsImpostor): number;
  128194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128195. sleepBody(impostor: PhysicsImpostor): void;
  128196. wakeUpBody(impostor: PhysicsImpostor): void;
  128197. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128198. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128199. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128200. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128201. getRadius(impostor: PhysicsImpostor): number;
  128202. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128203. dispose(): void;
  128204. /**
  128205. * Does a raycast in the physics world
  128206. * @param from when should the ray start?
  128207. * @param to when should the ray end?
  128208. * @returns PhysicsRaycastResult
  128209. */
  128210. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128211. }
  128212. }
  128213. declare module BABYLON {
  128214. /**
  128215. * Class containing static functions to help procedurally build meshes
  128216. */
  128217. export class RibbonBuilder {
  128218. /**
  128219. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128220. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128221. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128222. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128223. * * 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
  128224. * * 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
  128225. * * 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
  128226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128229. * * 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
  128230. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128231. * * 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
  128232. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128234. * @param name defines the name of the mesh
  128235. * @param options defines the options used to create the mesh
  128236. * @param scene defines the hosting scene
  128237. * @returns the ribbon mesh
  128238. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128240. */
  128241. static CreateRibbon(name: string, options: {
  128242. pathArray: Vector3[][];
  128243. closeArray?: boolean;
  128244. closePath?: boolean;
  128245. offset?: number;
  128246. updatable?: boolean;
  128247. sideOrientation?: number;
  128248. frontUVs?: Vector4;
  128249. backUVs?: Vector4;
  128250. instance?: Mesh;
  128251. invertUV?: boolean;
  128252. uvs?: Vector2[];
  128253. colors?: Color4[];
  128254. }, scene?: Nullable<Scene>): Mesh;
  128255. }
  128256. }
  128257. declare module BABYLON {
  128258. /**
  128259. * Class containing static functions to help procedurally build meshes
  128260. */
  128261. export class ShapeBuilder {
  128262. /**
  128263. * 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.
  128264. * * 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.
  128265. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128266. * * 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.
  128267. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128268. * * 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
  128269. * * 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
  128270. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128273. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128275. * @param name defines the name of the mesh
  128276. * @param options defines the options used to create the mesh
  128277. * @param scene defines the hosting scene
  128278. * @returns the extruded shape mesh
  128279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128281. */
  128282. static ExtrudeShape(name: string, options: {
  128283. shape: Vector3[];
  128284. path: Vector3[];
  128285. scale?: number;
  128286. rotation?: number;
  128287. cap?: number;
  128288. updatable?: boolean;
  128289. sideOrientation?: number;
  128290. frontUVs?: Vector4;
  128291. backUVs?: Vector4;
  128292. instance?: Mesh;
  128293. invertUV?: boolean;
  128294. }, scene?: Nullable<Scene>): Mesh;
  128295. /**
  128296. * Creates an custom extruded shape mesh.
  128297. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128298. * * 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.
  128299. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128300. * * 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
  128301. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128302. * * 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
  128303. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128304. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128305. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128306. * * 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
  128307. * * 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
  128308. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128313. * @param name defines the name of the mesh
  128314. * @param options defines the options used to create the mesh
  128315. * @param scene defines the hosting scene
  128316. * @returns the custom extruded shape mesh
  128317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128320. */
  128321. static ExtrudeShapeCustom(name: string, options: {
  128322. shape: Vector3[];
  128323. path: Vector3[];
  128324. scaleFunction?: any;
  128325. rotationFunction?: any;
  128326. ribbonCloseArray?: boolean;
  128327. ribbonClosePath?: boolean;
  128328. cap?: number;
  128329. updatable?: boolean;
  128330. sideOrientation?: number;
  128331. frontUVs?: Vector4;
  128332. backUVs?: Vector4;
  128333. instance?: Mesh;
  128334. invertUV?: boolean;
  128335. }, scene?: Nullable<Scene>): Mesh;
  128336. private static _ExtrudeShapeGeneric;
  128337. }
  128338. }
  128339. declare module BABYLON {
  128340. /**
  128341. * AmmoJS Physics plugin
  128342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128343. * @see https://github.com/kripken/ammo.js/
  128344. */
  128345. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128346. private _useDeltaForWorldStep;
  128347. /**
  128348. * Reference to the Ammo library
  128349. */
  128350. bjsAMMO: any;
  128351. /**
  128352. * Created ammoJS world which physics bodies are added to
  128353. */
  128354. world: any;
  128355. /**
  128356. * Name of the plugin
  128357. */
  128358. name: string;
  128359. private _timeStep;
  128360. private _fixedTimeStep;
  128361. private _maxSteps;
  128362. private _tmpQuaternion;
  128363. private _tmpAmmoTransform;
  128364. private _tmpAmmoQuaternion;
  128365. private _tmpAmmoConcreteContactResultCallback;
  128366. private _collisionConfiguration;
  128367. private _dispatcher;
  128368. private _overlappingPairCache;
  128369. private _solver;
  128370. private _softBodySolver;
  128371. private _tmpAmmoVectorA;
  128372. private _tmpAmmoVectorB;
  128373. private _tmpAmmoVectorC;
  128374. private _tmpAmmoVectorD;
  128375. private _tmpContactCallbackResult;
  128376. private _tmpAmmoVectorRCA;
  128377. private _tmpAmmoVectorRCB;
  128378. private _raycastResult;
  128379. private static readonly DISABLE_COLLISION_FLAG;
  128380. private static readonly KINEMATIC_FLAG;
  128381. private static readonly DISABLE_DEACTIVATION_FLAG;
  128382. /**
  128383. * Initializes the ammoJS plugin
  128384. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128385. * @param ammoInjection can be used to inject your own ammo reference
  128386. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128387. */
  128388. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128389. /**
  128390. * Sets the gravity of the physics world (m/(s^2))
  128391. * @param gravity Gravity to set
  128392. */
  128393. setGravity(gravity: Vector3): void;
  128394. /**
  128395. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128396. * @param timeStep timestep to use in seconds
  128397. */
  128398. setTimeStep(timeStep: number): void;
  128399. /**
  128400. * 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)
  128401. * @param fixedTimeStep fixedTimeStep to use in seconds
  128402. */
  128403. setFixedTimeStep(fixedTimeStep: number): void;
  128404. /**
  128405. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128406. * @param maxSteps the maximum number of steps by the physics engine per frame
  128407. */
  128408. setMaxSteps(maxSteps: number): void;
  128409. /**
  128410. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128411. * @returns the current timestep in seconds
  128412. */
  128413. getTimeStep(): number;
  128414. /**
  128415. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128416. */
  128417. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128418. private _isImpostorInContact;
  128419. private _isImpostorPairInContact;
  128420. private _stepSimulation;
  128421. /**
  128422. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128423. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128424. * After the step the babylon meshes are set to the position of the physics imposters
  128425. * @param delta amount of time to step forward
  128426. * @param impostors array of imposters to update before/after the step
  128427. */
  128428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128429. /**
  128430. * Update babylon mesh to match physics world object
  128431. * @param impostor imposter to match
  128432. */
  128433. private _afterSoftStep;
  128434. /**
  128435. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128436. * @param impostor imposter to match
  128437. */
  128438. private _ropeStep;
  128439. /**
  128440. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128441. * @param impostor imposter to match
  128442. */
  128443. private _softbodyOrClothStep;
  128444. private _tmpVector;
  128445. private _tmpMatrix;
  128446. /**
  128447. * Applies an impulse on the imposter
  128448. * @param impostor imposter to apply impulse to
  128449. * @param force amount of force to be applied to the imposter
  128450. * @param contactPoint the location to apply the impulse on the imposter
  128451. */
  128452. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128453. /**
  128454. * Applies a force on the imposter
  128455. * @param impostor imposter to apply force
  128456. * @param force amount of force to be applied to the imposter
  128457. * @param contactPoint the location to apply the force on the imposter
  128458. */
  128459. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128460. /**
  128461. * Creates a physics body using the plugin
  128462. * @param impostor the imposter to create the physics body on
  128463. */
  128464. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128465. /**
  128466. * Removes the physics body from the imposter and disposes of the body's memory
  128467. * @param impostor imposter to remove the physics body from
  128468. */
  128469. removePhysicsBody(impostor: PhysicsImpostor): void;
  128470. /**
  128471. * Generates a joint
  128472. * @param impostorJoint the imposter joint to create the joint with
  128473. */
  128474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128475. /**
  128476. * Removes a joint
  128477. * @param impostorJoint the imposter joint to remove the joint from
  128478. */
  128479. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128480. private _addMeshVerts;
  128481. /**
  128482. * Initialise the soft body vertices to match its object's (mesh) vertices
  128483. * Softbody vertices (nodes) are in world space and to match this
  128484. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128485. * @param impostor to create the softbody for
  128486. */
  128487. private _softVertexData;
  128488. /**
  128489. * Create an impostor's soft body
  128490. * @param impostor to create the softbody for
  128491. */
  128492. private _createSoftbody;
  128493. /**
  128494. * Create cloth for an impostor
  128495. * @param impostor to create the softbody for
  128496. */
  128497. private _createCloth;
  128498. /**
  128499. * Create rope for an impostor
  128500. * @param impostor to create the softbody for
  128501. */
  128502. private _createRope;
  128503. /**
  128504. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128505. * @param impostor to create the custom physics shape for
  128506. */
  128507. private _createCustom;
  128508. private _addHullVerts;
  128509. private _createShape;
  128510. /**
  128511. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128512. * @param impostor imposter containing the physics body and babylon object
  128513. */
  128514. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128515. /**
  128516. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128517. * @param impostor imposter containing the physics body and babylon object
  128518. * @param newPosition new position
  128519. * @param newRotation new rotation
  128520. */
  128521. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128522. /**
  128523. * If this plugin is supported
  128524. * @returns true if its supported
  128525. */
  128526. isSupported(): boolean;
  128527. /**
  128528. * Sets the linear velocity of the physics body
  128529. * @param impostor imposter to set the velocity on
  128530. * @param velocity velocity to set
  128531. */
  128532. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128533. /**
  128534. * Sets the angular velocity of the physics body
  128535. * @param impostor imposter to set the velocity on
  128536. * @param velocity velocity to set
  128537. */
  128538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128539. /**
  128540. * gets the linear velocity
  128541. * @param impostor imposter to get linear velocity from
  128542. * @returns linear velocity
  128543. */
  128544. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128545. /**
  128546. * gets the angular velocity
  128547. * @param impostor imposter to get angular velocity from
  128548. * @returns angular velocity
  128549. */
  128550. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128551. /**
  128552. * Sets the mass of physics body
  128553. * @param impostor imposter to set the mass on
  128554. * @param mass mass to set
  128555. */
  128556. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128557. /**
  128558. * Gets the mass of the physics body
  128559. * @param impostor imposter to get the mass from
  128560. * @returns mass
  128561. */
  128562. getBodyMass(impostor: PhysicsImpostor): number;
  128563. /**
  128564. * Gets friction of the impostor
  128565. * @param impostor impostor to get friction from
  128566. * @returns friction value
  128567. */
  128568. getBodyFriction(impostor: PhysicsImpostor): number;
  128569. /**
  128570. * Sets friction of the impostor
  128571. * @param impostor impostor to set friction on
  128572. * @param friction friction value
  128573. */
  128574. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128575. /**
  128576. * Gets restitution of the impostor
  128577. * @param impostor impostor to get restitution from
  128578. * @returns restitution value
  128579. */
  128580. getBodyRestitution(impostor: PhysicsImpostor): number;
  128581. /**
  128582. * Sets resitution of the impostor
  128583. * @param impostor impostor to set resitution on
  128584. * @param restitution resitution value
  128585. */
  128586. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128587. /**
  128588. * Gets pressure inside the impostor
  128589. * @param impostor impostor to get pressure from
  128590. * @returns pressure value
  128591. */
  128592. getBodyPressure(impostor: PhysicsImpostor): number;
  128593. /**
  128594. * Sets pressure inside a soft body impostor
  128595. * Cloth and rope must remain 0 pressure
  128596. * @param impostor impostor to set pressure on
  128597. * @param pressure pressure value
  128598. */
  128599. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128600. /**
  128601. * Gets stiffness of the impostor
  128602. * @param impostor impostor to get stiffness from
  128603. * @returns pressure value
  128604. */
  128605. getBodyStiffness(impostor: PhysicsImpostor): number;
  128606. /**
  128607. * Sets stiffness of the impostor
  128608. * @param impostor impostor to set stiffness on
  128609. * @param stiffness stiffness value from 0 to 1
  128610. */
  128611. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128612. /**
  128613. * Gets velocityIterations of the impostor
  128614. * @param impostor impostor to get velocity iterations from
  128615. * @returns velocityIterations value
  128616. */
  128617. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128618. /**
  128619. * Sets velocityIterations of the impostor
  128620. * @param impostor impostor to set velocity iterations on
  128621. * @param velocityIterations velocityIterations value
  128622. */
  128623. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128624. /**
  128625. * Gets positionIterations of the impostor
  128626. * @param impostor impostor to get position iterations from
  128627. * @returns positionIterations value
  128628. */
  128629. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128630. /**
  128631. * Sets positionIterations of the impostor
  128632. * @param impostor impostor to set position on
  128633. * @param positionIterations positionIterations value
  128634. */
  128635. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128636. /**
  128637. * Append an anchor to a cloth object
  128638. * @param impostor is the cloth impostor to add anchor to
  128639. * @param otherImpostor is the rigid impostor to anchor to
  128640. * @param width ratio across width from 0 to 1
  128641. * @param height ratio up height from 0 to 1
  128642. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128643. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128644. */
  128645. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128646. /**
  128647. * Append an hook to a rope object
  128648. * @param impostor is the rope impostor to add hook to
  128649. * @param otherImpostor is the rigid impostor to hook to
  128650. * @param length ratio along the rope from 0 to 1
  128651. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128652. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128653. */
  128654. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128655. /**
  128656. * Sleeps the physics body and stops it from being active
  128657. * @param impostor impostor to sleep
  128658. */
  128659. sleepBody(impostor: PhysicsImpostor): void;
  128660. /**
  128661. * Activates the physics body
  128662. * @param impostor impostor to activate
  128663. */
  128664. wakeUpBody(impostor: PhysicsImpostor): void;
  128665. /**
  128666. * Updates the distance parameters of the joint
  128667. * @param joint joint to update
  128668. * @param maxDistance maximum distance of the joint
  128669. * @param minDistance minimum distance of the joint
  128670. */
  128671. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128672. /**
  128673. * Sets a motor on the joint
  128674. * @param joint joint to set motor on
  128675. * @param speed speed of the motor
  128676. * @param maxForce maximum force of the motor
  128677. * @param motorIndex index of the motor
  128678. */
  128679. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128680. /**
  128681. * Sets the motors limit
  128682. * @param joint joint to set limit on
  128683. * @param upperLimit upper limit
  128684. * @param lowerLimit lower limit
  128685. */
  128686. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128687. /**
  128688. * Syncs the position and rotation of a mesh with the impostor
  128689. * @param mesh mesh to sync
  128690. * @param impostor impostor to update the mesh with
  128691. */
  128692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128693. /**
  128694. * Gets the radius of the impostor
  128695. * @param impostor impostor to get radius from
  128696. * @returns the radius
  128697. */
  128698. getRadius(impostor: PhysicsImpostor): number;
  128699. /**
  128700. * Gets the box size of the impostor
  128701. * @param impostor impostor to get box size from
  128702. * @param result the resulting box size
  128703. */
  128704. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128705. /**
  128706. * Disposes of the impostor
  128707. */
  128708. dispose(): void;
  128709. /**
  128710. * Does a raycast in the physics world
  128711. * @param from when should the ray start?
  128712. * @param to when should the ray end?
  128713. * @returns PhysicsRaycastResult
  128714. */
  128715. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128716. }
  128717. }
  128718. declare module BABYLON {
  128719. interface AbstractScene {
  128720. /**
  128721. * The list of reflection probes added to the scene
  128722. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128723. */
  128724. reflectionProbes: Array<ReflectionProbe>;
  128725. /**
  128726. * Removes the given reflection probe from this scene.
  128727. * @param toRemove The reflection probe to remove
  128728. * @returns The index of the removed reflection probe
  128729. */
  128730. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128731. /**
  128732. * Adds the given reflection probe to this scene.
  128733. * @param newReflectionProbe The reflection probe to add
  128734. */
  128735. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128736. }
  128737. /**
  128738. * Class used to generate realtime reflection / refraction cube textures
  128739. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128740. */
  128741. export class ReflectionProbe {
  128742. /** defines the name of the probe */
  128743. name: string;
  128744. private _scene;
  128745. private _renderTargetTexture;
  128746. private _projectionMatrix;
  128747. private _viewMatrix;
  128748. private _target;
  128749. private _add;
  128750. private _attachedMesh;
  128751. private _invertYAxis;
  128752. /** Gets or sets probe position (center of the cube map) */
  128753. position: Vector3;
  128754. /**
  128755. * Creates a new reflection probe
  128756. * @param name defines the name of the probe
  128757. * @param size defines the texture resolution (for each face)
  128758. * @param scene defines the hosting scene
  128759. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128760. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128761. */
  128762. constructor(
  128763. /** defines the name of the probe */
  128764. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128765. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128766. get samples(): number;
  128767. set samples(value: number);
  128768. /** Gets or sets the refresh rate to use (on every frame by default) */
  128769. get refreshRate(): number;
  128770. set refreshRate(value: number);
  128771. /**
  128772. * Gets the hosting scene
  128773. * @returns a Scene
  128774. */
  128775. getScene(): Scene;
  128776. /** Gets the internal CubeTexture used to render to */
  128777. get cubeTexture(): RenderTargetTexture;
  128778. /** Gets the list of meshes to render */
  128779. get renderList(): Nullable<AbstractMesh[]>;
  128780. /**
  128781. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128782. * @param mesh defines the mesh to attach to
  128783. */
  128784. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128785. /**
  128786. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128787. * @param renderingGroupId The rendering group id corresponding to its index
  128788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128789. */
  128790. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128791. /**
  128792. * Clean all associated resources
  128793. */
  128794. dispose(): void;
  128795. /**
  128796. * Converts the reflection probe information to a readable string for debug purpose.
  128797. * @param fullDetails Supports for multiple levels of logging within scene loading
  128798. * @returns the human readable reflection probe info
  128799. */
  128800. toString(fullDetails?: boolean): string;
  128801. /**
  128802. * Get the class name of the relfection probe.
  128803. * @returns "ReflectionProbe"
  128804. */
  128805. getClassName(): string;
  128806. /**
  128807. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128808. * @returns The JSON representation of the texture
  128809. */
  128810. serialize(): any;
  128811. /**
  128812. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128813. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128814. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128815. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128816. * @returns The parsed reflection probe if successful
  128817. */
  128818. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128819. }
  128820. }
  128821. declare module BABYLON {
  128822. /** @hidden */
  128823. export var _BabylonLoaderRegistered: boolean;
  128824. /**
  128825. * Helps setting up some configuration for the babylon file loader.
  128826. */
  128827. export class BabylonFileLoaderConfiguration {
  128828. /**
  128829. * The loader does not allow injecting custom physix engine into the plugins.
  128830. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128831. * So you could set this variable to your engine import to make it work.
  128832. */
  128833. static LoaderInjectedPhysicsEngine: any;
  128834. }
  128835. }
  128836. declare module BABYLON {
  128837. /**
  128838. * The Physically based simple base material of BJS.
  128839. *
  128840. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128841. * It is used as the base class for both the specGloss and metalRough conventions.
  128842. */
  128843. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128844. /**
  128845. * Number of Simultaneous lights allowed on the material.
  128846. */
  128847. maxSimultaneousLights: number;
  128848. /**
  128849. * If sets to true, disables all the lights affecting the material.
  128850. */
  128851. disableLighting: boolean;
  128852. /**
  128853. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128854. */
  128855. environmentTexture: BaseTexture;
  128856. /**
  128857. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128858. */
  128859. invertNormalMapX: boolean;
  128860. /**
  128861. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128862. */
  128863. invertNormalMapY: boolean;
  128864. /**
  128865. * Normal map used in the model.
  128866. */
  128867. normalTexture: BaseTexture;
  128868. /**
  128869. * Emissivie color used to self-illuminate the model.
  128870. */
  128871. emissiveColor: Color3;
  128872. /**
  128873. * Emissivie texture used to self-illuminate the model.
  128874. */
  128875. emissiveTexture: BaseTexture;
  128876. /**
  128877. * Occlusion Channel Strenght.
  128878. */
  128879. occlusionStrength: number;
  128880. /**
  128881. * Occlusion Texture of the material (adding extra occlusion effects).
  128882. */
  128883. occlusionTexture: BaseTexture;
  128884. /**
  128885. * Defines the alpha limits in alpha test mode.
  128886. */
  128887. alphaCutOff: number;
  128888. /**
  128889. * Gets the current double sided mode.
  128890. */
  128891. get doubleSided(): boolean;
  128892. /**
  128893. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128894. */
  128895. set doubleSided(value: boolean);
  128896. /**
  128897. * Stores the pre-calculated light information of a mesh in a texture.
  128898. */
  128899. lightmapTexture: BaseTexture;
  128900. /**
  128901. * If true, the light map contains occlusion information instead of lighting info.
  128902. */
  128903. useLightmapAsShadowmap: boolean;
  128904. /**
  128905. * Instantiates a new PBRMaterial instance.
  128906. *
  128907. * @param name The material name
  128908. * @param scene The scene the material will be use in.
  128909. */
  128910. constructor(name: string, scene: Scene);
  128911. getClassName(): string;
  128912. }
  128913. }
  128914. declare module BABYLON {
  128915. /**
  128916. * The PBR material of BJS following the metal roughness convention.
  128917. *
  128918. * This fits to the PBR convention in the GLTF definition:
  128919. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128920. */
  128921. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128922. /**
  128923. * The base color has two different interpretations depending on the value of metalness.
  128924. * When the material is a metal, the base color is the specific measured reflectance value
  128925. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128926. * of the material.
  128927. */
  128928. baseColor: Color3;
  128929. /**
  128930. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128931. * well as opacity information in the alpha channel.
  128932. */
  128933. baseTexture: BaseTexture;
  128934. /**
  128935. * Specifies the metallic scalar value of the material.
  128936. * Can also be used to scale the metalness values of the metallic texture.
  128937. */
  128938. metallic: number;
  128939. /**
  128940. * Specifies the roughness scalar value of the material.
  128941. * Can also be used to scale the roughness values of the metallic texture.
  128942. */
  128943. roughness: number;
  128944. /**
  128945. * Texture containing both the metallic value in the B channel and the
  128946. * roughness value in the G channel to keep better precision.
  128947. */
  128948. metallicRoughnessTexture: BaseTexture;
  128949. /**
  128950. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128951. *
  128952. * @param name The material name
  128953. * @param scene The scene the material will be use in.
  128954. */
  128955. constructor(name: string, scene: Scene);
  128956. /**
  128957. * Return the currrent class name of the material.
  128958. */
  128959. getClassName(): string;
  128960. /**
  128961. * Makes a duplicate of the current material.
  128962. * @param name - name to use for the new material.
  128963. */
  128964. clone(name: string): PBRMetallicRoughnessMaterial;
  128965. /**
  128966. * Serialize the material to a parsable JSON object.
  128967. */
  128968. serialize(): any;
  128969. /**
  128970. * Parses a JSON object correponding to the serialize function.
  128971. */
  128972. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128973. }
  128974. }
  128975. declare module BABYLON {
  128976. /**
  128977. * The PBR material of BJS following the specular glossiness convention.
  128978. *
  128979. * This fits to the PBR convention in the GLTF definition:
  128980. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128981. */
  128982. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128983. /**
  128984. * Specifies the diffuse color of the material.
  128985. */
  128986. diffuseColor: Color3;
  128987. /**
  128988. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128989. * channel.
  128990. */
  128991. diffuseTexture: BaseTexture;
  128992. /**
  128993. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128994. */
  128995. specularColor: Color3;
  128996. /**
  128997. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128998. */
  128999. glossiness: number;
  129000. /**
  129001. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129002. */
  129003. specularGlossinessTexture: BaseTexture;
  129004. /**
  129005. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129006. *
  129007. * @param name The material name
  129008. * @param scene The scene the material will be use in.
  129009. */
  129010. constructor(name: string, scene: Scene);
  129011. /**
  129012. * Return the currrent class name of the material.
  129013. */
  129014. getClassName(): string;
  129015. /**
  129016. * Makes a duplicate of the current material.
  129017. * @param name - name to use for the new material.
  129018. */
  129019. clone(name: string): PBRSpecularGlossinessMaterial;
  129020. /**
  129021. * Serialize the material to a parsable JSON object.
  129022. */
  129023. serialize(): any;
  129024. /**
  129025. * Parses a JSON object correponding to the serialize function.
  129026. */
  129027. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129028. }
  129029. }
  129030. declare module BABYLON {
  129031. /**
  129032. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129033. * It can help converting any input color in a desired output one. This can then be used to create effects
  129034. * from sepia, black and white to sixties or futuristic rendering...
  129035. *
  129036. * The only supported format is currently 3dl.
  129037. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129038. */
  129039. export class ColorGradingTexture extends BaseTexture {
  129040. /**
  129041. * The current texture matrix. (will always be identity in color grading texture)
  129042. */
  129043. private _textureMatrix;
  129044. /**
  129045. * The texture URL.
  129046. */
  129047. url: string;
  129048. /**
  129049. * Empty line regex stored for GC.
  129050. */
  129051. private static _noneEmptyLineRegex;
  129052. private _engine;
  129053. /**
  129054. * Instantiates a ColorGradingTexture from the following parameters.
  129055. *
  129056. * @param url The location of the color gradind data (currently only supporting 3dl)
  129057. * @param scene The scene the texture will be used in
  129058. */
  129059. constructor(url: string, scene: Scene);
  129060. /**
  129061. * Returns the texture matrix used in most of the material.
  129062. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129063. */
  129064. getTextureMatrix(): Matrix;
  129065. /**
  129066. * Occurs when the file being loaded is a .3dl LUT file.
  129067. */
  129068. private load3dlTexture;
  129069. /**
  129070. * Starts the loading process of the texture.
  129071. */
  129072. private loadTexture;
  129073. /**
  129074. * Clones the color gradind texture.
  129075. */
  129076. clone(): ColorGradingTexture;
  129077. /**
  129078. * Called during delayed load for textures.
  129079. */
  129080. delayLoad(): void;
  129081. /**
  129082. * Parses a color grading texture serialized by Babylon.
  129083. * @param parsedTexture The texture information being parsedTexture
  129084. * @param scene The scene to load the texture in
  129085. * @param rootUrl The root url of the data assets to load
  129086. * @return A color gradind texture
  129087. */
  129088. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129089. /**
  129090. * Serializes the LUT texture to json format.
  129091. */
  129092. serialize(): any;
  129093. }
  129094. }
  129095. declare module BABYLON {
  129096. /**
  129097. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129098. */
  129099. export class EquiRectangularCubeTexture extends BaseTexture {
  129100. /** The six faces of the cube. */
  129101. private static _FacesMapping;
  129102. private _noMipmap;
  129103. private _onLoad;
  129104. private _onError;
  129105. /** The size of the cubemap. */
  129106. private _size;
  129107. /** The buffer of the image. */
  129108. private _buffer;
  129109. /** The width of the input image. */
  129110. private _width;
  129111. /** The height of the input image. */
  129112. private _height;
  129113. /** The URL to the image. */
  129114. url: string;
  129115. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129116. coordinatesMode: number;
  129117. /**
  129118. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129119. * @param url The location of the image
  129120. * @param scene The scene the texture will be used in
  129121. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129122. * @param noMipmap Forces to not generate the mipmap if true
  129123. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129124. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129125. * @param onLoad — defines a callback called when texture is loaded
  129126. * @param onError — defines a callback called if there is an error
  129127. */
  129128. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129129. /**
  129130. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129131. */
  129132. private loadImage;
  129133. /**
  129134. * Convert the image buffer into a cubemap and create a CubeTexture.
  129135. */
  129136. private loadTexture;
  129137. /**
  129138. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129139. * @param buffer The ArrayBuffer that should be converted.
  129140. * @returns The buffer as Float32Array.
  129141. */
  129142. private getFloat32ArrayFromArrayBuffer;
  129143. /**
  129144. * Get the current class name of the texture useful for serialization or dynamic coding.
  129145. * @returns "EquiRectangularCubeTexture"
  129146. */
  129147. getClassName(): string;
  129148. /**
  129149. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129150. * @returns A clone of the current EquiRectangularCubeTexture.
  129151. */
  129152. clone(): EquiRectangularCubeTexture;
  129153. }
  129154. }
  129155. declare module BABYLON {
  129156. /**
  129157. * Based on jsTGALoader - Javascript loader for TGA file
  129158. * By Vincent Thibault
  129159. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129160. */
  129161. export class TGATools {
  129162. private static _TYPE_INDEXED;
  129163. private static _TYPE_RGB;
  129164. private static _TYPE_GREY;
  129165. private static _TYPE_RLE_INDEXED;
  129166. private static _TYPE_RLE_RGB;
  129167. private static _TYPE_RLE_GREY;
  129168. private static _ORIGIN_MASK;
  129169. private static _ORIGIN_SHIFT;
  129170. private static _ORIGIN_BL;
  129171. private static _ORIGIN_BR;
  129172. private static _ORIGIN_UL;
  129173. private static _ORIGIN_UR;
  129174. /**
  129175. * Gets the header of a TGA file
  129176. * @param data defines the TGA data
  129177. * @returns the header
  129178. */
  129179. static GetTGAHeader(data: Uint8Array): any;
  129180. /**
  129181. * Uploads TGA content to a Babylon Texture
  129182. * @hidden
  129183. */
  129184. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129185. /** @hidden */
  129186. 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;
  129187. /** @hidden */
  129188. 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;
  129189. /** @hidden */
  129190. 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;
  129191. /** @hidden */
  129192. 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;
  129193. /** @hidden */
  129194. 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;
  129195. /** @hidden */
  129196. 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;
  129197. }
  129198. }
  129199. declare module BABYLON {
  129200. /**
  129201. * Implementation of the TGA Texture Loader.
  129202. * @hidden
  129203. */
  129204. export class _TGATextureLoader implements IInternalTextureLoader {
  129205. /**
  129206. * Defines wether the loader supports cascade loading the different faces.
  129207. */
  129208. readonly supportCascades: boolean;
  129209. /**
  129210. * This returns if the loader support the current file information.
  129211. * @param extension defines the file extension of the file being loaded
  129212. * @returns true if the loader can load the specified file
  129213. */
  129214. canLoad(extension: string): boolean;
  129215. /**
  129216. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129217. * @param data contains the texture data
  129218. * @param texture defines the BabylonJS internal texture
  129219. * @param createPolynomials will be true if polynomials have been requested
  129220. * @param onLoad defines the callback to trigger once the texture is ready
  129221. * @param onError defines the callback to trigger in case of error
  129222. */
  129223. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129224. /**
  129225. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129226. * @param data contains the texture data
  129227. * @param texture defines the BabylonJS internal texture
  129228. * @param callback defines the method to call once ready to upload
  129229. */
  129230. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129231. }
  129232. }
  129233. declare module BABYLON {
  129234. /**
  129235. * Info about the .basis files
  129236. */
  129237. class BasisFileInfo {
  129238. /**
  129239. * If the file has alpha
  129240. */
  129241. hasAlpha: boolean;
  129242. /**
  129243. * Info about each image of the basis file
  129244. */
  129245. images: Array<{
  129246. levels: Array<{
  129247. width: number;
  129248. height: number;
  129249. transcodedPixels: ArrayBufferView;
  129250. }>;
  129251. }>;
  129252. }
  129253. /**
  129254. * Result of transcoding a basis file
  129255. */
  129256. class TranscodeResult {
  129257. /**
  129258. * Info about the .basis file
  129259. */
  129260. fileInfo: BasisFileInfo;
  129261. /**
  129262. * Format to use when loading the file
  129263. */
  129264. format: number;
  129265. }
  129266. /**
  129267. * Configuration options for the Basis transcoder
  129268. */
  129269. export class BasisTranscodeConfiguration {
  129270. /**
  129271. * Supported compression formats used to determine the supported output format of the transcoder
  129272. */
  129273. supportedCompressionFormats?: {
  129274. /**
  129275. * etc1 compression format
  129276. */
  129277. etc1?: boolean;
  129278. /**
  129279. * s3tc compression format
  129280. */
  129281. s3tc?: boolean;
  129282. /**
  129283. * pvrtc compression format
  129284. */
  129285. pvrtc?: boolean;
  129286. /**
  129287. * etc2 compression format
  129288. */
  129289. etc2?: boolean;
  129290. };
  129291. /**
  129292. * If mipmap levels should be loaded for transcoded images (Default: true)
  129293. */
  129294. loadMipmapLevels?: boolean;
  129295. /**
  129296. * Index of a single image to load (Default: all images)
  129297. */
  129298. loadSingleImage?: number;
  129299. }
  129300. /**
  129301. * Used to load .Basis files
  129302. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129303. */
  129304. export class BasisTools {
  129305. private static _IgnoreSupportedFormats;
  129306. /**
  129307. * URL to use when loading the basis transcoder
  129308. */
  129309. static JSModuleURL: string;
  129310. /**
  129311. * URL to use when loading the wasm module for the transcoder
  129312. */
  129313. static WasmModuleURL: string;
  129314. /**
  129315. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129316. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129317. * @returns internal format corresponding to the Basis format
  129318. */
  129319. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129320. private static _WorkerPromise;
  129321. private static _Worker;
  129322. private static _actionId;
  129323. private static _CreateWorkerAsync;
  129324. /**
  129325. * Transcodes a loaded image file to compressed pixel data
  129326. * @param data image data to transcode
  129327. * @param config configuration options for the transcoding
  129328. * @returns a promise resulting in the transcoded image
  129329. */
  129330. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129331. /**
  129332. * Loads a texture from the transcode result
  129333. * @param texture texture load to
  129334. * @param transcodeResult the result of transcoding the basis file to load from
  129335. */
  129336. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129337. }
  129338. }
  129339. declare module BABYLON {
  129340. /**
  129341. * Loader for .basis file format
  129342. */
  129343. export class _BasisTextureLoader implements IInternalTextureLoader {
  129344. /**
  129345. * Defines whether the loader supports cascade loading the different faces.
  129346. */
  129347. readonly supportCascades: boolean;
  129348. /**
  129349. * This returns if the loader support the current file information.
  129350. * @param extension defines the file extension of the file being loaded
  129351. * @returns true if the loader can load the specified file
  129352. */
  129353. canLoad(extension: string): boolean;
  129354. /**
  129355. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129356. * @param data contains the texture data
  129357. * @param texture defines the BabylonJS internal texture
  129358. * @param createPolynomials will be true if polynomials have been requested
  129359. * @param onLoad defines the callback to trigger once the texture is ready
  129360. * @param onError defines the callback to trigger in case of error
  129361. */
  129362. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129363. /**
  129364. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129365. * @param data contains the texture data
  129366. * @param texture defines the BabylonJS internal texture
  129367. * @param callback defines the method to call once ready to upload
  129368. */
  129369. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129370. }
  129371. }
  129372. declare module BABYLON {
  129373. /**
  129374. * 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.
  129375. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129376. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129377. */
  129378. export class CustomProceduralTexture extends ProceduralTexture {
  129379. private _animate;
  129380. private _time;
  129381. private _config;
  129382. private _texturePath;
  129383. /**
  129384. * Instantiates a new Custom Procedural Texture.
  129385. * 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.
  129386. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129387. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129388. * @param name Define the name of the texture
  129389. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129390. * @param size Define the size of the texture to create
  129391. * @param scene Define the scene the texture belongs to
  129392. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129393. * @param generateMipMaps Define if the texture should creates mip maps or not
  129394. */
  129395. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129396. private _loadJson;
  129397. /**
  129398. * Is the texture ready to be used ? (rendered at least once)
  129399. * @returns true if ready, otherwise, false.
  129400. */
  129401. isReady(): boolean;
  129402. /**
  129403. * Render the texture to its associated render target.
  129404. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129405. */
  129406. render(useCameraPostProcess?: boolean): void;
  129407. /**
  129408. * Update the list of dependant textures samplers in the shader.
  129409. */
  129410. updateTextures(): void;
  129411. /**
  129412. * Update the uniform values of the procedural texture in the shader.
  129413. */
  129414. updateShaderUniforms(): void;
  129415. /**
  129416. * Define if the texture animates or not.
  129417. */
  129418. get animate(): boolean;
  129419. set animate(value: boolean);
  129420. }
  129421. }
  129422. declare module BABYLON {
  129423. /** @hidden */
  129424. export var noisePixelShader: {
  129425. name: string;
  129426. shader: string;
  129427. };
  129428. }
  129429. declare module BABYLON {
  129430. /**
  129431. * Class used to generate noise procedural textures
  129432. */
  129433. export class NoiseProceduralTexture extends ProceduralTexture {
  129434. private _time;
  129435. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129436. brightness: number;
  129437. /** Defines the number of octaves to process */
  129438. octaves: number;
  129439. /** Defines the level of persistence (0.8 by default) */
  129440. persistence: number;
  129441. /** Gets or sets animation speed factor (default is 1) */
  129442. animationSpeedFactor: number;
  129443. /**
  129444. * Creates a new NoiseProceduralTexture
  129445. * @param name defines the name fo the texture
  129446. * @param size defines the size of the texture (default is 256)
  129447. * @param scene defines the hosting scene
  129448. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129449. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129450. */
  129451. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129452. private _updateShaderUniforms;
  129453. protected _getDefines(): string;
  129454. /** Generate the current state of the procedural texture */
  129455. render(useCameraPostProcess?: boolean): void;
  129456. /**
  129457. * Serializes this noise procedural texture
  129458. * @returns a serialized noise procedural texture object
  129459. */
  129460. serialize(): any;
  129461. /**
  129462. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129463. * @param parsedTexture defines parsed texture data
  129464. * @param scene defines the current scene
  129465. * @param rootUrl defines the root URL containing noise procedural texture information
  129466. * @returns a parsed NoiseProceduralTexture
  129467. */
  129468. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129469. }
  129470. }
  129471. declare module BABYLON {
  129472. /**
  129473. * Raw cube texture where the raw buffers are passed in
  129474. */
  129475. export class RawCubeTexture extends CubeTexture {
  129476. /**
  129477. * Creates a cube texture where the raw buffers are passed in.
  129478. * @param scene defines the scene the texture is attached to
  129479. * @param data defines the array of data to use to create each face
  129480. * @param size defines the size of the textures
  129481. * @param format defines the format of the data
  129482. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129483. * @param generateMipMaps defines if the engine should generate the mip levels
  129484. * @param invertY defines if data must be stored with Y axis inverted
  129485. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129486. * @param compression defines the compression used (null by default)
  129487. */
  129488. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129489. /**
  129490. * Updates the raw cube texture.
  129491. * @param data defines the data to store
  129492. * @param format defines the data format
  129493. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129494. * @param invertY defines if data must be stored with Y axis inverted
  129495. * @param compression defines the compression used (null by default)
  129496. * @param level defines which level of the texture to update
  129497. */
  129498. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129499. /**
  129500. * Updates a raw cube texture with RGBD encoded data.
  129501. * @param data defines the array of data [mipmap][face] to use to create each face
  129502. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129505. * @returns a promsie that resolves when the operation is complete
  129506. */
  129507. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129508. /**
  129509. * Clones the raw cube texture.
  129510. * @return a new cube texture
  129511. */
  129512. clone(): CubeTexture;
  129513. /** @hidden */
  129514. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129515. }
  129516. }
  129517. declare module BABYLON {
  129518. /**
  129519. * Class used to store 3D textures containing user data
  129520. */
  129521. export class RawTexture3D extends Texture {
  129522. /** Gets or sets the texture format to use */
  129523. format: number;
  129524. private _engine;
  129525. /**
  129526. * Create a new RawTexture3D
  129527. * @param data defines the data of the texture
  129528. * @param width defines the width of the texture
  129529. * @param height defines the height of the texture
  129530. * @param depth defines the depth of the texture
  129531. * @param format defines the texture format to use
  129532. * @param scene defines the hosting scene
  129533. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129534. * @param invertY defines if texture must be stored with Y axis inverted
  129535. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129536. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129537. */
  129538. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129539. /** Gets or sets the texture format to use */
  129540. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129541. /**
  129542. * Update the texture with new data
  129543. * @param data defines the data to store in the texture
  129544. */
  129545. update(data: ArrayBufferView): void;
  129546. }
  129547. }
  129548. declare module BABYLON {
  129549. /**
  129550. * Class used to store 2D array textures containing user data
  129551. */
  129552. export class RawTexture2DArray extends Texture {
  129553. /** Gets or sets the texture format to use */
  129554. format: number;
  129555. private _engine;
  129556. /**
  129557. * Create a new RawTexture2DArray
  129558. * @param data defines the data of the texture
  129559. * @param width defines the width of the texture
  129560. * @param height defines the height of the texture
  129561. * @param depth defines the number of layers of the texture
  129562. * @param format defines the texture format to use
  129563. * @param scene defines the hosting scene
  129564. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129565. * @param invertY defines if texture must be stored with Y axis inverted
  129566. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129567. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129568. */
  129569. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129570. /** Gets or sets the texture format to use */
  129571. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129572. /**
  129573. * Update the texture with new data
  129574. * @param data defines the data to store in the texture
  129575. */
  129576. update(data: ArrayBufferView): void;
  129577. }
  129578. }
  129579. declare module BABYLON {
  129580. /**
  129581. * Creates a refraction texture used by refraction channel of the standard material.
  129582. * It is like a mirror but to see through a material.
  129583. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129584. */
  129585. export class RefractionTexture extends RenderTargetTexture {
  129586. /**
  129587. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129588. * 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.
  129589. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129590. */
  129591. refractionPlane: Plane;
  129592. /**
  129593. * Define how deep under the surface we should see.
  129594. */
  129595. depth: number;
  129596. /**
  129597. * Creates a refraction texture used by refraction channel of the standard material.
  129598. * It is like a mirror but to see through a material.
  129599. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129600. * @param name Define the texture name
  129601. * @param size Define the size of the underlying texture
  129602. * @param scene Define the scene the refraction belongs to
  129603. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129604. */
  129605. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129606. /**
  129607. * Clone the refraction texture.
  129608. * @returns the cloned texture
  129609. */
  129610. clone(): RefractionTexture;
  129611. /**
  129612. * Serialize the texture to a JSON representation you could use in Parse later on
  129613. * @returns the serialized JSON representation
  129614. */
  129615. serialize(): any;
  129616. }
  129617. }
  129618. declare module BABYLON {
  129619. /**
  129620. * Defines the options related to the creation of an HtmlElementTexture
  129621. */
  129622. export interface IHtmlElementTextureOptions {
  129623. /**
  129624. * Defines wether mip maps should be created or not.
  129625. */
  129626. generateMipMaps?: boolean;
  129627. /**
  129628. * Defines the sampling mode of the texture.
  129629. */
  129630. samplingMode?: number;
  129631. /**
  129632. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129633. */
  129634. engine: Nullable<ThinEngine>;
  129635. /**
  129636. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129637. */
  129638. scene: Nullable<Scene>;
  129639. }
  129640. /**
  129641. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129642. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129643. * is automatically managed.
  129644. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129645. * in your application.
  129646. *
  129647. * As the update is not automatic, you need to call them manually.
  129648. */
  129649. export class HtmlElementTexture extends BaseTexture {
  129650. /**
  129651. * The texture URL.
  129652. */
  129653. element: HTMLVideoElement | HTMLCanvasElement;
  129654. private static readonly DefaultOptions;
  129655. private _textureMatrix;
  129656. private _engine;
  129657. private _isVideo;
  129658. private _generateMipMaps;
  129659. private _samplingMode;
  129660. /**
  129661. * Instantiates a HtmlElementTexture from the following parameters.
  129662. *
  129663. * @param name Defines the name of the texture
  129664. * @param element Defines the video or canvas the texture is filled with
  129665. * @param options Defines the other none mandatory texture creation options
  129666. */
  129667. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129668. private _createInternalTexture;
  129669. /**
  129670. * Returns the texture matrix used in most of the material.
  129671. */
  129672. getTextureMatrix(): Matrix;
  129673. /**
  129674. * Updates the content of the texture.
  129675. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129676. */
  129677. update(invertY?: Nullable<boolean>): void;
  129678. }
  129679. }
  129680. declare module BABYLON {
  129681. /**
  129682. * Defines the basic options interface of a TexturePacker Frame
  129683. */
  129684. export interface ITexturePackerFrame {
  129685. /**
  129686. * The frame ID
  129687. */
  129688. id: number;
  129689. /**
  129690. * The frames Scale
  129691. */
  129692. scale: Vector2;
  129693. /**
  129694. * The Frames offset
  129695. */
  129696. offset: Vector2;
  129697. }
  129698. /**
  129699. * This is a support class for frame Data on texture packer sets.
  129700. */
  129701. export class TexturePackerFrame implements ITexturePackerFrame {
  129702. /**
  129703. * The frame ID
  129704. */
  129705. id: number;
  129706. /**
  129707. * The frames Scale
  129708. */
  129709. scale: Vector2;
  129710. /**
  129711. * The Frames offset
  129712. */
  129713. offset: Vector2;
  129714. /**
  129715. * Initializes a texture package frame.
  129716. * @param id The numerical frame identifier
  129717. * @param scale Scalar Vector2 for UV frame
  129718. * @param offset Vector2 for the frame position in UV units.
  129719. * @returns TexturePackerFrame
  129720. */
  129721. constructor(id: number, scale: Vector2, offset: Vector2);
  129722. }
  129723. }
  129724. declare module BABYLON {
  129725. /**
  129726. * Defines the basic options interface of a TexturePacker
  129727. */
  129728. export interface ITexturePackerOptions {
  129729. /**
  129730. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129731. */
  129732. map?: string[];
  129733. /**
  129734. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129735. */
  129736. uvsIn?: string;
  129737. /**
  129738. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129739. */
  129740. uvsOut?: string;
  129741. /**
  129742. * number representing the layout style. Defaults to LAYOUT_STRIP
  129743. */
  129744. layout?: number;
  129745. /**
  129746. * number of columns if using custom column count layout(2). This defaults to 4.
  129747. */
  129748. colnum?: number;
  129749. /**
  129750. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129751. */
  129752. updateInputMeshes?: boolean;
  129753. /**
  129754. * boolean flag to dispose all the source textures. Defaults to true.
  129755. */
  129756. disposeSources?: boolean;
  129757. /**
  129758. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129759. */
  129760. fillBlanks?: boolean;
  129761. /**
  129762. * string value representing the context fill style color. Defaults to 'black'.
  129763. */
  129764. customFillColor?: string;
  129765. /**
  129766. * Width and Height Value of each Frame in the TexturePacker Sets
  129767. */
  129768. frameSize?: number;
  129769. /**
  129770. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129771. */
  129772. paddingRatio?: number;
  129773. /**
  129774. * Number that declares the fill method for the padding gutter.
  129775. */
  129776. paddingMode?: number;
  129777. /**
  129778. * If in SUBUV_COLOR padding mode what color to use.
  129779. */
  129780. paddingColor?: Color3 | Color4;
  129781. }
  129782. /**
  129783. * Defines the basic interface of a TexturePacker JSON File
  129784. */
  129785. export interface ITexturePackerJSON {
  129786. /**
  129787. * The frame ID
  129788. */
  129789. name: string;
  129790. /**
  129791. * The base64 channel data
  129792. */
  129793. sets: any;
  129794. /**
  129795. * The options of the Packer
  129796. */
  129797. options: ITexturePackerOptions;
  129798. /**
  129799. * The frame data of the Packer
  129800. */
  129801. frames: Array<number>;
  129802. }
  129803. /**
  129804. * This is a support class that generates a series of packed texture sets.
  129805. * @see https://doc.babylonjs.com/babylon101/materials
  129806. */
  129807. export class TexturePacker {
  129808. /** Packer Layout Constant 0 */
  129809. static readonly LAYOUT_STRIP: number;
  129810. /** Packer Layout Constant 1 */
  129811. static readonly LAYOUT_POWER2: number;
  129812. /** Packer Layout Constant 2 */
  129813. static readonly LAYOUT_COLNUM: number;
  129814. /** Packer Layout Constant 0 */
  129815. static readonly SUBUV_WRAP: number;
  129816. /** Packer Layout Constant 1 */
  129817. static readonly SUBUV_EXTEND: number;
  129818. /** Packer Layout Constant 2 */
  129819. static readonly SUBUV_COLOR: number;
  129820. /** The Name of the Texture Package */
  129821. name: string;
  129822. /** The scene scope of the TexturePacker */
  129823. scene: Scene;
  129824. /** The Meshes to target */
  129825. meshes: AbstractMesh[];
  129826. /** Arguments passed with the Constructor */
  129827. options: ITexturePackerOptions;
  129828. /** The promise that is started upon initialization */
  129829. promise: Nullable<Promise<TexturePacker | string>>;
  129830. /** The Container object for the channel sets that are generated */
  129831. sets: object;
  129832. /** The Container array for the frames that are generated */
  129833. frames: TexturePackerFrame[];
  129834. /** The expected number of textures the system is parsing. */
  129835. private _expecting;
  129836. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129837. private _paddingValue;
  129838. /**
  129839. * Initializes a texture package series from an array of meshes or a single mesh.
  129840. * @param name The name of the package
  129841. * @param meshes The target meshes to compose the package from
  129842. * @param options The arguments that texture packer should follow while building.
  129843. * @param scene The scene which the textures are scoped to.
  129844. * @returns TexturePacker
  129845. */
  129846. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129847. /**
  129848. * Starts the package process
  129849. * @param resolve The promises resolution function
  129850. * @returns TexturePacker
  129851. */
  129852. private _createFrames;
  129853. /**
  129854. * Calculates the Size of the Channel Sets
  129855. * @returns Vector2
  129856. */
  129857. private _calculateSize;
  129858. /**
  129859. * Calculates the UV data for the frames.
  129860. * @param baseSize the base frameSize
  129861. * @param padding the base frame padding
  129862. * @param dtSize size of the Dynamic Texture for that channel
  129863. * @param dtUnits is 1/dtSize
  129864. * @param update flag to update the input meshes
  129865. */
  129866. private _calculateMeshUVFrames;
  129867. /**
  129868. * Calculates the frames Offset.
  129869. * @param index of the frame
  129870. * @returns Vector2
  129871. */
  129872. private _getFrameOffset;
  129873. /**
  129874. * Updates a Mesh to the frame data
  129875. * @param mesh that is the target
  129876. * @param frameID or the frame index
  129877. */
  129878. private _updateMeshUV;
  129879. /**
  129880. * Updates a Meshes materials to use the texture packer channels
  129881. * @param m is the mesh to target
  129882. * @param force all channels on the packer to be set.
  129883. */
  129884. private _updateTextureReferences;
  129885. /**
  129886. * Public method to set a Mesh to a frame
  129887. * @param m that is the target
  129888. * @param frameID or the frame index
  129889. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129890. */
  129891. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129892. /**
  129893. * Starts the async promise to compile the texture packer.
  129894. * @returns Promise<void>
  129895. */
  129896. processAsync(): Promise<void>;
  129897. /**
  129898. * Disposes all textures associated with this packer
  129899. */
  129900. dispose(): void;
  129901. /**
  129902. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129903. * @param imageType is the image type to use.
  129904. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129905. */
  129906. download(imageType?: string, quality?: number): void;
  129907. /**
  129908. * Public method to load a texturePacker JSON file.
  129909. * @param data of the JSON file in string format.
  129910. */
  129911. updateFromJSON(data: string): void;
  129912. }
  129913. }
  129914. declare module BABYLON {
  129915. /**
  129916. * Enum used to define the target of a block
  129917. */
  129918. export enum NodeMaterialBlockTargets {
  129919. /** Vertex shader */
  129920. Vertex = 1,
  129921. /** Fragment shader */
  129922. Fragment = 2,
  129923. /** Neutral */
  129924. Neutral = 4,
  129925. /** Vertex and Fragment */
  129926. VertexAndFragment = 3
  129927. }
  129928. }
  129929. declare module BABYLON {
  129930. /**
  129931. * Defines the kind of connection point for node based material
  129932. */
  129933. export enum NodeMaterialBlockConnectionPointTypes {
  129934. /** Float */
  129935. Float = 1,
  129936. /** Int */
  129937. Int = 2,
  129938. /** Vector2 */
  129939. Vector2 = 4,
  129940. /** Vector3 */
  129941. Vector3 = 8,
  129942. /** Vector4 */
  129943. Vector4 = 16,
  129944. /** Color3 */
  129945. Color3 = 32,
  129946. /** Color4 */
  129947. Color4 = 64,
  129948. /** Matrix */
  129949. Matrix = 128,
  129950. /** Detect type based on connection */
  129951. AutoDetect = 1024,
  129952. /** Output type that will be defined by input type */
  129953. BasedOnInput = 2048
  129954. }
  129955. }
  129956. declare module BABYLON {
  129957. /**
  129958. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129959. */
  129960. export enum NodeMaterialBlockConnectionPointMode {
  129961. /** Value is an uniform */
  129962. Uniform = 0,
  129963. /** Value is a mesh attribute */
  129964. Attribute = 1,
  129965. /** Value is a varying between vertex and fragment shaders */
  129966. Varying = 2,
  129967. /** Mode is undefined */
  129968. Undefined = 3
  129969. }
  129970. }
  129971. declare module BABYLON {
  129972. /**
  129973. * Enum used to define system values e.g. values automatically provided by the system
  129974. */
  129975. export enum NodeMaterialSystemValues {
  129976. /** World */
  129977. World = 1,
  129978. /** View */
  129979. View = 2,
  129980. /** Projection */
  129981. Projection = 3,
  129982. /** ViewProjection */
  129983. ViewProjection = 4,
  129984. /** WorldView */
  129985. WorldView = 5,
  129986. /** WorldViewProjection */
  129987. WorldViewProjection = 6,
  129988. /** CameraPosition */
  129989. CameraPosition = 7,
  129990. /** Fog Color */
  129991. FogColor = 8,
  129992. /** Delta time */
  129993. DeltaTime = 9
  129994. }
  129995. }
  129996. declare module BABYLON {
  129997. /**
  129998. * Root class for all node material optimizers
  129999. */
  130000. export class NodeMaterialOptimizer {
  130001. /**
  130002. * Function used to optimize a NodeMaterial graph
  130003. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130004. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130005. */
  130006. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130007. }
  130008. }
  130009. declare module BABYLON {
  130010. /**
  130011. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130012. */
  130013. export class TransformBlock extends NodeMaterialBlock {
  130014. /**
  130015. * Defines the value to use to complement W value to transform it to a Vector4
  130016. */
  130017. complementW: number;
  130018. /**
  130019. * Defines the value to use to complement z value to transform it to a Vector4
  130020. */
  130021. complementZ: number;
  130022. /**
  130023. * Creates a new TransformBlock
  130024. * @param name defines the block name
  130025. */
  130026. constructor(name: string);
  130027. /**
  130028. * Gets the current class name
  130029. * @returns the class name
  130030. */
  130031. getClassName(): string;
  130032. /**
  130033. * Gets the vector input
  130034. */
  130035. get vector(): NodeMaterialConnectionPoint;
  130036. /**
  130037. * Gets the output component
  130038. */
  130039. get output(): NodeMaterialConnectionPoint;
  130040. /**
  130041. * Gets the xyz output component
  130042. */
  130043. get xyz(): NodeMaterialConnectionPoint;
  130044. /**
  130045. * Gets the matrix transform input
  130046. */
  130047. get transform(): NodeMaterialConnectionPoint;
  130048. protected _buildBlock(state: NodeMaterialBuildState): this;
  130049. serialize(): any;
  130050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130051. protected _dumpPropertiesCode(): string;
  130052. }
  130053. }
  130054. declare module BABYLON {
  130055. /**
  130056. * Block used to output the vertex position
  130057. */
  130058. export class VertexOutputBlock extends NodeMaterialBlock {
  130059. /**
  130060. * Creates a new VertexOutputBlock
  130061. * @param name defines the block name
  130062. */
  130063. constructor(name: string);
  130064. /**
  130065. * Gets the current class name
  130066. * @returns the class name
  130067. */
  130068. getClassName(): string;
  130069. /**
  130070. * Gets the vector input component
  130071. */
  130072. get vector(): NodeMaterialConnectionPoint;
  130073. protected _buildBlock(state: NodeMaterialBuildState): this;
  130074. }
  130075. }
  130076. declare module BABYLON {
  130077. /**
  130078. * Block used to output the final color
  130079. */
  130080. export class FragmentOutputBlock extends NodeMaterialBlock {
  130081. /**
  130082. * Create a new FragmentOutputBlock
  130083. * @param name defines the block name
  130084. */
  130085. constructor(name: string);
  130086. /**
  130087. * Gets the current class name
  130088. * @returns the class name
  130089. */
  130090. getClassName(): string;
  130091. /**
  130092. * Gets the rgba input component
  130093. */
  130094. get rgba(): NodeMaterialConnectionPoint;
  130095. /**
  130096. * Gets the rgb input component
  130097. */
  130098. get rgb(): NodeMaterialConnectionPoint;
  130099. /**
  130100. * Gets the a input component
  130101. */
  130102. get a(): NodeMaterialConnectionPoint;
  130103. protected _buildBlock(state: NodeMaterialBuildState): this;
  130104. }
  130105. }
  130106. declare module BABYLON {
  130107. /**
  130108. * Block used to read a reflection texture from a sampler
  130109. */
  130110. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130111. private _define3DName;
  130112. private _defineCubicName;
  130113. private _defineExplicitName;
  130114. private _defineProjectionName;
  130115. private _defineLocalCubicName;
  130116. private _defineSphericalName;
  130117. private _definePlanarName;
  130118. private _defineEquirectangularName;
  130119. private _defineMirroredEquirectangularFixedName;
  130120. private _defineEquirectangularFixedName;
  130121. private _defineSkyboxName;
  130122. private _cubeSamplerName;
  130123. private _2DSamplerName;
  130124. private _positionUVWName;
  130125. private _directionWName;
  130126. private _reflectionCoordsName;
  130127. private _reflection2DCoordsName;
  130128. private _reflectionColorName;
  130129. private _reflectionMatrixName;
  130130. /**
  130131. * Gets or sets the texture associated with the node
  130132. */
  130133. texture: Nullable<BaseTexture>;
  130134. /**
  130135. * Create a new TextureBlock
  130136. * @param name defines the block name
  130137. */
  130138. constructor(name: string);
  130139. /**
  130140. * Gets the current class name
  130141. * @returns the class name
  130142. */
  130143. getClassName(): string;
  130144. /**
  130145. * Gets the world position input component
  130146. */
  130147. get position(): NodeMaterialConnectionPoint;
  130148. /**
  130149. * Gets the world position input component
  130150. */
  130151. get worldPosition(): NodeMaterialConnectionPoint;
  130152. /**
  130153. * Gets the world normal input component
  130154. */
  130155. get worldNormal(): NodeMaterialConnectionPoint;
  130156. /**
  130157. * Gets the world input component
  130158. */
  130159. get world(): NodeMaterialConnectionPoint;
  130160. /**
  130161. * Gets the camera (or eye) position component
  130162. */
  130163. get cameraPosition(): NodeMaterialConnectionPoint;
  130164. /**
  130165. * Gets the view input component
  130166. */
  130167. get view(): NodeMaterialConnectionPoint;
  130168. /**
  130169. * Gets the rgb output component
  130170. */
  130171. get rgb(): NodeMaterialConnectionPoint;
  130172. /**
  130173. * Gets the r output component
  130174. */
  130175. get r(): NodeMaterialConnectionPoint;
  130176. /**
  130177. * Gets the g output component
  130178. */
  130179. get g(): NodeMaterialConnectionPoint;
  130180. /**
  130181. * Gets the b output component
  130182. */
  130183. get b(): NodeMaterialConnectionPoint;
  130184. autoConfigure(material: NodeMaterial): void;
  130185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130186. isReady(): boolean;
  130187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130188. private _injectVertexCode;
  130189. private _writeOutput;
  130190. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130191. protected _dumpPropertiesCode(): string;
  130192. serialize(): any;
  130193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130194. }
  130195. }
  130196. declare module BABYLON {
  130197. /**
  130198. * Interface used to configure the node material editor
  130199. */
  130200. export interface INodeMaterialEditorOptions {
  130201. /** Define the URl to load node editor script */
  130202. editorURL?: string;
  130203. }
  130204. /** @hidden */
  130205. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130206. NORMAL: boolean;
  130207. TANGENT: boolean;
  130208. UV1: boolean;
  130209. /** BONES */
  130210. NUM_BONE_INFLUENCERS: number;
  130211. BonesPerMesh: number;
  130212. BONETEXTURE: boolean;
  130213. /** MORPH TARGETS */
  130214. MORPHTARGETS: boolean;
  130215. MORPHTARGETS_NORMAL: boolean;
  130216. MORPHTARGETS_TANGENT: boolean;
  130217. MORPHTARGETS_UV: boolean;
  130218. NUM_MORPH_INFLUENCERS: number;
  130219. /** IMAGE PROCESSING */
  130220. IMAGEPROCESSING: boolean;
  130221. VIGNETTE: boolean;
  130222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130223. VIGNETTEBLENDMODEOPAQUE: boolean;
  130224. TONEMAPPING: boolean;
  130225. TONEMAPPING_ACES: boolean;
  130226. CONTRAST: boolean;
  130227. EXPOSURE: boolean;
  130228. COLORCURVES: boolean;
  130229. COLORGRADING: boolean;
  130230. COLORGRADING3D: boolean;
  130231. SAMPLER3DGREENDEPTH: boolean;
  130232. SAMPLER3DBGRMAP: boolean;
  130233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130234. /** MISC. */
  130235. BUMPDIRECTUV: number;
  130236. constructor();
  130237. setValue(name: string, value: boolean): void;
  130238. }
  130239. /**
  130240. * Class used to configure NodeMaterial
  130241. */
  130242. export interface INodeMaterialOptions {
  130243. /**
  130244. * Defines if blocks should emit comments
  130245. */
  130246. emitComments: boolean;
  130247. }
  130248. /**
  130249. * Class used to create a node based material built by assembling shader blocks
  130250. */
  130251. export class NodeMaterial extends PushMaterial {
  130252. private static _BuildIdGenerator;
  130253. private _options;
  130254. private _vertexCompilationState;
  130255. private _fragmentCompilationState;
  130256. private _sharedData;
  130257. private _buildId;
  130258. private _buildWasSuccessful;
  130259. private _cachedWorldViewMatrix;
  130260. private _cachedWorldViewProjectionMatrix;
  130261. private _optimizers;
  130262. private _animationFrame;
  130263. /** Define the Url to load node editor script */
  130264. static EditorURL: string;
  130265. /** Define the Url to load snippets */
  130266. static SnippetUrl: string;
  130267. private BJSNODEMATERIALEDITOR;
  130268. /** Get the inspector from bundle or global */
  130269. private _getGlobalNodeMaterialEditor;
  130270. /**
  130271. * Gets or sets data used by visual editor
  130272. * @see https://nme.babylonjs.com
  130273. */
  130274. editorData: any;
  130275. /**
  130276. * 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)
  130277. */
  130278. ignoreAlpha: boolean;
  130279. /**
  130280. * Defines the maximum number of lights that can be used in the material
  130281. */
  130282. maxSimultaneousLights: number;
  130283. /**
  130284. * Observable raised when the material is built
  130285. */
  130286. onBuildObservable: Observable<NodeMaterial>;
  130287. /**
  130288. * Gets or sets the root nodes of the material vertex shader
  130289. */
  130290. _vertexOutputNodes: NodeMaterialBlock[];
  130291. /**
  130292. * Gets or sets the root nodes of the material fragment (pixel) shader
  130293. */
  130294. _fragmentOutputNodes: NodeMaterialBlock[];
  130295. /** Gets or sets options to control the node material overall behavior */
  130296. get options(): INodeMaterialOptions;
  130297. set options(options: INodeMaterialOptions);
  130298. /**
  130299. * Default configuration related to image processing available in the standard Material.
  130300. */
  130301. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130302. /**
  130303. * Gets the image processing configuration used either in this material.
  130304. */
  130305. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130306. /**
  130307. * Sets the Default image processing configuration used either in the this material.
  130308. *
  130309. * If sets to null, the scene one is in use.
  130310. */
  130311. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130312. /**
  130313. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130314. */
  130315. attachedBlocks: NodeMaterialBlock[];
  130316. /**
  130317. * Create a new node based material
  130318. * @param name defines the material name
  130319. * @param scene defines the hosting scene
  130320. * @param options defines creation option
  130321. */
  130322. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130323. /**
  130324. * Gets the current class name of the material e.g. "NodeMaterial"
  130325. * @returns the class name
  130326. */
  130327. getClassName(): string;
  130328. /**
  130329. * Keep track of the image processing observer to allow dispose and replace.
  130330. */
  130331. private _imageProcessingObserver;
  130332. /**
  130333. * Attaches a new image processing configuration to the Standard Material.
  130334. * @param configuration
  130335. */
  130336. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130337. /**
  130338. * Get a block by its name
  130339. * @param name defines the name of the block to retrieve
  130340. * @returns the required block or null if not found
  130341. */
  130342. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130343. /**
  130344. * Get a block by its name
  130345. * @param predicate defines the predicate used to find the good candidate
  130346. * @returns the required block or null if not found
  130347. */
  130348. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130349. /**
  130350. * Get an input block by its name
  130351. * @param predicate defines the predicate used to find the good candidate
  130352. * @returns the required input block or null if not found
  130353. */
  130354. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130355. /**
  130356. * Gets the list of input blocks attached to this material
  130357. * @returns an array of InputBlocks
  130358. */
  130359. getInputBlocks(): InputBlock[];
  130360. /**
  130361. * Adds a new optimizer to the list of optimizers
  130362. * @param optimizer defines the optimizers to add
  130363. * @returns the current material
  130364. */
  130365. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130366. /**
  130367. * Remove an optimizer from the list of optimizers
  130368. * @param optimizer defines the optimizers to remove
  130369. * @returns the current material
  130370. */
  130371. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130372. /**
  130373. * Add a new block to the list of output nodes
  130374. * @param node defines the node to add
  130375. * @returns the current material
  130376. */
  130377. addOutputNode(node: NodeMaterialBlock): this;
  130378. /**
  130379. * Remove a block from the list of root nodes
  130380. * @param node defines the node to remove
  130381. * @returns the current material
  130382. */
  130383. removeOutputNode(node: NodeMaterialBlock): this;
  130384. private _addVertexOutputNode;
  130385. private _removeVertexOutputNode;
  130386. private _addFragmentOutputNode;
  130387. private _removeFragmentOutputNode;
  130388. /**
  130389. * Specifies if the material will require alpha blending
  130390. * @returns a boolean specifying if alpha blending is needed
  130391. */
  130392. needAlphaBlending(): boolean;
  130393. /**
  130394. * Specifies if this material should be rendered in alpha test mode
  130395. * @returns a boolean specifying if an alpha test is needed.
  130396. */
  130397. needAlphaTesting(): boolean;
  130398. private _initializeBlock;
  130399. private _resetDualBlocks;
  130400. /**
  130401. * Remove a block from the current node material
  130402. * @param block defines the block to remove
  130403. */
  130404. removeBlock(block: NodeMaterialBlock): void;
  130405. /**
  130406. * Build the material and generates the inner effect
  130407. * @param verbose defines if the build should log activity
  130408. */
  130409. build(verbose?: boolean): void;
  130410. /**
  130411. * Runs an otpimization phase to try to improve the shader code
  130412. */
  130413. optimize(): void;
  130414. private _prepareDefinesForAttributes;
  130415. /**
  130416. * Get if the submesh is ready to be used and all its information available.
  130417. * Child classes can use it to update shaders
  130418. * @param mesh defines the mesh to check
  130419. * @param subMesh defines which submesh to check
  130420. * @param useInstances specifies that instances should be used
  130421. * @returns a boolean indicating that the submesh is ready or not
  130422. */
  130423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130424. /**
  130425. * Get a string representing the shaders built by the current node graph
  130426. */
  130427. get compiledShaders(): string;
  130428. /**
  130429. * Binds the world matrix to the material
  130430. * @param world defines the world transformation matrix
  130431. */
  130432. bindOnlyWorldMatrix(world: Matrix): void;
  130433. /**
  130434. * Binds the submesh to this material by preparing the effect and shader to draw
  130435. * @param world defines the world transformation matrix
  130436. * @param mesh defines the mesh containing the submesh
  130437. * @param subMesh defines the submesh to bind the material to
  130438. */
  130439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130440. /**
  130441. * Gets the active textures from the material
  130442. * @returns an array of textures
  130443. */
  130444. getActiveTextures(): BaseTexture[];
  130445. /**
  130446. * Gets the list of texture blocks
  130447. * @returns an array of texture blocks
  130448. */
  130449. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130450. /**
  130451. * Specifies if the material uses a texture
  130452. * @param texture defines the texture to check against the material
  130453. * @returns a boolean specifying if the material uses the texture
  130454. */
  130455. hasTexture(texture: BaseTexture): boolean;
  130456. /**
  130457. * Disposes the material
  130458. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130459. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130460. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130461. */
  130462. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130463. /** Creates the node editor window. */
  130464. private _createNodeEditor;
  130465. /**
  130466. * Launch the node material editor
  130467. * @param config Define the configuration of the editor
  130468. * @return a promise fulfilled when the node editor is visible
  130469. */
  130470. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130471. /**
  130472. * Clear the current material
  130473. */
  130474. clear(): void;
  130475. /**
  130476. * Clear the current material and set it to a default state
  130477. */
  130478. setToDefault(): void;
  130479. /**
  130480. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130481. * @param url defines the url to load from
  130482. * @returns a promise that will fullfil when the material is fully loaded
  130483. */
  130484. loadAsync(url: string): Promise<void>;
  130485. private _gatherBlocks;
  130486. /**
  130487. * Generate a string containing the code declaration required to create an equivalent of this material
  130488. * @returns a string
  130489. */
  130490. generateCode(): string;
  130491. /**
  130492. * Serializes this material in a JSON representation
  130493. * @returns the serialized material object
  130494. */
  130495. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130496. private _restoreConnections;
  130497. /**
  130498. * Clear the current graph and load a new one from a serialization object
  130499. * @param source defines the JSON representation of the material
  130500. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130501. */
  130502. loadFromSerialization(source: any, rootUrl?: string): void;
  130503. /**
  130504. * Creates a node material from parsed material data
  130505. * @param source defines the JSON representation of the material
  130506. * @param scene defines the hosting scene
  130507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130508. * @returns a new node material
  130509. */
  130510. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130511. /**
  130512. * Creates a node material from a snippet saved in a remote file
  130513. * @param name defines the name of the material to create
  130514. * @param url defines the url to load from
  130515. * @param scene defines the hosting scene
  130516. * @returns a promise that will resolve to the new node material
  130517. */
  130518. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130519. /**
  130520. * Creates a node material from a snippet saved by the node material editor
  130521. * @param snippetId defines the snippet to load
  130522. * @param scene defines the hosting scene
  130523. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130524. * @returns a promise that will resolve to the new node material
  130525. */
  130526. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130527. /**
  130528. * Creates a new node material set to default basic configuration
  130529. * @param name defines the name of the material
  130530. * @param scene defines the hosting scene
  130531. * @returns a new NodeMaterial
  130532. */
  130533. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130534. }
  130535. }
  130536. declare module BABYLON {
  130537. /**
  130538. * Block used to read a texture from a sampler
  130539. */
  130540. export class TextureBlock extends NodeMaterialBlock {
  130541. private _defineName;
  130542. private _linearDefineName;
  130543. private _tempTextureRead;
  130544. private _samplerName;
  130545. private _transformedUVName;
  130546. private _textureTransformName;
  130547. private _textureInfoName;
  130548. private _mainUVName;
  130549. private _mainUVDefineName;
  130550. /**
  130551. * Gets or sets the texture associated with the node
  130552. */
  130553. texture: Nullable<Texture>;
  130554. /**
  130555. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130556. */
  130557. convertToGammaSpace: boolean;
  130558. /**
  130559. * Create a new TextureBlock
  130560. * @param name defines the block name
  130561. */
  130562. constructor(name: string);
  130563. /**
  130564. * Gets the current class name
  130565. * @returns the class name
  130566. */
  130567. getClassName(): string;
  130568. /**
  130569. * Gets the uv input component
  130570. */
  130571. get uv(): NodeMaterialConnectionPoint;
  130572. /**
  130573. * Gets the rgba output component
  130574. */
  130575. get rgba(): NodeMaterialConnectionPoint;
  130576. /**
  130577. * Gets the rgb output component
  130578. */
  130579. get rgb(): NodeMaterialConnectionPoint;
  130580. /**
  130581. * Gets the r output component
  130582. */
  130583. get r(): NodeMaterialConnectionPoint;
  130584. /**
  130585. * Gets the g output component
  130586. */
  130587. get g(): NodeMaterialConnectionPoint;
  130588. /**
  130589. * Gets the b output component
  130590. */
  130591. get b(): NodeMaterialConnectionPoint;
  130592. /**
  130593. * Gets the a output component
  130594. */
  130595. get a(): NodeMaterialConnectionPoint;
  130596. get target(): NodeMaterialBlockTargets;
  130597. autoConfigure(material: NodeMaterial): void;
  130598. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130600. isReady(): boolean;
  130601. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130602. private get _isMixed();
  130603. private _injectVertexCode;
  130604. private _writeTextureRead;
  130605. private _writeOutput;
  130606. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130607. protected _dumpPropertiesCode(): string;
  130608. serialize(): any;
  130609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130610. }
  130611. }
  130612. declare module BABYLON {
  130613. /**
  130614. * Class used to store shared data between 2 NodeMaterialBuildState
  130615. */
  130616. export class NodeMaterialBuildStateSharedData {
  130617. /**
  130618. * Gets the list of emitted varyings
  130619. */
  130620. temps: string[];
  130621. /**
  130622. * Gets the list of emitted varyings
  130623. */
  130624. varyings: string[];
  130625. /**
  130626. * Gets the varying declaration string
  130627. */
  130628. varyingDeclaration: string;
  130629. /**
  130630. * Input blocks
  130631. */
  130632. inputBlocks: InputBlock[];
  130633. /**
  130634. * Input blocks
  130635. */
  130636. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130637. /**
  130638. * Bindable blocks (Blocks that need to set data to the effect)
  130639. */
  130640. bindableBlocks: NodeMaterialBlock[];
  130641. /**
  130642. * List of blocks that can provide a compilation fallback
  130643. */
  130644. blocksWithFallbacks: NodeMaterialBlock[];
  130645. /**
  130646. * List of blocks that can provide a define update
  130647. */
  130648. blocksWithDefines: NodeMaterialBlock[];
  130649. /**
  130650. * List of blocks that can provide a repeatable content
  130651. */
  130652. repeatableContentBlocks: NodeMaterialBlock[];
  130653. /**
  130654. * List of blocks that can provide a dynamic list of uniforms
  130655. */
  130656. dynamicUniformBlocks: NodeMaterialBlock[];
  130657. /**
  130658. * List of blocks that can block the isReady function for the material
  130659. */
  130660. blockingBlocks: NodeMaterialBlock[];
  130661. /**
  130662. * Gets the list of animated inputs
  130663. */
  130664. animatedInputs: InputBlock[];
  130665. /**
  130666. * Build Id used to avoid multiple recompilations
  130667. */
  130668. buildId: number;
  130669. /** List of emitted variables */
  130670. variableNames: {
  130671. [key: string]: number;
  130672. };
  130673. /** List of emitted defines */
  130674. defineNames: {
  130675. [key: string]: number;
  130676. };
  130677. /** Should emit comments? */
  130678. emitComments: boolean;
  130679. /** Emit build activity */
  130680. verbose: boolean;
  130681. /** Gets or sets the hosting scene */
  130682. scene: Scene;
  130683. /**
  130684. * Gets the compilation hints emitted at compilation time
  130685. */
  130686. hints: {
  130687. needWorldViewMatrix: boolean;
  130688. needWorldViewProjectionMatrix: boolean;
  130689. needAlphaBlending: boolean;
  130690. needAlphaTesting: boolean;
  130691. };
  130692. /**
  130693. * List of compilation checks
  130694. */
  130695. checks: {
  130696. emitVertex: boolean;
  130697. emitFragment: boolean;
  130698. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130699. };
  130700. /** Creates a new shared data */
  130701. constructor();
  130702. /**
  130703. * Emits console errors and exceptions if there is a failing check
  130704. */
  130705. emitErrors(): void;
  130706. }
  130707. }
  130708. declare module BABYLON {
  130709. /**
  130710. * Class used to store node based material build state
  130711. */
  130712. export class NodeMaterialBuildState {
  130713. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130714. supportUniformBuffers: boolean;
  130715. /**
  130716. * Gets the list of emitted attributes
  130717. */
  130718. attributes: string[];
  130719. /**
  130720. * Gets the list of emitted uniforms
  130721. */
  130722. uniforms: string[];
  130723. /**
  130724. * Gets the list of emitted constants
  130725. */
  130726. constants: string[];
  130727. /**
  130728. * Gets the list of emitted samplers
  130729. */
  130730. samplers: string[];
  130731. /**
  130732. * Gets the list of emitted functions
  130733. */
  130734. functions: {
  130735. [key: string]: string;
  130736. };
  130737. /**
  130738. * Gets the list of emitted extensions
  130739. */
  130740. extensions: {
  130741. [key: string]: string;
  130742. };
  130743. /**
  130744. * Gets the target of the compilation state
  130745. */
  130746. target: NodeMaterialBlockTargets;
  130747. /**
  130748. * Gets the list of emitted counters
  130749. */
  130750. counters: {
  130751. [key: string]: number;
  130752. };
  130753. /**
  130754. * Shared data between multiple NodeMaterialBuildState instances
  130755. */
  130756. sharedData: NodeMaterialBuildStateSharedData;
  130757. /** @hidden */
  130758. _vertexState: NodeMaterialBuildState;
  130759. /** @hidden */
  130760. _attributeDeclaration: string;
  130761. /** @hidden */
  130762. _uniformDeclaration: string;
  130763. /** @hidden */
  130764. _constantDeclaration: string;
  130765. /** @hidden */
  130766. _samplerDeclaration: string;
  130767. /** @hidden */
  130768. _varyingTransfer: string;
  130769. private _repeatableContentAnchorIndex;
  130770. /** @hidden */
  130771. _builtCompilationString: string;
  130772. /**
  130773. * Gets the emitted compilation strings
  130774. */
  130775. compilationString: string;
  130776. /**
  130777. * Finalize the compilation strings
  130778. * @param state defines the current compilation state
  130779. */
  130780. finalize(state: NodeMaterialBuildState): void;
  130781. /** @hidden */
  130782. get _repeatableContentAnchor(): string;
  130783. /** @hidden */
  130784. _getFreeVariableName(prefix: string): string;
  130785. /** @hidden */
  130786. _getFreeDefineName(prefix: string): string;
  130787. /** @hidden */
  130788. _excludeVariableName(name: string): void;
  130789. /** @hidden */
  130790. _emit2DSampler(name: string): void;
  130791. /** @hidden */
  130792. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130793. /** @hidden */
  130794. _emitExtension(name: string, extension: string): void;
  130795. /** @hidden */
  130796. _emitFunction(name: string, code: string, comments: string): void;
  130797. /** @hidden */
  130798. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130799. replaceStrings?: {
  130800. search: RegExp;
  130801. replace: string;
  130802. }[];
  130803. repeatKey?: string;
  130804. }): string;
  130805. /** @hidden */
  130806. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130807. repeatKey?: string;
  130808. removeAttributes?: boolean;
  130809. removeUniforms?: boolean;
  130810. removeVaryings?: boolean;
  130811. removeIfDef?: boolean;
  130812. replaceStrings?: {
  130813. search: RegExp;
  130814. replace: string;
  130815. }[];
  130816. }, storeKey?: string): void;
  130817. /** @hidden */
  130818. _registerTempVariable(name: string): boolean;
  130819. /** @hidden */
  130820. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130821. /** @hidden */
  130822. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130823. /** @hidden */
  130824. _emitFloat(value: number): string;
  130825. }
  130826. }
  130827. declare module BABYLON {
  130828. /**
  130829. * Defines a block that can be used inside a node based material
  130830. */
  130831. export class NodeMaterialBlock {
  130832. private _buildId;
  130833. private _buildTarget;
  130834. private _target;
  130835. private _isFinalMerger;
  130836. private _isInput;
  130837. protected _isUnique: boolean;
  130838. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130839. inputsAreExclusive: boolean;
  130840. /** @hidden */
  130841. _codeVariableName: string;
  130842. /** @hidden */
  130843. _inputs: NodeMaterialConnectionPoint[];
  130844. /** @hidden */
  130845. _outputs: NodeMaterialConnectionPoint[];
  130846. /** @hidden */
  130847. _preparationId: number;
  130848. /**
  130849. * Gets or sets the name of the block
  130850. */
  130851. name: string;
  130852. /**
  130853. * Gets or sets the unique id of the node
  130854. */
  130855. uniqueId: number;
  130856. /**
  130857. * Gets or sets the comments associated with this block
  130858. */
  130859. comments: string;
  130860. /**
  130861. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130862. */
  130863. get isUnique(): boolean;
  130864. /**
  130865. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130866. */
  130867. get isFinalMerger(): boolean;
  130868. /**
  130869. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130870. */
  130871. get isInput(): boolean;
  130872. /**
  130873. * Gets or sets the build Id
  130874. */
  130875. get buildId(): number;
  130876. set buildId(value: number);
  130877. /**
  130878. * Gets or sets the target of the block
  130879. */
  130880. get target(): NodeMaterialBlockTargets;
  130881. set target(value: NodeMaterialBlockTargets);
  130882. /**
  130883. * Gets the list of input points
  130884. */
  130885. get inputs(): NodeMaterialConnectionPoint[];
  130886. /** Gets the list of output points */
  130887. get outputs(): NodeMaterialConnectionPoint[];
  130888. /**
  130889. * Find an input by its name
  130890. * @param name defines the name of the input to look for
  130891. * @returns the input or null if not found
  130892. */
  130893. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130894. /**
  130895. * Find an output by its name
  130896. * @param name defines the name of the outputto look for
  130897. * @returns the output or null if not found
  130898. */
  130899. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130900. /**
  130901. * Creates a new NodeMaterialBlock
  130902. * @param name defines the block name
  130903. * @param target defines the target of that block (Vertex by default)
  130904. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130905. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130906. */
  130907. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130908. /**
  130909. * Initialize the block and prepare the context for build
  130910. * @param state defines the state that will be used for the build
  130911. */
  130912. initialize(state: NodeMaterialBuildState): void;
  130913. /**
  130914. * Bind data to effect. Will only be called for blocks with isBindable === true
  130915. * @param effect defines the effect to bind data to
  130916. * @param nodeMaterial defines the hosting NodeMaterial
  130917. * @param mesh defines the mesh that will be rendered
  130918. */
  130919. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130920. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130921. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130922. protected _writeFloat(value: number): string;
  130923. /**
  130924. * Gets the current class name e.g. "NodeMaterialBlock"
  130925. * @returns the class name
  130926. */
  130927. getClassName(): string;
  130928. /**
  130929. * Register a new input. Must be called inside a block constructor
  130930. * @param name defines the connection point name
  130931. * @param type defines the connection point type
  130932. * @param isOptional defines a boolean indicating that this input can be omitted
  130933. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130934. * @returns the current block
  130935. */
  130936. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130937. /**
  130938. * Register a new output. Must be called inside a block constructor
  130939. * @param name defines the connection point name
  130940. * @param type defines the connection point type
  130941. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130942. * @returns the current block
  130943. */
  130944. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130945. /**
  130946. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130947. * @param forOutput defines an optional connection point to check compatibility with
  130948. * @returns the first available input or null
  130949. */
  130950. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130951. /**
  130952. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130953. * @param forBlock defines an optional block to check compatibility with
  130954. * @returns the first available input or null
  130955. */
  130956. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130957. /**
  130958. * Gets the sibling of the given output
  130959. * @param current defines the current output
  130960. * @returns the next output in the list or null
  130961. */
  130962. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130963. /**
  130964. * Connect current block with another block
  130965. * @param other defines the block to connect with
  130966. * @param options define the various options to help pick the right connections
  130967. * @returns the current block
  130968. */
  130969. connectTo(other: NodeMaterialBlock, options?: {
  130970. input?: string;
  130971. output?: string;
  130972. outputSwizzle?: string;
  130973. }): this | undefined;
  130974. protected _buildBlock(state: NodeMaterialBuildState): void;
  130975. /**
  130976. * Add uniforms, samplers and uniform buffers at compilation time
  130977. * @param state defines the state to update
  130978. * @param nodeMaterial defines the node material requesting the update
  130979. * @param defines defines the material defines to update
  130980. * @param uniformBuffers defines the list of uniform buffer names
  130981. */
  130982. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130983. /**
  130984. * Add potential fallbacks if shader compilation fails
  130985. * @param mesh defines the mesh to be rendered
  130986. * @param fallbacks defines the current prioritized list of fallbacks
  130987. */
  130988. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130989. /**
  130990. * Initialize defines for shader compilation
  130991. * @param mesh defines the mesh to be rendered
  130992. * @param nodeMaterial defines the node material requesting the update
  130993. * @param defines defines the material defines to update
  130994. * @param useInstances specifies that instances should be used
  130995. */
  130996. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130997. /**
  130998. * Update defines for shader compilation
  130999. * @param mesh defines the mesh to be rendered
  131000. * @param nodeMaterial defines the node material requesting the update
  131001. * @param defines defines the material defines to update
  131002. * @param useInstances specifies that instances should be used
  131003. */
  131004. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131005. /**
  131006. * Lets the block try to connect some inputs automatically
  131007. * @param material defines the hosting NodeMaterial
  131008. */
  131009. autoConfigure(material: NodeMaterial): void;
  131010. /**
  131011. * Function called when a block is declared as repeatable content generator
  131012. * @param vertexShaderState defines the current compilation state for the vertex shader
  131013. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131014. * @param mesh defines the mesh to be rendered
  131015. * @param defines defines the material defines to update
  131016. */
  131017. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131018. /**
  131019. * Checks if the block is ready
  131020. * @param mesh defines the mesh to be rendered
  131021. * @param nodeMaterial defines the node material requesting the update
  131022. * @param defines defines the material defines to update
  131023. * @param useInstances specifies that instances should be used
  131024. * @returns true if the block is ready
  131025. */
  131026. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131027. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131028. private _processBuild;
  131029. /**
  131030. * Compile the current node and generate the shader code
  131031. * @param state defines the current compilation state (uniforms, samplers, current string)
  131032. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131033. * @returns true if already built
  131034. */
  131035. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131036. protected _inputRename(name: string): string;
  131037. protected _outputRename(name: string): string;
  131038. protected _dumpPropertiesCode(): string;
  131039. /** @hidden */
  131040. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131041. /** @hidden */
  131042. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131043. /**
  131044. * Clone the current block to a new identical block
  131045. * @param scene defines the hosting scene
  131046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131047. * @returns a copy of the current block
  131048. */
  131049. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131050. /**
  131051. * Serializes this block in a JSON representation
  131052. * @returns the serialized block object
  131053. */
  131054. serialize(): any;
  131055. /** @hidden */
  131056. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131057. /**
  131058. * Release resources
  131059. */
  131060. dispose(): void;
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * Enum defining the type of animations supported by InputBlock
  131066. */
  131067. export enum AnimatedInputBlockTypes {
  131068. /** No animation */
  131069. None = 0,
  131070. /** Time based animation. Will only work for floats */
  131071. Time = 1
  131072. }
  131073. }
  131074. declare module BABYLON {
  131075. /**
  131076. * Block used to expose an input value
  131077. */
  131078. export class InputBlock extends NodeMaterialBlock {
  131079. private _mode;
  131080. private _associatedVariableName;
  131081. private _storedValue;
  131082. private _valueCallback;
  131083. private _type;
  131084. private _animationType;
  131085. /** Gets or set a value used to limit the range of float values */
  131086. min: number;
  131087. /** Gets or set a value used to limit the range of float values */
  131088. max: number;
  131089. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131090. isBoolean: boolean;
  131091. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131092. matrixMode: number;
  131093. /** @hidden */
  131094. _systemValue: Nullable<NodeMaterialSystemValues>;
  131095. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131096. visibleInInspector: boolean;
  131097. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131098. isConstant: boolean;
  131099. /** Gets or sets the group to use to display this block in the Inspector */
  131100. groupInInspector: string;
  131101. /** Gets an observable raised when the value is changed */
  131102. onValueChangedObservable: Observable<InputBlock>;
  131103. /**
  131104. * Gets or sets the connection point type (default is float)
  131105. */
  131106. get type(): NodeMaterialBlockConnectionPointTypes;
  131107. /**
  131108. * Creates a new InputBlock
  131109. * @param name defines the block name
  131110. * @param target defines the target of that block (Vertex by default)
  131111. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131112. */
  131113. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131114. /**
  131115. * Gets the output component
  131116. */
  131117. get output(): NodeMaterialConnectionPoint;
  131118. /**
  131119. * Set the source of this connection point to a vertex attribute
  131120. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131121. * @returns the current connection point
  131122. */
  131123. setAsAttribute(attributeName?: string): InputBlock;
  131124. /**
  131125. * Set the source of this connection point to a system value
  131126. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131127. * @returns the current connection point
  131128. */
  131129. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131130. /**
  131131. * Gets or sets the value of that point.
  131132. * Please note that this value will be ignored if valueCallback is defined
  131133. */
  131134. get value(): any;
  131135. set value(value: any);
  131136. /**
  131137. * Gets or sets a callback used to get the value of that point.
  131138. * Please note that setting this value will force the connection point to ignore the value property
  131139. */
  131140. get valueCallback(): () => any;
  131141. set valueCallback(value: () => any);
  131142. /**
  131143. * Gets or sets the associated variable name in the shader
  131144. */
  131145. get associatedVariableName(): string;
  131146. set associatedVariableName(value: string);
  131147. /** Gets or sets the type of animation applied to the input */
  131148. get animationType(): AnimatedInputBlockTypes;
  131149. set animationType(value: AnimatedInputBlockTypes);
  131150. /**
  131151. * Gets a boolean indicating that this connection point not defined yet
  131152. */
  131153. get isUndefined(): boolean;
  131154. /**
  131155. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131156. * In this case the connection point name must be the name of the uniform to use.
  131157. * Can only be set on inputs
  131158. */
  131159. get isUniform(): boolean;
  131160. set isUniform(value: boolean);
  131161. /**
  131162. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131163. * In this case the connection point name must be the name of the attribute to use
  131164. * Can only be set on inputs
  131165. */
  131166. get isAttribute(): boolean;
  131167. set isAttribute(value: boolean);
  131168. /**
  131169. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131170. * Can only be set on exit points
  131171. */
  131172. get isVarying(): boolean;
  131173. set isVarying(value: boolean);
  131174. /**
  131175. * Gets a boolean indicating that the current connection point is a system value
  131176. */
  131177. get isSystemValue(): boolean;
  131178. /**
  131179. * Gets or sets the current well known value or null if not defined as a system value
  131180. */
  131181. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131182. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131183. /**
  131184. * Gets the current class name
  131185. * @returns the class name
  131186. */
  131187. getClassName(): string;
  131188. /**
  131189. * Animate the input if animationType !== None
  131190. * @param scene defines the rendering scene
  131191. */
  131192. animate(scene: Scene): void;
  131193. private _emitDefine;
  131194. initialize(state: NodeMaterialBuildState): void;
  131195. /**
  131196. * Set the input block to its default value (based on its type)
  131197. */
  131198. setDefaultValue(): void;
  131199. private _emitConstant;
  131200. private _emit;
  131201. /** @hidden */
  131202. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131203. /** @hidden */
  131204. _transmit(effect: Effect, scene: Scene): void;
  131205. protected _buildBlock(state: NodeMaterialBuildState): void;
  131206. protected _dumpPropertiesCode(): string;
  131207. dispose(): void;
  131208. serialize(): any;
  131209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131210. }
  131211. }
  131212. declare module BABYLON {
  131213. /**
  131214. * Enum used to define the compatibility state between two connection points
  131215. */
  131216. export enum NodeMaterialConnectionPointCompatibilityStates {
  131217. /** Points are compatibles */
  131218. Compatible = 0,
  131219. /** Points are incompatible because of their types */
  131220. TypeIncompatible = 1,
  131221. /** Points are incompatible because of their targets (vertex vs fragment) */
  131222. TargetIncompatible = 2
  131223. }
  131224. /**
  131225. * Defines the direction of a connection point
  131226. */
  131227. export enum NodeMaterialConnectionPointDirection {
  131228. /** Input */
  131229. Input = 0,
  131230. /** Output */
  131231. Output = 1
  131232. }
  131233. /**
  131234. * Defines a connection point for a block
  131235. */
  131236. export class NodeMaterialConnectionPoint {
  131237. /** @hidden */
  131238. _ownerBlock: NodeMaterialBlock;
  131239. /** @hidden */
  131240. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131241. private _endpoints;
  131242. private _associatedVariableName;
  131243. private _direction;
  131244. /** @hidden */
  131245. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131246. /** @hidden */
  131247. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131248. private _type;
  131249. /** @hidden */
  131250. _enforceAssociatedVariableName: boolean;
  131251. /** Gets the direction of the point */
  131252. get direction(): NodeMaterialConnectionPointDirection;
  131253. /**
  131254. * Gets or sets the additional types supported by this connection point
  131255. */
  131256. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131257. /**
  131258. * Gets or sets the additional types excluded by this connection point
  131259. */
  131260. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131261. /**
  131262. * Observable triggered when this point is connected
  131263. */
  131264. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131265. /**
  131266. * Gets or sets the associated variable name in the shader
  131267. */
  131268. get associatedVariableName(): string;
  131269. set associatedVariableName(value: string);
  131270. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131271. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131272. /**
  131273. * Gets or sets the connection point type (default is float)
  131274. */
  131275. get type(): NodeMaterialBlockConnectionPointTypes;
  131276. set type(value: NodeMaterialBlockConnectionPointTypes);
  131277. /**
  131278. * Gets or sets the connection point name
  131279. */
  131280. name: string;
  131281. /**
  131282. * Gets or sets a boolean indicating that this connection point can be omitted
  131283. */
  131284. isOptional: boolean;
  131285. /**
  131286. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131287. */
  131288. define: string;
  131289. /** @hidden */
  131290. _prioritizeVertex: boolean;
  131291. private _target;
  131292. /** Gets or sets the target of that connection point */
  131293. get target(): NodeMaterialBlockTargets;
  131294. set target(value: NodeMaterialBlockTargets);
  131295. /**
  131296. * Gets a boolean indicating that the current point is connected
  131297. */
  131298. get isConnected(): boolean;
  131299. /**
  131300. * Gets a boolean indicating that the current point is connected to an input block
  131301. */
  131302. get isConnectedToInputBlock(): boolean;
  131303. /**
  131304. * Gets a the connected input block (if any)
  131305. */
  131306. get connectInputBlock(): Nullable<InputBlock>;
  131307. /** Get the other side of the connection (if any) */
  131308. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131309. /** Get the block that owns this connection point */
  131310. get ownerBlock(): NodeMaterialBlock;
  131311. /** Get the block connected on the other side of this connection (if any) */
  131312. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131313. /** Get the block connected on the endpoints of this connection (if any) */
  131314. get connectedBlocks(): Array<NodeMaterialBlock>;
  131315. /** Gets the list of connected endpoints */
  131316. get endpoints(): NodeMaterialConnectionPoint[];
  131317. /** Gets a boolean indicating if that output point is connected to at least one input */
  131318. get hasEndpoints(): boolean;
  131319. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131320. get isConnectedInVertexShader(): boolean;
  131321. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131322. get isConnectedInFragmentShader(): boolean;
  131323. /**
  131324. * Creates a new connection point
  131325. * @param name defines the connection point name
  131326. * @param ownerBlock defines the block hosting this connection point
  131327. * @param direction defines the direction of the connection point
  131328. */
  131329. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131330. /**
  131331. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131332. * @returns the class name
  131333. */
  131334. getClassName(): string;
  131335. /**
  131336. * Gets a boolean indicating if the current point can be connected to another point
  131337. * @param connectionPoint defines the other connection point
  131338. * @returns a boolean
  131339. */
  131340. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131341. /**
  131342. * Gets a number indicating if the current point can be connected to another point
  131343. * @param connectionPoint defines the other connection point
  131344. * @returns a number defining the compatibility state
  131345. */
  131346. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131347. /**
  131348. * Connect this point to another connection point
  131349. * @param connectionPoint defines the other connection point
  131350. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131351. * @returns the current connection point
  131352. */
  131353. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131354. /**
  131355. * Disconnect this point from one of his endpoint
  131356. * @param endpoint defines the other connection point
  131357. * @returns the current connection point
  131358. */
  131359. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131360. /**
  131361. * Serializes this point in a JSON representation
  131362. * @returns the serialized point object
  131363. */
  131364. serialize(): any;
  131365. /**
  131366. * Release resources
  131367. */
  131368. dispose(): void;
  131369. }
  131370. }
  131371. declare module BABYLON {
  131372. /**
  131373. * Block used to add support for vertex skinning (bones)
  131374. */
  131375. export class BonesBlock extends NodeMaterialBlock {
  131376. /**
  131377. * Creates a new BonesBlock
  131378. * @param name defines the block name
  131379. */
  131380. constructor(name: string);
  131381. /**
  131382. * Initialize the block and prepare the context for build
  131383. * @param state defines the state that will be used for the build
  131384. */
  131385. initialize(state: NodeMaterialBuildState): void;
  131386. /**
  131387. * Gets the current class name
  131388. * @returns the class name
  131389. */
  131390. getClassName(): string;
  131391. /**
  131392. * Gets the matrix indices input component
  131393. */
  131394. get matricesIndices(): NodeMaterialConnectionPoint;
  131395. /**
  131396. * Gets the matrix weights input component
  131397. */
  131398. get matricesWeights(): NodeMaterialConnectionPoint;
  131399. /**
  131400. * Gets the extra matrix indices input component
  131401. */
  131402. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131403. /**
  131404. * Gets the extra matrix weights input component
  131405. */
  131406. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131407. /**
  131408. * Gets the world input component
  131409. */
  131410. get world(): NodeMaterialConnectionPoint;
  131411. /**
  131412. * Gets the output component
  131413. */
  131414. get output(): NodeMaterialConnectionPoint;
  131415. autoConfigure(material: NodeMaterial): void;
  131416. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131417. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131418. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131419. protected _buildBlock(state: NodeMaterialBuildState): this;
  131420. }
  131421. }
  131422. declare module BABYLON {
  131423. /**
  131424. * Block used to add support for instances
  131425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131426. */
  131427. export class InstancesBlock extends NodeMaterialBlock {
  131428. /**
  131429. * Creates a new InstancesBlock
  131430. * @param name defines the block name
  131431. */
  131432. constructor(name: string);
  131433. /**
  131434. * Gets the current class name
  131435. * @returns the class name
  131436. */
  131437. getClassName(): string;
  131438. /**
  131439. * Gets the first world row input component
  131440. */
  131441. get world0(): NodeMaterialConnectionPoint;
  131442. /**
  131443. * Gets the second world row input component
  131444. */
  131445. get world1(): NodeMaterialConnectionPoint;
  131446. /**
  131447. * Gets the third world row input component
  131448. */
  131449. get world2(): NodeMaterialConnectionPoint;
  131450. /**
  131451. * Gets the forth world row input component
  131452. */
  131453. get world3(): NodeMaterialConnectionPoint;
  131454. /**
  131455. * Gets the world input component
  131456. */
  131457. get world(): NodeMaterialConnectionPoint;
  131458. /**
  131459. * Gets the output component
  131460. */
  131461. get output(): NodeMaterialConnectionPoint;
  131462. /**
  131463. * Gets the isntanceID component
  131464. */
  131465. get instanceID(): NodeMaterialConnectionPoint;
  131466. autoConfigure(material: NodeMaterial): void;
  131467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131468. protected _buildBlock(state: NodeMaterialBuildState): this;
  131469. }
  131470. }
  131471. declare module BABYLON {
  131472. /**
  131473. * Block used to add morph targets support to vertex shader
  131474. */
  131475. export class MorphTargetsBlock extends NodeMaterialBlock {
  131476. private _repeatableContentAnchor;
  131477. /**
  131478. * Create a new MorphTargetsBlock
  131479. * @param name defines the block name
  131480. */
  131481. constructor(name: string);
  131482. /**
  131483. * Gets the current class name
  131484. * @returns the class name
  131485. */
  131486. getClassName(): string;
  131487. /**
  131488. * Gets the position input component
  131489. */
  131490. get position(): NodeMaterialConnectionPoint;
  131491. /**
  131492. * Gets the normal input component
  131493. */
  131494. get normal(): NodeMaterialConnectionPoint;
  131495. /**
  131496. * Gets the tangent input component
  131497. */
  131498. get tangent(): NodeMaterialConnectionPoint;
  131499. /**
  131500. * Gets the tangent input component
  131501. */
  131502. get uv(): NodeMaterialConnectionPoint;
  131503. /**
  131504. * Gets the position output component
  131505. */
  131506. get positionOutput(): NodeMaterialConnectionPoint;
  131507. /**
  131508. * Gets the normal output component
  131509. */
  131510. get normalOutput(): NodeMaterialConnectionPoint;
  131511. /**
  131512. * Gets the tangent output component
  131513. */
  131514. get tangentOutput(): NodeMaterialConnectionPoint;
  131515. /**
  131516. * Gets the tangent output component
  131517. */
  131518. get uvOutput(): NodeMaterialConnectionPoint;
  131519. initialize(state: NodeMaterialBuildState): void;
  131520. autoConfigure(material: NodeMaterial): void;
  131521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131523. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131524. protected _buildBlock(state: NodeMaterialBuildState): this;
  131525. }
  131526. }
  131527. declare module BABYLON {
  131528. /**
  131529. * Block used to get data information from a light
  131530. */
  131531. export class LightInformationBlock extends NodeMaterialBlock {
  131532. private _lightDataUniformName;
  131533. private _lightColorUniformName;
  131534. private _lightTypeDefineName;
  131535. /**
  131536. * Gets or sets the light associated with this block
  131537. */
  131538. light: Nullable<Light>;
  131539. /**
  131540. * Creates a new LightInformationBlock
  131541. * @param name defines the block name
  131542. */
  131543. constructor(name: string);
  131544. /**
  131545. * Gets the current class name
  131546. * @returns the class name
  131547. */
  131548. getClassName(): string;
  131549. /**
  131550. * Gets the world position input component
  131551. */
  131552. get worldPosition(): NodeMaterialConnectionPoint;
  131553. /**
  131554. * Gets the direction output component
  131555. */
  131556. get direction(): NodeMaterialConnectionPoint;
  131557. /**
  131558. * Gets the direction output component
  131559. */
  131560. get color(): NodeMaterialConnectionPoint;
  131561. /**
  131562. * Gets the direction output component
  131563. */
  131564. get intensity(): NodeMaterialConnectionPoint;
  131565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131567. protected _buildBlock(state: NodeMaterialBuildState): this;
  131568. serialize(): any;
  131569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131570. }
  131571. }
  131572. declare module BABYLON {
  131573. /**
  131574. * Block used to add image processing support to fragment shader
  131575. */
  131576. export class ImageProcessingBlock extends NodeMaterialBlock {
  131577. /**
  131578. * Create a new ImageProcessingBlock
  131579. * @param name defines the block name
  131580. */
  131581. constructor(name: string);
  131582. /**
  131583. * Gets the current class name
  131584. * @returns the class name
  131585. */
  131586. getClassName(): string;
  131587. /**
  131588. * Gets the color input component
  131589. */
  131590. get color(): NodeMaterialConnectionPoint;
  131591. /**
  131592. * Gets the output component
  131593. */
  131594. get output(): NodeMaterialConnectionPoint;
  131595. /**
  131596. * Initialize the block and prepare the context for build
  131597. * @param state defines the state that will be used for the build
  131598. */
  131599. initialize(state: NodeMaterialBuildState): void;
  131600. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131602. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131603. protected _buildBlock(state: NodeMaterialBuildState): this;
  131604. }
  131605. }
  131606. declare module BABYLON {
  131607. /**
  131608. * Block used to pertub normals based on a normal map
  131609. */
  131610. export class PerturbNormalBlock extends NodeMaterialBlock {
  131611. private _tangentSpaceParameterName;
  131612. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131613. invertX: boolean;
  131614. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131615. invertY: boolean;
  131616. /**
  131617. * Create a new PerturbNormalBlock
  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 world position input component
  131628. */
  131629. get worldPosition(): NodeMaterialConnectionPoint;
  131630. /**
  131631. * Gets the world normal input component
  131632. */
  131633. get worldNormal(): NodeMaterialConnectionPoint;
  131634. /**
  131635. * Gets the world tangent input component
  131636. */
  131637. get worldTangent(): NodeMaterialConnectionPoint;
  131638. /**
  131639. * Gets the uv input component
  131640. */
  131641. get uv(): NodeMaterialConnectionPoint;
  131642. /**
  131643. * Gets the normal map color input component
  131644. */
  131645. get normalMapColor(): NodeMaterialConnectionPoint;
  131646. /**
  131647. * Gets the strength input component
  131648. */
  131649. get strength(): NodeMaterialConnectionPoint;
  131650. /**
  131651. * Gets the output component
  131652. */
  131653. get output(): NodeMaterialConnectionPoint;
  131654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131656. autoConfigure(material: NodeMaterial): void;
  131657. protected _buildBlock(state: NodeMaterialBuildState): this;
  131658. protected _dumpPropertiesCode(): string;
  131659. serialize(): any;
  131660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131661. }
  131662. }
  131663. declare module BABYLON {
  131664. /**
  131665. * Block used to discard a pixel if a value is smaller than a cutoff
  131666. */
  131667. export class DiscardBlock extends NodeMaterialBlock {
  131668. /**
  131669. * Create a new DiscardBlock
  131670. * @param name defines the block name
  131671. */
  131672. constructor(name: string);
  131673. /**
  131674. * Gets the current class name
  131675. * @returns the class name
  131676. */
  131677. getClassName(): string;
  131678. /**
  131679. * Gets the color input component
  131680. */
  131681. get value(): NodeMaterialConnectionPoint;
  131682. /**
  131683. * Gets the cutoff input component
  131684. */
  131685. get cutoff(): NodeMaterialConnectionPoint;
  131686. protected _buildBlock(state: NodeMaterialBuildState): this;
  131687. }
  131688. }
  131689. declare module BABYLON {
  131690. /**
  131691. * Block used to test if the fragment shader is front facing
  131692. */
  131693. export class FrontFacingBlock extends NodeMaterialBlock {
  131694. /**
  131695. * Creates a new FrontFacingBlock
  131696. * @param name defines the block name
  131697. */
  131698. constructor(name: string);
  131699. /**
  131700. * Gets the current class name
  131701. * @returns the class name
  131702. */
  131703. getClassName(): string;
  131704. /**
  131705. * Gets the output component
  131706. */
  131707. get output(): NodeMaterialConnectionPoint;
  131708. protected _buildBlock(state: NodeMaterialBuildState): this;
  131709. }
  131710. }
  131711. declare module BABYLON {
  131712. /**
  131713. * Block used to get the derivative value on x and y of a given input
  131714. */
  131715. export class DerivativeBlock extends NodeMaterialBlock {
  131716. /**
  131717. * Create a new DerivativeBlock
  131718. * @param name defines the block name
  131719. */
  131720. constructor(name: string);
  131721. /**
  131722. * Gets the current class name
  131723. * @returns the class name
  131724. */
  131725. getClassName(): string;
  131726. /**
  131727. * Gets the input component
  131728. */
  131729. get input(): NodeMaterialConnectionPoint;
  131730. /**
  131731. * Gets the derivative output on x
  131732. */
  131733. get dx(): NodeMaterialConnectionPoint;
  131734. /**
  131735. * Gets the derivative output on y
  131736. */
  131737. get dy(): NodeMaterialConnectionPoint;
  131738. protected _buildBlock(state: NodeMaterialBuildState): this;
  131739. }
  131740. }
  131741. declare module BABYLON {
  131742. /**
  131743. * Block used to add support for scene fog
  131744. */
  131745. export class FogBlock extends NodeMaterialBlock {
  131746. private _fogDistanceName;
  131747. private _fogParameters;
  131748. /**
  131749. * Create a new FogBlock
  131750. * @param name defines the block name
  131751. */
  131752. constructor(name: string);
  131753. /**
  131754. * Gets the current class name
  131755. * @returns the class name
  131756. */
  131757. getClassName(): string;
  131758. /**
  131759. * Gets the world position input component
  131760. */
  131761. get worldPosition(): NodeMaterialConnectionPoint;
  131762. /**
  131763. * Gets the view input component
  131764. */
  131765. get view(): NodeMaterialConnectionPoint;
  131766. /**
  131767. * Gets the color input component
  131768. */
  131769. get input(): NodeMaterialConnectionPoint;
  131770. /**
  131771. * Gets the fog color input component
  131772. */
  131773. get fogColor(): NodeMaterialConnectionPoint;
  131774. /**
  131775. * Gets the output component
  131776. */
  131777. get output(): NodeMaterialConnectionPoint;
  131778. autoConfigure(material: NodeMaterial): void;
  131779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131780. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131781. protected _buildBlock(state: NodeMaterialBuildState): this;
  131782. }
  131783. }
  131784. declare module BABYLON {
  131785. /**
  131786. * Block used to add light in the fragment shader
  131787. */
  131788. export class LightBlock extends NodeMaterialBlock {
  131789. private _lightId;
  131790. /**
  131791. * Gets or sets the light associated with this block
  131792. */
  131793. light: Nullable<Light>;
  131794. /**
  131795. * Create a new LightBlock
  131796. * @param name defines the block name
  131797. */
  131798. constructor(name: string);
  131799. /**
  131800. * Gets the current class name
  131801. * @returns the class name
  131802. */
  131803. getClassName(): string;
  131804. /**
  131805. * Gets the world position input component
  131806. */
  131807. get worldPosition(): NodeMaterialConnectionPoint;
  131808. /**
  131809. * Gets the world normal input component
  131810. */
  131811. get worldNormal(): NodeMaterialConnectionPoint;
  131812. /**
  131813. * Gets the camera (or eye) position component
  131814. */
  131815. get cameraPosition(): NodeMaterialConnectionPoint;
  131816. /**
  131817. * Gets the glossiness component
  131818. */
  131819. get glossiness(): NodeMaterialConnectionPoint;
  131820. /**
  131821. * Gets the glossinness power component
  131822. */
  131823. get glossPower(): NodeMaterialConnectionPoint;
  131824. /**
  131825. * Gets the diffuse color component
  131826. */
  131827. get diffuseColor(): NodeMaterialConnectionPoint;
  131828. /**
  131829. * Gets the specular color component
  131830. */
  131831. get specularColor(): NodeMaterialConnectionPoint;
  131832. /**
  131833. * Gets the diffuse output component
  131834. */
  131835. get diffuseOutput(): NodeMaterialConnectionPoint;
  131836. /**
  131837. * Gets the specular output component
  131838. */
  131839. get specularOutput(): NodeMaterialConnectionPoint;
  131840. /**
  131841. * Gets the shadow output component
  131842. */
  131843. get shadow(): NodeMaterialConnectionPoint;
  131844. autoConfigure(material: NodeMaterial): void;
  131845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131846. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131848. private _injectVertexCode;
  131849. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131850. serialize(): any;
  131851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131852. }
  131853. }
  131854. declare module BABYLON {
  131855. /**
  131856. * Block used to multiply 2 values
  131857. */
  131858. export class MultiplyBlock extends NodeMaterialBlock {
  131859. /**
  131860. * Creates a new MultiplyBlock
  131861. * @param name defines the block name
  131862. */
  131863. constructor(name: string);
  131864. /**
  131865. * Gets the current class name
  131866. * @returns the class name
  131867. */
  131868. getClassName(): string;
  131869. /**
  131870. * Gets the left operand input component
  131871. */
  131872. get left(): NodeMaterialConnectionPoint;
  131873. /**
  131874. * Gets the right operand input component
  131875. */
  131876. get right(): NodeMaterialConnectionPoint;
  131877. /**
  131878. * Gets the output component
  131879. */
  131880. get output(): NodeMaterialConnectionPoint;
  131881. protected _buildBlock(state: NodeMaterialBuildState): this;
  131882. }
  131883. }
  131884. declare module BABYLON {
  131885. /**
  131886. * Block used to add 2 vectors
  131887. */
  131888. export class AddBlock extends NodeMaterialBlock {
  131889. /**
  131890. * Creates a new AddBlock
  131891. * @param name defines the block name
  131892. */
  131893. constructor(name: string);
  131894. /**
  131895. * Gets the current class name
  131896. * @returns the class name
  131897. */
  131898. getClassName(): string;
  131899. /**
  131900. * Gets the left operand input component
  131901. */
  131902. get left(): NodeMaterialConnectionPoint;
  131903. /**
  131904. * Gets the right operand input component
  131905. */
  131906. get right(): NodeMaterialConnectionPoint;
  131907. /**
  131908. * Gets the output component
  131909. */
  131910. get output(): NodeMaterialConnectionPoint;
  131911. protected _buildBlock(state: NodeMaterialBuildState): this;
  131912. }
  131913. }
  131914. declare module BABYLON {
  131915. /**
  131916. * Block used to scale a vector by a float
  131917. */
  131918. export class ScaleBlock extends NodeMaterialBlock {
  131919. /**
  131920. * Creates a new ScaleBlock
  131921. * @param name defines the block name
  131922. */
  131923. constructor(name: string);
  131924. /**
  131925. * Gets the current class name
  131926. * @returns the class name
  131927. */
  131928. getClassName(): string;
  131929. /**
  131930. * Gets the input component
  131931. */
  131932. get input(): NodeMaterialConnectionPoint;
  131933. /**
  131934. * Gets the factor input component
  131935. */
  131936. get factor(): NodeMaterialConnectionPoint;
  131937. /**
  131938. * Gets the output component
  131939. */
  131940. get output(): NodeMaterialConnectionPoint;
  131941. protected _buildBlock(state: NodeMaterialBuildState): this;
  131942. }
  131943. }
  131944. declare module BABYLON {
  131945. /**
  131946. * Block used to clamp a float
  131947. */
  131948. export class ClampBlock extends NodeMaterialBlock {
  131949. /** Gets or sets the minimum range */
  131950. minimum: number;
  131951. /** Gets or sets the maximum range */
  131952. maximum: number;
  131953. /**
  131954. * Creates a new ClampBlock
  131955. * @param name defines the block name
  131956. */
  131957. constructor(name: string);
  131958. /**
  131959. * Gets the current class name
  131960. * @returns the class name
  131961. */
  131962. getClassName(): string;
  131963. /**
  131964. * Gets the value input component
  131965. */
  131966. get value(): NodeMaterialConnectionPoint;
  131967. /**
  131968. * Gets the output component
  131969. */
  131970. get output(): NodeMaterialConnectionPoint;
  131971. protected _buildBlock(state: NodeMaterialBuildState): this;
  131972. protected _dumpPropertiesCode(): string;
  131973. serialize(): any;
  131974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131975. }
  131976. }
  131977. declare module BABYLON {
  131978. /**
  131979. * Block used to apply a cross product between 2 vectors
  131980. */
  131981. export class CrossBlock extends NodeMaterialBlock {
  131982. /**
  131983. * Creates a new CrossBlock
  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 left operand input component
  131994. */
  131995. get left(): NodeMaterialConnectionPoint;
  131996. /**
  131997. * Gets the right operand input component
  131998. */
  131999. get right(): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Gets the output component
  132002. */
  132003. get output(): NodeMaterialConnectionPoint;
  132004. protected _buildBlock(state: NodeMaterialBuildState): this;
  132005. }
  132006. }
  132007. declare module BABYLON {
  132008. /**
  132009. * Block used to apply a dot product between 2 vectors
  132010. */
  132011. export class DotBlock extends NodeMaterialBlock {
  132012. /**
  132013. * Creates a new DotBlock
  132014. * @param name defines the block name
  132015. */
  132016. constructor(name: string);
  132017. /**
  132018. * Gets the current class name
  132019. * @returns the class name
  132020. */
  132021. getClassName(): string;
  132022. /**
  132023. * Gets the left operand input component
  132024. */
  132025. get left(): NodeMaterialConnectionPoint;
  132026. /**
  132027. * Gets the right operand input component
  132028. */
  132029. get right(): NodeMaterialConnectionPoint;
  132030. /**
  132031. * Gets the output component
  132032. */
  132033. get output(): NodeMaterialConnectionPoint;
  132034. protected _buildBlock(state: NodeMaterialBuildState): this;
  132035. }
  132036. }
  132037. declare module BABYLON {
  132038. /**
  132039. * Block used to remap a float from a range to a new one
  132040. */
  132041. export class RemapBlock extends NodeMaterialBlock {
  132042. /**
  132043. * Gets or sets the source range
  132044. */
  132045. sourceRange: Vector2;
  132046. /**
  132047. * Gets or sets the target range
  132048. */
  132049. targetRange: Vector2;
  132050. /**
  132051. * Creates a new RemapBlock
  132052. * @param name defines the block name
  132053. */
  132054. constructor(name: string);
  132055. /**
  132056. * Gets the current class name
  132057. * @returns the class name
  132058. */
  132059. getClassName(): string;
  132060. /**
  132061. * Gets the input component
  132062. */
  132063. get input(): NodeMaterialConnectionPoint;
  132064. /**
  132065. * Gets the source min input component
  132066. */
  132067. get sourceMin(): NodeMaterialConnectionPoint;
  132068. /**
  132069. * Gets the source max input component
  132070. */
  132071. get sourceMax(): NodeMaterialConnectionPoint;
  132072. /**
  132073. * Gets the target min input component
  132074. */
  132075. get targetMin(): NodeMaterialConnectionPoint;
  132076. /**
  132077. * Gets the target max input component
  132078. */
  132079. get targetMax(): NodeMaterialConnectionPoint;
  132080. /**
  132081. * Gets the output component
  132082. */
  132083. get output(): NodeMaterialConnectionPoint;
  132084. protected _buildBlock(state: NodeMaterialBuildState): this;
  132085. protected _dumpPropertiesCode(): string;
  132086. serialize(): any;
  132087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132088. }
  132089. }
  132090. declare module BABYLON {
  132091. /**
  132092. * Block used to normalize a vector
  132093. */
  132094. export class NormalizeBlock extends NodeMaterialBlock {
  132095. /**
  132096. * Creates a new NormalizeBlock
  132097. * @param name defines the block name
  132098. */
  132099. constructor(name: string);
  132100. /**
  132101. * Gets the current class name
  132102. * @returns the class name
  132103. */
  132104. getClassName(): string;
  132105. /**
  132106. * Gets the input component
  132107. */
  132108. get input(): NodeMaterialConnectionPoint;
  132109. /**
  132110. * Gets the output component
  132111. */
  132112. get output(): NodeMaterialConnectionPoint;
  132113. protected _buildBlock(state: NodeMaterialBuildState): this;
  132114. }
  132115. }
  132116. declare module BABYLON {
  132117. /**
  132118. * Operations supported by the Trigonometry block
  132119. */
  132120. export enum TrigonometryBlockOperations {
  132121. /** Cos */
  132122. Cos = 0,
  132123. /** Sin */
  132124. Sin = 1,
  132125. /** Abs */
  132126. Abs = 2,
  132127. /** Exp */
  132128. Exp = 3,
  132129. /** Exp2 */
  132130. Exp2 = 4,
  132131. /** Round */
  132132. Round = 5,
  132133. /** Floor */
  132134. Floor = 6,
  132135. /** Ceiling */
  132136. Ceiling = 7,
  132137. /** Square root */
  132138. Sqrt = 8,
  132139. /** Log */
  132140. Log = 9,
  132141. /** Tangent */
  132142. Tan = 10,
  132143. /** Arc tangent */
  132144. ArcTan = 11,
  132145. /** Arc cosinus */
  132146. ArcCos = 12,
  132147. /** Arc sinus */
  132148. ArcSin = 13,
  132149. /** Fraction */
  132150. Fract = 14,
  132151. /** Sign */
  132152. Sign = 15,
  132153. /** To radians (from degrees) */
  132154. Radians = 16,
  132155. /** To degrees (from radians) */
  132156. Degrees = 17
  132157. }
  132158. /**
  132159. * Block used to apply trigonometry operation to floats
  132160. */
  132161. export class TrigonometryBlock extends NodeMaterialBlock {
  132162. /**
  132163. * Gets or sets the operation applied by the block
  132164. */
  132165. operation: TrigonometryBlockOperations;
  132166. /**
  132167. * Creates a new TrigonometryBlock
  132168. * @param name defines the block name
  132169. */
  132170. constructor(name: string);
  132171. /**
  132172. * Gets the current class name
  132173. * @returns the class name
  132174. */
  132175. getClassName(): string;
  132176. /**
  132177. * Gets the input component
  132178. */
  132179. get input(): NodeMaterialConnectionPoint;
  132180. /**
  132181. * Gets the output component
  132182. */
  132183. get output(): NodeMaterialConnectionPoint;
  132184. protected _buildBlock(state: NodeMaterialBuildState): this;
  132185. serialize(): any;
  132186. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132187. protected _dumpPropertiesCode(): string;
  132188. }
  132189. }
  132190. declare module BABYLON {
  132191. /**
  132192. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132193. */
  132194. export class ColorMergerBlock extends NodeMaterialBlock {
  132195. /**
  132196. * Create a new ColorMergerBlock
  132197. * @param name defines the block name
  132198. */
  132199. constructor(name: string);
  132200. /**
  132201. * Gets the current class name
  132202. * @returns the class name
  132203. */
  132204. getClassName(): string;
  132205. /**
  132206. * Gets the rgb component (input)
  132207. */
  132208. get rgbIn(): NodeMaterialConnectionPoint;
  132209. /**
  132210. * Gets the r component (input)
  132211. */
  132212. get r(): NodeMaterialConnectionPoint;
  132213. /**
  132214. * Gets the g component (input)
  132215. */
  132216. get g(): NodeMaterialConnectionPoint;
  132217. /**
  132218. * Gets the b component (input)
  132219. */
  132220. get b(): NodeMaterialConnectionPoint;
  132221. /**
  132222. * Gets the a component (input)
  132223. */
  132224. get a(): NodeMaterialConnectionPoint;
  132225. /**
  132226. * Gets the rgba component (output)
  132227. */
  132228. get rgba(): NodeMaterialConnectionPoint;
  132229. /**
  132230. * Gets the rgb component (output)
  132231. */
  132232. get rgbOut(): NodeMaterialConnectionPoint;
  132233. /**
  132234. * Gets the rgb component (output)
  132235. * @deprecated Please use rgbOut instead.
  132236. */
  132237. get rgb(): NodeMaterialConnectionPoint;
  132238. protected _buildBlock(state: NodeMaterialBuildState): this;
  132239. }
  132240. }
  132241. declare module BABYLON {
  132242. /**
  132243. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132244. */
  132245. export class VectorMergerBlock extends NodeMaterialBlock {
  132246. /**
  132247. * Create a new VectorMergerBlock
  132248. * @param name defines the block name
  132249. */
  132250. constructor(name: string);
  132251. /**
  132252. * Gets the current class name
  132253. * @returns the class name
  132254. */
  132255. getClassName(): string;
  132256. /**
  132257. * Gets the xyz component (input)
  132258. */
  132259. get xyzIn(): NodeMaterialConnectionPoint;
  132260. /**
  132261. * Gets the xy component (input)
  132262. */
  132263. get xyIn(): NodeMaterialConnectionPoint;
  132264. /**
  132265. * Gets the x component (input)
  132266. */
  132267. get x(): NodeMaterialConnectionPoint;
  132268. /**
  132269. * Gets the y component (input)
  132270. */
  132271. get y(): NodeMaterialConnectionPoint;
  132272. /**
  132273. * Gets the z component (input)
  132274. */
  132275. get z(): NodeMaterialConnectionPoint;
  132276. /**
  132277. * Gets the w component (input)
  132278. */
  132279. get w(): NodeMaterialConnectionPoint;
  132280. /**
  132281. * Gets the xyzw component (output)
  132282. */
  132283. get xyzw(): NodeMaterialConnectionPoint;
  132284. /**
  132285. * Gets the xyz component (output)
  132286. */
  132287. get xyzOut(): NodeMaterialConnectionPoint;
  132288. /**
  132289. * Gets the xy component (output)
  132290. */
  132291. get xyOut(): NodeMaterialConnectionPoint;
  132292. /**
  132293. * Gets the xy component (output)
  132294. * @deprecated Please use xyOut instead.
  132295. */
  132296. get xy(): NodeMaterialConnectionPoint;
  132297. /**
  132298. * Gets the xyz component (output)
  132299. * @deprecated Please use xyzOut instead.
  132300. */
  132301. get xyz(): NodeMaterialConnectionPoint;
  132302. protected _buildBlock(state: NodeMaterialBuildState): this;
  132303. }
  132304. }
  132305. declare module BABYLON {
  132306. /**
  132307. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132308. */
  132309. export class ColorSplitterBlock extends NodeMaterialBlock {
  132310. /**
  132311. * Create a new ColorSplitterBlock
  132312. * @param name defines the block name
  132313. */
  132314. constructor(name: string);
  132315. /**
  132316. * Gets the current class name
  132317. * @returns the class name
  132318. */
  132319. getClassName(): string;
  132320. /**
  132321. * Gets the rgba component (input)
  132322. */
  132323. get rgba(): NodeMaterialConnectionPoint;
  132324. /**
  132325. * Gets the rgb component (input)
  132326. */
  132327. get rgbIn(): NodeMaterialConnectionPoint;
  132328. /**
  132329. * Gets the rgb component (output)
  132330. */
  132331. get rgbOut(): NodeMaterialConnectionPoint;
  132332. /**
  132333. * Gets the r component (output)
  132334. */
  132335. get r(): NodeMaterialConnectionPoint;
  132336. /**
  132337. * Gets the g component (output)
  132338. */
  132339. get g(): NodeMaterialConnectionPoint;
  132340. /**
  132341. * Gets the b component (output)
  132342. */
  132343. get b(): NodeMaterialConnectionPoint;
  132344. /**
  132345. * Gets the a component (output)
  132346. */
  132347. get a(): NodeMaterialConnectionPoint;
  132348. protected _inputRename(name: string): string;
  132349. protected _outputRename(name: string): string;
  132350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132351. }
  132352. }
  132353. declare module BABYLON {
  132354. /**
  132355. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132356. */
  132357. export class VectorSplitterBlock extends NodeMaterialBlock {
  132358. /**
  132359. * Create a new VectorSplitterBlock
  132360. * @param name defines the block name
  132361. */
  132362. constructor(name: string);
  132363. /**
  132364. * Gets the current class name
  132365. * @returns the class name
  132366. */
  132367. getClassName(): string;
  132368. /**
  132369. * Gets the xyzw component (input)
  132370. */
  132371. get xyzw(): NodeMaterialConnectionPoint;
  132372. /**
  132373. * Gets the xyz component (input)
  132374. */
  132375. get xyzIn(): NodeMaterialConnectionPoint;
  132376. /**
  132377. * Gets the xy component (input)
  132378. */
  132379. get xyIn(): NodeMaterialConnectionPoint;
  132380. /**
  132381. * Gets the xyz component (output)
  132382. */
  132383. get xyzOut(): NodeMaterialConnectionPoint;
  132384. /**
  132385. * Gets the xy component (output)
  132386. */
  132387. get xyOut(): NodeMaterialConnectionPoint;
  132388. /**
  132389. * Gets the x component (output)
  132390. */
  132391. get x(): NodeMaterialConnectionPoint;
  132392. /**
  132393. * Gets the y component (output)
  132394. */
  132395. get y(): NodeMaterialConnectionPoint;
  132396. /**
  132397. * Gets the z component (output)
  132398. */
  132399. get z(): NodeMaterialConnectionPoint;
  132400. /**
  132401. * Gets the w component (output)
  132402. */
  132403. get w(): NodeMaterialConnectionPoint;
  132404. protected _inputRename(name: string): string;
  132405. protected _outputRename(name: string): string;
  132406. protected _buildBlock(state: NodeMaterialBuildState): this;
  132407. }
  132408. }
  132409. declare module BABYLON {
  132410. /**
  132411. * Block used to lerp between 2 values
  132412. */
  132413. export class LerpBlock extends NodeMaterialBlock {
  132414. /**
  132415. * Creates a new LerpBlock
  132416. * @param name defines the block name
  132417. */
  132418. constructor(name: string);
  132419. /**
  132420. * Gets the current class name
  132421. * @returns the class name
  132422. */
  132423. getClassName(): string;
  132424. /**
  132425. * Gets the left operand input component
  132426. */
  132427. get left(): NodeMaterialConnectionPoint;
  132428. /**
  132429. * Gets the right operand input component
  132430. */
  132431. get right(): NodeMaterialConnectionPoint;
  132432. /**
  132433. * Gets the gradient operand input component
  132434. */
  132435. get gradient(): NodeMaterialConnectionPoint;
  132436. /**
  132437. * Gets the output component
  132438. */
  132439. get output(): NodeMaterialConnectionPoint;
  132440. protected _buildBlock(state: NodeMaterialBuildState): this;
  132441. }
  132442. }
  132443. declare module BABYLON {
  132444. /**
  132445. * Block used to divide 2 vectors
  132446. */
  132447. export class DivideBlock extends NodeMaterialBlock {
  132448. /**
  132449. * Creates a new DivideBlock
  132450. * @param name defines the block name
  132451. */
  132452. constructor(name: string);
  132453. /**
  132454. * Gets the current class name
  132455. * @returns the class name
  132456. */
  132457. getClassName(): string;
  132458. /**
  132459. * Gets the left operand input component
  132460. */
  132461. get left(): NodeMaterialConnectionPoint;
  132462. /**
  132463. * Gets the right operand input component
  132464. */
  132465. get right(): NodeMaterialConnectionPoint;
  132466. /**
  132467. * Gets the output component
  132468. */
  132469. get output(): NodeMaterialConnectionPoint;
  132470. protected _buildBlock(state: NodeMaterialBuildState): this;
  132471. }
  132472. }
  132473. declare module BABYLON {
  132474. /**
  132475. * Block used to subtract 2 vectors
  132476. */
  132477. export class SubtractBlock extends NodeMaterialBlock {
  132478. /**
  132479. * Creates a new SubtractBlock
  132480. * @param name defines the block name
  132481. */
  132482. constructor(name: string);
  132483. /**
  132484. * Gets the current class name
  132485. * @returns the class name
  132486. */
  132487. getClassName(): string;
  132488. /**
  132489. * Gets the left operand input component
  132490. */
  132491. get left(): NodeMaterialConnectionPoint;
  132492. /**
  132493. * Gets the right operand input component
  132494. */
  132495. get right(): NodeMaterialConnectionPoint;
  132496. /**
  132497. * Gets the output component
  132498. */
  132499. get output(): NodeMaterialConnectionPoint;
  132500. protected _buildBlock(state: NodeMaterialBuildState): this;
  132501. }
  132502. }
  132503. declare module BABYLON {
  132504. /**
  132505. * Block used to step a value
  132506. */
  132507. export class StepBlock extends NodeMaterialBlock {
  132508. /**
  132509. * Creates a new StepBlock
  132510. * @param name defines the block name
  132511. */
  132512. constructor(name: string);
  132513. /**
  132514. * Gets the current class name
  132515. * @returns the class name
  132516. */
  132517. getClassName(): string;
  132518. /**
  132519. * Gets the value operand input component
  132520. */
  132521. get value(): NodeMaterialConnectionPoint;
  132522. /**
  132523. * Gets the edge operand input component
  132524. */
  132525. get edge(): NodeMaterialConnectionPoint;
  132526. /**
  132527. * Gets the output component
  132528. */
  132529. get output(): NodeMaterialConnectionPoint;
  132530. protected _buildBlock(state: NodeMaterialBuildState): this;
  132531. }
  132532. }
  132533. declare module BABYLON {
  132534. /**
  132535. * Block used to get the opposite (1 - x) of a value
  132536. */
  132537. export class OneMinusBlock extends NodeMaterialBlock {
  132538. /**
  132539. * Creates a new OneMinusBlock
  132540. * @param name defines the block name
  132541. */
  132542. constructor(name: string);
  132543. /**
  132544. * Gets the current class name
  132545. * @returns the class name
  132546. */
  132547. getClassName(): string;
  132548. /**
  132549. * Gets the input component
  132550. */
  132551. get input(): NodeMaterialConnectionPoint;
  132552. /**
  132553. * Gets the output component
  132554. */
  132555. get output(): NodeMaterialConnectionPoint;
  132556. protected _buildBlock(state: NodeMaterialBuildState): this;
  132557. }
  132558. }
  132559. declare module BABYLON {
  132560. /**
  132561. * Block used to get the view direction
  132562. */
  132563. export class ViewDirectionBlock extends NodeMaterialBlock {
  132564. /**
  132565. * Creates a new ViewDirectionBlock
  132566. * @param name defines the block name
  132567. */
  132568. constructor(name: string);
  132569. /**
  132570. * Gets the current class name
  132571. * @returns the class name
  132572. */
  132573. getClassName(): string;
  132574. /**
  132575. * Gets the world position component
  132576. */
  132577. get worldPosition(): NodeMaterialConnectionPoint;
  132578. /**
  132579. * Gets the camera position component
  132580. */
  132581. get cameraPosition(): NodeMaterialConnectionPoint;
  132582. /**
  132583. * Gets the output component
  132584. */
  132585. get output(): NodeMaterialConnectionPoint;
  132586. autoConfigure(material: NodeMaterial): void;
  132587. protected _buildBlock(state: NodeMaterialBuildState): this;
  132588. }
  132589. }
  132590. declare module BABYLON {
  132591. /**
  132592. * Block used to compute fresnel value
  132593. */
  132594. export class FresnelBlock extends NodeMaterialBlock {
  132595. /**
  132596. * Create a new FresnelBlock
  132597. * @param name defines the block name
  132598. */
  132599. constructor(name: string);
  132600. /**
  132601. * Gets the current class name
  132602. * @returns the class name
  132603. */
  132604. getClassName(): string;
  132605. /**
  132606. * Gets the world normal input component
  132607. */
  132608. get worldNormal(): NodeMaterialConnectionPoint;
  132609. /**
  132610. * Gets the view direction input component
  132611. */
  132612. get viewDirection(): NodeMaterialConnectionPoint;
  132613. /**
  132614. * Gets the bias input component
  132615. */
  132616. get bias(): NodeMaterialConnectionPoint;
  132617. /**
  132618. * Gets the camera (or eye) position component
  132619. */
  132620. get power(): NodeMaterialConnectionPoint;
  132621. /**
  132622. * Gets the fresnel output component
  132623. */
  132624. get fresnel(): NodeMaterialConnectionPoint;
  132625. autoConfigure(material: NodeMaterial): void;
  132626. protected _buildBlock(state: NodeMaterialBuildState): this;
  132627. }
  132628. }
  132629. declare module BABYLON {
  132630. /**
  132631. * Block used to get the max of 2 values
  132632. */
  132633. export class MaxBlock extends NodeMaterialBlock {
  132634. /**
  132635. * Creates a new MaxBlock
  132636. * @param name defines the block name
  132637. */
  132638. constructor(name: string);
  132639. /**
  132640. * Gets the current class name
  132641. * @returns the class name
  132642. */
  132643. getClassName(): string;
  132644. /**
  132645. * Gets the left operand input component
  132646. */
  132647. get left(): NodeMaterialConnectionPoint;
  132648. /**
  132649. * Gets the right operand input component
  132650. */
  132651. get right(): NodeMaterialConnectionPoint;
  132652. /**
  132653. * Gets the output component
  132654. */
  132655. get output(): NodeMaterialConnectionPoint;
  132656. protected _buildBlock(state: NodeMaterialBuildState): this;
  132657. }
  132658. }
  132659. declare module BABYLON {
  132660. /**
  132661. * Block used to get the min of 2 values
  132662. */
  132663. export class MinBlock extends NodeMaterialBlock {
  132664. /**
  132665. * Creates a new MinBlock
  132666. * @param name defines the block name
  132667. */
  132668. constructor(name: string);
  132669. /**
  132670. * Gets the current class name
  132671. * @returns the class name
  132672. */
  132673. getClassName(): string;
  132674. /**
  132675. * Gets the left operand input component
  132676. */
  132677. get left(): NodeMaterialConnectionPoint;
  132678. /**
  132679. * Gets the right operand input component
  132680. */
  132681. get right(): NodeMaterialConnectionPoint;
  132682. /**
  132683. * Gets the output component
  132684. */
  132685. get output(): NodeMaterialConnectionPoint;
  132686. protected _buildBlock(state: NodeMaterialBuildState): this;
  132687. }
  132688. }
  132689. declare module BABYLON {
  132690. /**
  132691. * Block used to get the distance between 2 values
  132692. */
  132693. export class DistanceBlock extends NodeMaterialBlock {
  132694. /**
  132695. * Creates a new DistanceBlock
  132696. * @param name defines the block name
  132697. */
  132698. constructor(name: string);
  132699. /**
  132700. * Gets the current class name
  132701. * @returns the class name
  132702. */
  132703. getClassName(): string;
  132704. /**
  132705. * Gets the left operand input component
  132706. */
  132707. get left(): NodeMaterialConnectionPoint;
  132708. /**
  132709. * Gets the right operand input component
  132710. */
  132711. get right(): NodeMaterialConnectionPoint;
  132712. /**
  132713. * Gets the output component
  132714. */
  132715. get output(): NodeMaterialConnectionPoint;
  132716. protected _buildBlock(state: NodeMaterialBuildState): this;
  132717. }
  132718. }
  132719. declare module BABYLON {
  132720. /**
  132721. * Block used to get the length of a vector
  132722. */
  132723. export class LengthBlock extends NodeMaterialBlock {
  132724. /**
  132725. * Creates a new LengthBlock
  132726. * @param name defines the block name
  132727. */
  132728. constructor(name: string);
  132729. /**
  132730. * Gets the current class name
  132731. * @returns the class name
  132732. */
  132733. getClassName(): string;
  132734. /**
  132735. * Gets the value input component
  132736. */
  132737. get value(): NodeMaterialConnectionPoint;
  132738. /**
  132739. * Gets the output component
  132740. */
  132741. get output(): NodeMaterialConnectionPoint;
  132742. protected _buildBlock(state: NodeMaterialBuildState): this;
  132743. }
  132744. }
  132745. declare module BABYLON {
  132746. /**
  132747. * Block used to get negative version of a value (i.e. x * -1)
  132748. */
  132749. export class NegateBlock extends NodeMaterialBlock {
  132750. /**
  132751. * Creates a new NegateBlock
  132752. * @param name defines the block name
  132753. */
  132754. constructor(name: string);
  132755. /**
  132756. * Gets the current class name
  132757. * @returns the class name
  132758. */
  132759. getClassName(): string;
  132760. /**
  132761. * Gets the value input component
  132762. */
  132763. get value(): NodeMaterialConnectionPoint;
  132764. /**
  132765. * Gets the output component
  132766. */
  132767. get output(): NodeMaterialConnectionPoint;
  132768. protected _buildBlock(state: NodeMaterialBuildState): this;
  132769. }
  132770. }
  132771. declare module BABYLON {
  132772. /**
  132773. * Block used to get the value of the first parameter raised to the power of the second
  132774. */
  132775. export class PowBlock extends NodeMaterialBlock {
  132776. /**
  132777. * Creates a new PowBlock
  132778. * @param name defines the block name
  132779. */
  132780. constructor(name: string);
  132781. /**
  132782. * Gets the current class name
  132783. * @returns the class name
  132784. */
  132785. getClassName(): string;
  132786. /**
  132787. * Gets the value operand input component
  132788. */
  132789. get value(): NodeMaterialConnectionPoint;
  132790. /**
  132791. * Gets the power operand input component
  132792. */
  132793. get power(): NodeMaterialConnectionPoint;
  132794. /**
  132795. * Gets the output component
  132796. */
  132797. get output(): NodeMaterialConnectionPoint;
  132798. protected _buildBlock(state: NodeMaterialBuildState): this;
  132799. }
  132800. }
  132801. declare module BABYLON {
  132802. /**
  132803. * Block used to get a random number
  132804. */
  132805. export class RandomNumberBlock extends NodeMaterialBlock {
  132806. /**
  132807. * Creates a new RandomNumberBlock
  132808. * @param name defines the block name
  132809. */
  132810. constructor(name: string);
  132811. /**
  132812. * Gets the current class name
  132813. * @returns the class name
  132814. */
  132815. getClassName(): string;
  132816. /**
  132817. * Gets the seed input component
  132818. */
  132819. get seed(): NodeMaterialConnectionPoint;
  132820. /**
  132821. * Gets the output component
  132822. */
  132823. get output(): NodeMaterialConnectionPoint;
  132824. protected _buildBlock(state: NodeMaterialBuildState): this;
  132825. }
  132826. }
  132827. declare module BABYLON {
  132828. /**
  132829. * Block used to compute arc tangent of 2 values
  132830. */
  132831. export class ArcTan2Block extends NodeMaterialBlock {
  132832. /**
  132833. * Creates a new ArcTan2Block
  132834. * @param name defines the block name
  132835. */
  132836. constructor(name: string);
  132837. /**
  132838. * Gets the current class name
  132839. * @returns the class name
  132840. */
  132841. getClassName(): string;
  132842. /**
  132843. * Gets the x operand input component
  132844. */
  132845. get x(): NodeMaterialConnectionPoint;
  132846. /**
  132847. * Gets the y operand input component
  132848. */
  132849. get y(): NodeMaterialConnectionPoint;
  132850. /**
  132851. * Gets the output component
  132852. */
  132853. get output(): NodeMaterialConnectionPoint;
  132854. protected _buildBlock(state: NodeMaterialBuildState): this;
  132855. }
  132856. }
  132857. declare module BABYLON {
  132858. /**
  132859. * Block used to smooth step a value
  132860. */
  132861. export class SmoothStepBlock extends NodeMaterialBlock {
  132862. /**
  132863. * Creates a new SmoothStepBlock
  132864. * @param name defines the block name
  132865. */
  132866. constructor(name: string);
  132867. /**
  132868. * Gets the current class name
  132869. * @returns the class name
  132870. */
  132871. getClassName(): string;
  132872. /**
  132873. * Gets the value operand input component
  132874. */
  132875. get value(): NodeMaterialConnectionPoint;
  132876. /**
  132877. * Gets the first edge operand input component
  132878. */
  132879. get edge0(): NodeMaterialConnectionPoint;
  132880. /**
  132881. * Gets the second edge operand input component
  132882. */
  132883. get edge1(): NodeMaterialConnectionPoint;
  132884. /**
  132885. * Gets the output component
  132886. */
  132887. get output(): NodeMaterialConnectionPoint;
  132888. protected _buildBlock(state: NodeMaterialBuildState): this;
  132889. }
  132890. }
  132891. declare module BABYLON {
  132892. /**
  132893. * Block used to get the reciprocal (1 / x) of a value
  132894. */
  132895. export class ReciprocalBlock extends NodeMaterialBlock {
  132896. /**
  132897. * Creates a new ReciprocalBlock
  132898. * @param name defines the block name
  132899. */
  132900. constructor(name: string);
  132901. /**
  132902. * Gets the current class name
  132903. * @returns the class name
  132904. */
  132905. getClassName(): string;
  132906. /**
  132907. * Gets the input component
  132908. */
  132909. get input(): NodeMaterialConnectionPoint;
  132910. /**
  132911. * Gets the output component
  132912. */
  132913. get output(): NodeMaterialConnectionPoint;
  132914. protected _buildBlock(state: NodeMaterialBuildState): this;
  132915. }
  132916. }
  132917. declare module BABYLON {
  132918. /**
  132919. * Block used to replace a color by another one
  132920. */
  132921. export class ReplaceColorBlock extends NodeMaterialBlock {
  132922. /**
  132923. * Creates a new ReplaceColorBlock
  132924. * @param name defines the block name
  132925. */
  132926. constructor(name: string);
  132927. /**
  132928. * Gets the current class name
  132929. * @returns the class name
  132930. */
  132931. getClassName(): string;
  132932. /**
  132933. * Gets the value input component
  132934. */
  132935. get value(): NodeMaterialConnectionPoint;
  132936. /**
  132937. * Gets the reference input component
  132938. */
  132939. get reference(): NodeMaterialConnectionPoint;
  132940. /**
  132941. * Gets the distance input component
  132942. */
  132943. get distance(): NodeMaterialConnectionPoint;
  132944. /**
  132945. * Gets the replacement input component
  132946. */
  132947. get replacement(): NodeMaterialConnectionPoint;
  132948. /**
  132949. * Gets the output component
  132950. */
  132951. get output(): NodeMaterialConnectionPoint;
  132952. protected _buildBlock(state: NodeMaterialBuildState): this;
  132953. }
  132954. }
  132955. declare module BABYLON {
  132956. /**
  132957. * Block used to posterize a value
  132958. * @see https://en.wikipedia.org/wiki/Posterization
  132959. */
  132960. export class PosterizeBlock extends NodeMaterialBlock {
  132961. /**
  132962. * Creates a new PosterizeBlock
  132963. * @param name defines the block name
  132964. */
  132965. constructor(name: string);
  132966. /**
  132967. * Gets the current class name
  132968. * @returns the class name
  132969. */
  132970. getClassName(): string;
  132971. /**
  132972. * Gets the value input component
  132973. */
  132974. get value(): NodeMaterialConnectionPoint;
  132975. /**
  132976. * Gets the steps input component
  132977. */
  132978. get steps(): NodeMaterialConnectionPoint;
  132979. /**
  132980. * Gets the output component
  132981. */
  132982. get output(): NodeMaterialConnectionPoint;
  132983. protected _buildBlock(state: NodeMaterialBuildState): this;
  132984. }
  132985. }
  132986. declare module BABYLON {
  132987. /**
  132988. * Operations supported by the Wave block
  132989. */
  132990. export enum WaveBlockKind {
  132991. /** SawTooth */
  132992. SawTooth = 0,
  132993. /** Square */
  132994. Square = 1,
  132995. /** Triangle */
  132996. Triangle = 2
  132997. }
  132998. /**
  132999. * Block used to apply wave operation to floats
  133000. */
  133001. export class WaveBlock extends NodeMaterialBlock {
  133002. /**
  133003. * Gets or sets the kibnd of wave to be applied by the block
  133004. */
  133005. kind: WaveBlockKind;
  133006. /**
  133007. * Creates a new WaveBlock
  133008. * @param name defines the block name
  133009. */
  133010. constructor(name: string);
  133011. /**
  133012. * Gets the current class name
  133013. * @returns the class name
  133014. */
  133015. getClassName(): string;
  133016. /**
  133017. * Gets the input component
  133018. */
  133019. get input(): NodeMaterialConnectionPoint;
  133020. /**
  133021. * Gets the output component
  133022. */
  133023. get output(): NodeMaterialConnectionPoint;
  133024. protected _buildBlock(state: NodeMaterialBuildState): this;
  133025. serialize(): any;
  133026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133027. }
  133028. }
  133029. declare module BABYLON {
  133030. /**
  133031. * Class used to store a color step for the GradientBlock
  133032. */
  133033. export class GradientBlockColorStep {
  133034. /**
  133035. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133036. */
  133037. step: number;
  133038. /**
  133039. * Gets or sets the color associated with this step
  133040. */
  133041. color: Color3;
  133042. /**
  133043. * Creates a new GradientBlockColorStep
  133044. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133045. * @param color defines the color associated with this step
  133046. */
  133047. constructor(
  133048. /**
  133049. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133050. */
  133051. step: number,
  133052. /**
  133053. * Gets or sets the color associated with this step
  133054. */
  133055. color: Color3);
  133056. }
  133057. /**
  133058. * Block used to return a color from a gradient based on an input value between 0 and 1
  133059. */
  133060. export class GradientBlock extends NodeMaterialBlock {
  133061. /**
  133062. * Gets or sets the list of color steps
  133063. */
  133064. colorSteps: GradientBlockColorStep[];
  133065. /**
  133066. * Creates a new GradientBlock
  133067. * @param name defines the block name
  133068. */
  133069. constructor(name: string);
  133070. /**
  133071. * Gets the current class name
  133072. * @returns the class name
  133073. */
  133074. getClassName(): string;
  133075. /**
  133076. * Gets the gradient input component
  133077. */
  133078. get gradient(): NodeMaterialConnectionPoint;
  133079. /**
  133080. * Gets the output component
  133081. */
  133082. get output(): NodeMaterialConnectionPoint;
  133083. private _writeColorConstant;
  133084. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133085. serialize(): any;
  133086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133087. protected _dumpPropertiesCode(): string;
  133088. }
  133089. }
  133090. declare module BABYLON {
  133091. /**
  133092. * Block used to normalize lerp between 2 values
  133093. */
  133094. export class NLerpBlock extends NodeMaterialBlock {
  133095. /**
  133096. * Creates a new NLerpBlock
  133097. * @param name defines the block name
  133098. */
  133099. constructor(name: string);
  133100. /**
  133101. * Gets the current class name
  133102. * @returns the class name
  133103. */
  133104. getClassName(): string;
  133105. /**
  133106. * Gets the left operand input component
  133107. */
  133108. get left(): NodeMaterialConnectionPoint;
  133109. /**
  133110. * Gets the right operand input component
  133111. */
  133112. get right(): NodeMaterialConnectionPoint;
  133113. /**
  133114. * Gets the gradient operand input component
  133115. */
  133116. get gradient(): NodeMaterialConnectionPoint;
  133117. /**
  133118. * Gets the output component
  133119. */
  133120. get output(): NodeMaterialConnectionPoint;
  133121. protected _buildBlock(state: NodeMaterialBuildState): this;
  133122. }
  133123. }
  133124. declare module BABYLON {
  133125. /**
  133126. * block used to Generate a Worley Noise 3D Noise Pattern
  133127. */
  133128. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133129. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133130. manhattanDistance: boolean;
  133131. /**
  133132. * Creates a new WorleyNoise3DBlock
  133133. * @param name defines the block name
  133134. */
  133135. constructor(name: string);
  133136. /**
  133137. * Gets the current class name
  133138. * @returns the class name
  133139. */
  133140. getClassName(): string;
  133141. /**
  133142. * Gets the seed input component
  133143. */
  133144. get seed(): NodeMaterialConnectionPoint;
  133145. /**
  133146. * Gets the jitter input component
  133147. */
  133148. get jitter(): NodeMaterialConnectionPoint;
  133149. /**
  133150. * Gets the output component
  133151. */
  133152. get output(): NodeMaterialConnectionPoint;
  133153. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133154. /**
  133155. * Exposes the properties to the UI?
  133156. */
  133157. protected _dumpPropertiesCode(): string;
  133158. /**
  133159. * Exposes the properties to the Seralize?
  133160. */
  133161. serialize(): any;
  133162. /**
  133163. * Exposes the properties to the deseralize?
  133164. */
  133165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133166. }
  133167. }
  133168. declare module BABYLON {
  133169. /**
  133170. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133171. */
  133172. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133173. /**
  133174. * Creates a new SimplexPerlin3DBlock
  133175. * @param name defines the block name
  133176. */
  133177. constructor(name: string);
  133178. /**
  133179. * Gets the current class name
  133180. * @returns the class name
  133181. */
  133182. getClassName(): string;
  133183. /**
  133184. * Gets the seed operand input component
  133185. */
  133186. get seed(): NodeMaterialConnectionPoint;
  133187. /**
  133188. * Gets the output component
  133189. */
  133190. get output(): NodeMaterialConnectionPoint;
  133191. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133192. }
  133193. }
  133194. declare module BABYLON {
  133195. /**
  133196. * Block used to blend normals
  133197. */
  133198. export class NormalBlendBlock extends NodeMaterialBlock {
  133199. /**
  133200. * Creates a new NormalBlendBlock
  133201. * @param name defines the block name
  133202. */
  133203. constructor(name: string);
  133204. /**
  133205. * Gets the current class name
  133206. * @returns the class name
  133207. */
  133208. getClassName(): string;
  133209. /**
  133210. * Gets the first input component
  133211. */
  133212. get normalMap0(): NodeMaterialConnectionPoint;
  133213. /**
  133214. * Gets the second input component
  133215. */
  133216. get normalMap1(): NodeMaterialConnectionPoint;
  133217. /**
  133218. * Gets the output component
  133219. */
  133220. get output(): NodeMaterialConnectionPoint;
  133221. protected _buildBlock(state: NodeMaterialBuildState): this;
  133222. }
  133223. }
  133224. declare module BABYLON {
  133225. /**
  133226. * Block used to rotate a 2d vector by a given angle
  133227. */
  133228. export class Rotate2dBlock extends NodeMaterialBlock {
  133229. /**
  133230. * Creates a new Rotate2dBlock
  133231. * @param name defines the block name
  133232. */
  133233. constructor(name: string);
  133234. /**
  133235. * Gets the current class name
  133236. * @returns the class name
  133237. */
  133238. getClassName(): string;
  133239. /**
  133240. * Gets the input vector
  133241. */
  133242. get input(): NodeMaterialConnectionPoint;
  133243. /**
  133244. * Gets the input angle
  133245. */
  133246. get angle(): NodeMaterialConnectionPoint;
  133247. /**
  133248. * Gets the output component
  133249. */
  133250. get output(): NodeMaterialConnectionPoint;
  133251. autoConfigure(material: NodeMaterial): void;
  133252. protected _buildBlock(state: NodeMaterialBuildState): this;
  133253. }
  133254. }
  133255. declare module BABYLON {
  133256. /**
  133257. * Block used to get the reflected vector from a direction and a normal
  133258. */
  133259. export class ReflectBlock extends NodeMaterialBlock {
  133260. /**
  133261. * Creates a new ReflectBlock
  133262. * @param name defines the block name
  133263. */
  133264. constructor(name: string);
  133265. /**
  133266. * Gets the current class name
  133267. * @returns the class name
  133268. */
  133269. getClassName(): string;
  133270. /**
  133271. * Gets the incident component
  133272. */
  133273. get incident(): NodeMaterialConnectionPoint;
  133274. /**
  133275. * Gets the normal component
  133276. */
  133277. get normal(): NodeMaterialConnectionPoint;
  133278. /**
  133279. * Gets the output component
  133280. */
  133281. get output(): NodeMaterialConnectionPoint;
  133282. protected _buildBlock(state: NodeMaterialBuildState): this;
  133283. }
  133284. }
  133285. declare module BABYLON {
  133286. /**
  133287. * Block used to get the refracted vector from a direction and a normal
  133288. */
  133289. export class RefractBlock extends NodeMaterialBlock {
  133290. /**
  133291. * Creates a new RefractBlock
  133292. * @param name defines the block name
  133293. */
  133294. constructor(name: string);
  133295. /**
  133296. * Gets the current class name
  133297. * @returns the class name
  133298. */
  133299. getClassName(): string;
  133300. /**
  133301. * Gets the incident component
  133302. */
  133303. get incident(): NodeMaterialConnectionPoint;
  133304. /**
  133305. * Gets the normal component
  133306. */
  133307. get normal(): NodeMaterialConnectionPoint;
  133308. /**
  133309. * Gets the index of refraction component
  133310. */
  133311. get ior(): NodeMaterialConnectionPoint;
  133312. /**
  133313. * Gets the output component
  133314. */
  133315. get output(): NodeMaterialConnectionPoint;
  133316. protected _buildBlock(state: NodeMaterialBuildState): this;
  133317. }
  133318. }
  133319. declare module BABYLON {
  133320. /**
  133321. * Block used to desaturate a color
  133322. */
  133323. export class DesaturateBlock extends NodeMaterialBlock {
  133324. /**
  133325. * Creates a new DesaturateBlock
  133326. * @param name defines the block name
  133327. */
  133328. constructor(name: string);
  133329. /**
  133330. * Gets the current class name
  133331. * @returns the class name
  133332. */
  133333. getClassName(): string;
  133334. /**
  133335. * Gets the color operand input component
  133336. */
  133337. get color(): NodeMaterialConnectionPoint;
  133338. /**
  133339. * Gets the level operand input component
  133340. */
  133341. get level(): NodeMaterialConnectionPoint;
  133342. /**
  133343. * Gets the output component
  133344. */
  133345. get output(): NodeMaterialConnectionPoint;
  133346. protected _buildBlock(state: NodeMaterialBuildState): this;
  133347. }
  133348. }
  133349. declare module BABYLON {
  133350. /**
  133351. * Effect Render Options
  133352. */
  133353. export interface IEffectRendererOptions {
  133354. /**
  133355. * Defines the vertices positions.
  133356. */
  133357. positions?: number[];
  133358. /**
  133359. * Defines the indices.
  133360. */
  133361. indices?: number[];
  133362. }
  133363. /**
  133364. * Helper class to render one or more effects
  133365. */
  133366. export class EffectRenderer {
  133367. private engine;
  133368. private static _DefaultOptions;
  133369. private _vertexBuffers;
  133370. private _indexBuffer;
  133371. private _ringBufferIndex;
  133372. private _ringScreenBuffer;
  133373. private _fullscreenViewport;
  133374. private _getNextFrameBuffer;
  133375. /**
  133376. * Creates an effect renderer
  133377. * @param engine the engine to use for rendering
  133378. * @param options defines the options of the effect renderer
  133379. */
  133380. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133381. /**
  133382. * Sets the current viewport in normalized coordinates 0-1
  133383. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133384. */
  133385. setViewport(viewport?: Viewport): void;
  133386. /**
  133387. * Binds the embedded attributes buffer to the effect.
  133388. * @param effect Defines the effect to bind the attributes for
  133389. */
  133390. bindBuffers(effect: Effect): void;
  133391. /**
  133392. * Sets the current effect wrapper to use during draw.
  133393. * The effect needs to be ready before calling this api.
  133394. * This also sets the default full screen position attribute.
  133395. * @param effectWrapper Defines the effect to draw with
  133396. */
  133397. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133398. /**
  133399. * Draws a full screen quad.
  133400. */
  133401. draw(): void;
  133402. /**
  133403. * renders one or more effects to a specified texture
  133404. * @param effectWrappers list of effects to renderer
  133405. * @param outputTexture texture to draw to, if null it will render to the screen
  133406. */
  133407. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133408. /**
  133409. * Disposes of the effect renderer
  133410. */
  133411. dispose(): void;
  133412. }
  133413. /**
  133414. * Options to create an EffectWrapper
  133415. */
  133416. interface EffectWrapperCreationOptions {
  133417. /**
  133418. * Engine to use to create the effect
  133419. */
  133420. engine: ThinEngine;
  133421. /**
  133422. * Fragment shader for the effect
  133423. */
  133424. fragmentShader: string;
  133425. /**
  133426. * Vertex shader for the effect
  133427. */
  133428. vertexShader?: string;
  133429. /**
  133430. * Attributes to use in the shader
  133431. */
  133432. attributeNames?: Array<string>;
  133433. /**
  133434. * Uniforms to use in the shader
  133435. */
  133436. uniformNames?: Array<string>;
  133437. /**
  133438. * Texture sampler names to use in the shader
  133439. */
  133440. samplerNames?: Array<string>;
  133441. /**
  133442. * The friendly name of the effect displayed in Spector.
  133443. */
  133444. name?: string;
  133445. }
  133446. /**
  133447. * Wraps an effect to be used for rendering
  133448. */
  133449. export class EffectWrapper {
  133450. /**
  133451. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133452. */
  133453. onApplyObservable: Observable<{}>;
  133454. /**
  133455. * The underlying effect
  133456. */
  133457. effect: Effect;
  133458. /**
  133459. * Creates an effect to be renderer
  133460. * @param creationOptions options to create the effect
  133461. */
  133462. constructor(creationOptions: EffectWrapperCreationOptions);
  133463. /**
  133464. * Disposes of the effect wrapper
  133465. */
  133466. dispose(): void;
  133467. }
  133468. }
  133469. declare module BABYLON {
  133470. /**
  133471. * Helper class to push actions to a pool of workers.
  133472. */
  133473. export class WorkerPool implements IDisposable {
  133474. private _workerInfos;
  133475. private _pendingActions;
  133476. /**
  133477. * Constructor
  133478. * @param workers Array of workers to use for actions
  133479. */
  133480. constructor(workers: Array<Worker>);
  133481. /**
  133482. * Terminates all workers and clears any pending actions.
  133483. */
  133484. dispose(): void;
  133485. /**
  133486. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133487. * pended until a worker has completed its action.
  133488. * @param action The action to perform. Call onComplete when the action is complete.
  133489. */
  133490. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133491. private _execute;
  133492. }
  133493. }
  133494. declare module BABYLON {
  133495. /**
  133496. * Configuration for Draco compression
  133497. */
  133498. export interface IDracoCompressionConfiguration {
  133499. /**
  133500. * Configuration for the decoder.
  133501. */
  133502. decoder: {
  133503. /**
  133504. * The url to the WebAssembly module.
  133505. */
  133506. wasmUrl?: string;
  133507. /**
  133508. * The url to the WebAssembly binary.
  133509. */
  133510. wasmBinaryUrl?: string;
  133511. /**
  133512. * The url to the fallback JavaScript module.
  133513. */
  133514. fallbackUrl?: string;
  133515. };
  133516. }
  133517. /**
  133518. * Draco compression (https://google.github.io/draco/)
  133519. *
  133520. * This class wraps the Draco module.
  133521. *
  133522. * **Encoder**
  133523. *
  133524. * The encoder is not currently implemented.
  133525. *
  133526. * **Decoder**
  133527. *
  133528. * 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.
  133529. *
  133530. * To update the configuration, use the following code:
  133531. * ```javascript
  133532. * DracoCompression.Configuration = {
  133533. * decoder: {
  133534. * wasmUrl: "<url to the WebAssembly library>",
  133535. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133536. * fallbackUrl: "<url to the fallback JavaScript library>",
  133537. * }
  133538. * };
  133539. * ```
  133540. *
  133541. * 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.
  133542. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133543. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133544. *
  133545. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133546. * ```javascript
  133547. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133548. * ```
  133549. *
  133550. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133551. */
  133552. export class DracoCompression implements IDisposable {
  133553. private _workerPoolPromise?;
  133554. private _decoderModulePromise?;
  133555. /**
  133556. * The configuration. Defaults to the following urls:
  133557. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133558. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133559. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133560. */
  133561. static Configuration: IDracoCompressionConfiguration;
  133562. /**
  133563. * Returns true if the decoder configuration is available.
  133564. */
  133565. static get DecoderAvailable(): boolean;
  133566. /**
  133567. * Default number of workers to create when creating the draco compression object.
  133568. */
  133569. static DefaultNumWorkers: number;
  133570. private static GetDefaultNumWorkers;
  133571. private static _Default;
  133572. /**
  133573. * Default instance for the draco compression object.
  133574. */
  133575. static get Default(): DracoCompression;
  133576. /**
  133577. * Constructor
  133578. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133579. */
  133580. constructor(numWorkers?: number);
  133581. /**
  133582. * Stop all async operations and release resources.
  133583. */
  133584. dispose(): void;
  133585. /**
  133586. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133587. * @returns a promise that resolves when ready
  133588. */
  133589. whenReadyAsync(): Promise<void>;
  133590. /**
  133591. * Decode Draco compressed mesh data to vertex data.
  133592. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133593. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133594. * @returns A promise that resolves with the decoded vertex data
  133595. */
  133596. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133597. [kind: string]: number;
  133598. }): Promise<VertexData>;
  133599. }
  133600. }
  133601. declare module BABYLON {
  133602. /**
  133603. * Class for building Constructive Solid Geometry
  133604. */
  133605. export class CSG {
  133606. private polygons;
  133607. /**
  133608. * The world matrix
  133609. */
  133610. matrix: Matrix;
  133611. /**
  133612. * Stores the position
  133613. */
  133614. position: Vector3;
  133615. /**
  133616. * Stores the rotation
  133617. */
  133618. rotation: Vector3;
  133619. /**
  133620. * Stores the rotation quaternion
  133621. */
  133622. rotationQuaternion: Nullable<Quaternion>;
  133623. /**
  133624. * Stores the scaling vector
  133625. */
  133626. scaling: Vector3;
  133627. /**
  133628. * Convert the Mesh to CSG
  133629. * @param mesh The Mesh to convert to CSG
  133630. * @returns A new CSG from the Mesh
  133631. */
  133632. static FromMesh(mesh: Mesh): CSG;
  133633. /**
  133634. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133635. * @param polygons Polygons used to construct a CSG solid
  133636. */
  133637. private static FromPolygons;
  133638. /**
  133639. * Clones, or makes a deep copy, of the CSG
  133640. * @returns A new CSG
  133641. */
  133642. clone(): CSG;
  133643. /**
  133644. * Unions this CSG with another CSG
  133645. * @param csg The CSG to union against this CSG
  133646. * @returns The unioned CSG
  133647. */
  133648. union(csg: CSG): CSG;
  133649. /**
  133650. * Unions this CSG with another CSG in place
  133651. * @param csg The CSG to union against this CSG
  133652. */
  133653. unionInPlace(csg: CSG): void;
  133654. /**
  133655. * Subtracts this CSG with another CSG
  133656. * @param csg The CSG to subtract against this CSG
  133657. * @returns A new CSG
  133658. */
  133659. subtract(csg: CSG): CSG;
  133660. /**
  133661. * Subtracts this CSG with another CSG in place
  133662. * @param csg The CSG to subtact against this CSG
  133663. */
  133664. subtractInPlace(csg: CSG): void;
  133665. /**
  133666. * Intersect this CSG with another CSG
  133667. * @param csg The CSG to intersect against this CSG
  133668. * @returns A new CSG
  133669. */
  133670. intersect(csg: CSG): CSG;
  133671. /**
  133672. * Intersects this CSG with another CSG in place
  133673. * @param csg The CSG to intersect against this CSG
  133674. */
  133675. intersectInPlace(csg: CSG): void;
  133676. /**
  133677. * Return a new CSG solid with solid and empty space switched. This solid is
  133678. * not modified.
  133679. * @returns A new CSG solid with solid and empty space switched
  133680. */
  133681. inverse(): CSG;
  133682. /**
  133683. * Inverses the CSG in place
  133684. */
  133685. inverseInPlace(): void;
  133686. /**
  133687. * This is used to keep meshes transformations so they can be restored
  133688. * when we build back a Babylon Mesh
  133689. * NB : All CSG operations are performed in world coordinates
  133690. * @param csg The CSG to copy the transform attributes from
  133691. * @returns This CSG
  133692. */
  133693. copyTransformAttributes(csg: CSG): CSG;
  133694. /**
  133695. * Build Raw mesh from CSG
  133696. * Coordinates here are in world space
  133697. * @param name The name of the mesh geometry
  133698. * @param scene The Scene
  133699. * @param keepSubMeshes Specifies if the submeshes should be kept
  133700. * @returns A new Mesh
  133701. */
  133702. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133703. /**
  133704. * Build Mesh from CSG taking material and transforms into account
  133705. * @param name The name of the Mesh
  133706. * @param material The material of the Mesh
  133707. * @param scene The Scene
  133708. * @param keepSubMeshes Specifies if submeshes should be kept
  133709. * @returns The new Mesh
  133710. */
  133711. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133712. }
  133713. }
  133714. declare module BABYLON {
  133715. /**
  133716. * Class used to create a trail following a mesh
  133717. */
  133718. export class TrailMesh extends Mesh {
  133719. private _generator;
  133720. private _autoStart;
  133721. private _running;
  133722. private _diameter;
  133723. private _length;
  133724. private _sectionPolygonPointsCount;
  133725. private _sectionVectors;
  133726. private _sectionNormalVectors;
  133727. private _beforeRenderObserver;
  133728. /**
  133729. * @constructor
  133730. * @param name The value used by scene.getMeshByName() to do a lookup.
  133731. * @param generator The mesh or transform node to generate a trail.
  133732. * @param scene The scene to add this mesh to.
  133733. * @param diameter Diameter of trailing mesh. Default is 1.
  133734. * @param length Length of trailing mesh. Default is 60.
  133735. * @param autoStart Automatically start trailing mesh. Default true.
  133736. */
  133737. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133738. /**
  133739. * "TrailMesh"
  133740. * @returns "TrailMesh"
  133741. */
  133742. getClassName(): string;
  133743. private _createMesh;
  133744. /**
  133745. * Start trailing mesh.
  133746. */
  133747. start(): void;
  133748. /**
  133749. * Stop trailing mesh.
  133750. */
  133751. stop(): void;
  133752. /**
  133753. * Update trailing mesh geometry.
  133754. */
  133755. update(): void;
  133756. /**
  133757. * Returns a new TrailMesh object.
  133758. * @param name is a string, the name given to the new mesh
  133759. * @param newGenerator use new generator object for cloned trail mesh
  133760. * @returns a new mesh
  133761. */
  133762. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133763. /**
  133764. * Serializes this trail mesh
  133765. * @param serializationObject object to write serialization to
  133766. */
  133767. serialize(serializationObject: any): void;
  133768. /**
  133769. * Parses a serialized trail mesh
  133770. * @param parsedMesh the serialized mesh
  133771. * @param scene the scene to create the trail mesh in
  133772. * @returns the created trail mesh
  133773. */
  133774. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133775. }
  133776. }
  133777. declare module BABYLON {
  133778. /**
  133779. * Class containing static functions to help procedurally build meshes
  133780. */
  133781. export class TiledBoxBuilder {
  133782. /**
  133783. * Creates a box mesh
  133784. * 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)
  133785. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133789. * @param name defines the name of the mesh
  133790. * @param options defines the options used to create the mesh
  133791. * @param scene defines the hosting scene
  133792. * @returns the box mesh
  133793. */
  133794. static CreateTiledBox(name: string, options: {
  133795. pattern?: number;
  133796. width?: number;
  133797. height?: number;
  133798. depth?: number;
  133799. tileSize?: number;
  133800. tileWidth?: number;
  133801. tileHeight?: number;
  133802. alignHorizontal?: number;
  133803. alignVertical?: number;
  133804. faceUV?: Vector4[];
  133805. faceColors?: Color4[];
  133806. sideOrientation?: number;
  133807. updatable?: boolean;
  133808. }, scene?: Nullable<Scene>): Mesh;
  133809. }
  133810. }
  133811. declare module BABYLON {
  133812. /**
  133813. * Class containing static functions to help procedurally build meshes
  133814. */
  133815. export class TorusKnotBuilder {
  133816. /**
  133817. * Creates a torus knot mesh
  133818. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133819. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133820. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133821. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133825. * @param name defines the name of the mesh
  133826. * @param options defines the options used to create the mesh
  133827. * @param scene defines the hosting scene
  133828. * @returns the torus knot mesh
  133829. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133830. */
  133831. static CreateTorusKnot(name: string, options: {
  133832. radius?: number;
  133833. tube?: number;
  133834. radialSegments?: number;
  133835. tubularSegments?: number;
  133836. p?: number;
  133837. q?: number;
  133838. updatable?: boolean;
  133839. sideOrientation?: number;
  133840. frontUVs?: Vector4;
  133841. backUVs?: Vector4;
  133842. }, scene: any): Mesh;
  133843. }
  133844. }
  133845. declare module BABYLON {
  133846. /**
  133847. * Polygon
  133848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133849. */
  133850. export class Polygon {
  133851. /**
  133852. * Creates a rectangle
  133853. * @param xmin bottom X coord
  133854. * @param ymin bottom Y coord
  133855. * @param xmax top X coord
  133856. * @param ymax top Y coord
  133857. * @returns points that make the resulting rectation
  133858. */
  133859. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133860. /**
  133861. * Creates a circle
  133862. * @param radius radius of circle
  133863. * @param cx scale in x
  133864. * @param cy scale in y
  133865. * @param numberOfSides number of sides that make up the circle
  133866. * @returns points that make the resulting circle
  133867. */
  133868. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133869. /**
  133870. * Creates a polygon from input string
  133871. * @param input Input polygon data
  133872. * @returns the parsed points
  133873. */
  133874. static Parse(input: string): Vector2[];
  133875. /**
  133876. * Starts building a polygon from x and y coordinates
  133877. * @param x x coordinate
  133878. * @param y y coordinate
  133879. * @returns the started path2
  133880. */
  133881. static StartingAt(x: number, y: number): Path2;
  133882. }
  133883. /**
  133884. * Builds a polygon
  133885. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133886. */
  133887. export class PolygonMeshBuilder {
  133888. private _points;
  133889. private _outlinepoints;
  133890. private _holes;
  133891. private _name;
  133892. private _scene;
  133893. private _epoints;
  133894. private _eholes;
  133895. private _addToepoint;
  133896. /**
  133897. * Babylon reference to the earcut plugin.
  133898. */
  133899. bjsEarcut: any;
  133900. /**
  133901. * Creates a PolygonMeshBuilder
  133902. * @param name name of the builder
  133903. * @param contours Path of the polygon
  133904. * @param scene scene to add to when creating the mesh
  133905. * @param earcutInjection can be used to inject your own earcut reference
  133906. */
  133907. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133908. /**
  133909. * Adds a whole within the polygon
  133910. * @param hole Array of points defining the hole
  133911. * @returns this
  133912. */
  133913. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133914. /**
  133915. * Creates the polygon
  133916. * @param updatable If the mesh should be updatable
  133917. * @param depth The depth of the mesh created
  133918. * @returns the created mesh
  133919. */
  133920. build(updatable?: boolean, depth?: number): Mesh;
  133921. /**
  133922. * Creates the polygon
  133923. * @param depth The depth of the mesh created
  133924. * @returns the created VertexData
  133925. */
  133926. buildVertexData(depth?: number): VertexData;
  133927. /**
  133928. * Adds a side to the polygon
  133929. * @param positions points that make the polygon
  133930. * @param normals normals of the polygon
  133931. * @param uvs uvs of the polygon
  133932. * @param indices indices of the polygon
  133933. * @param bounds bounds of the polygon
  133934. * @param points points of the polygon
  133935. * @param depth depth of the polygon
  133936. * @param flip flip of the polygon
  133937. */
  133938. private addSide;
  133939. }
  133940. }
  133941. declare module BABYLON {
  133942. /**
  133943. * Class containing static functions to help procedurally build meshes
  133944. */
  133945. export class PolygonBuilder {
  133946. /**
  133947. * Creates a polygon mesh
  133948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133949. * * 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
  133950. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133953. * * Remember you can only change the shape positions, not their number when updating a polygon
  133954. * @param name defines the name of the mesh
  133955. * @param options defines the options used to create the mesh
  133956. * @param scene defines the hosting scene
  133957. * @param earcutInjection can be used to inject your own earcut reference
  133958. * @returns the polygon mesh
  133959. */
  133960. static CreatePolygon(name: string, options: {
  133961. shape: Vector3[];
  133962. holes?: Vector3[][];
  133963. depth?: number;
  133964. faceUV?: Vector4[];
  133965. faceColors?: Color4[];
  133966. updatable?: boolean;
  133967. sideOrientation?: number;
  133968. frontUVs?: Vector4;
  133969. backUVs?: Vector4;
  133970. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133971. /**
  133972. * Creates an extruded polygon mesh, with depth in the Y direction.
  133973. * * 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)
  133974. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133975. * @param name defines the name of the mesh
  133976. * @param options defines the options used to create the mesh
  133977. * @param scene defines the hosting scene
  133978. * @param earcutInjection can be used to inject your own earcut reference
  133979. * @returns the polygon mesh
  133980. */
  133981. static ExtrudePolygon(name: string, options: {
  133982. shape: Vector3[];
  133983. holes?: Vector3[][];
  133984. depth?: number;
  133985. faceUV?: Vector4[];
  133986. faceColors?: Color4[];
  133987. updatable?: boolean;
  133988. sideOrientation?: number;
  133989. frontUVs?: Vector4;
  133990. backUVs?: Vector4;
  133991. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133992. }
  133993. }
  133994. declare module BABYLON {
  133995. /**
  133996. * Class containing static functions to help procedurally build meshes
  133997. */
  133998. export class LatheBuilder {
  133999. /**
  134000. * Creates lathe mesh.
  134001. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134002. * * 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
  134003. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134004. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134005. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134006. * * 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
  134007. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134008. * * 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
  134009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 lathe mesh
  134017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134018. */
  134019. static CreateLathe(name: string, options: {
  134020. shape: Vector3[];
  134021. radius?: number;
  134022. tessellation?: number;
  134023. clip?: number;
  134024. arc?: number;
  134025. closed?: boolean;
  134026. updatable?: boolean;
  134027. sideOrientation?: number;
  134028. frontUVs?: Vector4;
  134029. backUVs?: Vector4;
  134030. cap?: number;
  134031. invertUV?: boolean;
  134032. }, scene?: Nullable<Scene>): Mesh;
  134033. }
  134034. }
  134035. declare module BABYLON {
  134036. /**
  134037. * Class containing static functions to help procedurally build meshes
  134038. */
  134039. export class TiledPlaneBuilder {
  134040. /**
  134041. * Creates a tiled plane mesh
  134042. * * The parameter `pattern` will, depending on value, do nothing or
  134043. * * * flip (reflect about central vertical) alternate tiles across and up
  134044. * * * flip every tile on alternate rows
  134045. * * * rotate (180 degs) alternate tiles across and up
  134046. * * * rotate every tile on alternate rows
  134047. * * * flip and rotate alternate tiles across and up
  134048. * * * flip and rotate every tile on alternate rows
  134049. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134050. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134053. * * 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)
  134054. * * 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)
  134055. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134056. * @param name defines the name of the mesh
  134057. * @param options defines the options used to create the mesh
  134058. * @param scene defines the hosting scene
  134059. * @returns the box mesh
  134060. */
  134061. static CreateTiledPlane(name: string, options: {
  134062. pattern?: number;
  134063. tileSize?: number;
  134064. tileWidth?: number;
  134065. tileHeight?: number;
  134066. size?: number;
  134067. width?: number;
  134068. height?: number;
  134069. alignHorizontal?: number;
  134070. alignVertical?: number;
  134071. sideOrientation?: number;
  134072. frontUVs?: Vector4;
  134073. backUVs?: Vector4;
  134074. updatable?: boolean;
  134075. }, scene?: Nullable<Scene>): Mesh;
  134076. }
  134077. }
  134078. declare module BABYLON {
  134079. /**
  134080. * Class containing static functions to help procedurally build meshes
  134081. */
  134082. export class TubeBuilder {
  134083. /**
  134084. * Creates a tube mesh.
  134085. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134086. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134087. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134088. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134089. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134090. * * 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)
  134091. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134092. * * 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
  134093. * * 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
  134094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134098. * @param name defines the name of the mesh
  134099. * @param options defines the options used to create the mesh
  134100. * @param scene defines the hosting scene
  134101. * @returns the tube mesh
  134102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134103. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134104. */
  134105. static CreateTube(name: string, options: {
  134106. path: Vector3[];
  134107. radius?: number;
  134108. tessellation?: number;
  134109. radiusFunction?: {
  134110. (i: number, distance: number): number;
  134111. };
  134112. cap?: number;
  134113. arc?: number;
  134114. updatable?: boolean;
  134115. sideOrientation?: number;
  134116. frontUVs?: Vector4;
  134117. backUVs?: Vector4;
  134118. instance?: Mesh;
  134119. invertUV?: boolean;
  134120. }, scene?: Nullable<Scene>): Mesh;
  134121. }
  134122. }
  134123. declare module BABYLON {
  134124. /**
  134125. * Class containing static functions to help procedurally build meshes
  134126. */
  134127. export class IcoSphereBuilder {
  134128. /**
  134129. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134130. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134131. * * 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`)
  134132. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134133. * * 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
  134134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134137. * @param name defines the name of the mesh
  134138. * @param options defines the options used to create the mesh
  134139. * @param scene defines the hosting scene
  134140. * @returns the icosahedron mesh
  134141. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134142. */
  134143. static CreateIcoSphere(name: string, options: {
  134144. radius?: number;
  134145. radiusX?: number;
  134146. radiusY?: number;
  134147. radiusZ?: number;
  134148. flat?: boolean;
  134149. subdivisions?: number;
  134150. sideOrientation?: number;
  134151. frontUVs?: Vector4;
  134152. backUVs?: Vector4;
  134153. updatable?: boolean;
  134154. }, scene?: Nullable<Scene>): Mesh;
  134155. }
  134156. }
  134157. declare module BABYLON {
  134158. /**
  134159. * Class containing static functions to help procedurally build meshes
  134160. */
  134161. export class DecalBuilder {
  134162. /**
  134163. * Creates a decal mesh.
  134164. * 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
  134165. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134166. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134167. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134168. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134169. * @param name defines the name of the mesh
  134170. * @param sourceMesh defines the mesh where the decal must be applied
  134171. * @param options defines the options used to create the mesh
  134172. * @param scene defines the hosting scene
  134173. * @returns the decal mesh
  134174. * @see https://doc.babylonjs.com/how_to/decals
  134175. */
  134176. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134177. position?: Vector3;
  134178. normal?: Vector3;
  134179. size?: Vector3;
  134180. angle?: number;
  134181. }): Mesh;
  134182. }
  134183. }
  134184. declare module BABYLON {
  134185. /**
  134186. * Class containing static functions to help procedurally build meshes
  134187. */
  134188. export class MeshBuilder {
  134189. /**
  134190. * Creates a box mesh
  134191. * * The parameter `size` sets the size (float) of each box side (default 1)
  134192. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134193. * * 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)
  134194. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134199. * @param name defines the name of the mesh
  134200. * @param options defines the options used to create the mesh
  134201. * @param scene defines the hosting scene
  134202. * @returns the box mesh
  134203. */
  134204. static CreateBox(name: string, options: {
  134205. size?: number;
  134206. width?: number;
  134207. height?: number;
  134208. depth?: number;
  134209. faceUV?: Vector4[];
  134210. faceColors?: Color4[];
  134211. sideOrientation?: number;
  134212. frontUVs?: Vector4;
  134213. backUVs?: Vector4;
  134214. updatable?: boolean;
  134215. }, scene?: Nullable<Scene>): Mesh;
  134216. /**
  134217. * Creates a tiled box mesh
  134218. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134220. * @param name defines the name of the mesh
  134221. * @param options defines the options used to create the mesh
  134222. * @param scene defines the hosting scene
  134223. * @returns the tiled box mesh
  134224. */
  134225. static CreateTiledBox(name: string, options: {
  134226. pattern?: number;
  134227. size?: number;
  134228. width?: number;
  134229. height?: number;
  134230. depth: number;
  134231. tileSize?: number;
  134232. tileWidth?: number;
  134233. tileHeight?: number;
  134234. faceUV?: Vector4[];
  134235. faceColors?: Color4[];
  134236. alignHorizontal?: number;
  134237. alignVertical?: number;
  134238. sideOrientation?: number;
  134239. updatable?: boolean;
  134240. }, scene?: Nullable<Scene>): Mesh;
  134241. /**
  134242. * Creates a sphere mesh
  134243. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134244. * * 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`)
  134245. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134246. * * 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
  134247. * * 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)
  134248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134251. * @param name defines the name of the mesh
  134252. * @param options defines the options used to create the mesh
  134253. * @param scene defines the hosting scene
  134254. * @returns the sphere mesh
  134255. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134256. */
  134257. static CreateSphere(name: string, options: {
  134258. segments?: number;
  134259. diameter?: number;
  134260. diameterX?: number;
  134261. diameterY?: number;
  134262. diameterZ?: number;
  134263. arc?: number;
  134264. slice?: number;
  134265. sideOrientation?: number;
  134266. frontUVs?: Vector4;
  134267. backUVs?: Vector4;
  134268. updatable?: boolean;
  134269. }, scene?: Nullable<Scene>): Mesh;
  134270. /**
  134271. * Creates a plane polygonal mesh. By default, this is a disc
  134272. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134273. * * 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
  134274. * * 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
  134275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134278. * @param name defines the name of the mesh
  134279. * @param options defines the options used to create the mesh
  134280. * @param scene defines the hosting scene
  134281. * @returns the plane polygonal mesh
  134282. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134283. */
  134284. static CreateDisc(name: string, options: {
  134285. radius?: number;
  134286. tessellation?: number;
  134287. arc?: number;
  134288. updatable?: boolean;
  134289. sideOrientation?: number;
  134290. frontUVs?: Vector4;
  134291. backUVs?: Vector4;
  134292. }, scene?: Nullable<Scene>): Mesh;
  134293. /**
  134294. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134295. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134296. * * 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`)
  134297. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134298. * * 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
  134299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134302. * @param name defines the name of the mesh
  134303. * @param options defines the options used to create the mesh
  134304. * @param scene defines the hosting scene
  134305. * @returns the icosahedron mesh
  134306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134307. */
  134308. static CreateIcoSphere(name: string, options: {
  134309. radius?: number;
  134310. radiusX?: number;
  134311. radiusY?: number;
  134312. radiusZ?: number;
  134313. flat?: boolean;
  134314. subdivisions?: number;
  134315. sideOrientation?: number;
  134316. frontUVs?: Vector4;
  134317. backUVs?: Vector4;
  134318. updatable?: boolean;
  134319. }, scene?: Nullable<Scene>): Mesh;
  134320. /**
  134321. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134322. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134323. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134324. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134325. * * 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
  134326. * * 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
  134327. * * 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
  134328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134331. * * 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
  134332. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134333. * * 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
  134334. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134336. * @param name defines the name of the mesh
  134337. * @param options defines the options used to create the mesh
  134338. * @param scene defines the hosting scene
  134339. * @returns the ribbon mesh
  134340. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134341. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134342. */
  134343. static CreateRibbon(name: string, options: {
  134344. pathArray: Vector3[][];
  134345. closeArray?: boolean;
  134346. closePath?: boolean;
  134347. offset?: number;
  134348. updatable?: boolean;
  134349. sideOrientation?: number;
  134350. frontUVs?: Vector4;
  134351. backUVs?: Vector4;
  134352. instance?: Mesh;
  134353. invertUV?: boolean;
  134354. uvs?: Vector2[];
  134355. colors?: Color4[];
  134356. }, scene?: Nullable<Scene>): Mesh;
  134357. /**
  134358. * Creates a cylinder or a cone mesh
  134359. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134360. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134361. * * 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.
  134362. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134363. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134364. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134365. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134366. * * 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).
  134367. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134368. * * 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).
  134369. * * 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
  134370. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134371. * * 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
  134372. * * 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.
  134373. * * If `enclose` is false, a ring surface is one element.
  134374. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134375. * * 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
  134376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134379. * @param name defines the name of the mesh
  134380. * @param options defines the options used to create the mesh
  134381. * @param scene defines the hosting scene
  134382. * @returns the cylinder mesh
  134383. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134384. */
  134385. static CreateCylinder(name: string, options: {
  134386. height?: number;
  134387. diameterTop?: number;
  134388. diameterBottom?: number;
  134389. diameter?: number;
  134390. tessellation?: number;
  134391. subdivisions?: number;
  134392. arc?: number;
  134393. faceColors?: Color4[];
  134394. faceUV?: Vector4[];
  134395. updatable?: boolean;
  134396. hasRings?: boolean;
  134397. enclose?: boolean;
  134398. cap?: number;
  134399. sideOrientation?: number;
  134400. frontUVs?: Vector4;
  134401. backUVs?: Vector4;
  134402. }, scene?: Nullable<Scene>): Mesh;
  134403. /**
  134404. * Creates a torus mesh
  134405. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134406. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134407. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134411. * @param name defines the name of the mesh
  134412. * @param options defines the options used to create the mesh
  134413. * @param scene defines the hosting scene
  134414. * @returns the torus mesh
  134415. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134416. */
  134417. static CreateTorus(name: string, options: {
  134418. diameter?: number;
  134419. thickness?: number;
  134420. tessellation?: number;
  134421. updatable?: boolean;
  134422. sideOrientation?: number;
  134423. frontUVs?: Vector4;
  134424. backUVs?: Vector4;
  134425. }, scene?: Nullable<Scene>): Mesh;
  134426. /**
  134427. * Creates a torus knot mesh
  134428. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134429. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134430. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134431. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134435. * @param name defines the name of the mesh
  134436. * @param options defines the options used to create the mesh
  134437. * @param scene defines the hosting scene
  134438. * @returns the torus knot mesh
  134439. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134440. */
  134441. static CreateTorusKnot(name: string, options: {
  134442. radius?: number;
  134443. tube?: number;
  134444. radialSegments?: number;
  134445. tubularSegments?: number;
  134446. p?: number;
  134447. q?: number;
  134448. updatable?: boolean;
  134449. sideOrientation?: number;
  134450. frontUVs?: Vector4;
  134451. backUVs?: Vector4;
  134452. }, scene?: Nullable<Scene>): Mesh;
  134453. /**
  134454. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134455. * * 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
  134456. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134457. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134458. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134459. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134460. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134461. * * 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
  134462. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134465. * @param name defines the name of the new line system
  134466. * @param options defines the options used to create the line system
  134467. * @param scene defines the hosting scene
  134468. * @returns a new line system mesh
  134469. */
  134470. static CreateLineSystem(name: string, options: {
  134471. lines: Vector3[][];
  134472. updatable?: boolean;
  134473. instance?: Nullable<LinesMesh>;
  134474. colors?: Nullable<Color4[][]>;
  134475. useVertexAlpha?: boolean;
  134476. }, scene: Nullable<Scene>): LinesMesh;
  134477. /**
  134478. * Creates a line mesh
  134479. * 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
  134480. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134481. * * The parameter `points` is an array successive Vector3
  134482. * * 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
  134483. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134484. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134485. * * When updating an instance, remember that only point positions can change, not the number of points
  134486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134488. * @param name defines the name of the new line system
  134489. * @param options defines the options used to create the line system
  134490. * @param scene defines the hosting scene
  134491. * @returns a new line mesh
  134492. */
  134493. static CreateLines(name: string, options: {
  134494. points: Vector3[];
  134495. updatable?: boolean;
  134496. instance?: Nullable<LinesMesh>;
  134497. colors?: Color4[];
  134498. useVertexAlpha?: boolean;
  134499. }, scene?: Nullable<Scene>): LinesMesh;
  134500. /**
  134501. * Creates a dashed line mesh
  134502. * * 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
  134503. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134504. * * The parameter `points` is an array successive Vector3
  134505. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134506. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134507. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134508. * * 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
  134509. * * When updating an instance, remember that only point positions can change, not the number of points
  134510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134511. * @param name defines the name of the mesh
  134512. * @param options defines the options used to create the mesh
  134513. * @param scene defines the hosting scene
  134514. * @returns the dashed line mesh
  134515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134516. */
  134517. static CreateDashedLines(name: string, options: {
  134518. points: Vector3[];
  134519. dashSize?: number;
  134520. gapSize?: number;
  134521. dashNb?: number;
  134522. updatable?: boolean;
  134523. instance?: LinesMesh;
  134524. }, scene?: Nullable<Scene>): LinesMesh;
  134525. /**
  134526. * 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.
  134527. * * 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.
  134528. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134529. * * 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.
  134530. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134531. * * 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
  134532. * * 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
  134533. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134538. * @param name defines the name of the mesh
  134539. * @param options defines the options used to create the mesh
  134540. * @param scene defines the hosting scene
  134541. * @returns the extruded shape mesh
  134542. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134544. */
  134545. static ExtrudeShape(name: string, options: {
  134546. shape: Vector3[];
  134547. path: Vector3[];
  134548. scale?: number;
  134549. rotation?: number;
  134550. cap?: number;
  134551. updatable?: boolean;
  134552. sideOrientation?: number;
  134553. frontUVs?: Vector4;
  134554. backUVs?: Vector4;
  134555. instance?: Mesh;
  134556. invertUV?: boolean;
  134557. }, scene?: Nullable<Scene>): Mesh;
  134558. /**
  134559. * Creates an custom extruded shape mesh.
  134560. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134561. * * 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.
  134562. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134563. * * 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
  134564. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134565. * * 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
  134566. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134567. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134568. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134569. * * 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
  134570. * * 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
  134571. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134574. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134576. * @param name defines the name of the mesh
  134577. * @param options defines the options used to create the mesh
  134578. * @param scene defines the hosting scene
  134579. * @returns the custom extruded shape mesh
  134580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134581. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134583. */
  134584. static ExtrudeShapeCustom(name: string, options: {
  134585. shape: Vector3[];
  134586. path: Vector3[];
  134587. scaleFunction?: any;
  134588. rotationFunction?: any;
  134589. ribbonCloseArray?: boolean;
  134590. ribbonClosePath?: boolean;
  134591. cap?: number;
  134592. updatable?: boolean;
  134593. sideOrientation?: number;
  134594. frontUVs?: Vector4;
  134595. backUVs?: Vector4;
  134596. instance?: Mesh;
  134597. invertUV?: boolean;
  134598. }, scene?: Nullable<Scene>): Mesh;
  134599. /**
  134600. * Creates lathe mesh.
  134601. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134602. * * 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
  134603. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134604. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134605. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134606. * * 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
  134607. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134608. * * 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
  134609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134613. * @param name defines the name of the mesh
  134614. * @param options defines the options used to create the mesh
  134615. * @param scene defines the hosting scene
  134616. * @returns the lathe mesh
  134617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134618. */
  134619. static CreateLathe(name: string, options: {
  134620. shape: Vector3[];
  134621. radius?: number;
  134622. tessellation?: number;
  134623. clip?: number;
  134624. arc?: number;
  134625. closed?: boolean;
  134626. updatable?: boolean;
  134627. sideOrientation?: number;
  134628. frontUVs?: Vector4;
  134629. backUVs?: Vector4;
  134630. cap?: number;
  134631. invertUV?: boolean;
  134632. }, scene?: Nullable<Scene>): Mesh;
  134633. /**
  134634. * Creates a tiled plane mesh
  134635. * * You can set a limited pattern arrangement with the tiles
  134636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134639. * @param name defines the name of the mesh
  134640. * @param options defines the options used to create the mesh
  134641. * @param scene defines the hosting scene
  134642. * @returns the plane mesh
  134643. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134644. */
  134645. static CreateTiledPlane(name: string, options: {
  134646. pattern?: number;
  134647. tileSize?: number;
  134648. tileWidth?: number;
  134649. tileHeight?: number;
  134650. size?: number;
  134651. width?: number;
  134652. height?: number;
  134653. alignHorizontal?: number;
  134654. alignVertical?: number;
  134655. sideOrientation?: number;
  134656. frontUVs?: Vector4;
  134657. backUVs?: Vector4;
  134658. updatable?: boolean;
  134659. }, scene?: Nullable<Scene>): Mesh;
  134660. /**
  134661. * Creates a plane mesh
  134662. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134663. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134664. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134668. * @param name defines the name of the mesh
  134669. * @param options defines the options used to create the mesh
  134670. * @param scene defines the hosting scene
  134671. * @returns the plane mesh
  134672. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134673. */
  134674. static CreatePlane(name: string, options: {
  134675. size?: number;
  134676. width?: number;
  134677. height?: number;
  134678. sideOrientation?: number;
  134679. frontUVs?: Vector4;
  134680. backUVs?: Vector4;
  134681. updatable?: boolean;
  134682. sourcePlane?: Plane;
  134683. }, scene?: Nullable<Scene>): Mesh;
  134684. /**
  134685. * Creates a ground mesh
  134686. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134687. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134689. * @param name defines the name of the mesh
  134690. * @param options defines the options used to create the mesh
  134691. * @param scene defines the hosting scene
  134692. * @returns the ground mesh
  134693. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134694. */
  134695. static CreateGround(name: string, options: {
  134696. width?: number;
  134697. height?: number;
  134698. subdivisions?: number;
  134699. subdivisionsX?: number;
  134700. subdivisionsY?: number;
  134701. updatable?: boolean;
  134702. }, scene?: Nullable<Scene>): Mesh;
  134703. /**
  134704. * Creates a tiled ground mesh
  134705. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134706. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134707. * * 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
  134708. * * 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
  134709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134710. * @param name defines the name of the mesh
  134711. * @param options defines the options used to create the mesh
  134712. * @param scene defines the hosting scene
  134713. * @returns the tiled ground mesh
  134714. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134715. */
  134716. static CreateTiledGround(name: string, options: {
  134717. xmin: number;
  134718. zmin: number;
  134719. xmax: number;
  134720. zmax: number;
  134721. subdivisions?: {
  134722. w: number;
  134723. h: number;
  134724. };
  134725. precision?: {
  134726. w: number;
  134727. h: number;
  134728. };
  134729. updatable?: boolean;
  134730. }, scene?: Nullable<Scene>): Mesh;
  134731. /**
  134732. * Creates a ground mesh from a height map
  134733. * * The parameter `url` sets the URL of the height map image resource.
  134734. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134735. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134736. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134737. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134738. * * 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.
  134739. * * 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).
  134740. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134742. * @param name defines the name of the mesh
  134743. * @param url defines the url to the height map
  134744. * @param options defines the options used to create the mesh
  134745. * @param scene defines the hosting scene
  134746. * @returns the ground mesh
  134747. * @see https://doc.babylonjs.com/babylon101/height_map
  134748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134749. */
  134750. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134751. width?: number;
  134752. height?: number;
  134753. subdivisions?: number;
  134754. minHeight?: number;
  134755. maxHeight?: number;
  134756. colorFilter?: Color3;
  134757. alphaFilter?: number;
  134758. updatable?: boolean;
  134759. onReady?: (mesh: GroundMesh) => void;
  134760. }, scene?: Nullable<Scene>): GroundMesh;
  134761. /**
  134762. * Creates a polygon mesh
  134763. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134764. * * 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
  134765. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134768. * * Remember you can only change the shape positions, not their number when updating a polygon
  134769. * @param name defines the name of the mesh
  134770. * @param options defines the options used to create the mesh
  134771. * @param scene defines the hosting scene
  134772. * @param earcutInjection can be used to inject your own earcut reference
  134773. * @returns the polygon mesh
  134774. */
  134775. static CreatePolygon(name: string, options: {
  134776. shape: Vector3[];
  134777. holes?: Vector3[][];
  134778. depth?: number;
  134779. faceUV?: Vector4[];
  134780. faceColors?: Color4[];
  134781. updatable?: boolean;
  134782. sideOrientation?: number;
  134783. frontUVs?: Vector4;
  134784. backUVs?: Vector4;
  134785. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134786. /**
  134787. * Creates an extruded polygon mesh, with depth in the Y direction.
  134788. * * 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)
  134789. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134790. * @param name defines the name of the mesh
  134791. * @param options defines the options used to create the mesh
  134792. * @param scene defines the hosting scene
  134793. * @param earcutInjection can be used to inject your own earcut reference
  134794. * @returns the polygon mesh
  134795. */
  134796. static ExtrudePolygon(name: string, options: {
  134797. shape: Vector3[];
  134798. holes?: Vector3[][];
  134799. depth?: number;
  134800. faceUV?: Vector4[];
  134801. faceColors?: Color4[];
  134802. updatable?: boolean;
  134803. sideOrientation?: number;
  134804. frontUVs?: Vector4;
  134805. backUVs?: Vector4;
  134806. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134807. /**
  134808. * Creates a tube mesh.
  134809. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134810. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134811. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134812. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134813. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134814. * * 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)
  134815. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134816. * * 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
  134817. * * 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
  134818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134822. * @param name defines the name of the mesh
  134823. * @param options defines the options used to create the mesh
  134824. * @param scene defines the hosting scene
  134825. * @returns the tube mesh
  134826. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134827. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134828. */
  134829. static CreateTube(name: string, options: {
  134830. path: Vector3[];
  134831. radius?: number;
  134832. tessellation?: number;
  134833. radiusFunction?: {
  134834. (i: number, distance: number): number;
  134835. };
  134836. cap?: number;
  134837. arc?: number;
  134838. updatable?: boolean;
  134839. sideOrientation?: number;
  134840. frontUVs?: Vector4;
  134841. backUVs?: Vector4;
  134842. instance?: Mesh;
  134843. invertUV?: boolean;
  134844. }, scene?: Nullable<Scene>): Mesh;
  134845. /**
  134846. * Creates a polyhedron mesh
  134847. * * 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
  134848. * * The parameter `size` (positive float, default 1) sets the polygon size
  134849. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134850. * * 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`
  134851. * * 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
  134852. * * 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)`)
  134853. * * 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
  134854. * * 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
  134855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134858. * @param name defines the name of the mesh
  134859. * @param options defines the options used to create the mesh
  134860. * @param scene defines the hosting scene
  134861. * @returns the polyhedron mesh
  134862. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134863. */
  134864. static CreatePolyhedron(name: string, options: {
  134865. type?: number;
  134866. size?: number;
  134867. sizeX?: number;
  134868. sizeY?: number;
  134869. sizeZ?: number;
  134870. custom?: any;
  134871. faceUV?: Vector4[];
  134872. faceColors?: Color4[];
  134873. flat?: boolean;
  134874. updatable?: boolean;
  134875. sideOrientation?: number;
  134876. frontUVs?: Vector4;
  134877. backUVs?: Vector4;
  134878. }, scene?: Nullable<Scene>): Mesh;
  134879. /**
  134880. * Creates a decal mesh.
  134881. * 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
  134882. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134883. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134884. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134885. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134886. * @param name defines the name of the mesh
  134887. * @param sourceMesh defines the mesh where the decal must be applied
  134888. * @param options defines the options used to create the mesh
  134889. * @param scene defines the hosting scene
  134890. * @returns the decal mesh
  134891. * @see https://doc.babylonjs.com/how_to/decals
  134892. */
  134893. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134894. position?: Vector3;
  134895. normal?: Vector3;
  134896. size?: Vector3;
  134897. angle?: number;
  134898. }): Mesh;
  134899. }
  134900. }
  134901. declare module BABYLON {
  134902. /**
  134903. * A simplifier interface for future simplification implementations
  134904. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134905. */
  134906. export interface ISimplifier {
  134907. /**
  134908. * Simplification of a given mesh according to the given settings.
  134909. * Since this requires computation, it is assumed that the function runs async.
  134910. * @param settings The settings of the simplification, including quality and distance
  134911. * @param successCallback A callback that will be called after the mesh was simplified.
  134912. * @param errorCallback in case of an error, this callback will be called. optional.
  134913. */
  134914. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134915. }
  134916. /**
  134917. * Expected simplification settings.
  134918. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134920. */
  134921. export interface ISimplificationSettings {
  134922. /**
  134923. * Gets or sets the expected quality
  134924. */
  134925. quality: number;
  134926. /**
  134927. * Gets or sets the distance when this optimized version should be used
  134928. */
  134929. distance: number;
  134930. /**
  134931. * Gets an already optimized mesh
  134932. */
  134933. optimizeMesh?: boolean;
  134934. }
  134935. /**
  134936. * Class used to specify simplification options
  134937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134938. */
  134939. export class SimplificationSettings implements ISimplificationSettings {
  134940. /** expected quality */
  134941. quality: number;
  134942. /** distance when this optimized version should be used */
  134943. distance: number;
  134944. /** already optimized mesh */
  134945. optimizeMesh?: boolean | undefined;
  134946. /**
  134947. * Creates a SimplificationSettings
  134948. * @param quality expected quality
  134949. * @param distance distance when this optimized version should be used
  134950. * @param optimizeMesh already optimized mesh
  134951. */
  134952. constructor(
  134953. /** expected quality */
  134954. quality: number,
  134955. /** distance when this optimized version should be used */
  134956. distance: number,
  134957. /** already optimized mesh */
  134958. optimizeMesh?: boolean | undefined);
  134959. }
  134960. /**
  134961. * Interface used to define a simplification task
  134962. */
  134963. export interface ISimplificationTask {
  134964. /**
  134965. * Array of settings
  134966. */
  134967. settings: Array<ISimplificationSettings>;
  134968. /**
  134969. * Simplification type
  134970. */
  134971. simplificationType: SimplificationType;
  134972. /**
  134973. * Mesh to simplify
  134974. */
  134975. mesh: Mesh;
  134976. /**
  134977. * Callback called on success
  134978. */
  134979. successCallback?: () => void;
  134980. /**
  134981. * Defines if parallel processing can be used
  134982. */
  134983. parallelProcessing: boolean;
  134984. }
  134985. /**
  134986. * Queue used to order the simplification tasks
  134987. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134988. */
  134989. export class SimplificationQueue {
  134990. private _simplificationArray;
  134991. /**
  134992. * Gets a boolean indicating that the process is still running
  134993. */
  134994. running: boolean;
  134995. /**
  134996. * Creates a new queue
  134997. */
  134998. constructor();
  134999. /**
  135000. * Adds a new simplification task
  135001. * @param task defines a task to add
  135002. */
  135003. addTask(task: ISimplificationTask): void;
  135004. /**
  135005. * Execute next task
  135006. */
  135007. executeNext(): void;
  135008. /**
  135009. * Execute a simplification task
  135010. * @param task defines the task to run
  135011. */
  135012. runSimplification(task: ISimplificationTask): void;
  135013. private getSimplifier;
  135014. }
  135015. /**
  135016. * The implemented types of simplification
  135017. * At the moment only Quadratic Error Decimation is implemented
  135018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135019. */
  135020. export enum SimplificationType {
  135021. /** Quadratic error decimation */
  135022. QUADRATIC = 0
  135023. }
  135024. }
  135025. declare module BABYLON {
  135026. interface Scene {
  135027. /** @hidden (Backing field) */
  135028. _simplificationQueue: SimplificationQueue;
  135029. /**
  135030. * Gets or sets the simplification queue attached to the scene
  135031. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135032. */
  135033. simplificationQueue: SimplificationQueue;
  135034. }
  135035. interface Mesh {
  135036. /**
  135037. * Simplify the mesh according to the given array of settings.
  135038. * Function will return immediately and will simplify async
  135039. * @param settings a collection of simplification settings
  135040. * @param parallelProcessing should all levels calculate parallel or one after the other
  135041. * @param simplificationType the type of simplification to run
  135042. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135043. * @returns the current mesh
  135044. */
  135045. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135046. }
  135047. /**
  135048. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135049. * created in a scene
  135050. */
  135051. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135052. /**
  135053. * The component name helpfull to identify the component in the list of scene components.
  135054. */
  135055. readonly name: string;
  135056. /**
  135057. * The scene the component belongs to.
  135058. */
  135059. scene: Scene;
  135060. /**
  135061. * Creates a new instance of the component for the given scene
  135062. * @param scene Defines the scene to register the component in
  135063. */
  135064. constructor(scene: Scene);
  135065. /**
  135066. * Registers the component in a given scene
  135067. */
  135068. register(): void;
  135069. /**
  135070. * Rebuilds the elements related to this component in case of
  135071. * context lost for instance.
  135072. */
  135073. rebuild(): void;
  135074. /**
  135075. * Disposes the component and the associated ressources
  135076. */
  135077. dispose(): void;
  135078. private _beforeCameraUpdate;
  135079. }
  135080. }
  135081. declare module BABYLON {
  135082. /**
  135083. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135084. */
  135085. export interface INavigationEnginePlugin {
  135086. /**
  135087. * plugin name
  135088. */
  135089. name: string;
  135090. /**
  135091. * Creates a navigation mesh
  135092. * @param meshes array of all the geometry used to compute the navigatio mesh
  135093. * @param parameters bunch of parameters used to filter geometry
  135094. */
  135095. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135096. /**
  135097. * Create a navigation mesh debug mesh
  135098. * @param scene is where the mesh will be added
  135099. * @returns debug display mesh
  135100. */
  135101. createDebugNavMesh(scene: Scene): Mesh;
  135102. /**
  135103. * Get a navigation mesh constrained position, closest to the parameter position
  135104. * @param position world position
  135105. * @returns the closest point to position constrained by the navigation mesh
  135106. */
  135107. getClosestPoint(position: Vector3): Vector3;
  135108. /**
  135109. * Get a navigation mesh constrained position, within a particular radius
  135110. * @param position world position
  135111. * @param maxRadius the maximum distance to the constrained world position
  135112. * @returns the closest point to position constrained by the navigation mesh
  135113. */
  135114. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135115. /**
  135116. * Compute the final position from a segment made of destination-position
  135117. * @param position world position
  135118. * @param destination world position
  135119. * @returns the resulting point along the navmesh
  135120. */
  135121. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135122. /**
  135123. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135124. * @param start world position
  135125. * @param end world position
  135126. * @returns array containing world position composing the path
  135127. */
  135128. computePath(start: Vector3, end: Vector3): Vector3[];
  135129. /**
  135130. * If this plugin is supported
  135131. * @returns true if plugin is supported
  135132. */
  135133. isSupported(): boolean;
  135134. /**
  135135. * Create a new Crowd so you can add agents
  135136. * @param maxAgents the maximum agent count in the crowd
  135137. * @param maxAgentRadius the maximum radius an agent can have
  135138. * @param scene to attach the crowd to
  135139. * @returns the crowd you can add agents to
  135140. */
  135141. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135142. /**
  135143. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135144. * The queries will try to find a solution within those bounds
  135145. * default is (1,1,1)
  135146. * @param extent x,y,z value that define the extent around the queries point of reference
  135147. */
  135148. setDefaultQueryExtent(extent: Vector3): void;
  135149. /**
  135150. * Get the Bounding box extent specified by setDefaultQueryExtent
  135151. * @returns the box extent values
  135152. */
  135153. getDefaultQueryExtent(): Vector3;
  135154. /**
  135155. * Release all resources
  135156. */
  135157. dispose(): void;
  135158. }
  135159. /**
  135160. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135161. */
  135162. export interface ICrowd {
  135163. /**
  135164. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135165. * You can attach anything to that node. The node position is updated in the scene update tick.
  135166. * @param pos world position that will be constrained by the navigation mesh
  135167. * @param parameters agent parameters
  135168. * @param transform hooked to the agent that will be update by the scene
  135169. * @returns agent index
  135170. */
  135171. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135172. /**
  135173. * Returns the agent position in world space
  135174. * @param index agent index returned by addAgent
  135175. * @returns world space position
  135176. */
  135177. getAgentPosition(index: number): Vector3;
  135178. /**
  135179. * Gets the agent velocity in world space
  135180. * @param index agent index returned by addAgent
  135181. * @returns world space velocity
  135182. */
  135183. getAgentVelocity(index: number): Vector3;
  135184. /**
  135185. * remove a particular agent previously created
  135186. * @param index agent index returned by addAgent
  135187. */
  135188. removeAgent(index: number): void;
  135189. /**
  135190. * get the list of all agents attached to this crowd
  135191. * @returns list of agent indices
  135192. */
  135193. getAgents(): number[];
  135194. /**
  135195. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135196. * @param deltaTime in seconds
  135197. */
  135198. update(deltaTime: number): void;
  135199. /**
  135200. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135201. * @param index agent index returned by addAgent
  135202. * @param destination targeted world position
  135203. */
  135204. agentGoto(index: number, destination: Vector3): void;
  135205. /**
  135206. * Teleport the agent to a new position
  135207. * @param index agent index returned by addAgent
  135208. * @param destination targeted world position
  135209. */
  135210. agentTeleport(index: number, destination: Vector3): void;
  135211. /**
  135212. * Update agent parameters
  135213. * @param index agent index returned by addAgent
  135214. * @param parameters agent parameters
  135215. */
  135216. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135217. /**
  135218. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135219. * The queries will try to find a solution within those bounds
  135220. * default is (1,1,1)
  135221. * @param extent x,y,z value that define the extent around the queries point of reference
  135222. */
  135223. setDefaultQueryExtent(extent: Vector3): void;
  135224. /**
  135225. * Get the Bounding box extent specified by setDefaultQueryExtent
  135226. * @returns the box extent values
  135227. */
  135228. getDefaultQueryExtent(): Vector3;
  135229. /**
  135230. * Release all resources
  135231. */
  135232. dispose(): void;
  135233. }
  135234. /**
  135235. * Configures an agent
  135236. */
  135237. export interface IAgentParameters {
  135238. /**
  135239. * Agent radius. [Limit: >= 0]
  135240. */
  135241. radius: number;
  135242. /**
  135243. * Agent height. [Limit: > 0]
  135244. */
  135245. height: number;
  135246. /**
  135247. * Maximum allowed acceleration. [Limit: >= 0]
  135248. */
  135249. maxAcceleration: number;
  135250. /**
  135251. * Maximum allowed speed. [Limit: >= 0]
  135252. */
  135253. maxSpeed: number;
  135254. /**
  135255. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135256. */
  135257. collisionQueryRange: number;
  135258. /**
  135259. * The path visibility optimization range. [Limit: > 0]
  135260. */
  135261. pathOptimizationRange: number;
  135262. /**
  135263. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135264. */
  135265. separationWeight: number;
  135266. }
  135267. /**
  135268. * Configures the navigation mesh creation
  135269. */
  135270. export interface INavMeshParameters {
  135271. /**
  135272. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135273. */
  135274. cs: number;
  135275. /**
  135276. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135277. */
  135278. ch: number;
  135279. /**
  135280. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135281. */
  135282. walkableSlopeAngle: number;
  135283. /**
  135284. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135285. * be considered walkable. [Limit: >= 3] [Units: vx]
  135286. */
  135287. walkableHeight: number;
  135288. /**
  135289. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135290. */
  135291. walkableClimb: number;
  135292. /**
  135293. * The distance to erode/shrink the walkable area of the heightfield away from
  135294. * obstructions. [Limit: >=0] [Units: vx]
  135295. */
  135296. walkableRadius: number;
  135297. /**
  135298. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135299. */
  135300. maxEdgeLen: number;
  135301. /**
  135302. * The maximum distance a simplfied contour's border edges should deviate
  135303. * the original raw contour. [Limit: >=0] [Units: vx]
  135304. */
  135305. maxSimplificationError: number;
  135306. /**
  135307. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135308. */
  135309. minRegionArea: number;
  135310. /**
  135311. * Any regions with a span count smaller than this value will, if possible,
  135312. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135313. */
  135314. mergeRegionArea: number;
  135315. /**
  135316. * The maximum number of vertices allowed for polygons generated during the
  135317. * contour to polygon conversion process. [Limit: >= 3]
  135318. */
  135319. maxVertsPerPoly: number;
  135320. /**
  135321. * Sets the sampling distance to use when generating the detail mesh.
  135322. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135323. */
  135324. detailSampleDist: number;
  135325. /**
  135326. * The maximum distance the detail mesh surface should deviate from heightfield
  135327. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135328. */
  135329. detailSampleMaxError: number;
  135330. }
  135331. }
  135332. declare module BABYLON {
  135333. /**
  135334. * RecastJS navigation plugin
  135335. */
  135336. export class RecastJSPlugin implements INavigationEnginePlugin {
  135337. /**
  135338. * Reference to the Recast library
  135339. */
  135340. bjsRECAST: any;
  135341. /**
  135342. * plugin name
  135343. */
  135344. name: string;
  135345. /**
  135346. * the first navmesh created. We might extend this to support multiple navmeshes
  135347. */
  135348. navMesh: any;
  135349. /**
  135350. * Initializes the recastJS plugin
  135351. * @param recastInjection can be used to inject your own recast reference
  135352. */
  135353. constructor(recastInjection?: any);
  135354. /**
  135355. * Creates a navigation mesh
  135356. * @param meshes array of all the geometry used to compute the navigatio mesh
  135357. * @param parameters bunch of parameters used to filter geometry
  135358. */
  135359. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135360. /**
  135361. * Create a navigation mesh debug mesh
  135362. * @param scene is where the mesh will be added
  135363. * @returns debug display mesh
  135364. */
  135365. createDebugNavMesh(scene: Scene): Mesh;
  135366. /**
  135367. * Get a navigation mesh constrained position, closest to the parameter position
  135368. * @param position world position
  135369. * @returns the closest point to position constrained by the navigation mesh
  135370. */
  135371. getClosestPoint(position: Vector3): Vector3;
  135372. /**
  135373. * Get a navigation mesh constrained position, within a particular radius
  135374. * @param position world position
  135375. * @param maxRadius the maximum distance to the constrained world position
  135376. * @returns the closest point to position constrained by the navigation mesh
  135377. */
  135378. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135379. /**
  135380. * Compute the final position from a segment made of destination-position
  135381. * @param position world position
  135382. * @param destination world position
  135383. * @returns the resulting point along the navmesh
  135384. */
  135385. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135386. /**
  135387. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135388. * @param start world position
  135389. * @param end world position
  135390. * @returns array containing world position composing the path
  135391. */
  135392. computePath(start: Vector3, end: Vector3): Vector3[];
  135393. /**
  135394. * Create a new Crowd so you can add agents
  135395. * @param maxAgents the maximum agent count in the crowd
  135396. * @param maxAgentRadius the maximum radius an agent can have
  135397. * @param scene to attach the crowd to
  135398. * @returns the crowd you can add agents to
  135399. */
  135400. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135401. /**
  135402. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135403. * The queries will try to find a solution within those bounds
  135404. * default is (1,1,1)
  135405. * @param extent x,y,z value that define the extent around the queries point of reference
  135406. */
  135407. setDefaultQueryExtent(extent: Vector3): void;
  135408. /**
  135409. * Get the Bounding box extent specified by setDefaultQueryExtent
  135410. * @returns the box extent values
  135411. */
  135412. getDefaultQueryExtent(): Vector3;
  135413. /**
  135414. * Disposes
  135415. */
  135416. dispose(): void;
  135417. /**
  135418. * If this plugin is supported
  135419. * @returns true if plugin is supported
  135420. */
  135421. isSupported(): boolean;
  135422. }
  135423. /**
  135424. * Recast detour crowd implementation
  135425. */
  135426. export class RecastJSCrowd implements ICrowd {
  135427. /**
  135428. * Recast/detour plugin
  135429. */
  135430. bjsRECASTPlugin: RecastJSPlugin;
  135431. /**
  135432. * Link to the detour crowd
  135433. */
  135434. recastCrowd: any;
  135435. /**
  135436. * One transform per agent
  135437. */
  135438. transforms: TransformNode[];
  135439. /**
  135440. * All agents created
  135441. */
  135442. agents: number[];
  135443. /**
  135444. * Link to the scene is kept to unregister the crowd from the scene
  135445. */
  135446. private _scene;
  135447. /**
  135448. * Observer for crowd updates
  135449. */
  135450. private _onBeforeAnimationsObserver;
  135451. /**
  135452. * Constructor
  135453. * @param plugin recastJS plugin
  135454. * @param maxAgents the maximum agent count in the crowd
  135455. * @param maxAgentRadius the maximum radius an agent can have
  135456. * @param scene to attach the crowd to
  135457. * @returns the crowd you can add agents to
  135458. */
  135459. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135460. /**
  135461. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135462. * You can attach anything to that node. The node position is updated in the scene update tick.
  135463. * @param pos world position that will be constrained by the navigation mesh
  135464. * @param parameters agent parameters
  135465. * @param transform hooked to the agent that will be update by the scene
  135466. * @returns agent index
  135467. */
  135468. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135469. /**
  135470. * Returns the agent position in world space
  135471. * @param index agent index returned by addAgent
  135472. * @returns world space position
  135473. */
  135474. getAgentPosition(index: number): Vector3;
  135475. /**
  135476. * Returns the agent velocity in world space
  135477. * @param index agent index returned by addAgent
  135478. * @returns world space velocity
  135479. */
  135480. getAgentVelocity(index: number): Vector3;
  135481. /**
  135482. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135483. * @param index agent index returned by addAgent
  135484. * @param destination targeted world position
  135485. */
  135486. agentGoto(index: number, destination: Vector3): void;
  135487. /**
  135488. * Teleport the agent to a new position
  135489. * @param index agent index returned by addAgent
  135490. * @param destination targeted world position
  135491. */
  135492. agentTeleport(index: number, destination: Vector3): void;
  135493. /**
  135494. * Update agent parameters
  135495. * @param index agent index returned by addAgent
  135496. * @param parameters agent parameters
  135497. */
  135498. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135499. /**
  135500. * remove a particular agent previously created
  135501. * @param index agent index returned by addAgent
  135502. */
  135503. removeAgent(index: number): void;
  135504. /**
  135505. * get the list of all agents attached to this crowd
  135506. * @returns list of agent indices
  135507. */
  135508. getAgents(): number[];
  135509. /**
  135510. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135511. * @param deltaTime in seconds
  135512. */
  135513. update(deltaTime: number): void;
  135514. /**
  135515. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135516. * The queries will try to find a solution within those bounds
  135517. * default is (1,1,1)
  135518. * @param extent x,y,z value that define the extent around the queries point of reference
  135519. */
  135520. setDefaultQueryExtent(extent: Vector3): void;
  135521. /**
  135522. * Get the Bounding box extent specified by setDefaultQueryExtent
  135523. * @returns the box extent values
  135524. */
  135525. getDefaultQueryExtent(): Vector3;
  135526. /**
  135527. * Release all resources
  135528. */
  135529. dispose(): void;
  135530. }
  135531. }
  135532. declare module BABYLON {
  135533. /**
  135534. * Class used to enable access to IndexedDB
  135535. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135536. */
  135537. export class Database implements IOfflineProvider {
  135538. private _callbackManifestChecked;
  135539. private _currentSceneUrl;
  135540. private _db;
  135541. private _enableSceneOffline;
  135542. private _enableTexturesOffline;
  135543. private _manifestVersionFound;
  135544. private _mustUpdateRessources;
  135545. private _hasReachedQuota;
  135546. private _isSupported;
  135547. private _idbFactory;
  135548. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135549. private static IsUASupportingBlobStorage;
  135550. /**
  135551. * Gets a boolean indicating if Database storate is enabled (off by default)
  135552. */
  135553. static IDBStorageEnabled: boolean;
  135554. /**
  135555. * Gets a boolean indicating if scene must be saved in the database
  135556. */
  135557. get enableSceneOffline(): boolean;
  135558. /**
  135559. * Gets a boolean indicating if textures must be saved in the database
  135560. */
  135561. get enableTexturesOffline(): boolean;
  135562. /**
  135563. * Creates a new Database
  135564. * @param urlToScene defines the url to load the scene
  135565. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135566. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135567. */
  135568. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135569. private static _ParseURL;
  135570. private static _ReturnFullUrlLocation;
  135571. private _checkManifestFile;
  135572. /**
  135573. * Open the database and make it available
  135574. * @param successCallback defines the callback to call on success
  135575. * @param errorCallback defines the callback to call on error
  135576. */
  135577. open(successCallback: () => void, errorCallback: () => void): void;
  135578. /**
  135579. * Loads an image from the database
  135580. * @param url defines the url to load from
  135581. * @param image defines the target DOM image
  135582. */
  135583. loadImage(url: string, image: HTMLImageElement): void;
  135584. private _loadImageFromDBAsync;
  135585. private _saveImageIntoDBAsync;
  135586. private _checkVersionFromDB;
  135587. private _loadVersionFromDBAsync;
  135588. private _saveVersionIntoDBAsync;
  135589. /**
  135590. * Loads a file from database
  135591. * @param url defines the URL to load from
  135592. * @param sceneLoaded defines a callback to call on success
  135593. * @param progressCallBack defines a callback to call when progress changed
  135594. * @param errorCallback defines a callback to call on error
  135595. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135596. */
  135597. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135598. private _loadFileAsync;
  135599. private _saveFileAsync;
  135600. /**
  135601. * Validates if xhr data is correct
  135602. * @param xhr defines the request to validate
  135603. * @param dataType defines the expected data type
  135604. * @returns true if data is correct
  135605. */
  135606. private static _ValidateXHRData;
  135607. }
  135608. }
  135609. declare module BABYLON {
  135610. /** @hidden */
  135611. export var gpuUpdateParticlesPixelShader: {
  135612. name: string;
  135613. shader: string;
  135614. };
  135615. }
  135616. declare module BABYLON {
  135617. /** @hidden */
  135618. export var gpuUpdateParticlesVertexShader: {
  135619. name: string;
  135620. shader: string;
  135621. };
  135622. }
  135623. declare module BABYLON {
  135624. /** @hidden */
  135625. export var clipPlaneFragmentDeclaration2: {
  135626. name: string;
  135627. shader: string;
  135628. };
  135629. }
  135630. declare module BABYLON {
  135631. /** @hidden */
  135632. export var gpuRenderParticlesPixelShader: {
  135633. name: string;
  135634. shader: string;
  135635. };
  135636. }
  135637. declare module BABYLON {
  135638. /** @hidden */
  135639. export var clipPlaneVertexDeclaration2: {
  135640. name: string;
  135641. shader: string;
  135642. };
  135643. }
  135644. declare module BABYLON {
  135645. /** @hidden */
  135646. export var gpuRenderParticlesVertexShader: {
  135647. name: string;
  135648. shader: string;
  135649. };
  135650. }
  135651. declare module BABYLON {
  135652. /**
  135653. * This represents a GPU particle system in Babylon
  135654. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135655. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135656. */
  135657. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135658. /**
  135659. * The layer mask we are rendering the particles through.
  135660. */
  135661. layerMask: number;
  135662. private _capacity;
  135663. private _activeCount;
  135664. private _currentActiveCount;
  135665. private _accumulatedCount;
  135666. private _renderEffect;
  135667. private _updateEffect;
  135668. private _buffer0;
  135669. private _buffer1;
  135670. private _spriteBuffer;
  135671. private _updateVAO;
  135672. private _renderVAO;
  135673. private _targetIndex;
  135674. private _sourceBuffer;
  135675. private _targetBuffer;
  135676. private _engine;
  135677. private _currentRenderId;
  135678. private _started;
  135679. private _stopped;
  135680. private _timeDelta;
  135681. private _randomTexture;
  135682. private _randomTexture2;
  135683. private _attributesStrideSize;
  135684. private _updateEffectOptions;
  135685. private _randomTextureSize;
  135686. private _actualFrame;
  135687. private readonly _rawTextureWidth;
  135688. /**
  135689. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135690. */
  135691. static get IsSupported(): boolean;
  135692. /**
  135693. * An event triggered when the system is disposed.
  135694. */
  135695. onDisposeObservable: Observable<GPUParticleSystem>;
  135696. /**
  135697. * Gets the maximum number of particles active at the same time.
  135698. * @returns The max number of active particles.
  135699. */
  135700. getCapacity(): number;
  135701. /**
  135702. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135703. * to override the particles.
  135704. */
  135705. forceDepthWrite: boolean;
  135706. /**
  135707. * Gets or set the number of active particles
  135708. */
  135709. get activeParticleCount(): number;
  135710. set activeParticleCount(value: number);
  135711. private _preWarmDone;
  135712. /**
  135713. * Specifies if the particles are updated in emitter local space or world space.
  135714. * This is always false for GPU particles
  135715. */
  135716. get isLocal(): boolean;
  135717. set isLocal(value: boolean);
  135718. /**
  135719. * Is this system ready to be used/rendered
  135720. * @return true if the system is ready
  135721. */
  135722. isReady(): boolean;
  135723. /**
  135724. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135725. * @returns True if it has been started, otherwise false.
  135726. */
  135727. isStarted(): boolean;
  135728. /**
  135729. * Starts the particle system and begins to emit
  135730. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135731. */
  135732. start(delay?: number): void;
  135733. /**
  135734. * Stops the particle system.
  135735. */
  135736. stop(): void;
  135737. /**
  135738. * Remove all active particles
  135739. */
  135740. reset(): void;
  135741. /**
  135742. * Returns the string "GPUParticleSystem"
  135743. * @returns a string containing the class name
  135744. */
  135745. getClassName(): string;
  135746. private _colorGradientsTexture;
  135747. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135748. /**
  135749. * Adds a new color gradient
  135750. * @param gradient defines the gradient to use (between 0 and 1)
  135751. * @param color1 defines the color to affect to the specified gradient
  135752. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135753. * @returns the current particle system
  135754. */
  135755. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135756. /**
  135757. * Remove a specific color gradient
  135758. * @param gradient defines the gradient to remove
  135759. * @returns the current particle system
  135760. */
  135761. removeColorGradient(gradient: number): GPUParticleSystem;
  135762. private _angularSpeedGradientsTexture;
  135763. private _sizeGradientsTexture;
  135764. private _velocityGradientsTexture;
  135765. private _limitVelocityGradientsTexture;
  135766. private _dragGradientsTexture;
  135767. private _addFactorGradient;
  135768. /**
  135769. * Adds a new size gradient
  135770. * @param gradient defines the gradient to use (between 0 and 1)
  135771. * @param factor defines the size factor to affect to the specified gradient
  135772. * @returns the current particle system
  135773. */
  135774. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135775. /**
  135776. * Remove a specific size gradient
  135777. * @param gradient defines the gradient to remove
  135778. * @returns the current particle system
  135779. */
  135780. removeSizeGradient(gradient: number): GPUParticleSystem;
  135781. /**
  135782. * Adds a new angular speed gradient
  135783. * @param gradient defines the gradient to use (between 0 and 1)
  135784. * @param factor defines the angular speed to affect to the specified gradient
  135785. * @returns the current particle system
  135786. */
  135787. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135788. /**
  135789. * Remove a specific angular speed gradient
  135790. * @param gradient defines the gradient to remove
  135791. * @returns the current particle system
  135792. */
  135793. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135794. /**
  135795. * Adds a new velocity gradient
  135796. * @param gradient defines the gradient to use (between 0 and 1)
  135797. * @param factor defines the velocity to affect to the specified gradient
  135798. * @returns the current particle system
  135799. */
  135800. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135801. /**
  135802. * Remove a specific velocity gradient
  135803. * @param gradient defines the gradient to remove
  135804. * @returns the current particle system
  135805. */
  135806. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135807. /**
  135808. * Adds a new limit velocity gradient
  135809. * @param gradient defines the gradient to use (between 0 and 1)
  135810. * @param factor defines the limit velocity value to affect to the specified gradient
  135811. * @returns the current particle system
  135812. */
  135813. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135814. /**
  135815. * Remove a specific limit velocity gradient
  135816. * @param gradient defines the gradient to remove
  135817. * @returns the current particle system
  135818. */
  135819. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135820. /**
  135821. * Adds a new drag gradient
  135822. * @param gradient defines the gradient to use (between 0 and 1)
  135823. * @param factor defines the drag value to affect to the specified gradient
  135824. * @returns the current particle system
  135825. */
  135826. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135827. /**
  135828. * Remove a specific drag gradient
  135829. * @param gradient defines the gradient to remove
  135830. * @returns the current particle system
  135831. */
  135832. removeDragGradient(gradient: number): GPUParticleSystem;
  135833. /**
  135834. * Not supported by GPUParticleSystem
  135835. * @param gradient defines the gradient to use (between 0 and 1)
  135836. * @param factor defines the emit rate value to affect to the specified gradient
  135837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135838. * @returns the current particle system
  135839. */
  135840. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135841. /**
  135842. * Not supported by GPUParticleSystem
  135843. * @param gradient defines the gradient to remove
  135844. * @returns the current particle system
  135845. */
  135846. removeEmitRateGradient(gradient: number): IParticleSystem;
  135847. /**
  135848. * Not supported by GPUParticleSystem
  135849. * @param gradient defines the gradient to use (between 0 and 1)
  135850. * @param factor defines the start size value to affect to the specified gradient
  135851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135852. * @returns the current particle system
  135853. */
  135854. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135855. /**
  135856. * Not supported by GPUParticleSystem
  135857. * @param gradient defines the gradient to remove
  135858. * @returns the current particle system
  135859. */
  135860. removeStartSizeGradient(gradient: number): IParticleSystem;
  135861. /**
  135862. * Not supported by GPUParticleSystem
  135863. * @param gradient defines the gradient to use (between 0 and 1)
  135864. * @param min defines the color remap minimal range
  135865. * @param max defines the color remap maximal range
  135866. * @returns the current particle system
  135867. */
  135868. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135869. /**
  135870. * Not supported by GPUParticleSystem
  135871. * @param gradient defines the gradient to remove
  135872. * @returns the current particle system
  135873. */
  135874. removeColorRemapGradient(): IParticleSystem;
  135875. /**
  135876. * Not supported by GPUParticleSystem
  135877. * @param gradient defines the gradient to use (between 0 and 1)
  135878. * @param min defines the alpha remap minimal range
  135879. * @param max defines the alpha remap maximal range
  135880. * @returns the current particle system
  135881. */
  135882. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135883. /**
  135884. * Not supported by GPUParticleSystem
  135885. * @param gradient defines the gradient to remove
  135886. * @returns the current particle system
  135887. */
  135888. removeAlphaRemapGradient(): IParticleSystem;
  135889. /**
  135890. * Not supported by GPUParticleSystem
  135891. * @param gradient defines the gradient to use (between 0 and 1)
  135892. * @param color defines the color to affect to the specified gradient
  135893. * @returns the current particle system
  135894. */
  135895. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135896. /**
  135897. * Not supported by GPUParticleSystem
  135898. * @param gradient defines the gradient to remove
  135899. * @returns the current particle system
  135900. */
  135901. removeRampGradient(): IParticleSystem;
  135902. /**
  135903. * Not supported by GPUParticleSystem
  135904. * @returns the list of ramp gradients
  135905. */
  135906. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135907. /**
  135908. * Not supported by GPUParticleSystem
  135909. * Gets or sets a boolean indicating that ramp gradients must be used
  135910. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135911. */
  135912. get useRampGradients(): boolean;
  135913. set useRampGradients(value: boolean);
  135914. /**
  135915. * Not supported by GPUParticleSystem
  135916. * @param gradient defines the gradient to use (between 0 and 1)
  135917. * @param factor defines the life time factor to affect to the specified gradient
  135918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135919. * @returns the current particle system
  135920. */
  135921. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135922. /**
  135923. * Not supported by GPUParticleSystem
  135924. * @param gradient defines the gradient to remove
  135925. * @returns the current particle system
  135926. */
  135927. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135928. /**
  135929. * Instantiates a GPU particle system.
  135930. * 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.
  135931. * @param name The name of the particle system
  135932. * @param options The options used to create the system
  135933. * @param scene The scene the particle system belongs to
  135934. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135935. */
  135936. constructor(name: string, options: Partial<{
  135937. capacity: number;
  135938. randomTextureSize: number;
  135939. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135940. protected _reset(): void;
  135941. private _createUpdateVAO;
  135942. private _createRenderVAO;
  135943. private _initialize;
  135944. /** @hidden */
  135945. _recreateUpdateEffect(): void;
  135946. /** @hidden */
  135947. _recreateRenderEffect(): void;
  135948. /**
  135949. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135950. * @param preWarm defines if we are in the pre-warmimg phase
  135951. */
  135952. animate(preWarm?: boolean): void;
  135953. private _createFactorGradientTexture;
  135954. private _createSizeGradientTexture;
  135955. private _createAngularSpeedGradientTexture;
  135956. private _createVelocityGradientTexture;
  135957. private _createLimitVelocityGradientTexture;
  135958. private _createDragGradientTexture;
  135959. private _createColorGradientTexture;
  135960. /**
  135961. * Renders the particle system in its current state
  135962. * @param preWarm defines if the system should only update the particles but not render them
  135963. * @returns the current number of particles
  135964. */
  135965. render(preWarm?: boolean): number;
  135966. /**
  135967. * Rebuilds the particle system
  135968. */
  135969. rebuild(): void;
  135970. private _releaseBuffers;
  135971. private _releaseVAOs;
  135972. /**
  135973. * Disposes the particle system and free the associated resources
  135974. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135975. */
  135976. dispose(disposeTexture?: boolean): void;
  135977. /**
  135978. * Clones the particle system.
  135979. * @param name The name of the cloned object
  135980. * @param newEmitter The new emitter to use
  135981. * @returns the cloned particle system
  135982. */
  135983. clone(name: string, newEmitter: any): GPUParticleSystem;
  135984. /**
  135985. * Serializes the particle system to a JSON object.
  135986. * @returns the JSON object
  135987. */
  135988. serialize(): any;
  135989. /**
  135990. * Parses a JSON object to create a GPU particle system.
  135991. * @param parsedParticleSystem The JSON object to parse
  135992. * @param scene The scene to create the particle system in
  135993. * @param rootUrl The root url to use to load external dependencies like texture
  135994. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135995. * @returns the parsed GPU particle system
  135996. */
  135997. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135998. }
  135999. }
  136000. declare module BABYLON {
  136001. /**
  136002. * Represents a set of particle systems working together to create a specific effect
  136003. */
  136004. export class ParticleSystemSet implements IDisposable {
  136005. /**
  136006. * Gets or sets base Assets URL
  136007. */
  136008. static BaseAssetsUrl: string;
  136009. private _emitterCreationOptions;
  136010. private _emitterNode;
  136011. /**
  136012. * Gets the particle system list
  136013. */
  136014. systems: IParticleSystem[];
  136015. /**
  136016. * Gets the emitter node used with this set
  136017. */
  136018. get emitterNode(): Nullable<TransformNode>;
  136019. /**
  136020. * Creates a new emitter mesh as a sphere
  136021. * @param options defines the options used to create the sphere
  136022. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136023. * @param scene defines the hosting scene
  136024. */
  136025. setEmitterAsSphere(options: {
  136026. diameter: number;
  136027. segments: number;
  136028. color: Color3;
  136029. }, renderingGroupId: number, scene: Scene): void;
  136030. /**
  136031. * Starts all particle systems of the set
  136032. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136033. */
  136034. start(emitter?: AbstractMesh): void;
  136035. /**
  136036. * Release all associated resources
  136037. */
  136038. dispose(): void;
  136039. /**
  136040. * Serialize the set into a JSON compatible object
  136041. * @returns a JSON compatible representation of the set
  136042. */
  136043. serialize(): any;
  136044. /**
  136045. * Parse a new ParticleSystemSet from a serialized source
  136046. * @param data defines a JSON compatible representation of the set
  136047. * @param scene defines the hosting scene
  136048. * @param gpu defines if we want GPU particles or CPU particles
  136049. * @returns a new ParticleSystemSet
  136050. */
  136051. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136052. }
  136053. }
  136054. declare module BABYLON {
  136055. /**
  136056. * This class is made for on one-liner static method to help creating particle system set.
  136057. */
  136058. export class ParticleHelper {
  136059. /**
  136060. * Gets or sets base Assets URL
  136061. */
  136062. static BaseAssetsUrl: string;
  136063. /**
  136064. * Create a default particle system that you can tweak
  136065. * @param emitter defines the emitter to use
  136066. * @param capacity defines the system capacity (default is 500 particles)
  136067. * @param scene defines the hosting scene
  136068. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136069. * @returns the new Particle system
  136070. */
  136071. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136072. /**
  136073. * This is the main static method (one-liner) of this helper to create different particle systems
  136074. * @param type This string represents the type to the particle system to create
  136075. * @param scene The scene where the particle system should live
  136076. * @param gpu If the system will use gpu
  136077. * @returns the ParticleSystemSet created
  136078. */
  136079. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136080. /**
  136081. * Static function used to export a particle system to a ParticleSystemSet variable.
  136082. * Please note that the emitter shape is not exported
  136083. * @param systems defines the particle systems to export
  136084. * @returns the created particle system set
  136085. */
  136086. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136087. }
  136088. }
  136089. declare module BABYLON {
  136090. interface Engine {
  136091. /**
  136092. * Create an effect to use with particle systems.
  136093. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136094. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136095. * @param uniformsNames defines a list of attribute names
  136096. * @param samplers defines an array of string used to represent textures
  136097. * @param defines defines the string containing the defines to use to compile the shaders
  136098. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136099. * @param onCompiled defines a function to call when the effect creation is successful
  136100. * @param onError defines a function to call when the effect creation has failed
  136101. * @returns the new Effect
  136102. */
  136103. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136104. }
  136105. interface Mesh {
  136106. /**
  136107. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136108. * @returns an array of IParticleSystem
  136109. */
  136110. getEmittedParticleSystems(): IParticleSystem[];
  136111. /**
  136112. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136113. * @returns an array of IParticleSystem
  136114. */
  136115. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136116. }
  136117. /**
  136118. * @hidden
  136119. */
  136120. export var _IDoNeedToBeInTheBuild: number;
  136121. }
  136122. declare module BABYLON {
  136123. /** Defines the 4 color options */
  136124. export enum PointColor {
  136125. /** color value */
  136126. Color = 2,
  136127. /** uv value */
  136128. UV = 1,
  136129. /** random value */
  136130. Random = 0,
  136131. /** stated value */
  136132. Stated = 3
  136133. }
  136134. /**
  136135. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136136. * 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.
  136137. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136138. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136139. *
  136140. * Full documentation here : TO BE ENTERED
  136141. */
  136142. export class PointsCloudSystem implements IDisposable {
  136143. /**
  136144. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136145. * Example : var p = SPS.particles[i];
  136146. */
  136147. particles: CloudPoint[];
  136148. /**
  136149. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136150. */
  136151. nbParticles: number;
  136152. /**
  136153. * This a counter for your own usage. It's not set by any SPS functions.
  136154. */
  136155. counter: number;
  136156. /**
  136157. * The PCS name. This name is also given to the underlying mesh.
  136158. */
  136159. name: string;
  136160. /**
  136161. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136162. */
  136163. mesh: Mesh;
  136164. /**
  136165. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136166. * Please read :
  136167. */
  136168. vars: any;
  136169. /**
  136170. * @hidden
  136171. */
  136172. _size: number;
  136173. private _scene;
  136174. private _promises;
  136175. private _positions;
  136176. private _indices;
  136177. private _normals;
  136178. private _colors;
  136179. private _uvs;
  136180. private _indices32;
  136181. private _positions32;
  136182. private _colors32;
  136183. private _uvs32;
  136184. private _updatable;
  136185. private _isVisibilityBoxLocked;
  136186. private _alwaysVisible;
  136187. private _groups;
  136188. private _groupCounter;
  136189. private _computeParticleColor;
  136190. private _computeParticleTexture;
  136191. private _computeParticleRotation;
  136192. private _computeBoundingBox;
  136193. private _isReady;
  136194. /**
  136195. * Creates a PCS (Points Cloud System) object
  136196. * @param name (String) is the PCS name, this will be the underlying mesh name
  136197. * @param pointSize (number) is the size for each point
  136198. * @param scene (Scene) is the scene in which the PCS is added
  136199. * @param options defines the options of the PCS e.g.
  136200. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136201. */
  136202. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136203. updatable?: boolean;
  136204. });
  136205. /**
  136206. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136207. * If no points were added to the PCS, the returned mesh is just a single point.
  136208. * @returns a promise for the created mesh
  136209. */
  136210. buildMeshAsync(): Promise<Mesh>;
  136211. /**
  136212. * @hidden
  136213. */
  136214. private _buildMesh;
  136215. private _addParticle;
  136216. private _randomUnitVector;
  136217. private _getColorIndicesForCoord;
  136218. private _setPointsColorOrUV;
  136219. private _colorFromTexture;
  136220. private _calculateDensity;
  136221. /**
  136222. * Adds points to the PCS in random positions within a unit sphere
  136223. * @param nb (positive integer) the number of particles to be created from this model
  136224. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136225. * @returns the number of groups in the system
  136226. */
  136227. addPoints(nb: number, pointFunction?: any): number;
  136228. /**
  136229. * Adds points to the PCS from the surface of the model shape
  136230. * @param mesh is any Mesh object that will be used as a surface model for the points
  136231. * @param nb (positive integer) the number of particles to be created from this model
  136232. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136233. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136234. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136235. * @returns the number of groups in the system
  136236. */
  136237. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136238. /**
  136239. * Adds points to the PCS inside the model shape
  136240. * @param mesh is any Mesh object that will be used as a surface model for the points
  136241. * @param nb (positive integer) the number of particles to be created from this model
  136242. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136243. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136244. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136245. * @returns the number of groups in the system
  136246. */
  136247. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136248. /**
  136249. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136250. * This method calls `updateParticle()` for each particle of the SPS.
  136251. * For an animated SPS, it is usually called within the render loop.
  136252. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136253. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136254. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136255. * @returns the PCS.
  136256. */
  136257. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136258. /**
  136259. * Disposes the PCS.
  136260. */
  136261. dispose(): void;
  136262. /**
  136263. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136264. * doc :
  136265. * @returns the PCS.
  136266. */
  136267. refreshVisibleSize(): PointsCloudSystem;
  136268. /**
  136269. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136270. * @param size the size (float) of the visibility box
  136271. * note : this doesn't lock the PCS mesh bounding box.
  136272. * doc :
  136273. */
  136274. setVisibilityBox(size: number): void;
  136275. /**
  136276. * Gets whether the PCS is always visible or not
  136277. * doc :
  136278. */
  136279. get isAlwaysVisible(): boolean;
  136280. /**
  136281. * Sets the PCS as always visible or not
  136282. * doc :
  136283. */
  136284. set isAlwaysVisible(val: boolean);
  136285. /**
  136286. * Tells to `setParticles()` to compute the particle rotations or not
  136287. * Default value : false. The PCS is faster when it's set to false
  136288. * Note : particle rotations are only applied to parent particles
  136289. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136290. */
  136291. set computeParticleRotation(val: boolean);
  136292. /**
  136293. * Tells to `setParticles()` to compute the particle colors or not.
  136294. * Default value : true. The PCS is faster when it's set to false.
  136295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136296. */
  136297. set computeParticleColor(val: boolean);
  136298. set computeParticleTexture(val: boolean);
  136299. /**
  136300. * Gets if `setParticles()` computes the particle colors or not.
  136301. * Default value : false. The PCS is faster when it's set to false.
  136302. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136303. */
  136304. get computeParticleColor(): boolean;
  136305. /**
  136306. * Gets if `setParticles()` computes the particle textures or not.
  136307. * Default value : false. The PCS is faster when it's set to false.
  136308. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136309. */
  136310. get computeParticleTexture(): boolean;
  136311. /**
  136312. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136313. */
  136314. set computeBoundingBox(val: boolean);
  136315. /**
  136316. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136317. */
  136318. get computeBoundingBox(): boolean;
  136319. /**
  136320. * This function does nothing. It may be overwritten to set all the particle first values.
  136321. * The PCS doesn't call this function, you may have to call it by your own.
  136322. * doc :
  136323. */
  136324. initParticles(): void;
  136325. /**
  136326. * This function does nothing. It may be overwritten to recycle a particle
  136327. * The PCS doesn't call this function, you can to call it
  136328. * doc :
  136329. * @param particle The particle to recycle
  136330. * @returns the recycled particle
  136331. */
  136332. recycleParticle(particle: CloudPoint): CloudPoint;
  136333. /**
  136334. * Updates a particle : this function should be overwritten by the user.
  136335. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136336. * doc :
  136337. * @example : just set a particle position or velocity and recycle conditions
  136338. * @param particle The particle to update
  136339. * @returns the updated particle
  136340. */
  136341. updateParticle(particle: CloudPoint): CloudPoint;
  136342. /**
  136343. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136344. * This does nothing and may be overwritten by the user.
  136345. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136346. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136347. * @param update the boolean update value actually passed to setParticles()
  136348. */
  136349. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136350. /**
  136351. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136352. * This will be passed three parameters.
  136353. * This does nothing and may be overwritten by the user.
  136354. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136355. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136356. * @param update the boolean update value actually passed to setParticles()
  136357. */
  136358. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136359. }
  136360. }
  136361. declare module BABYLON {
  136362. /**
  136363. * Represents one particle of a points cloud system.
  136364. */
  136365. export class CloudPoint {
  136366. /**
  136367. * particle global index
  136368. */
  136369. idx: number;
  136370. /**
  136371. * The color of the particle
  136372. */
  136373. color: Nullable<Color4>;
  136374. /**
  136375. * The world space position of the particle.
  136376. */
  136377. position: Vector3;
  136378. /**
  136379. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136380. */
  136381. rotation: Vector3;
  136382. /**
  136383. * The world space rotation quaternion of the particle.
  136384. */
  136385. rotationQuaternion: Nullable<Quaternion>;
  136386. /**
  136387. * The uv of the particle.
  136388. */
  136389. uv: Nullable<Vector2>;
  136390. /**
  136391. * The current speed of the particle.
  136392. */
  136393. velocity: Vector3;
  136394. /**
  136395. * The pivot point in the particle local space.
  136396. */
  136397. pivot: Vector3;
  136398. /**
  136399. * Must the particle be translated from its pivot point in its local space ?
  136400. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136401. * Default : false
  136402. */
  136403. translateFromPivot: boolean;
  136404. /**
  136405. * Index of this particle in the global "positions" array (Internal use)
  136406. * @hidden
  136407. */
  136408. _pos: number;
  136409. /**
  136410. * @hidden Index of this particle in the global "indices" array (Internal use)
  136411. */
  136412. _ind: number;
  136413. /**
  136414. * Group this particle belongs to
  136415. */
  136416. _group: PointsGroup;
  136417. /**
  136418. * Group id of this particle
  136419. */
  136420. groupId: number;
  136421. /**
  136422. * Index of the particle in its group id (Internal use)
  136423. */
  136424. idxInGroup: number;
  136425. /**
  136426. * @hidden Particle BoundingInfo object (Internal use)
  136427. */
  136428. _boundingInfo: BoundingInfo;
  136429. /**
  136430. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136431. */
  136432. _pcs: PointsCloudSystem;
  136433. /**
  136434. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136435. */
  136436. _stillInvisible: boolean;
  136437. /**
  136438. * @hidden Last computed particle rotation matrix
  136439. */
  136440. _rotationMatrix: number[];
  136441. /**
  136442. * Parent particle Id, if any.
  136443. * Default null.
  136444. */
  136445. parentId: Nullable<number>;
  136446. /**
  136447. * @hidden Internal global position in the PCS.
  136448. */
  136449. _globalPosition: Vector3;
  136450. /**
  136451. * Creates a Point Cloud object.
  136452. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136453. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136454. * @param group (PointsGroup) is the group the particle belongs to
  136455. * @param groupId (integer) is the group identifier in the PCS.
  136456. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136457. * @param pcs defines the PCS it is associated to
  136458. */
  136459. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136460. /**
  136461. * get point size
  136462. */
  136463. get size(): Vector3;
  136464. /**
  136465. * Set point size
  136466. */
  136467. set size(scale: Vector3);
  136468. /**
  136469. * Legacy support, changed quaternion to rotationQuaternion
  136470. */
  136471. get quaternion(): Nullable<Quaternion>;
  136472. /**
  136473. * Legacy support, changed quaternion to rotationQuaternion
  136474. */
  136475. set quaternion(q: Nullable<Quaternion>);
  136476. /**
  136477. * Returns a boolean. True if the particle intersects a mesh, else false
  136478. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136479. * @param target is the object (point or mesh) what the intersection is computed against
  136480. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136481. * @returns true if it intersects
  136482. */
  136483. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136484. /**
  136485. * get the rotation matrix of the particle
  136486. * @hidden
  136487. */
  136488. getRotationMatrix(m: Matrix): void;
  136489. }
  136490. /**
  136491. * Represents a group of points in a points cloud system
  136492. * * PCS internal tool, don't use it manually.
  136493. */
  136494. export class PointsGroup {
  136495. /**
  136496. * The group id
  136497. * @hidden
  136498. */
  136499. groupID: number;
  136500. /**
  136501. * image data for group (internal use)
  136502. * @hidden
  136503. */
  136504. _groupImageData: Nullable<ArrayBufferView>;
  136505. /**
  136506. * Image Width (internal use)
  136507. * @hidden
  136508. */
  136509. _groupImgWidth: number;
  136510. /**
  136511. * Image Height (internal use)
  136512. * @hidden
  136513. */
  136514. _groupImgHeight: number;
  136515. /**
  136516. * Custom position function (internal use)
  136517. * @hidden
  136518. */
  136519. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136520. /**
  136521. * density per facet for surface points
  136522. * @hidden
  136523. */
  136524. _groupDensity: number[];
  136525. /**
  136526. * Only when points are colored by texture carries pointer to texture list array
  136527. * @hidden
  136528. */
  136529. _textureNb: number;
  136530. /**
  136531. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136532. * PCS internal tool, don't use it manually.
  136533. * @hidden
  136534. */
  136535. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136536. }
  136537. }
  136538. declare module BABYLON {
  136539. interface Scene {
  136540. /** @hidden (Backing field) */
  136541. _physicsEngine: Nullable<IPhysicsEngine>;
  136542. /** @hidden */
  136543. _physicsTimeAccumulator: number;
  136544. /**
  136545. * Gets the current physics engine
  136546. * @returns a IPhysicsEngine or null if none attached
  136547. */
  136548. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136549. /**
  136550. * Enables physics to the current scene
  136551. * @param gravity defines the scene's gravity for the physics engine
  136552. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136553. * @return a boolean indicating if the physics engine was initialized
  136554. */
  136555. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136556. /**
  136557. * Disables and disposes the physics engine associated with the scene
  136558. */
  136559. disablePhysicsEngine(): void;
  136560. /**
  136561. * Gets a boolean indicating if there is an active physics engine
  136562. * @returns a boolean indicating if there is an active physics engine
  136563. */
  136564. isPhysicsEnabled(): boolean;
  136565. /**
  136566. * Deletes a physics compound impostor
  136567. * @param compound defines the compound to delete
  136568. */
  136569. deleteCompoundImpostor(compound: any): void;
  136570. /**
  136571. * An event triggered when physic simulation is about to be run
  136572. */
  136573. onBeforePhysicsObservable: Observable<Scene>;
  136574. /**
  136575. * An event triggered when physic simulation has been done
  136576. */
  136577. onAfterPhysicsObservable: Observable<Scene>;
  136578. }
  136579. interface AbstractMesh {
  136580. /** @hidden */
  136581. _physicsImpostor: Nullable<PhysicsImpostor>;
  136582. /**
  136583. * Gets or sets impostor used for physic simulation
  136584. * @see http://doc.babylonjs.com/features/physics_engine
  136585. */
  136586. physicsImpostor: Nullable<PhysicsImpostor>;
  136587. /**
  136588. * Gets the current physics impostor
  136589. * @see http://doc.babylonjs.com/features/physics_engine
  136590. * @returns a physics impostor or null
  136591. */
  136592. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136593. /** Apply a physic impulse to the mesh
  136594. * @param force defines the force to apply
  136595. * @param contactPoint defines where to apply the force
  136596. * @returns the current mesh
  136597. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136598. */
  136599. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136600. /**
  136601. * Creates a physic joint between two meshes
  136602. * @param otherMesh defines the other mesh to use
  136603. * @param pivot1 defines the pivot to use on this mesh
  136604. * @param pivot2 defines the pivot to use on the other mesh
  136605. * @param options defines additional options (can be plugin dependent)
  136606. * @returns the current mesh
  136607. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136608. */
  136609. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136610. /** @hidden */
  136611. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136612. }
  136613. /**
  136614. * Defines the physics engine scene component responsible to manage a physics engine
  136615. */
  136616. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136617. /**
  136618. * The component name helpful to identify the component in the list of scene components.
  136619. */
  136620. readonly name: string;
  136621. /**
  136622. * The scene the component belongs to.
  136623. */
  136624. scene: Scene;
  136625. /**
  136626. * Creates a new instance of the component for the given scene
  136627. * @param scene Defines the scene to register the component in
  136628. */
  136629. constructor(scene: Scene);
  136630. /**
  136631. * Registers the component in a given scene
  136632. */
  136633. register(): void;
  136634. /**
  136635. * Rebuilds the elements related to this component in case of
  136636. * context lost for instance.
  136637. */
  136638. rebuild(): void;
  136639. /**
  136640. * Disposes the component and the associated ressources
  136641. */
  136642. dispose(): void;
  136643. }
  136644. }
  136645. declare module BABYLON {
  136646. /**
  136647. * A helper for physics simulations
  136648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136649. */
  136650. export class PhysicsHelper {
  136651. private _scene;
  136652. private _physicsEngine;
  136653. /**
  136654. * Initializes the Physics helper
  136655. * @param scene Babylon.js scene
  136656. */
  136657. constructor(scene: Scene);
  136658. /**
  136659. * Applies a radial explosion impulse
  136660. * @param origin the origin of the explosion
  136661. * @param radiusOrEventOptions the radius or the options of radial explosion
  136662. * @param strength the explosion strength
  136663. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136664. * @returns A physics radial explosion event, or null
  136665. */
  136666. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136667. /**
  136668. * Applies a radial explosion force
  136669. * @param origin the origin of the explosion
  136670. * @param radiusOrEventOptions the radius or the options of radial explosion
  136671. * @param strength the explosion strength
  136672. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136673. * @returns A physics radial explosion event, or null
  136674. */
  136675. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136676. /**
  136677. * Creates a gravitational field
  136678. * @param origin the origin of the explosion
  136679. * @param radiusOrEventOptions the radius or the options of radial explosion
  136680. * @param strength the explosion strength
  136681. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136682. * @returns A physics gravitational field event, or null
  136683. */
  136684. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136685. /**
  136686. * Creates a physics updraft event
  136687. * @param origin the origin of the updraft
  136688. * @param radiusOrEventOptions the radius or the options of the updraft
  136689. * @param strength the strength of the updraft
  136690. * @param height the height of the updraft
  136691. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136692. * @returns A physics updraft event, or null
  136693. */
  136694. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136695. /**
  136696. * Creates a physics vortex event
  136697. * @param origin the of the vortex
  136698. * @param radiusOrEventOptions the radius or the options of the vortex
  136699. * @param strength the strength of the vortex
  136700. * @param height the height of the vortex
  136701. * @returns a Physics vortex event, or null
  136702. * A physics vortex event or null
  136703. */
  136704. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136705. }
  136706. /**
  136707. * Represents a physics radial explosion event
  136708. */
  136709. class PhysicsRadialExplosionEvent {
  136710. private _scene;
  136711. private _options;
  136712. private _sphere;
  136713. private _dataFetched;
  136714. /**
  136715. * Initializes a radial explosioin event
  136716. * @param _scene BabylonJS scene
  136717. * @param _options The options for the vortex event
  136718. */
  136719. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136720. /**
  136721. * Returns the data related to the radial explosion event (sphere).
  136722. * @returns The radial explosion event data
  136723. */
  136724. getData(): PhysicsRadialExplosionEventData;
  136725. /**
  136726. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136727. * @param impostor A physics imposter
  136728. * @param origin the origin of the explosion
  136729. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136730. */
  136731. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136732. /**
  136733. * Triggers affecterd impostors callbacks
  136734. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136735. */
  136736. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136737. /**
  136738. * Disposes the sphere.
  136739. * @param force Specifies if the sphere should be disposed by force
  136740. */
  136741. dispose(force?: boolean): void;
  136742. /*** Helpers ***/
  136743. private _prepareSphere;
  136744. private _intersectsWithSphere;
  136745. }
  136746. /**
  136747. * Represents a gravitational field event
  136748. */
  136749. class PhysicsGravitationalFieldEvent {
  136750. private _physicsHelper;
  136751. private _scene;
  136752. private _origin;
  136753. private _options;
  136754. private _tickCallback;
  136755. private _sphere;
  136756. private _dataFetched;
  136757. /**
  136758. * Initializes the physics gravitational field event
  136759. * @param _physicsHelper A physics helper
  136760. * @param _scene BabylonJS scene
  136761. * @param _origin The origin position of the gravitational field event
  136762. * @param _options The options for the vortex event
  136763. */
  136764. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136765. /**
  136766. * Returns the data related to the gravitational field event (sphere).
  136767. * @returns A gravitational field event
  136768. */
  136769. getData(): PhysicsGravitationalFieldEventData;
  136770. /**
  136771. * Enables the gravitational field.
  136772. */
  136773. enable(): void;
  136774. /**
  136775. * Disables the gravitational field.
  136776. */
  136777. disable(): void;
  136778. /**
  136779. * Disposes the sphere.
  136780. * @param force The force to dispose from the gravitational field event
  136781. */
  136782. dispose(force?: boolean): void;
  136783. private _tick;
  136784. }
  136785. /**
  136786. * Represents a physics updraft event
  136787. */
  136788. class PhysicsUpdraftEvent {
  136789. private _scene;
  136790. private _origin;
  136791. private _options;
  136792. private _physicsEngine;
  136793. private _originTop;
  136794. private _originDirection;
  136795. private _tickCallback;
  136796. private _cylinder;
  136797. private _cylinderPosition;
  136798. private _dataFetched;
  136799. /**
  136800. * Initializes the physics updraft event
  136801. * @param _scene BabylonJS scene
  136802. * @param _origin The origin position of the updraft
  136803. * @param _options The options for the updraft event
  136804. */
  136805. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136806. /**
  136807. * Returns the data related to the updraft event (cylinder).
  136808. * @returns A physics updraft event
  136809. */
  136810. getData(): PhysicsUpdraftEventData;
  136811. /**
  136812. * Enables the updraft.
  136813. */
  136814. enable(): void;
  136815. /**
  136816. * Disables the updraft.
  136817. */
  136818. disable(): void;
  136819. /**
  136820. * Disposes the cylinder.
  136821. * @param force Specifies if the updraft should be disposed by force
  136822. */
  136823. dispose(force?: boolean): void;
  136824. private getImpostorHitData;
  136825. private _tick;
  136826. /*** Helpers ***/
  136827. private _prepareCylinder;
  136828. private _intersectsWithCylinder;
  136829. }
  136830. /**
  136831. * Represents a physics vortex event
  136832. */
  136833. class PhysicsVortexEvent {
  136834. private _scene;
  136835. private _origin;
  136836. private _options;
  136837. private _physicsEngine;
  136838. private _originTop;
  136839. private _tickCallback;
  136840. private _cylinder;
  136841. private _cylinderPosition;
  136842. private _dataFetched;
  136843. /**
  136844. * Initializes the physics vortex event
  136845. * @param _scene The BabylonJS scene
  136846. * @param _origin The origin position of the vortex
  136847. * @param _options The options for the vortex event
  136848. */
  136849. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136850. /**
  136851. * Returns the data related to the vortex event (cylinder).
  136852. * @returns The physics vortex event data
  136853. */
  136854. getData(): PhysicsVortexEventData;
  136855. /**
  136856. * Enables the vortex.
  136857. */
  136858. enable(): void;
  136859. /**
  136860. * Disables the cortex.
  136861. */
  136862. disable(): void;
  136863. /**
  136864. * Disposes the sphere.
  136865. * @param force
  136866. */
  136867. dispose(force?: boolean): void;
  136868. private getImpostorHitData;
  136869. private _tick;
  136870. /*** Helpers ***/
  136871. private _prepareCylinder;
  136872. private _intersectsWithCylinder;
  136873. }
  136874. /**
  136875. * Options fot the radial explosion event
  136876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136877. */
  136878. export class PhysicsRadialExplosionEventOptions {
  136879. /**
  136880. * The radius of the sphere for the radial explosion.
  136881. */
  136882. radius: number;
  136883. /**
  136884. * The strenth of the explosion.
  136885. */
  136886. strength: number;
  136887. /**
  136888. * The strenght of the force in correspondence to the distance of the affected object
  136889. */
  136890. falloff: PhysicsRadialImpulseFalloff;
  136891. /**
  136892. * Sphere options for the radial explosion.
  136893. */
  136894. sphere: {
  136895. segments: number;
  136896. diameter: number;
  136897. };
  136898. /**
  136899. * Sphere options for the radial explosion.
  136900. */
  136901. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136902. }
  136903. /**
  136904. * Options fot the updraft event
  136905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136906. */
  136907. export class PhysicsUpdraftEventOptions {
  136908. /**
  136909. * The radius of the cylinder for the vortex
  136910. */
  136911. radius: number;
  136912. /**
  136913. * The strenth of the updraft.
  136914. */
  136915. strength: number;
  136916. /**
  136917. * The height of the cylinder for the updraft.
  136918. */
  136919. height: number;
  136920. /**
  136921. * The mode for the the updraft.
  136922. */
  136923. updraftMode: PhysicsUpdraftMode;
  136924. }
  136925. /**
  136926. * Options fot the vortex event
  136927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136928. */
  136929. export class PhysicsVortexEventOptions {
  136930. /**
  136931. * The radius of the cylinder for the vortex
  136932. */
  136933. radius: number;
  136934. /**
  136935. * The strenth of the vortex.
  136936. */
  136937. strength: number;
  136938. /**
  136939. * The height of the cylinder for the vortex.
  136940. */
  136941. height: number;
  136942. /**
  136943. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136944. */
  136945. centripetalForceThreshold: number;
  136946. /**
  136947. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136948. */
  136949. centripetalForceMultiplier: number;
  136950. /**
  136951. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136952. */
  136953. centrifugalForceMultiplier: number;
  136954. /**
  136955. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136956. */
  136957. updraftForceMultiplier: number;
  136958. }
  136959. /**
  136960. * The strenght of the force in correspondence to the distance of the affected object
  136961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136962. */
  136963. export enum PhysicsRadialImpulseFalloff {
  136964. /** Defines that impulse is constant in strength across it's whole radius */
  136965. Constant = 0,
  136966. /** Defines that impulse gets weaker if it's further from the origin */
  136967. Linear = 1
  136968. }
  136969. /**
  136970. * The strength of the force in correspondence to the distance of the affected object
  136971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136972. */
  136973. export enum PhysicsUpdraftMode {
  136974. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136975. Center = 0,
  136976. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136977. Perpendicular = 1
  136978. }
  136979. /**
  136980. * Interface for a physics hit data
  136981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136982. */
  136983. export interface PhysicsHitData {
  136984. /**
  136985. * The force applied at the contact point
  136986. */
  136987. force: Vector3;
  136988. /**
  136989. * The contact point
  136990. */
  136991. contactPoint: Vector3;
  136992. /**
  136993. * The distance from the origin to the contact point
  136994. */
  136995. distanceFromOrigin: number;
  136996. }
  136997. /**
  136998. * Interface for radial explosion event data
  136999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137000. */
  137001. export interface PhysicsRadialExplosionEventData {
  137002. /**
  137003. * A sphere used for the radial explosion event
  137004. */
  137005. sphere: Mesh;
  137006. }
  137007. /**
  137008. * Interface for gravitational field event data
  137009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137010. */
  137011. export interface PhysicsGravitationalFieldEventData {
  137012. /**
  137013. * A sphere mesh used for the gravitational field event
  137014. */
  137015. sphere: Mesh;
  137016. }
  137017. /**
  137018. * Interface for updraft event data
  137019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137020. */
  137021. export interface PhysicsUpdraftEventData {
  137022. /**
  137023. * A cylinder used for the updraft event
  137024. */
  137025. cylinder: Mesh;
  137026. }
  137027. /**
  137028. * Interface for vortex event data
  137029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137030. */
  137031. export interface PhysicsVortexEventData {
  137032. /**
  137033. * A cylinder used for the vortex event
  137034. */
  137035. cylinder: Mesh;
  137036. }
  137037. /**
  137038. * Interface for an affected physics impostor
  137039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137040. */
  137041. export interface PhysicsAffectedImpostorWithData {
  137042. /**
  137043. * The impostor affected by the effect
  137044. */
  137045. impostor: PhysicsImpostor;
  137046. /**
  137047. * The data about the hit/horce from the explosion
  137048. */
  137049. hitData: PhysicsHitData;
  137050. }
  137051. }
  137052. declare module BABYLON {
  137053. /** @hidden */
  137054. export var blackAndWhitePixelShader: {
  137055. name: string;
  137056. shader: string;
  137057. };
  137058. }
  137059. declare module BABYLON {
  137060. /**
  137061. * Post process used to render in black and white
  137062. */
  137063. export class BlackAndWhitePostProcess extends PostProcess {
  137064. /**
  137065. * Linear about to convert he result to black and white (default: 1)
  137066. */
  137067. degree: number;
  137068. /**
  137069. * Creates a black and white post process
  137070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137071. * @param name The name of the effect.
  137072. * @param options The required width/height ratio to downsize to before computing the render pass.
  137073. * @param camera The camera to apply the render pass to.
  137074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137075. * @param engine The engine which the post process will be applied. (default: current engine)
  137076. * @param reusable If the post process can be reused on the same frame. (default: false)
  137077. */
  137078. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137079. }
  137080. }
  137081. declare module BABYLON {
  137082. /**
  137083. * This represents a set of one or more post processes in Babylon.
  137084. * A post process can be used to apply a shader to a texture after it is rendered.
  137085. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137086. */
  137087. export class PostProcessRenderEffect {
  137088. private _postProcesses;
  137089. private _getPostProcesses;
  137090. private _singleInstance;
  137091. private _cameras;
  137092. private _indicesForCamera;
  137093. /**
  137094. * Name of the effect
  137095. * @hidden
  137096. */
  137097. _name: string;
  137098. /**
  137099. * Instantiates a post process render effect.
  137100. * A post process can be used to apply a shader to a texture after it is rendered.
  137101. * @param engine The engine the effect is tied to
  137102. * @param name The name of the effect
  137103. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137104. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137105. */
  137106. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137107. /**
  137108. * Checks if all the post processes in the effect are supported.
  137109. */
  137110. get isSupported(): boolean;
  137111. /**
  137112. * Updates the current state of the effect
  137113. * @hidden
  137114. */
  137115. _update(): void;
  137116. /**
  137117. * Attaches the effect on cameras
  137118. * @param cameras The camera to attach to.
  137119. * @hidden
  137120. */
  137121. _attachCameras(cameras: Camera): void;
  137122. /**
  137123. * Attaches the effect on cameras
  137124. * @param cameras The camera to attach to.
  137125. * @hidden
  137126. */
  137127. _attachCameras(cameras: Camera[]): void;
  137128. /**
  137129. * Detaches the effect on cameras
  137130. * @param cameras The camera to detatch from.
  137131. * @hidden
  137132. */
  137133. _detachCameras(cameras: Camera): void;
  137134. /**
  137135. * Detatches the effect on cameras
  137136. * @param cameras The camera to detatch from.
  137137. * @hidden
  137138. */
  137139. _detachCameras(cameras: Camera[]): void;
  137140. /**
  137141. * Enables the effect on given cameras
  137142. * @param cameras The camera to enable.
  137143. * @hidden
  137144. */
  137145. _enable(cameras: Camera): void;
  137146. /**
  137147. * Enables the effect on given cameras
  137148. * @param cameras The camera to enable.
  137149. * @hidden
  137150. */
  137151. _enable(cameras: Nullable<Camera[]>): void;
  137152. /**
  137153. * Disables the effect on the given cameras
  137154. * @param cameras The camera to disable.
  137155. * @hidden
  137156. */
  137157. _disable(cameras: Camera): void;
  137158. /**
  137159. * Disables the effect on the given cameras
  137160. * @param cameras The camera to disable.
  137161. * @hidden
  137162. */
  137163. _disable(cameras: Nullable<Camera[]>): void;
  137164. /**
  137165. * Gets a list of the post processes contained in the effect.
  137166. * @param camera The camera to get the post processes on.
  137167. * @returns The list of the post processes in the effect.
  137168. */
  137169. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137170. }
  137171. }
  137172. declare module BABYLON {
  137173. /** @hidden */
  137174. export var extractHighlightsPixelShader: {
  137175. name: string;
  137176. shader: string;
  137177. };
  137178. }
  137179. declare module BABYLON {
  137180. /**
  137181. * 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.
  137182. */
  137183. export class ExtractHighlightsPostProcess extends PostProcess {
  137184. /**
  137185. * The luminance threshold, pixels below this value will be set to black.
  137186. */
  137187. threshold: number;
  137188. /** @hidden */
  137189. _exposure: number;
  137190. /**
  137191. * Post process which has the input texture to be used when performing highlight extraction
  137192. * @hidden
  137193. */
  137194. _inputPostProcess: Nullable<PostProcess>;
  137195. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137196. }
  137197. }
  137198. declare module BABYLON {
  137199. /** @hidden */
  137200. export var bloomMergePixelShader: {
  137201. name: string;
  137202. shader: string;
  137203. };
  137204. }
  137205. declare module BABYLON {
  137206. /**
  137207. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137208. */
  137209. export class BloomMergePostProcess extends PostProcess {
  137210. /** Weight of the bloom to be added to the original input. */
  137211. weight: number;
  137212. /**
  137213. * Creates a new instance of @see BloomMergePostProcess
  137214. * @param name The name of the effect.
  137215. * @param originalFromInput Post process which's input will be used for the merge.
  137216. * @param blurred Blurred highlights post process which's output will be used.
  137217. * @param weight Weight of the bloom to be added to the original input.
  137218. * @param options The required width/height ratio to downsize to before computing the render pass.
  137219. * @param camera The camera to apply the render pass to.
  137220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137221. * @param engine The engine which the post process will be applied. (default: current engine)
  137222. * @param reusable If the post process can be reused on the same frame. (default: false)
  137223. * @param textureType Type of textures used when performing the post process. (default: 0)
  137224. * @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)
  137225. */
  137226. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137227. /** Weight of the bloom to be added to the original input. */
  137228. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137229. }
  137230. }
  137231. declare module BABYLON {
  137232. /**
  137233. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137234. */
  137235. export class BloomEffect extends PostProcessRenderEffect {
  137236. private bloomScale;
  137237. /**
  137238. * @hidden Internal
  137239. */
  137240. _effects: Array<PostProcess>;
  137241. /**
  137242. * @hidden Internal
  137243. */
  137244. _downscale: ExtractHighlightsPostProcess;
  137245. private _blurX;
  137246. private _blurY;
  137247. private _merge;
  137248. /**
  137249. * The luminance threshold to find bright areas of the image to bloom.
  137250. */
  137251. get threshold(): number;
  137252. set threshold(value: number);
  137253. /**
  137254. * The strength of the bloom.
  137255. */
  137256. get weight(): number;
  137257. set weight(value: number);
  137258. /**
  137259. * Specifies the size of the bloom blur kernel, relative to the final output size
  137260. */
  137261. get kernel(): number;
  137262. set kernel(value: number);
  137263. /**
  137264. * Creates a new instance of @see BloomEffect
  137265. * @param scene The scene the effect belongs to.
  137266. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137267. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137268. * @param bloomWeight The the strength of bloom.
  137269. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137270. * @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)
  137271. */
  137272. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137273. /**
  137274. * Disposes each of the internal effects for a given camera.
  137275. * @param camera The camera to dispose the effect on.
  137276. */
  137277. disposeEffects(camera: Camera): void;
  137278. /**
  137279. * @hidden Internal
  137280. */
  137281. _updateEffects(): void;
  137282. /**
  137283. * Internal
  137284. * @returns if all the contained post processes are ready.
  137285. * @hidden
  137286. */
  137287. _isReady(): boolean;
  137288. }
  137289. }
  137290. declare module BABYLON {
  137291. /** @hidden */
  137292. export var chromaticAberrationPixelShader: {
  137293. name: string;
  137294. shader: string;
  137295. };
  137296. }
  137297. declare module BABYLON {
  137298. /**
  137299. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137300. */
  137301. export class ChromaticAberrationPostProcess extends PostProcess {
  137302. /**
  137303. * The amount of seperation of rgb channels (default: 30)
  137304. */
  137305. aberrationAmount: number;
  137306. /**
  137307. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137308. */
  137309. radialIntensity: number;
  137310. /**
  137311. * 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))
  137312. */
  137313. direction: Vector2;
  137314. /**
  137315. * 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))
  137316. */
  137317. centerPosition: Vector2;
  137318. /**
  137319. * Creates a new instance ChromaticAberrationPostProcess
  137320. * @param name The name of the effect.
  137321. * @param screenWidth The width of the screen to apply the effect on.
  137322. * @param screenHeight The height of the screen to apply the effect on.
  137323. * @param options The required width/height ratio to downsize to before computing the render pass.
  137324. * @param camera The camera to apply the render pass to.
  137325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137326. * @param engine The engine which the post process will be applied. (default: current engine)
  137327. * @param reusable If the post process can be reused on the same frame. (default: false)
  137328. * @param textureType Type of textures used when performing the post process. (default: 0)
  137329. * @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)
  137330. */
  137331. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137332. }
  137333. }
  137334. declare module BABYLON {
  137335. /** @hidden */
  137336. export var circleOfConfusionPixelShader: {
  137337. name: string;
  137338. shader: string;
  137339. };
  137340. }
  137341. declare module BABYLON {
  137342. /**
  137343. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137344. */
  137345. export class CircleOfConfusionPostProcess extends PostProcess {
  137346. /**
  137347. * 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.
  137348. */
  137349. lensSize: number;
  137350. /**
  137351. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137352. */
  137353. fStop: number;
  137354. /**
  137355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137356. */
  137357. focusDistance: number;
  137358. /**
  137359. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137360. */
  137361. focalLength: number;
  137362. private _depthTexture;
  137363. /**
  137364. * Creates a new instance CircleOfConfusionPostProcess
  137365. * @param name The name of the effect.
  137366. * @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.
  137367. * @param options The required width/height ratio to downsize to before computing the render pass.
  137368. * @param camera The camera to apply the render pass to.
  137369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137370. * @param engine The engine which the post process will be applied. (default: current engine)
  137371. * @param reusable If the post process can be reused on the same frame. (default: false)
  137372. * @param textureType Type of textures used when performing the post process. (default: 0)
  137373. * @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)
  137374. */
  137375. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137376. /**
  137377. * 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.
  137378. */
  137379. set depthTexture(value: RenderTargetTexture);
  137380. }
  137381. }
  137382. declare module BABYLON {
  137383. /** @hidden */
  137384. export var colorCorrectionPixelShader: {
  137385. name: string;
  137386. shader: string;
  137387. };
  137388. }
  137389. declare module BABYLON {
  137390. /**
  137391. *
  137392. * This post-process allows the modification of rendered colors by using
  137393. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137394. *
  137395. * The object needs to be provided an url to a texture containing the color
  137396. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137397. * Use an image editing software to tweak the LUT to match your needs.
  137398. *
  137399. * For an example of a color LUT, see here:
  137400. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137401. * For explanations on color grading, see here:
  137402. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137403. *
  137404. */
  137405. export class ColorCorrectionPostProcess extends PostProcess {
  137406. private _colorTableTexture;
  137407. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137408. }
  137409. }
  137410. declare module BABYLON {
  137411. /** @hidden */
  137412. export var convolutionPixelShader: {
  137413. name: string;
  137414. shader: string;
  137415. };
  137416. }
  137417. declare module BABYLON {
  137418. /**
  137419. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137420. * input texture to perform effects such as edge detection or sharpening
  137421. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137422. */
  137423. export class ConvolutionPostProcess extends PostProcess {
  137424. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137425. kernel: number[];
  137426. /**
  137427. * Creates a new instance ConvolutionPostProcess
  137428. * @param name The name of the effect.
  137429. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137430. * @param options The required width/height ratio to downsize to before computing the render pass.
  137431. * @param camera The camera to apply the render pass to.
  137432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137433. * @param engine The engine which the post process will be applied. (default: current engine)
  137434. * @param reusable If the post process can be reused on the same frame. (default: false)
  137435. * @param textureType Type of textures used when performing the post process. (default: 0)
  137436. */
  137437. constructor(name: string,
  137438. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137439. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137440. /**
  137441. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137442. */
  137443. static EdgeDetect0Kernel: number[];
  137444. /**
  137445. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137446. */
  137447. static EdgeDetect1Kernel: number[];
  137448. /**
  137449. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137450. */
  137451. static EdgeDetect2Kernel: number[];
  137452. /**
  137453. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137454. */
  137455. static SharpenKernel: number[];
  137456. /**
  137457. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137458. */
  137459. static EmbossKernel: number[];
  137460. /**
  137461. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137462. */
  137463. static GaussianKernel: number[];
  137464. }
  137465. }
  137466. declare module BABYLON {
  137467. /**
  137468. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137469. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137470. * based on samples that have a large difference in distance than the center pixel.
  137471. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137472. */
  137473. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137474. direction: Vector2;
  137475. /**
  137476. * Creates a new instance CircleOfConfusionPostProcess
  137477. * @param name The name of the effect.
  137478. * @param scene The scene the effect belongs to.
  137479. * @param direction The direction the blur should be applied.
  137480. * @param kernel The size of the kernel used to blur.
  137481. * @param options The required width/height ratio to downsize to before computing the render pass.
  137482. * @param camera The camera to apply the render pass to.
  137483. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137484. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137486. * @param engine The engine which the post process will be applied. (default: current engine)
  137487. * @param reusable If the post process can be reused on the same frame. (default: false)
  137488. * @param textureType Type of textures used when performing the post process. (default: 0)
  137489. * @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)
  137490. */
  137491. 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);
  137492. }
  137493. }
  137494. declare module BABYLON {
  137495. /** @hidden */
  137496. export var depthOfFieldMergePixelShader: {
  137497. name: string;
  137498. shader: string;
  137499. };
  137500. }
  137501. declare module BABYLON {
  137502. /**
  137503. * Options to be set when merging outputs from the default pipeline.
  137504. */
  137505. export class DepthOfFieldMergePostProcessOptions {
  137506. /**
  137507. * The original image to merge on top of
  137508. */
  137509. originalFromInput: PostProcess;
  137510. /**
  137511. * Parameters to perform the merge of the depth of field effect
  137512. */
  137513. depthOfField?: {
  137514. circleOfConfusion: PostProcess;
  137515. blurSteps: Array<PostProcess>;
  137516. };
  137517. /**
  137518. * Parameters to perform the merge of bloom effect
  137519. */
  137520. bloom?: {
  137521. blurred: PostProcess;
  137522. weight: number;
  137523. };
  137524. }
  137525. /**
  137526. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137527. */
  137528. export class DepthOfFieldMergePostProcess extends PostProcess {
  137529. private blurSteps;
  137530. /**
  137531. * Creates a new instance of DepthOfFieldMergePostProcess
  137532. * @param name The name of the effect.
  137533. * @param originalFromInput Post process which's input will be used for the merge.
  137534. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137535. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137536. * @param options The required width/height ratio to downsize to before computing the render pass.
  137537. * @param camera The camera to apply the render pass to.
  137538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137539. * @param engine The engine which the post process will be applied. (default: current engine)
  137540. * @param reusable If the post process can be reused on the same frame. (default: false)
  137541. * @param textureType Type of textures used when performing the post process. (default: 0)
  137542. * @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)
  137543. */
  137544. 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);
  137545. /**
  137546. * Updates the effect with the current post process compile time values and recompiles the shader.
  137547. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137548. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137549. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137550. * @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
  137551. * @param onCompiled Called when the shader has been compiled.
  137552. * @param onError Called if there is an error when compiling a shader.
  137553. */
  137554. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137555. }
  137556. }
  137557. declare module BABYLON {
  137558. /**
  137559. * Specifies the level of max blur that should be applied when using the depth of field effect
  137560. */
  137561. export enum DepthOfFieldEffectBlurLevel {
  137562. /**
  137563. * Subtle blur
  137564. */
  137565. Low = 0,
  137566. /**
  137567. * Medium blur
  137568. */
  137569. Medium = 1,
  137570. /**
  137571. * Large blur
  137572. */
  137573. High = 2
  137574. }
  137575. /**
  137576. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137577. */
  137578. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137579. private _circleOfConfusion;
  137580. /**
  137581. * @hidden Internal, blurs from high to low
  137582. */
  137583. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137584. private _depthOfFieldBlurY;
  137585. private _dofMerge;
  137586. /**
  137587. * @hidden Internal post processes in depth of field effect
  137588. */
  137589. _effects: Array<PostProcess>;
  137590. /**
  137591. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137592. */
  137593. set focalLength(value: number);
  137594. get focalLength(): number;
  137595. /**
  137596. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137597. */
  137598. set fStop(value: number);
  137599. get fStop(): number;
  137600. /**
  137601. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137602. */
  137603. set focusDistance(value: number);
  137604. get focusDistance(): number;
  137605. /**
  137606. * 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.
  137607. */
  137608. set lensSize(value: number);
  137609. get lensSize(): number;
  137610. /**
  137611. * Creates a new instance DepthOfFieldEffect
  137612. * @param scene The scene the effect belongs to.
  137613. * @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.
  137614. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137615. * @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)
  137616. */
  137617. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137618. /**
  137619. * Get the current class name of the current effet
  137620. * @returns "DepthOfFieldEffect"
  137621. */
  137622. getClassName(): string;
  137623. /**
  137624. * 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.
  137625. */
  137626. set depthTexture(value: RenderTargetTexture);
  137627. /**
  137628. * Disposes each of the internal effects for a given camera.
  137629. * @param camera The camera to dispose the effect on.
  137630. */
  137631. disposeEffects(camera: Camera): void;
  137632. /**
  137633. * @hidden Internal
  137634. */
  137635. _updateEffects(): void;
  137636. /**
  137637. * Internal
  137638. * @returns if all the contained post processes are ready.
  137639. * @hidden
  137640. */
  137641. _isReady(): boolean;
  137642. }
  137643. }
  137644. declare module BABYLON {
  137645. /** @hidden */
  137646. export var displayPassPixelShader: {
  137647. name: string;
  137648. shader: string;
  137649. };
  137650. }
  137651. declare module BABYLON {
  137652. /**
  137653. * DisplayPassPostProcess which produces an output the same as it's input
  137654. */
  137655. export class DisplayPassPostProcess extends PostProcess {
  137656. /**
  137657. * Creates the DisplayPassPostProcess
  137658. * @param name The name of the effect.
  137659. * @param options The required width/height ratio to downsize to before computing the render pass.
  137660. * @param camera The camera to apply the render pass to.
  137661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137662. * @param engine The engine which the post process will be applied. (default: current engine)
  137663. * @param reusable If the post process can be reused on the same frame. (default: false)
  137664. */
  137665. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137666. }
  137667. }
  137668. declare module BABYLON {
  137669. /** @hidden */
  137670. export var filterPixelShader: {
  137671. name: string;
  137672. shader: string;
  137673. };
  137674. }
  137675. declare module BABYLON {
  137676. /**
  137677. * Applies a kernel filter to the image
  137678. */
  137679. export class FilterPostProcess extends PostProcess {
  137680. /** The matrix to be applied to the image */
  137681. kernelMatrix: Matrix;
  137682. /**
  137683. *
  137684. * @param name The name of the effect.
  137685. * @param kernelMatrix The matrix to be applied to the image
  137686. * @param options The required width/height ratio to downsize to before computing the render pass.
  137687. * @param camera The camera to apply the render pass to.
  137688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137689. * @param engine The engine which the post process will be applied. (default: current engine)
  137690. * @param reusable If the post process can be reused on the same frame. (default: false)
  137691. */
  137692. constructor(name: string,
  137693. /** The matrix to be applied to the image */
  137694. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137695. }
  137696. }
  137697. declare module BABYLON {
  137698. /** @hidden */
  137699. export var fxaaPixelShader: {
  137700. name: string;
  137701. shader: string;
  137702. };
  137703. }
  137704. declare module BABYLON {
  137705. /** @hidden */
  137706. export var fxaaVertexShader: {
  137707. name: string;
  137708. shader: string;
  137709. };
  137710. }
  137711. declare module BABYLON {
  137712. /**
  137713. * Fxaa post process
  137714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137715. */
  137716. export class FxaaPostProcess extends PostProcess {
  137717. /** @hidden */
  137718. texelWidth: number;
  137719. /** @hidden */
  137720. texelHeight: number;
  137721. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137722. private _getDefines;
  137723. }
  137724. }
  137725. declare module BABYLON {
  137726. /** @hidden */
  137727. export var grainPixelShader: {
  137728. name: string;
  137729. shader: string;
  137730. };
  137731. }
  137732. declare module BABYLON {
  137733. /**
  137734. * The GrainPostProcess adds noise to the image at mid luminance levels
  137735. */
  137736. export class GrainPostProcess extends PostProcess {
  137737. /**
  137738. * The intensity of the grain added (default: 30)
  137739. */
  137740. intensity: number;
  137741. /**
  137742. * If the grain should be randomized on every frame
  137743. */
  137744. animated: boolean;
  137745. /**
  137746. * Creates a new instance of @see GrainPostProcess
  137747. * @param name The name of the effect.
  137748. * @param options The required width/height ratio to downsize to before computing the render pass.
  137749. * @param camera The camera to apply the render pass to.
  137750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137751. * @param engine The engine which the post process will be applied. (default: current engine)
  137752. * @param reusable If the post process can be reused on the same frame. (default: false)
  137753. * @param textureType Type of textures used when performing the post process. (default: 0)
  137754. * @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)
  137755. */
  137756. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137757. }
  137758. }
  137759. declare module BABYLON {
  137760. /** @hidden */
  137761. export var highlightsPixelShader: {
  137762. name: string;
  137763. shader: string;
  137764. };
  137765. }
  137766. declare module BABYLON {
  137767. /**
  137768. * Extracts highlights from the image
  137769. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137770. */
  137771. export class HighlightsPostProcess extends PostProcess {
  137772. /**
  137773. * Extracts highlights from the image
  137774. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137775. * @param name The name of the effect.
  137776. * @param options The required width/height ratio to downsize to before computing the render pass.
  137777. * @param camera The camera to apply the render pass to.
  137778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137779. * @param engine The engine which the post process will be applied. (default: current engine)
  137780. * @param reusable If the post process can be reused on the same frame. (default: false)
  137781. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137782. */
  137783. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137784. }
  137785. }
  137786. declare module BABYLON {
  137787. /** @hidden */
  137788. export var mrtFragmentDeclaration: {
  137789. name: string;
  137790. shader: string;
  137791. };
  137792. }
  137793. declare module BABYLON {
  137794. /** @hidden */
  137795. export var geometryPixelShader: {
  137796. name: string;
  137797. shader: string;
  137798. };
  137799. }
  137800. declare module BABYLON {
  137801. /** @hidden */
  137802. export var geometryVertexShader: {
  137803. name: string;
  137804. shader: string;
  137805. };
  137806. }
  137807. declare module BABYLON {
  137808. /** @hidden */
  137809. interface ISavedTransformationMatrix {
  137810. world: Matrix;
  137811. viewProjection: Matrix;
  137812. }
  137813. /**
  137814. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137815. */
  137816. export class GeometryBufferRenderer {
  137817. /**
  137818. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137819. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137820. */
  137821. static readonly POSITION_TEXTURE_TYPE: number;
  137822. /**
  137823. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137824. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137825. */
  137826. static readonly VELOCITY_TEXTURE_TYPE: number;
  137827. /**
  137828. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137829. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137830. */
  137831. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137832. /**
  137833. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137834. * in order to compute objects velocities when enableVelocity is set to "true"
  137835. * @hidden
  137836. */
  137837. _previousTransformationMatrices: {
  137838. [index: number]: ISavedTransformationMatrix;
  137839. };
  137840. /**
  137841. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137842. * in order to compute objects velocities when enableVelocity is set to "true"
  137843. * @hidden
  137844. */
  137845. _previousBonesTransformationMatrices: {
  137846. [index: number]: Float32Array;
  137847. };
  137848. /**
  137849. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137850. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137851. */
  137852. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137853. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137854. renderTransparentMeshes: boolean;
  137855. private _scene;
  137856. private _multiRenderTarget;
  137857. private _ratio;
  137858. private _enablePosition;
  137859. private _enableVelocity;
  137860. private _enableReflectivity;
  137861. private _positionIndex;
  137862. private _velocityIndex;
  137863. private _reflectivityIndex;
  137864. protected _effect: Effect;
  137865. protected _cachedDefines: string;
  137866. /**
  137867. * Set the render list (meshes to be rendered) used in the G buffer.
  137868. */
  137869. set renderList(meshes: Mesh[]);
  137870. /**
  137871. * Gets wether or not G buffer are supported by the running hardware.
  137872. * This requires draw buffer supports
  137873. */
  137874. get isSupported(): boolean;
  137875. /**
  137876. * Returns the index of the given texture type in the G-Buffer textures array
  137877. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137878. * @returns the index of the given texture type in the G-Buffer textures array
  137879. */
  137880. getTextureIndex(textureType: number): number;
  137881. /**
  137882. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137883. */
  137884. get enablePosition(): boolean;
  137885. /**
  137886. * Sets whether or not objects positions are enabled for the G buffer.
  137887. */
  137888. set enablePosition(enable: boolean);
  137889. /**
  137890. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137891. */
  137892. get enableVelocity(): boolean;
  137893. /**
  137894. * Sets wether or not objects velocities are enabled for the G buffer.
  137895. */
  137896. set enableVelocity(enable: boolean);
  137897. /**
  137898. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137899. */
  137900. get enableReflectivity(): boolean;
  137901. /**
  137902. * Sets wether or not objects roughness are enabled for the G buffer.
  137903. */
  137904. set enableReflectivity(enable: boolean);
  137905. /**
  137906. * Gets the scene associated with the buffer.
  137907. */
  137908. get scene(): Scene;
  137909. /**
  137910. * Gets the ratio used by the buffer during its creation.
  137911. * How big is the buffer related to the main canvas.
  137912. */
  137913. get ratio(): number;
  137914. /** @hidden */
  137915. static _SceneComponentInitialization: (scene: Scene) => void;
  137916. /**
  137917. * Creates a new G Buffer for the scene
  137918. * @param scene The scene the buffer belongs to
  137919. * @param ratio How big is the buffer related to the main canvas.
  137920. */
  137921. constructor(scene: Scene, ratio?: number);
  137922. /**
  137923. * Checks wether everything is ready to render a submesh to the G buffer.
  137924. * @param subMesh the submesh to check readiness for
  137925. * @param useInstances is the mesh drawn using instance or not
  137926. * @returns true if ready otherwise false
  137927. */
  137928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137929. /**
  137930. * Gets the current underlying G Buffer.
  137931. * @returns the buffer
  137932. */
  137933. getGBuffer(): MultiRenderTarget;
  137934. /**
  137935. * Gets the number of samples used to render the buffer (anti aliasing).
  137936. */
  137937. get samples(): number;
  137938. /**
  137939. * Sets the number of samples used to render the buffer (anti aliasing).
  137940. */
  137941. set samples(value: number);
  137942. /**
  137943. * Disposes the renderer and frees up associated resources.
  137944. */
  137945. dispose(): void;
  137946. protected _createRenderTargets(): void;
  137947. private _copyBonesTransformationMatrices;
  137948. }
  137949. }
  137950. declare module BABYLON {
  137951. interface Scene {
  137952. /** @hidden (Backing field) */
  137953. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137954. /**
  137955. * Gets or Sets the current geometry buffer associated to the scene.
  137956. */
  137957. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137958. /**
  137959. * Enables a GeometryBufferRender and associates it with the scene
  137960. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137961. * @returns the GeometryBufferRenderer
  137962. */
  137963. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137964. /**
  137965. * Disables the GeometryBufferRender associated with the scene
  137966. */
  137967. disableGeometryBufferRenderer(): void;
  137968. }
  137969. /**
  137970. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137971. * in several rendering techniques.
  137972. */
  137973. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137974. /**
  137975. * The component name helpful to identify the component in the list of scene components.
  137976. */
  137977. readonly name: string;
  137978. /**
  137979. * The scene the component belongs to.
  137980. */
  137981. scene: Scene;
  137982. /**
  137983. * Creates a new instance of the component for the given scene
  137984. * @param scene Defines the scene to register the component in
  137985. */
  137986. constructor(scene: Scene);
  137987. /**
  137988. * Registers the component in a given scene
  137989. */
  137990. register(): void;
  137991. /**
  137992. * Rebuilds the elements related to this component in case of
  137993. * context lost for instance.
  137994. */
  137995. rebuild(): void;
  137996. /**
  137997. * Disposes the component and the associated ressources
  137998. */
  137999. dispose(): void;
  138000. private _gatherRenderTargets;
  138001. }
  138002. }
  138003. declare module BABYLON {
  138004. /** @hidden */
  138005. export var motionBlurPixelShader: {
  138006. name: string;
  138007. shader: string;
  138008. };
  138009. }
  138010. declare module BABYLON {
  138011. /**
  138012. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138013. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138014. * As an example, all you have to do is to create the post-process:
  138015. * var mb = new BABYLON.MotionBlurPostProcess(
  138016. * 'mb', // The name of the effect.
  138017. * scene, // The scene containing the objects to blur according to their velocity.
  138018. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138019. * camera // The camera to apply the render pass to.
  138020. * );
  138021. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138022. */
  138023. export class MotionBlurPostProcess extends PostProcess {
  138024. /**
  138025. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138026. */
  138027. motionStrength: number;
  138028. /**
  138029. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138030. */
  138031. get motionBlurSamples(): number;
  138032. /**
  138033. * Sets the number of iterations to be used for motion blur quality
  138034. */
  138035. set motionBlurSamples(samples: number);
  138036. private _motionBlurSamples;
  138037. private _geometryBufferRenderer;
  138038. /**
  138039. * Creates a new instance MotionBlurPostProcess
  138040. * @param name The name of the effect.
  138041. * @param scene The scene containing the objects to blur according to their velocity.
  138042. * @param options The required width/height ratio to downsize to before computing the render pass.
  138043. * @param camera The camera to apply the render pass to.
  138044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138045. * @param engine The engine which the post process will be applied. (default: current engine)
  138046. * @param reusable If the post process can be reused on the same frame. (default: false)
  138047. * @param textureType Type of textures used when performing the post process. (default: 0)
  138048. * @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)
  138049. */
  138050. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138051. /**
  138052. * Excludes the given skinned mesh from computing bones velocities.
  138053. * 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.
  138054. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138055. */
  138056. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138057. /**
  138058. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138059. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138060. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138061. */
  138062. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138063. /**
  138064. * Disposes the post process.
  138065. * @param camera The camera to dispose the post process on.
  138066. */
  138067. dispose(camera?: Camera): void;
  138068. }
  138069. }
  138070. declare module BABYLON {
  138071. /** @hidden */
  138072. export var refractionPixelShader: {
  138073. name: string;
  138074. shader: string;
  138075. };
  138076. }
  138077. declare module BABYLON {
  138078. /**
  138079. * Post process which applies a refractin texture
  138080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138081. */
  138082. export class RefractionPostProcess extends PostProcess {
  138083. /** the base color of the refraction (used to taint the rendering) */
  138084. color: Color3;
  138085. /** simulated refraction depth */
  138086. depth: number;
  138087. /** the coefficient of the base color (0 to remove base color tainting) */
  138088. colorLevel: number;
  138089. private _refTexture;
  138090. private _ownRefractionTexture;
  138091. /**
  138092. * Gets or sets the refraction texture
  138093. * Please note that you are responsible for disposing the texture if you set it manually
  138094. */
  138095. get refractionTexture(): Texture;
  138096. set refractionTexture(value: Texture);
  138097. /**
  138098. * Initializes the RefractionPostProcess
  138099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138100. * @param name The name of the effect.
  138101. * @param refractionTextureUrl Url of the refraction texture to use
  138102. * @param color the base color of the refraction (used to taint the rendering)
  138103. * @param depth simulated refraction depth
  138104. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138105. * @param camera The camera to apply the render pass to.
  138106. * @param options The required width/height ratio to downsize to before computing the render pass.
  138107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138108. * @param engine The engine which the post process will be applied. (default: current engine)
  138109. * @param reusable If the post process can be reused on the same frame. (default: false)
  138110. */
  138111. constructor(name: string, refractionTextureUrl: string,
  138112. /** the base color of the refraction (used to taint the rendering) */
  138113. color: Color3,
  138114. /** simulated refraction depth */
  138115. depth: number,
  138116. /** the coefficient of the base color (0 to remove base color tainting) */
  138117. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138118. /**
  138119. * Disposes of the post process
  138120. * @param camera Camera to dispose post process on
  138121. */
  138122. dispose(camera: Camera): void;
  138123. }
  138124. }
  138125. declare module BABYLON {
  138126. /** @hidden */
  138127. export var sharpenPixelShader: {
  138128. name: string;
  138129. shader: string;
  138130. };
  138131. }
  138132. declare module BABYLON {
  138133. /**
  138134. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138135. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138136. */
  138137. export class SharpenPostProcess extends PostProcess {
  138138. /**
  138139. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138140. */
  138141. colorAmount: number;
  138142. /**
  138143. * How much sharpness should be applied (default: 0.3)
  138144. */
  138145. edgeAmount: number;
  138146. /**
  138147. * Creates a new instance ConvolutionPostProcess
  138148. * @param name The name of the effect.
  138149. * @param options The required width/height ratio to downsize to before computing the render pass.
  138150. * @param camera The camera to apply the render pass to.
  138151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138152. * @param engine The engine which the post process will be applied. (default: current engine)
  138153. * @param reusable If the post process can be reused on the same frame. (default: false)
  138154. * @param textureType Type of textures used when performing the post process. (default: 0)
  138155. * @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)
  138156. */
  138157. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138158. }
  138159. }
  138160. declare module BABYLON {
  138161. /**
  138162. * PostProcessRenderPipeline
  138163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138164. */
  138165. export class PostProcessRenderPipeline {
  138166. private engine;
  138167. private _renderEffects;
  138168. private _renderEffectsForIsolatedPass;
  138169. /**
  138170. * List of inspectable custom properties (used by the Inspector)
  138171. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138172. */
  138173. inspectableCustomProperties: IInspectable[];
  138174. /**
  138175. * @hidden
  138176. */
  138177. protected _cameras: Camera[];
  138178. /** @hidden */
  138179. _name: string;
  138180. /**
  138181. * Gets pipeline name
  138182. */
  138183. get name(): string;
  138184. /** Gets the list of attached cameras */
  138185. get cameras(): Camera[];
  138186. /**
  138187. * Initializes a PostProcessRenderPipeline
  138188. * @param engine engine to add the pipeline to
  138189. * @param name name of the pipeline
  138190. */
  138191. constructor(engine: Engine, name: string);
  138192. /**
  138193. * Gets the class name
  138194. * @returns "PostProcessRenderPipeline"
  138195. */
  138196. getClassName(): string;
  138197. /**
  138198. * If all the render effects in the pipeline are supported
  138199. */
  138200. get isSupported(): boolean;
  138201. /**
  138202. * Adds an effect to the pipeline
  138203. * @param renderEffect the effect to add
  138204. */
  138205. addEffect(renderEffect: PostProcessRenderEffect): void;
  138206. /** @hidden */
  138207. _rebuild(): void;
  138208. /** @hidden */
  138209. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138210. /** @hidden */
  138211. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138212. /** @hidden */
  138213. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138214. /** @hidden */
  138215. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138216. /** @hidden */
  138217. _attachCameras(cameras: Camera, unique: boolean): void;
  138218. /** @hidden */
  138219. _attachCameras(cameras: Camera[], unique: boolean): void;
  138220. /** @hidden */
  138221. _detachCameras(cameras: Camera): void;
  138222. /** @hidden */
  138223. _detachCameras(cameras: Nullable<Camera[]>): void;
  138224. /** @hidden */
  138225. _update(): void;
  138226. /** @hidden */
  138227. _reset(): void;
  138228. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138229. /**
  138230. * Disposes of the pipeline
  138231. */
  138232. dispose(): void;
  138233. }
  138234. }
  138235. declare module BABYLON {
  138236. /**
  138237. * PostProcessRenderPipelineManager class
  138238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138239. */
  138240. export class PostProcessRenderPipelineManager {
  138241. private _renderPipelines;
  138242. /**
  138243. * Initializes a PostProcessRenderPipelineManager
  138244. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138245. */
  138246. constructor();
  138247. /**
  138248. * Gets the list of supported render pipelines
  138249. */
  138250. get supportedPipelines(): PostProcessRenderPipeline[];
  138251. /**
  138252. * Adds a pipeline to the manager
  138253. * @param renderPipeline The pipeline to add
  138254. */
  138255. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138256. /**
  138257. * Attaches a camera to the pipeline
  138258. * @param renderPipelineName The name of the pipeline to attach to
  138259. * @param cameras the camera to attach
  138260. * @param unique if the camera can be attached multiple times to the pipeline
  138261. */
  138262. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138263. /**
  138264. * Detaches a camera from the pipeline
  138265. * @param renderPipelineName The name of the pipeline to detach from
  138266. * @param cameras the camera to detach
  138267. */
  138268. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138269. /**
  138270. * Enables an effect by name on a pipeline
  138271. * @param renderPipelineName the name of the pipeline to enable the effect in
  138272. * @param renderEffectName the name of the effect to enable
  138273. * @param cameras the cameras that the effect should be enabled on
  138274. */
  138275. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138276. /**
  138277. * Disables an effect by name on a pipeline
  138278. * @param renderPipelineName the name of the pipeline to disable the effect in
  138279. * @param renderEffectName the name of the effect to disable
  138280. * @param cameras the cameras that the effect should be disabled on
  138281. */
  138282. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138283. /**
  138284. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138285. */
  138286. update(): void;
  138287. /** @hidden */
  138288. _rebuild(): void;
  138289. /**
  138290. * Disposes of the manager and pipelines
  138291. */
  138292. dispose(): void;
  138293. }
  138294. }
  138295. declare module BABYLON {
  138296. interface Scene {
  138297. /** @hidden (Backing field) */
  138298. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138299. /**
  138300. * Gets the postprocess render pipeline manager
  138301. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138302. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138303. */
  138304. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138305. }
  138306. /**
  138307. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138308. */
  138309. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138310. /**
  138311. * The component name helpfull to identify the component in the list of scene components.
  138312. */
  138313. readonly name: string;
  138314. /**
  138315. * The scene the component belongs to.
  138316. */
  138317. scene: Scene;
  138318. /**
  138319. * Creates a new instance of the component for the given scene
  138320. * @param scene Defines the scene to register the component in
  138321. */
  138322. constructor(scene: Scene);
  138323. /**
  138324. * Registers the component in a given scene
  138325. */
  138326. register(): void;
  138327. /**
  138328. * Rebuilds the elements related to this component in case of
  138329. * context lost for instance.
  138330. */
  138331. rebuild(): void;
  138332. /**
  138333. * Disposes the component and the associated ressources
  138334. */
  138335. dispose(): void;
  138336. private _gatherRenderTargets;
  138337. }
  138338. }
  138339. declare module BABYLON {
  138340. /**
  138341. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138342. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138343. */
  138344. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138345. private _scene;
  138346. private _camerasToBeAttached;
  138347. /**
  138348. * ID of the sharpen post process,
  138349. */
  138350. private readonly SharpenPostProcessId;
  138351. /**
  138352. * @ignore
  138353. * ID of the image processing post process;
  138354. */
  138355. readonly ImageProcessingPostProcessId: string;
  138356. /**
  138357. * @ignore
  138358. * ID of the Fast Approximate Anti-Aliasing post process;
  138359. */
  138360. readonly FxaaPostProcessId: string;
  138361. /**
  138362. * ID of the chromatic aberration post process,
  138363. */
  138364. private readonly ChromaticAberrationPostProcessId;
  138365. /**
  138366. * ID of the grain post process
  138367. */
  138368. private readonly GrainPostProcessId;
  138369. /**
  138370. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138371. */
  138372. sharpen: SharpenPostProcess;
  138373. private _sharpenEffect;
  138374. private bloom;
  138375. /**
  138376. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138377. */
  138378. depthOfField: DepthOfFieldEffect;
  138379. /**
  138380. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138381. */
  138382. fxaa: FxaaPostProcess;
  138383. /**
  138384. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138385. */
  138386. imageProcessing: ImageProcessingPostProcess;
  138387. /**
  138388. * Chromatic aberration post process which will shift rgb colors in the image
  138389. */
  138390. chromaticAberration: ChromaticAberrationPostProcess;
  138391. private _chromaticAberrationEffect;
  138392. /**
  138393. * Grain post process which add noise to the image
  138394. */
  138395. grain: GrainPostProcess;
  138396. private _grainEffect;
  138397. /**
  138398. * Glow post process which adds a glow to emissive areas of the image
  138399. */
  138400. private _glowLayer;
  138401. /**
  138402. * Animations which can be used to tweak settings over a period of time
  138403. */
  138404. animations: Animation[];
  138405. private _imageProcessingConfigurationObserver;
  138406. private _sharpenEnabled;
  138407. private _bloomEnabled;
  138408. private _depthOfFieldEnabled;
  138409. private _depthOfFieldBlurLevel;
  138410. private _fxaaEnabled;
  138411. private _imageProcessingEnabled;
  138412. private _defaultPipelineTextureType;
  138413. private _bloomScale;
  138414. private _chromaticAberrationEnabled;
  138415. private _grainEnabled;
  138416. private _buildAllowed;
  138417. /**
  138418. * Gets active scene
  138419. */
  138420. get scene(): Scene;
  138421. /**
  138422. * Enable or disable the sharpen process from the pipeline
  138423. */
  138424. set sharpenEnabled(enabled: boolean);
  138425. get sharpenEnabled(): boolean;
  138426. private _resizeObserver;
  138427. private _hardwareScaleLevel;
  138428. private _bloomKernel;
  138429. /**
  138430. * Specifies the size of the bloom blur kernel, relative to the final output size
  138431. */
  138432. get bloomKernel(): number;
  138433. set bloomKernel(value: number);
  138434. /**
  138435. * Specifies the weight of the bloom in the final rendering
  138436. */
  138437. private _bloomWeight;
  138438. /**
  138439. * Specifies the luma threshold for the area that will be blurred by the bloom
  138440. */
  138441. private _bloomThreshold;
  138442. private _hdr;
  138443. /**
  138444. * The strength of the bloom.
  138445. */
  138446. set bloomWeight(value: number);
  138447. get bloomWeight(): number;
  138448. /**
  138449. * The strength of the bloom.
  138450. */
  138451. set bloomThreshold(value: number);
  138452. get bloomThreshold(): number;
  138453. /**
  138454. * The scale of the bloom, lower value will provide better performance.
  138455. */
  138456. set bloomScale(value: number);
  138457. get bloomScale(): number;
  138458. /**
  138459. * Enable or disable the bloom from the pipeline
  138460. */
  138461. set bloomEnabled(enabled: boolean);
  138462. get bloomEnabled(): boolean;
  138463. private _rebuildBloom;
  138464. /**
  138465. * If the depth of field is enabled.
  138466. */
  138467. get depthOfFieldEnabled(): boolean;
  138468. set depthOfFieldEnabled(enabled: boolean);
  138469. /**
  138470. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138471. */
  138472. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138473. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138474. /**
  138475. * If the anti aliasing is enabled.
  138476. */
  138477. set fxaaEnabled(enabled: boolean);
  138478. get fxaaEnabled(): boolean;
  138479. private _samples;
  138480. /**
  138481. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138482. */
  138483. set samples(sampleCount: number);
  138484. get samples(): number;
  138485. /**
  138486. * If image processing is enabled.
  138487. */
  138488. set imageProcessingEnabled(enabled: boolean);
  138489. get imageProcessingEnabled(): boolean;
  138490. /**
  138491. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138492. */
  138493. set glowLayerEnabled(enabled: boolean);
  138494. get glowLayerEnabled(): boolean;
  138495. /**
  138496. * Gets the glow layer (or null if not defined)
  138497. */
  138498. get glowLayer(): Nullable<GlowLayer>;
  138499. /**
  138500. * Enable or disable the chromaticAberration process from the pipeline
  138501. */
  138502. set chromaticAberrationEnabled(enabled: boolean);
  138503. get chromaticAberrationEnabled(): boolean;
  138504. /**
  138505. * Enable or disable the grain process from the pipeline
  138506. */
  138507. set grainEnabled(enabled: boolean);
  138508. get grainEnabled(): boolean;
  138509. /**
  138510. * @constructor
  138511. * @param name - The rendering pipeline name (default: "")
  138512. * @param hdr - If high dynamic range textures should be used (default: true)
  138513. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138514. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138515. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138516. */
  138517. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138518. /**
  138519. * Get the class name
  138520. * @returns "DefaultRenderingPipeline"
  138521. */
  138522. getClassName(): string;
  138523. /**
  138524. * Force the compilation of the entire pipeline.
  138525. */
  138526. prepare(): void;
  138527. private _hasCleared;
  138528. private _prevPostProcess;
  138529. private _prevPrevPostProcess;
  138530. private _setAutoClearAndTextureSharing;
  138531. private _depthOfFieldSceneObserver;
  138532. private _buildPipeline;
  138533. private _disposePostProcesses;
  138534. /**
  138535. * Adds a camera to the pipeline
  138536. * @param camera the camera to be added
  138537. */
  138538. addCamera(camera: Camera): void;
  138539. /**
  138540. * Removes a camera from the pipeline
  138541. * @param camera the camera to remove
  138542. */
  138543. removeCamera(camera: Camera): void;
  138544. /**
  138545. * Dispose of the pipeline and stop all post processes
  138546. */
  138547. dispose(): void;
  138548. /**
  138549. * Serialize the rendering pipeline (Used when exporting)
  138550. * @returns the serialized object
  138551. */
  138552. serialize(): any;
  138553. /**
  138554. * Parse the serialized pipeline
  138555. * @param source Source pipeline.
  138556. * @param scene The scene to load the pipeline to.
  138557. * @param rootUrl The URL of the serialized pipeline.
  138558. * @returns An instantiated pipeline from the serialized object.
  138559. */
  138560. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138561. }
  138562. }
  138563. declare module BABYLON {
  138564. /** @hidden */
  138565. export var lensHighlightsPixelShader: {
  138566. name: string;
  138567. shader: string;
  138568. };
  138569. }
  138570. declare module BABYLON {
  138571. /** @hidden */
  138572. export var depthOfFieldPixelShader: {
  138573. name: string;
  138574. shader: string;
  138575. };
  138576. }
  138577. declare module BABYLON {
  138578. /**
  138579. * BABYLON.JS Chromatic Aberration GLSL Shader
  138580. * Author: Olivier Guyot
  138581. * Separates very slightly R, G and B colors on the edges of the screen
  138582. * Inspired by Francois Tarlier & Martins Upitis
  138583. */
  138584. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138585. /**
  138586. * @ignore
  138587. * The chromatic aberration PostProcess id in the pipeline
  138588. */
  138589. LensChromaticAberrationEffect: string;
  138590. /**
  138591. * @ignore
  138592. * The highlights enhancing PostProcess id in the pipeline
  138593. */
  138594. HighlightsEnhancingEffect: string;
  138595. /**
  138596. * @ignore
  138597. * The depth-of-field PostProcess id in the pipeline
  138598. */
  138599. LensDepthOfFieldEffect: string;
  138600. private _scene;
  138601. private _depthTexture;
  138602. private _grainTexture;
  138603. private _chromaticAberrationPostProcess;
  138604. private _highlightsPostProcess;
  138605. private _depthOfFieldPostProcess;
  138606. private _edgeBlur;
  138607. private _grainAmount;
  138608. private _chromaticAberration;
  138609. private _distortion;
  138610. private _highlightsGain;
  138611. private _highlightsThreshold;
  138612. private _dofDistance;
  138613. private _dofAperture;
  138614. private _dofDarken;
  138615. private _dofPentagon;
  138616. private _blurNoise;
  138617. /**
  138618. * @constructor
  138619. *
  138620. * Effect parameters are as follow:
  138621. * {
  138622. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138623. * edge_blur: number; // from 0 to x (1 for realism)
  138624. * distortion: number; // from 0 to x (1 for realism)
  138625. * grain_amount: number; // from 0 to 1
  138626. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138627. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138628. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138629. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138630. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138631. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138632. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138633. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138634. * }
  138635. * Note: if an effect parameter is unset, effect is disabled
  138636. *
  138637. * @param name The rendering pipeline name
  138638. * @param parameters - An object containing all parameters (see above)
  138639. * @param scene The scene linked to this pipeline
  138640. * @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)
  138641. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138642. */
  138643. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138644. /**
  138645. * Get the class name
  138646. * @returns "LensRenderingPipeline"
  138647. */
  138648. getClassName(): string;
  138649. /**
  138650. * Gets associated scene
  138651. */
  138652. get scene(): Scene;
  138653. /**
  138654. * Gets or sets the edge blur
  138655. */
  138656. get edgeBlur(): number;
  138657. set edgeBlur(value: number);
  138658. /**
  138659. * Gets or sets the grain amount
  138660. */
  138661. get grainAmount(): number;
  138662. set grainAmount(value: number);
  138663. /**
  138664. * Gets or sets the chromatic aberration amount
  138665. */
  138666. get chromaticAberration(): number;
  138667. set chromaticAberration(value: number);
  138668. /**
  138669. * Gets or sets the depth of field aperture
  138670. */
  138671. get dofAperture(): number;
  138672. set dofAperture(value: number);
  138673. /**
  138674. * Gets or sets the edge distortion
  138675. */
  138676. get edgeDistortion(): number;
  138677. set edgeDistortion(value: number);
  138678. /**
  138679. * Gets or sets the depth of field distortion
  138680. */
  138681. get dofDistortion(): number;
  138682. set dofDistortion(value: number);
  138683. /**
  138684. * Gets or sets the darken out of focus amount
  138685. */
  138686. get darkenOutOfFocus(): number;
  138687. set darkenOutOfFocus(value: number);
  138688. /**
  138689. * Gets or sets a boolean indicating if blur noise is enabled
  138690. */
  138691. get blurNoise(): boolean;
  138692. set blurNoise(value: boolean);
  138693. /**
  138694. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138695. */
  138696. get pentagonBokeh(): boolean;
  138697. set pentagonBokeh(value: boolean);
  138698. /**
  138699. * Gets or sets the highlight grain amount
  138700. */
  138701. get highlightsGain(): number;
  138702. set highlightsGain(value: number);
  138703. /**
  138704. * Gets or sets the highlight threshold
  138705. */
  138706. get highlightsThreshold(): number;
  138707. set highlightsThreshold(value: number);
  138708. /**
  138709. * Sets the amount of blur at the edges
  138710. * @param amount blur amount
  138711. */
  138712. setEdgeBlur(amount: number): void;
  138713. /**
  138714. * Sets edge blur to 0
  138715. */
  138716. disableEdgeBlur(): void;
  138717. /**
  138718. * Sets the amout of grain
  138719. * @param amount Amount of grain
  138720. */
  138721. setGrainAmount(amount: number): void;
  138722. /**
  138723. * Set grain amount to 0
  138724. */
  138725. disableGrain(): void;
  138726. /**
  138727. * Sets the chromatic aberration amount
  138728. * @param amount amount of chromatic aberration
  138729. */
  138730. setChromaticAberration(amount: number): void;
  138731. /**
  138732. * Sets chromatic aberration amount to 0
  138733. */
  138734. disableChromaticAberration(): void;
  138735. /**
  138736. * Sets the EdgeDistortion amount
  138737. * @param amount amount of EdgeDistortion
  138738. */
  138739. setEdgeDistortion(amount: number): void;
  138740. /**
  138741. * Sets edge distortion to 0
  138742. */
  138743. disableEdgeDistortion(): void;
  138744. /**
  138745. * Sets the FocusDistance amount
  138746. * @param amount amount of FocusDistance
  138747. */
  138748. setFocusDistance(amount: number): void;
  138749. /**
  138750. * Disables depth of field
  138751. */
  138752. disableDepthOfField(): void;
  138753. /**
  138754. * Sets the Aperture amount
  138755. * @param amount amount of Aperture
  138756. */
  138757. setAperture(amount: number): void;
  138758. /**
  138759. * Sets the DarkenOutOfFocus amount
  138760. * @param amount amount of DarkenOutOfFocus
  138761. */
  138762. setDarkenOutOfFocus(amount: number): void;
  138763. private _pentagonBokehIsEnabled;
  138764. /**
  138765. * Creates a pentagon bokeh effect
  138766. */
  138767. enablePentagonBokeh(): void;
  138768. /**
  138769. * Disables the pentagon bokeh effect
  138770. */
  138771. disablePentagonBokeh(): void;
  138772. /**
  138773. * Enables noise blur
  138774. */
  138775. enableNoiseBlur(): void;
  138776. /**
  138777. * Disables noise blur
  138778. */
  138779. disableNoiseBlur(): void;
  138780. /**
  138781. * Sets the HighlightsGain amount
  138782. * @param amount amount of HighlightsGain
  138783. */
  138784. setHighlightsGain(amount: number): void;
  138785. /**
  138786. * Sets the HighlightsThreshold amount
  138787. * @param amount amount of HighlightsThreshold
  138788. */
  138789. setHighlightsThreshold(amount: number): void;
  138790. /**
  138791. * Disables highlights
  138792. */
  138793. disableHighlights(): void;
  138794. /**
  138795. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138796. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138797. */
  138798. dispose(disableDepthRender?: boolean): void;
  138799. private _createChromaticAberrationPostProcess;
  138800. private _createHighlightsPostProcess;
  138801. private _createDepthOfFieldPostProcess;
  138802. private _createGrainTexture;
  138803. }
  138804. }
  138805. declare module BABYLON {
  138806. /** @hidden */
  138807. export var ssao2PixelShader: {
  138808. name: string;
  138809. shader: string;
  138810. };
  138811. }
  138812. declare module BABYLON {
  138813. /** @hidden */
  138814. export var ssaoCombinePixelShader: {
  138815. name: string;
  138816. shader: string;
  138817. };
  138818. }
  138819. declare module BABYLON {
  138820. /**
  138821. * Render pipeline to produce ssao effect
  138822. */
  138823. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138824. /**
  138825. * @ignore
  138826. * The PassPostProcess id in the pipeline that contains the original scene color
  138827. */
  138828. SSAOOriginalSceneColorEffect: string;
  138829. /**
  138830. * @ignore
  138831. * The SSAO PostProcess id in the pipeline
  138832. */
  138833. SSAORenderEffect: string;
  138834. /**
  138835. * @ignore
  138836. * The horizontal blur PostProcess id in the pipeline
  138837. */
  138838. SSAOBlurHRenderEffect: string;
  138839. /**
  138840. * @ignore
  138841. * The vertical blur PostProcess id in the pipeline
  138842. */
  138843. SSAOBlurVRenderEffect: string;
  138844. /**
  138845. * @ignore
  138846. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138847. */
  138848. SSAOCombineRenderEffect: string;
  138849. /**
  138850. * The output strength of the SSAO post-process. Default value is 1.0.
  138851. */
  138852. totalStrength: number;
  138853. /**
  138854. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138855. */
  138856. maxZ: number;
  138857. /**
  138858. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138859. */
  138860. minZAspect: number;
  138861. private _samples;
  138862. /**
  138863. * Number of samples used for the SSAO calculations. Default value is 8
  138864. */
  138865. set samples(n: number);
  138866. get samples(): number;
  138867. private _textureSamples;
  138868. /**
  138869. * Number of samples to use for antialiasing
  138870. */
  138871. set textureSamples(n: number);
  138872. get textureSamples(): number;
  138873. /**
  138874. * Ratio object used for SSAO ratio and blur ratio
  138875. */
  138876. private _ratio;
  138877. /**
  138878. * Dynamically generated sphere sampler.
  138879. */
  138880. private _sampleSphere;
  138881. /**
  138882. * Blur filter offsets
  138883. */
  138884. private _samplerOffsets;
  138885. private _expensiveBlur;
  138886. /**
  138887. * If bilateral blur should be used
  138888. */
  138889. set expensiveBlur(b: boolean);
  138890. get expensiveBlur(): boolean;
  138891. /**
  138892. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138893. */
  138894. radius: number;
  138895. /**
  138896. * The base color of the SSAO post-process
  138897. * The final result is "base + ssao" between [0, 1]
  138898. */
  138899. base: number;
  138900. /**
  138901. * Support test.
  138902. */
  138903. static get IsSupported(): boolean;
  138904. private _scene;
  138905. private _depthTexture;
  138906. private _normalTexture;
  138907. private _randomTexture;
  138908. private _originalColorPostProcess;
  138909. private _ssaoPostProcess;
  138910. private _blurHPostProcess;
  138911. private _blurVPostProcess;
  138912. private _ssaoCombinePostProcess;
  138913. /**
  138914. * Gets active scene
  138915. */
  138916. get scene(): Scene;
  138917. /**
  138918. * @constructor
  138919. * @param name The rendering pipeline name
  138920. * @param scene The scene linked to this pipeline
  138921. * @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 }
  138922. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138923. */
  138924. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138925. /**
  138926. * Get the class name
  138927. * @returns "SSAO2RenderingPipeline"
  138928. */
  138929. getClassName(): string;
  138930. /**
  138931. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138932. */
  138933. dispose(disableGeometryBufferRenderer?: boolean): void;
  138934. private _createBlurPostProcess;
  138935. /** @hidden */
  138936. _rebuild(): void;
  138937. private _bits;
  138938. private _radicalInverse_VdC;
  138939. private _hammersley;
  138940. private _hemisphereSample_uniform;
  138941. private _generateHemisphere;
  138942. private _createSSAOPostProcess;
  138943. private _createSSAOCombinePostProcess;
  138944. private _createRandomTexture;
  138945. /**
  138946. * Serialize the rendering pipeline (Used when exporting)
  138947. * @returns the serialized object
  138948. */
  138949. serialize(): any;
  138950. /**
  138951. * Parse the serialized pipeline
  138952. * @param source Source pipeline.
  138953. * @param scene The scene to load the pipeline to.
  138954. * @param rootUrl The URL of the serialized pipeline.
  138955. * @returns An instantiated pipeline from the serialized object.
  138956. */
  138957. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138958. }
  138959. }
  138960. declare module BABYLON {
  138961. /** @hidden */
  138962. export var ssaoPixelShader: {
  138963. name: string;
  138964. shader: string;
  138965. };
  138966. }
  138967. declare module BABYLON {
  138968. /**
  138969. * Render pipeline to produce ssao effect
  138970. */
  138971. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138972. /**
  138973. * @ignore
  138974. * The PassPostProcess id in the pipeline that contains the original scene color
  138975. */
  138976. SSAOOriginalSceneColorEffect: string;
  138977. /**
  138978. * @ignore
  138979. * The SSAO PostProcess id in the pipeline
  138980. */
  138981. SSAORenderEffect: string;
  138982. /**
  138983. * @ignore
  138984. * The horizontal blur PostProcess id in the pipeline
  138985. */
  138986. SSAOBlurHRenderEffect: string;
  138987. /**
  138988. * @ignore
  138989. * The vertical blur PostProcess id in the pipeline
  138990. */
  138991. SSAOBlurVRenderEffect: string;
  138992. /**
  138993. * @ignore
  138994. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138995. */
  138996. SSAOCombineRenderEffect: string;
  138997. /**
  138998. * The output strength of the SSAO post-process. Default value is 1.0.
  138999. */
  139000. totalStrength: number;
  139001. /**
  139002. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139003. */
  139004. radius: number;
  139005. /**
  139006. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139007. * Must not be equal to fallOff and superior to fallOff.
  139008. * Default value is 0.0075
  139009. */
  139010. area: number;
  139011. /**
  139012. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139013. * Must not be equal to area and inferior to area.
  139014. * Default value is 0.000001
  139015. */
  139016. fallOff: number;
  139017. /**
  139018. * The base color of the SSAO post-process
  139019. * The final result is "base + ssao" between [0, 1]
  139020. */
  139021. base: number;
  139022. private _scene;
  139023. private _depthTexture;
  139024. private _randomTexture;
  139025. private _originalColorPostProcess;
  139026. private _ssaoPostProcess;
  139027. private _blurHPostProcess;
  139028. private _blurVPostProcess;
  139029. private _ssaoCombinePostProcess;
  139030. private _firstUpdate;
  139031. /**
  139032. * Gets active scene
  139033. */
  139034. get scene(): Scene;
  139035. /**
  139036. * @constructor
  139037. * @param name - The rendering pipeline name
  139038. * @param scene - The scene linked to this pipeline
  139039. * @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 }
  139040. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139041. */
  139042. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139043. /**
  139044. * Get the class name
  139045. * @returns "SSAORenderingPipeline"
  139046. */
  139047. getClassName(): string;
  139048. /**
  139049. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139050. */
  139051. dispose(disableDepthRender?: boolean): void;
  139052. private _createBlurPostProcess;
  139053. /** @hidden */
  139054. _rebuild(): void;
  139055. private _createSSAOPostProcess;
  139056. private _createSSAOCombinePostProcess;
  139057. private _createRandomTexture;
  139058. }
  139059. }
  139060. declare module BABYLON {
  139061. /** @hidden */
  139062. export var screenSpaceReflectionPixelShader: {
  139063. name: string;
  139064. shader: string;
  139065. };
  139066. }
  139067. declare module BABYLON {
  139068. /**
  139069. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139070. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139071. */
  139072. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139073. /**
  139074. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139075. */
  139076. threshold: number;
  139077. /**
  139078. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139079. */
  139080. strength: number;
  139081. /**
  139082. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139083. */
  139084. reflectionSpecularFalloffExponent: number;
  139085. /**
  139086. * 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]
  139087. */
  139088. step: number;
  139089. /**
  139090. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139091. */
  139092. roughnessFactor: number;
  139093. private _geometryBufferRenderer;
  139094. private _enableSmoothReflections;
  139095. private _reflectionSamples;
  139096. private _smoothSteps;
  139097. /**
  139098. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139099. * @param name The name of the effect.
  139100. * @param scene The scene containing the objects to calculate reflections.
  139101. * @param options The required width/height ratio to downsize to before computing the render pass.
  139102. * @param camera The camera to apply the render pass to.
  139103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139104. * @param engine The engine which the post process will be applied. (default: current engine)
  139105. * @param reusable If the post process can be reused on the same frame. (default: false)
  139106. * @param textureType Type of textures used when performing the post process. (default: 0)
  139107. * @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)
  139108. */
  139109. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139110. /**
  139111. * Gets wether or not smoothing reflections is enabled.
  139112. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139113. */
  139114. get enableSmoothReflections(): boolean;
  139115. /**
  139116. * Sets wether or not smoothing reflections is enabled.
  139117. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139118. */
  139119. set enableSmoothReflections(enabled: boolean);
  139120. /**
  139121. * Gets the number of samples taken while computing reflections. More samples count is high,
  139122. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139123. */
  139124. get reflectionSamples(): number;
  139125. /**
  139126. * Sets the number of samples taken while computing reflections. More samples count is high,
  139127. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139128. */
  139129. set reflectionSamples(samples: number);
  139130. /**
  139131. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139132. * more the post-process will require GPU power and can generate a drop in FPS.
  139133. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139134. */
  139135. get smoothSteps(): number;
  139136. set smoothSteps(steps: number);
  139137. private _updateEffectDefines;
  139138. }
  139139. }
  139140. declare module BABYLON {
  139141. /** @hidden */
  139142. export var standardPixelShader: {
  139143. name: string;
  139144. shader: string;
  139145. };
  139146. }
  139147. declare module BABYLON {
  139148. /**
  139149. * Standard rendering pipeline
  139150. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139151. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139152. */
  139153. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139154. /**
  139155. * Public members
  139156. */
  139157. /**
  139158. * Post-process which contains the original scene color before the pipeline applies all the effects
  139159. */
  139160. originalPostProcess: Nullable<PostProcess>;
  139161. /**
  139162. * Post-process used to down scale an image x4
  139163. */
  139164. downSampleX4PostProcess: Nullable<PostProcess>;
  139165. /**
  139166. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139167. */
  139168. brightPassPostProcess: Nullable<PostProcess>;
  139169. /**
  139170. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139171. */
  139172. blurHPostProcesses: PostProcess[];
  139173. /**
  139174. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139175. */
  139176. blurVPostProcesses: PostProcess[];
  139177. /**
  139178. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139179. */
  139180. textureAdderPostProcess: Nullable<PostProcess>;
  139181. /**
  139182. * Post-process used to create volumetric lighting effect
  139183. */
  139184. volumetricLightPostProcess: Nullable<PostProcess>;
  139185. /**
  139186. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139187. */
  139188. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139189. /**
  139190. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139191. */
  139192. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139193. /**
  139194. * Post-process used to merge the volumetric light effect and the real scene color
  139195. */
  139196. volumetricLightMergePostProces: Nullable<PostProcess>;
  139197. /**
  139198. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139199. */
  139200. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139201. /**
  139202. * Base post-process used to calculate the average luminance of the final image for HDR
  139203. */
  139204. luminancePostProcess: Nullable<PostProcess>;
  139205. /**
  139206. * Post-processes used to create down sample post-processes in order to get
  139207. * the average luminance of the final image for HDR
  139208. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139209. */
  139210. luminanceDownSamplePostProcesses: PostProcess[];
  139211. /**
  139212. * Post-process used to create a HDR effect (light adaptation)
  139213. */
  139214. hdrPostProcess: Nullable<PostProcess>;
  139215. /**
  139216. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139217. */
  139218. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139219. /**
  139220. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139221. */
  139222. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139223. /**
  139224. * Post-process used to merge the final HDR post-process and the real scene color
  139225. */
  139226. hdrFinalPostProcess: Nullable<PostProcess>;
  139227. /**
  139228. * Post-process used to create a lens flare effect
  139229. */
  139230. lensFlarePostProcess: Nullable<PostProcess>;
  139231. /**
  139232. * Post-process that merges the result of the lens flare post-process and the real scene color
  139233. */
  139234. lensFlareComposePostProcess: Nullable<PostProcess>;
  139235. /**
  139236. * Post-process used to create a motion blur effect
  139237. */
  139238. motionBlurPostProcess: Nullable<PostProcess>;
  139239. /**
  139240. * Post-process used to create a depth of field effect
  139241. */
  139242. depthOfFieldPostProcess: Nullable<PostProcess>;
  139243. /**
  139244. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139245. */
  139246. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139247. /**
  139248. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139249. */
  139250. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139251. /**
  139252. * Represents the brightness threshold in order to configure the illuminated surfaces
  139253. */
  139254. brightThreshold: number;
  139255. /**
  139256. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139257. */
  139258. blurWidth: number;
  139259. /**
  139260. * Sets if the blur for highlighted surfaces must be only horizontal
  139261. */
  139262. horizontalBlur: boolean;
  139263. /**
  139264. * Gets the overall exposure used by the pipeline
  139265. */
  139266. get exposure(): number;
  139267. /**
  139268. * Sets the overall exposure used by the pipeline
  139269. */
  139270. set exposure(value: number);
  139271. /**
  139272. * Texture used typically to simulate "dirty" on camera lens
  139273. */
  139274. lensTexture: Nullable<Texture>;
  139275. /**
  139276. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139277. */
  139278. volumetricLightCoefficient: number;
  139279. /**
  139280. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139281. */
  139282. volumetricLightPower: number;
  139283. /**
  139284. * Used the set the blur intensity to smooth the volumetric lights
  139285. */
  139286. volumetricLightBlurScale: number;
  139287. /**
  139288. * Light (spot or directional) used to generate the volumetric lights rays
  139289. * The source light must have a shadow generate so the pipeline can get its
  139290. * depth map
  139291. */
  139292. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139293. /**
  139294. * For eye adaptation, represents the minimum luminance the eye can see
  139295. */
  139296. hdrMinimumLuminance: number;
  139297. /**
  139298. * For eye adaptation, represents the decrease luminance speed
  139299. */
  139300. hdrDecreaseRate: number;
  139301. /**
  139302. * For eye adaptation, represents the increase luminance speed
  139303. */
  139304. hdrIncreaseRate: number;
  139305. /**
  139306. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139307. */
  139308. get hdrAutoExposure(): boolean;
  139309. /**
  139310. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139311. */
  139312. set hdrAutoExposure(value: boolean);
  139313. /**
  139314. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139315. */
  139316. lensColorTexture: Nullable<Texture>;
  139317. /**
  139318. * The overall strengh for the lens flare effect
  139319. */
  139320. lensFlareStrength: number;
  139321. /**
  139322. * Dispersion coefficient for lens flare ghosts
  139323. */
  139324. lensFlareGhostDispersal: number;
  139325. /**
  139326. * Main lens flare halo width
  139327. */
  139328. lensFlareHaloWidth: number;
  139329. /**
  139330. * Based on the lens distortion effect, defines how much the lens flare result
  139331. * is distorted
  139332. */
  139333. lensFlareDistortionStrength: number;
  139334. /**
  139335. * Configures the blur intensity used for for lens flare (halo)
  139336. */
  139337. lensFlareBlurWidth: number;
  139338. /**
  139339. * Lens star texture must be used to simulate rays on the flares and is available
  139340. * in the documentation
  139341. */
  139342. lensStarTexture: Nullable<Texture>;
  139343. /**
  139344. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139345. * flare effect by taking account of the dirt texture
  139346. */
  139347. lensFlareDirtTexture: Nullable<Texture>;
  139348. /**
  139349. * Represents the focal length for the depth of field effect
  139350. */
  139351. depthOfFieldDistance: number;
  139352. /**
  139353. * Represents the blur intensity for the blurred part of the depth of field effect
  139354. */
  139355. depthOfFieldBlurWidth: number;
  139356. /**
  139357. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139358. */
  139359. get motionStrength(): number;
  139360. /**
  139361. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139362. */
  139363. set motionStrength(strength: number);
  139364. /**
  139365. * Gets wether or not the motion blur post-process is object based or screen based.
  139366. */
  139367. get objectBasedMotionBlur(): boolean;
  139368. /**
  139369. * Sets wether or not the motion blur post-process should be object based or screen based
  139370. */
  139371. set objectBasedMotionBlur(value: boolean);
  139372. /**
  139373. * List of animations for the pipeline (IAnimatable implementation)
  139374. */
  139375. animations: Animation[];
  139376. /**
  139377. * Private members
  139378. */
  139379. private _scene;
  139380. private _currentDepthOfFieldSource;
  139381. private _basePostProcess;
  139382. private _fixedExposure;
  139383. private _currentExposure;
  139384. private _hdrAutoExposure;
  139385. private _hdrCurrentLuminance;
  139386. private _motionStrength;
  139387. private _isObjectBasedMotionBlur;
  139388. private _floatTextureType;
  139389. private _camerasToBeAttached;
  139390. private _ratio;
  139391. private _bloomEnabled;
  139392. private _depthOfFieldEnabled;
  139393. private _vlsEnabled;
  139394. private _lensFlareEnabled;
  139395. private _hdrEnabled;
  139396. private _motionBlurEnabled;
  139397. private _fxaaEnabled;
  139398. private _screenSpaceReflectionsEnabled;
  139399. private _motionBlurSamples;
  139400. private _volumetricLightStepsCount;
  139401. private _samples;
  139402. /**
  139403. * @ignore
  139404. * Specifies if the bloom pipeline is enabled
  139405. */
  139406. get BloomEnabled(): boolean;
  139407. set BloomEnabled(enabled: boolean);
  139408. /**
  139409. * @ignore
  139410. * Specifies if the depth of field pipeline is enabed
  139411. */
  139412. get DepthOfFieldEnabled(): boolean;
  139413. set DepthOfFieldEnabled(enabled: boolean);
  139414. /**
  139415. * @ignore
  139416. * Specifies if the lens flare pipeline is enabed
  139417. */
  139418. get LensFlareEnabled(): boolean;
  139419. set LensFlareEnabled(enabled: boolean);
  139420. /**
  139421. * @ignore
  139422. * Specifies if the HDR pipeline is enabled
  139423. */
  139424. get HDREnabled(): boolean;
  139425. set HDREnabled(enabled: boolean);
  139426. /**
  139427. * @ignore
  139428. * Specifies if the volumetric lights scattering effect is enabled
  139429. */
  139430. get VLSEnabled(): boolean;
  139431. set VLSEnabled(enabled: boolean);
  139432. /**
  139433. * @ignore
  139434. * Specifies if the motion blur effect is enabled
  139435. */
  139436. get MotionBlurEnabled(): boolean;
  139437. set MotionBlurEnabled(enabled: boolean);
  139438. /**
  139439. * Specifies if anti-aliasing is enabled
  139440. */
  139441. get fxaaEnabled(): boolean;
  139442. set fxaaEnabled(enabled: boolean);
  139443. /**
  139444. * Specifies if screen space reflections are enabled.
  139445. */
  139446. get screenSpaceReflectionsEnabled(): boolean;
  139447. set screenSpaceReflectionsEnabled(enabled: boolean);
  139448. /**
  139449. * Specifies the number of steps used to calculate the volumetric lights
  139450. * Typically in interval [50, 200]
  139451. */
  139452. get volumetricLightStepsCount(): number;
  139453. set volumetricLightStepsCount(count: number);
  139454. /**
  139455. * Specifies the number of samples used for the motion blur effect
  139456. * Typically in interval [16, 64]
  139457. */
  139458. get motionBlurSamples(): number;
  139459. set motionBlurSamples(samples: number);
  139460. /**
  139461. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139462. */
  139463. get samples(): number;
  139464. set samples(sampleCount: number);
  139465. /**
  139466. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139467. * @constructor
  139468. * @param name The rendering pipeline name
  139469. * @param scene The scene linked to this pipeline
  139470. * @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)
  139471. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139472. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139473. */
  139474. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139475. private _buildPipeline;
  139476. private _createDownSampleX4PostProcess;
  139477. private _createBrightPassPostProcess;
  139478. private _createBlurPostProcesses;
  139479. private _createTextureAdderPostProcess;
  139480. private _createVolumetricLightPostProcess;
  139481. private _createLuminancePostProcesses;
  139482. private _createHdrPostProcess;
  139483. private _createLensFlarePostProcess;
  139484. private _createDepthOfFieldPostProcess;
  139485. private _createMotionBlurPostProcess;
  139486. private _getDepthTexture;
  139487. private _disposePostProcesses;
  139488. /**
  139489. * Dispose of the pipeline and stop all post processes
  139490. */
  139491. dispose(): void;
  139492. /**
  139493. * Serialize the rendering pipeline (Used when exporting)
  139494. * @returns the serialized object
  139495. */
  139496. serialize(): any;
  139497. /**
  139498. * Parse the serialized pipeline
  139499. * @param source Source pipeline.
  139500. * @param scene The scene to load the pipeline to.
  139501. * @param rootUrl The URL of the serialized pipeline.
  139502. * @returns An instantiated pipeline from the serialized object.
  139503. */
  139504. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139505. /**
  139506. * Luminance steps
  139507. */
  139508. static LuminanceSteps: number;
  139509. }
  139510. }
  139511. declare module BABYLON {
  139512. /** @hidden */
  139513. export var tonemapPixelShader: {
  139514. name: string;
  139515. shader: string;
  139516. };
  139517. }
  139518. declare module BABYLON {
  139519. /** Defines operator used for tonemapping */
  139520. export enum TonemappingOperator {
  139521. /** Hable */
  139522. Hable = 0,
  139523. /** Reinhard */
  139524. Reinhard = 1,
  139525. /** HejiDawson */
  139526. HejiDawson = 2,
  139527. /** Photographic */
  139528. Photographic = 3
  139529. }
  139530. /**
  139531. * Defines a post process to apply tone mapping
  139532. */
  139533. export class TonemapPostProcess extends PostProcess {
  139534. private _operator;
  139535. /** Defines the required exposure adjustement */
  139536. exposureAdjustment: number;
  139537. /**
  139538. * Creates a new TonemapPostProcess
  139539. * @param name defines the name of the postprocess
  139540. * @param _operator defines the operator to use
  139541. * @param exposureAdjustment defines the required exposure adjustement
  139542. * @param camera defines the camera to use (can be null)
  139543. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139544. * @param engine defines the hosting engine (can be ignore if camera is set)
  139545. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139546. */
  139547. constructor(name: string, _operator: TonemappingOperator,
  139548. /** Defines the required exposure adjustement */
  139549. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139550. }
  139551. }
  139552. declare module BABYLON {
  139553. /** @hidden */
  139554. export var volumetricLightScatteringPixelShader: {
  139555. name: string;
  139556. shader: string;
  139557. };
  139558. }
  139559. declare module BABYLON {
  139560. /** @hidden */
  139561. export var volumetricLightScatteringPassVertexShader: {
  139562. name: string;
  139563. shader: string;
  139564. };
  139565. }
  139566. declare module BABYLON {
  139567. /** @hidden */
  139568. export var volumetricLightScatteringPassPixelShader: {
  139569. name: string;
  139570. shader: string;
  139571. };
  139572. }
  139573. declare module BABYLON {
  139574. /**
  139575. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139576. */
  139577. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139578. private _volumetricLightScatteringPass;
  139579. private _volumetricLightScatteringRTT;
  139580. private _viewPort;
  139581. private _screenCoordinates;
  139582. private _cachedDefines;
  139583. /**
  139584. * If not undefined, the mesh position is computed from the attached node position
  139585. */
  139586. attachedNode: {
  139587. position: Vector3;
  139588. };
  139589. /**
  139590. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139591. */
  139592. customMeshPosition: Vector3;
  139593. /**
  139594. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139595. */
  139596. useCustomMeshPosition: boolean;
  139597. /**
  139598. * If the post-process should inverse the light scattering direction
  139599. */
  139600. invert: boolean;
  139601. /**
  139602. * The internal mesh used by the post-process
  139603. */
  139604. mesh: Mesh;
  139605. /**
  139606. * @hidden
  139607. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139608. */
  139609. get useDiffuseColor(): boolean;
  139610. set useDiffuseColor(useDiffuseColor: boolean);
  139611. /**
  139612. * Array containing the excluded meshes not rendered in the internal pass
  139613. */
  139614. excludedMeshes: AbstractMesh[];
  139615. /**
  139616. * Controls the overall intensity of the post-process
  139617. */
  139618. exposure: number;
  139619. /**
  139620. * Dissipates each sample's contribution in range [0, 1]
  139621. */
  139622. decay: number;
  139623. /**
  139624. * Controls the overall intensity of each sample
  139625. */
  139626. weight: number;
  139627. /**
  139628. * Controls the density of each sample
  139629. */
  139630. density: number;
  139631. /**
  139632. * @constructor
  139633. * @param name The post-process name
  139634. * @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)
  139635. * @param camera The camera that the post-process will be attached to
  139636. * @param mesh The mesh used to create the light scattering
  139637. * @param samples The post-process quality, default 100
  139638. * @param samplingModeThe post-process filtering mode
  139639. * @param engine The babylon engine
  139640. * @param reusable If the post-process is reusable
  139641. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139642. */
  139643. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139644. /**
  139645. * Returns the string "VolumetricLightScatteringPostProcess"
  139646. * @returns "VolumetricLightScatteringPostProcess"
  139647. */
  139648. getClassName(): string;
  139649. private _isReady;
  139650. /**
  139651. * Sets the new light position for light scattering effect
  139652. * @param position The new custom light position
  139653. */
  139654. setCustomMeshPosition(position: Vector3): void;
  139655. /**
  139656. * Returns the light position for light scattering effect
  139657. * @return Vector3 The custom light position
  139658. */
  139659. getCustomMeshPosition(): Vector3;
  139660. /**
  139661. * Disposes the internal assets and detaches the post-process from the camera
  139662. */
  139663. dispose(camera: Camera): void;
  139664. /**
  139665. * Returns the render target texture used by the post-process
  139666. * @return the render target texture used by the post-process
  139667. */
  139668. getPass(): RenderTargetTexture;
  139669. private _meshExcluded;
  139670. private _createPass;
  139671. private _updateMeshScreenCoordinates;
  139672. /**
  139673. * Creates a default mesh for the Volumeric Light Scattering post-process
  139674. * @param name The mesh name
  139675. * @param scene The scene where to create the mesh
  139676. * @return the default mesh
  139677. */
  139678. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139679. }
  139680. }
  139681. declare module BABYLON {
  139682. interface Scene {
  139683. /** @hidden (Backing field) */
  139684. _boundingBoxRenderer: BoundingBoxRenderer;
  139685. /** @hidden (Backing field) */
  139686. _forceShowBoundingBoxes: boolean;
  139687. /**
  139688. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139689. */
  139690. forceShowBoundingBoxes: boolean;
  139691. /**
  139692. * Gets the bounding box renderer associated with the scene
  139693. * @returns a BoundingBoxRenderer
  139694. */
  139695. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139696. }
  139697. interface AbstractMesh {
  139698. /** @hidden (Backing field) */
  139699. _showBoundingBox: boolean;
  139700. /**
  139701. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139702. */
  139703. showBoundingBox: boolean;
  139704. }
  139705. /**
  139706. * Component responsible of rendering the bounding box of the meshes in a scene.
  139707. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139708. */
  139709. export class BoundingBoxRenderer implements ISceneComponent {
  139710. /**
  139711. * The component name helpfull to identify the component in the list of scene components.
  139712. */
  139713. readonly name: string;
  139714. /**
  139715. * The scene the component belongs to.
  139716. */
  139717. scene: Scene;
  139718. /**
  139719. * Color of the bounding box lines placed in front of an object
  139720. */
  139721. frontColor: Color3;
  139722. /**
  139723. * Color of the bounding box lines placed behind an object
  139724. */
  139725. backColor: Color3;
  139726. /**
  139727. * Defines if the renderer should show the back lines or not
  139728. */
  139729. showBackLines: boolean;
  139730. /**
  139731. * @hidden
  139732. */
  139733. renderList: SmartArray<BoundingBox>;
  139734. private _colorShader;
  139735. private _vertexBuffers;
  139736. private _indexBuffer;
  139737. private _fillIndexBuffer;
  139738. private _fillIndexData;
  139739. /**
  139740. * Instantiates a new bounding box renderer in a scene.
  139741. * @param scene the scene the renderer renders in
  139742. */
  139743. constructor(scene: Scene);
  139744. /**
  139745. * Registers the component in a given scene
  139746. */
  139747. register(): void;
  139748. private _evaluateSubMesh;
  139749. private _activeMesh;
  139750. private _prepareRessources;
  139751. private _createIndexBuffer;
  139752. /**
  139753. * Rebuilds the elements related to this component in case of
  139754. * context lost for instance.
  139755. */
  139756. rebuild(): void;
  139757. /**
  139758. * @hidden
  139759. */
  139760. reset(): void;
  139761. /**
  139762. * Render the bounding boxes of a specific rendering group
  139763. * @param renderingGroupId defines the rendering group to render
  139764. */
  139765. render(renderingGroupId: number): void;
  139766. /**
  139767. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139768. * @param mesh Define the mesh to render the occlusion bounding box for
  139769. */
  139770. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139771. /**
  139772. * Dispose and release the resources attached to this renderer.
  139773. */
  139774. dispose(): void;
  139775. }
  139776. }
  139777. declare module BABYLON {
  139778. interface Scene {
  139779. /** @hidden (Backing field) */
  139780. _depthRenderer: {
  139781. [id: string]: DepthRenderer;
  139782. };
  139783. /**
  139784. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139785. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139786. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139787. * @returns the created depth renderer
  139788. */
  139789. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139790. /**
  139791. * Disables a depth renderer for a given camera
  139792. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139793. */
  139794. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139795. }
  139796. /**
  139797. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139798. * in several rendering techniques.
  139799. */
  139800. export class DepthRendererSceneComponent implements ISceneComponent {
  139801. /**
  139802. * The component name helpfull to identify the component in the list of scene components.
  139803. */
  139804. readonly name: string;
  139805. /**
  139806. * The scene the component belongs to.
  139807. */
  139808. scene: Scene;
  139809. /**
  139810. * Creates a new instance of the component for the given scene
  139811. * @param scene Defines the scene to register the component in
  139812. */
  139813. constructor(scene: Scene);
  139814. /**
  139815. * Registers the component in a given scene
  139816. */
  139817. register(): void;
  139818. /**
  139819. * Rebuilds the elements related to this component in case of
  139820. * context lost for instance.
  139821. */
  139822. rebuild(): void;
  139823. /**
  139824. * Disposes the component and the associated ressources
  139825. */
  139826. dispose(): void;
  139827. private _gatherRenderTargets;
  139828. private _gatherActiveCameraRenderTargets;
  139829. }
  139830. }
  139831. declare module BABYLON {
  139832. /** @hidden */
  139833. export var outlinePixelShader: {
  139834. name: string;
  139835. shader: string;
  139836. };
  139837. }
  139838. declare module BABYLON {
  139839. /** @hidden */
  139840. export var outlineVertexShader: {
  139841. name: string;
  139842. shader: string;
  139843. };
  139844. }
  139845. declare module BABYLON {
  139846. interface Scene {
  139847. /** @hidden */
  139848. _outlineRenderer: OutlineRenderer;
  139849. /**
  139850. * Gets the outline renderer associated with the scene
  139851. * @returns a OutlineRenderer
  139852. */
  139853. getOutlineRenderer(): OutlineRenderer;
  139854. }
  139855. interface AbstractMesh {
  139856. /** @hidden (Backing field) */
  139857. _renderOutline: boolean;
  139858. /**
  139859. * Gets or sets a boolean indicating if the outline must be rendered as well
  139860. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139861. */
  139862. renderOutline: boolean;
  139863. /** @hidden (Backing field) */
  139864. _renderOverlay: boolean;
  139865. /**
  139866. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139867. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139868. */
  139869. renderOverlay: boolean;
  139870. }
  139871. /**
  139872. * This class is responsible to draw bothe outline/overlay of meshes.
  139873. * It should not be used directly but through the available method on mesh.
  139874. */
  139875. export class OutlineRenderer implements ISceneComponent {
  139876. /**
  139877. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139878. */
  139879. private static _StencilReference;
  139880. /**
  139881. * The name of the component. Each component must have a unique name.
  139882. */
  139883. name: string;
  139884. /**
  139885. * The scene the component belongs to.
  139886. */
  139887. scene: Scene;
  139888. /**
  139889. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139890. */
  139891. zOffset: number;
  139892. private _engine;
  139893. private _effect;
  139894. private _cachedDefines;
  139895. private _savedDepthWrite;
  139896. /**
  139897. * Instantiates a new outline renderer. (There could be only one per scene).
  139898. * @param scene Defines the scene it belongs to
  139899. */
  139900. constructor(scene: Scene);
  139901. /**
  139902. * Register the component to one instance of a scene.
  139903. */
  139904. register(): void;
  139905. /**
  139906. * Rebuilds the elements related to this component in case of
  139907. * context lost for instance.
  139908. */
  139909. rebuild(): void;
  139910. /**
  139911. * Disposes the component and the associated ressources.
  139912. */
  139913. dispose(): void;
  139914. /**
  139915. * Renders the outline in the canvas.
  139916. * @param subMesh Defines the sumesh to render
  139917. * @param batch Defines the batch of meshes in case of instances
  139918. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139919. */
  139920. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139921. /**
  139922. * Returns whether or not the outline renderer is ready for a given submesh.
  139923. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139924. * @param subMesh Defines the submesh to check readyness for
  139925. * @param useInstances Defines wheter wee are trying to render instances or not
  139926. * @returns true if ready otherwise false
  139927. */
  139928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139929. private _beforeRenderingMesh;
  139930. private _afterRenderingMesh;
  139931. }
  139932. }
  139933. declare module BABYLON {
  139934. /**
  139935. * Defines the basic options interface of a Sprite Frame Source Size.
  139936. */
  139937. export interface ISpriteJSONSpriteSourceSize {
  139938. /**
  139939. * number of the original width of the Frame
  139940. */
  139941. w: number;
  139942. /**
  139943. * number of the original height of the Frame
  139944. */
  139945. h: number;
  139946. }
  139947. /**
  139948. * Defines the basic options interface of a Sprite Frame Data.
  139949. */
  139950. export interface ISpriteJSONSpriteFrameData {
  139951. /**
  139952. * number of the x offset of the Frame
  139953. */
  139954. x: number;
  139955. /**
  139956. * number of the y offset of the Frame
  139957. */
  139958. y: number;
  139959. /**
  139960. * number of the width of the Frame
  139961. */
  139962. w: number;
  139963. /**
  139964. * number of the height of the Frame
  139965. */
  139966. h: number;
  139967. }
  139968. /**
  139969. * Defines the basic options interface of a JSON Sprite.
  139970. */
  139971. export interface ISpriteJSONSprite {
  139972. /**
  139973. * string name of the Frame
  139974. */
  139975. filename: string;
  139976. /**
  139977. * ISpriteJSONSpriteFrame basic object of the frame data
  139978. */
  139979. frame: ISpriteJSONSpriteFrameData;
  139980. /**
  139981. * boolean to flag is the frame was rotated.
  139982. */
  139983. rotated: boolean;
  139984. /**
  139985. * boolean to flag is the frame was trimmed.
  139986. */
  139987. trimmed: boolean;
  139988. /**
  139989. * ISpriteJSONSpriteFrame basic object of the source data
  139990. */
  139991. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139992. /**
  139993. * ISpriteJSONSpriteFrame basic object of the source data
  139994. */
  139995. sourceSize: ISpriteJSONSpriteSourceSize;
  139996. }
  139997. /**
  139998. * Defines the basic options interface of a JSON atlas.
  139999. */
  140000. export interface ISpriteJSONAtlas {
  140001. /**
  140002. * Array of objects that contain the frame data.
  140003. */
  140004. frames: Array<ISpriteJSONSprite>;
  140005. /**
  140006. * object basic object containing the sprite meta data.
  140007. */
  140008. meta?: object;
  140009. }
  140010. }
  140011. declare module BABYLON {
  140012. /** @hidden */
  140013. export var spriteMapPixelShader: {
  140014. name: string;
  140015. shader: string;
  140016. };
  140017. }
  140018. declare module BABYLON {
  140019. /** @hidden */
  140020. export var spriteMapVertexShader: {
  140021. name: string;
  140022. shader: string;
  140023. };
  140024. }
  140025. declare module BABYLON {
  140026. /**
  140027. * Defines the basic options interface of a SpriteMap
  140028. */
  140029. export interface ISpriteMapOptions {
  140030. /**
  140031. * Vector2 of the number of cells in the grid.
  140032. */
  140033. stageSize?: Vector2;
  140034. /**
  140035. * Vector2 of the size of the output plane in World Units.
  140036. */
  140037. outputSize?: Vector2;
  140038. /**
  140039. * Vector3 of the position of the output plane in World Units.
  140040. */
  140041. outputPosition?: Vector3;
  140042. /**
  140043. * Vector3 of the rotation of the output plane.
  140044. */
  140045. outputRotation?: Vector3;
  140046. /**
  140047. * number of layers that the system will reserve in resources.
  140048. */
  140049. layerCount?: number;
  140050. /**
  140051. * number of max animation frames a single cell will reserve in resources.
  140052. */
  140053. maxAnimationFrames?: number;
  140054. /**
  140055. * number cell index of the base tile when the system compiles.
  140056. */
  140057. baseTile?: number;
  140058. /**
  140059. * boolean flip the sprite after its been repositioned by the framing data.
  140060. */
  140061. flipU?: boolean;
  140062. /**
  140063. * Vector3 scalar of the global RGB values of the SpriteMap.
  140064. */
  140065. colorMultiply?: Vector3;
  140066. }
  140067. /**
  140068. * Defines the IDisposable interface in order to be cleanable from resources.
  140069. */
  140070. export interface ISpriteMap extends IDisposable {
  140071. /**
  140072. * String name of the SpriteMap.
  140073. */
  140074. name: string;
  140075. /**
  140076. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140077. */
  140078. atlasJSON: ISpriteJSONAtlas;
  140079. /**
  140080. * Texture of the SpriteMap.
  140081. */
  140082. spriteSheet: Texture;
  140083. /**
  140084. * The parameters to initialize the SpriteMap with.
  140085. */
  140086. options: ISpriteMapOptions;
  140087. }
  140088. /**
  140089. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140090. */
  140091. export class SpriteMap implements ISpriteMap {
  140092. /** The Name of the spriteMap */
  140093. name: string;
  140094. /** The JSON file with the frame and meta data */
  140095. atlasJSON: ISpriteJSONAtlas;
  140096. /** The systems Sprite Sheet Texture */
  140097. spriteSheet: Texture;
  140098. /** Arguments passed with the Constructor */
  140099. options: ISpriteMapOptions;
  140100. /** Public Sprite Storage array, parsed from atlasJSON */
  140101. sprites: Array<ISpriteJSONSprite>;
  140102. /** Returns the Number of Sprites in the System */
  140103. get spriteCount(): number;
  140104. /** Returns the Position of Output Plane*/
  140105. get position(): Vector3;
  140106. /** Returns the Position of Output Plane*/
  140107. set position(v: Vector3);
  140108. /** Returns the Rotation of Output Plane*/
  140109. get rotation(): Vector3;
  140110. /** Returns the Rotation of Output Plane*/
  140111. set rotation(v: Vector3);
  140112. /** Sets the AnimationMap*/
  140113. get animationMap(): RawTexture;
  140114. /** Sets the AnimationMap*/
  140115. set animationMap(v: RawTexture);
  140116. /** Scene that the SpriteMap was created in */
  140117. private _scene;
  140118. /** Texture Buffer of Float32 that holds tile frame data*/
  140119. private _frameMap;
  140120. /** Texture Buffers of Float32 that holds tileMap data*/
  140121. private _tileMaps;
  140122. /** Texture Buffer of Float32 that holds Animation Data*/
  140123. private _animationMap;
  140124. /** Custom ShaderMaterial Central to the System*/
  140125. private _material;
  140126. /** Custom ShaderMaterial Central to the System*/
  140127. private _output;
  140128. /** Systems Time Ticker*/
  140129. private _time;
  140130. /**
  140131. * Creates a new SpriteMap
  140132. * @param name defines the SpriteMaps Name
  140133. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140134. * @param spriteSheet is the Texture that the Sprites are on.
  140135. * @param options a basic deployment configuration
  140136. * @param scene The Scene that the map is deployed on
  140137. */
  140138. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140139. /**
  140140. * Returns tileID location
  140141. * @returns Vector2 the cell position ID
  140142. */
  140143. getTileID(): Vector2;
  140144. /**
  140145. * Gets the UV location of the mouse over the SpriteMap.
  140146. * @returns Vector2 the UV position of the mouse interaction
  140147. */
  140148. getMousePosition(): Vector2;
  140149. /**
  140150. * Creates the "frame" texture Buffer
  140151. * -------------------------------------
  140152. * Structure of frames
  140153. * "filename": "Falling-Water-2.png",
  140154. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140155. * "rotated": true,
  140156. * "trimmed": true,
  140157. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140158. * "sourceSize": {"w":32,"h":32}
  140159. * @returns RawTexture of the frameMap
  140160. */
  140161. private _createFrameBuffer;
  140162. /**
  140163. * Creates the tileMap texture Buffer
  140164. * @param buffer normally and array of numbers, or a false to generate from scratch
  140165. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140166. * @returns RawTexture of the tileMap
  140167. */
  140168. private _createTileBuffer;
  140169. /**
  140170. * Modifies the data of the tileMaps
  140171. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140172. * @param pos is the iVector2 Coordinates of the Tile
  140173. * @param tile The SpriteIndex of the new Tile
  140174. */
  140175. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140176. /**
  140177. * Creates the animationMap texture Buffer
  140178. * @param buffer normally and array of numbers, or a false to generate from scratch
  140179. * @returns RawTexture of the animationMap
  140180. */
  140181. private _createTileAnimationBuffer;
  140182. /**
  140183. * Modifies the data of the animationMap
  140184. * @param cellID is the Index of the Sprite
  140185. * @param _frame is the target Animation frame
  140186. * @param toCell is the Target Index of the next frame of the animation
  140187. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140188. * @param speed is a global scalar of the time variable on the map.
  140189. */
  140190. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140191. /**
  140192. * Exports the .tilemaps file
  140193. */
  140194. saveTileMaps(): void;
  140195. /**
  140196. * Imports the .tilemaps file
  140197. * @param url of the .tilemaps file
  140198. */
  140199. loadTileMaps(url: string): void;
  140200. /**
  140201. * Release associated resources
  140202. */
  140203. dispose(): void;
  140204. }
  140205. }
  140206. declare module BABYLON {
  140207. /**
  140208. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140209. * @see http://doc.babylonjs.com/babylon101/sprites
  140210. */
  140211. export class SpritePackedManager extends SpriteManager {
  140212. /** defines the packed manager's name */
  140213. name: string;
  140214. /**
  140215. * Creates a new sprite manager from a packed sprite sheet
  140216. * @param name defines the manager's name
  140217. * @param imgUrl defines the sprite sheet url
  140218. * @param capacity defines the maximum allowed number of sprites
  140219. * @param scene defines the hosting scene
  140220. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140221. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140222. * @param samplingMode defines the smapling mode to use with spritesheet
  140223. * @param fromPacked set to true; do not alter
  140224. */
  140225. constructor(
  140226. /** defines the packed manager's name */
  140227. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140228. }
  140229. }
  140230. declare module BABYLON {
  140231. /**
  140232. * Defines the list of states available for a task inside a AssetsManager
  140233. */
  140234. export enum AssetTaskState {
  140235. /**
  140236. * Initialization
  140237. */
  140238. INIT = 0,
  140239. /**
  140240. * Running
  140241. */
  140242. RUNNING = 1,
  140243. /**
  140244. * Done
  140245. */
  140246. DONE = 2,
  140247. /**
  140248. * Error
  140249. */
  140250. ERROR = 3
  140251. }
  140252. /**
  140253. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140254. */
  140255. export abstract class AbstractAssetTask {
  140256. /**
  140257. * Task name
  140258. */ name: string;
  140259. /**
  140260. * Callback called when the task is successful
  140261. */
  140262. onSuccess: (task: any) => void;
  140263. /**
  140264. * Callback called when the task is not successful
  140265. */
  140266. onError: (task: any, message?: string, exception?: any) => void;
  140267. /**
  140268. * Creates a new AssetsManager
  140269. * @param name defines the name of the task
  140270. */
  140271. constructor(
  140272. /**
  140273. * Task name
  140274. */ name: string);
  140275. private _isCompleted;
  140276. private _taskState;
  140277. private _errorObject;
  140278. /**
  140279. * Get if the task is completed
  140280. */
  140281. get isCompleted(): boolean;
  140282. /**
  140283. * Gets the current state of the task
  140284. */
  140285. get taskState(): AssetTaskState;
  140286. /**
  140287. * Gets the current error object (if task is in error)
  140288. */
  140289. get errorObject(): {
  140290. message?: string;
  140291. exception?: any;
  140292. };
  140293. /**
  140294. * Internal only
  140295. * @hidden
  140296. */
  140297. _setErrorObject(message?: string, exception?: any): void;
  140298. /**
  140299. * Execute the current task
  140300. * @param scene defines the scene where you want your assets to be loaded
  140301. * @param onSuccess is a callback called when the task is successfully executed
  140302. * @param onError is a callback called if an error occurs
  140303. */
  140304. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140305. /**
  140306. * Execute the current task
  140307. * @param scene defines the scene where you want your assets to be loaded
  140308. * @param onSuccess is a callback called when the task is successfully executed
  140309. * @param onError is a callback called if an error occurs
  140310. */
  140311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140312. /**
  140313. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140314. * This can be used with failed tasks that have the reason for failure fixed.
  140315. */
  140316. reset(): void;
  140317. private onErrorCallback;
  140318. private onDoneCallback;
  140319. }
  140320. /**
  140321. * Define the interface used by progress events raised during assets loading
  140322. */
  140323. export interface IAssetsProgressEvent {
  140324. /**
  140325. * Defines the number of remaining tasks to process
  140326. */
  140327. remainingCount: number;
  140328. /**
  140329. * Defines the total number of tasks
  140330. */
  140331. totalCount: number;
  140332. /**
  140333. * Defines the task that was just processed
  140334. */
  140335. task: AbstractAssetTask;
  140336. }
  140337. /**
  140338. * Class used to share progress information about assets loading
  140339. */
  140340. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140341. /**
  140342. * Defines the number of remaining tasks to process
  140343. */
  140344. remainingCount: number;
  140345. /**
  140346. * Defines the total number of tasks
  140347. */
  140348. totalCount: number;
  140349. /**
  140350. * Defines the task that was just processed
  140351. */
  140352. task: AbstractAssetTask;
  140353. /**
  140354. * Creates a AssetsProgressEvent
  140355. * @param remainingCount defines the number of remaining tasks to process
  140356. * @param totalCount defines the total number of tasks
  140357. * @param task defines the task that was just processed
  140358. */
  140359. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140360. }
  140361. /**
  140362. * Define a task used by AssetsManager to load meshes
  140363. */
  140364. export class MeshAssetTask extends AbstractAssetTask {
  140365. /**
  140366. * Defines the name of the task
  140367. */
  140368. name: string;
  140369. /**
  140370. * Defines the list of mesh's names you want to load
  140371. */
  140372. meshesNames: any;
  140373. /**
  140374. * Defines the root url to use as a base to load your meshes and associated resources
  140375. */
  140376. rootUrl: string;
  140377. /**
  140378. * Defines the filename of the scene to load from
  140379. */
  140380. sceneFilename: string;
  140381. /**
  140382. * Gets the list of loaded meshes
  140383. */
  140384. loadedMeshes: Array<AbstractMesh>;
  140385. /**
  140386. * Gets the list of loaded particle systems
  140387. */
  140388. loadedParticleSystems: Array<IParticleSystem>;
  140389. /**
  140390. * Gets the list of loaded skeletons
  140391. */
  140392. loadedSkeletons: Array<Skeleton>;
  140393. /**
  140394. * Gets the list of loaded animation groups
  140395. */
  140396. loadedAnimationGroups: Array<AnimationGroup>;
  140397. /**
  140398. * Callback called when the task is successful
  140399. */
  140400. onSuccess: (task: MeshAssetTask) => void;
  140401. /**
  140402. * Callback called when the task is successful
  140403. */
  140404. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140405. /**
  140406. * Creates a new MeshAssetTask
  140407. * @param name defines the name of the task
  140408. * @param meshesNames defines the list of mesh's names you want to load
  140409. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140410. * @param sceneFilename defines the filename of the scene to load from
  140411. */
  140412. constructor(
  140413. /**
  140414. * Defines the name of the task
  140415. */
  140416. name: string,
  140417. /**
  140418. * Defines the list of mesh's names you want to load
  140419. */
  140420. meshesNames: any,
  140421. /**
  140422. * Defines the root url to use as a base to load your meshes and associated resources
  140423. */
  140424. rootUrl: string,
  140425. /**
  140426. * Defines the filename of the scene to load from
  140427. */
  140428. sceneFilename: string);
  140429. /**
  140430. * Execute the current task
  140431. * @param scene defines the scene where you want your assets to be loaded
  140432. * @param onSuccess is a callback called when the task is successfully executed
  140433. * @param onError is a callback called if an error occurs
  140434. */
  140435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140436. }
  140437. /**
  140438. * Define a task used by AssetsManager to load text content
  140439. */
  140440. export class TextFileAssetTask extends AbstractAssetTask {
  140441. /**
  140442. * Defines the name of the task
  140443. */
  140444. name: string;
  140445. /**
  140446. * Defines the location of the file to load
  140447. */
  140448. url: string;
  140449. /**
  140450. * Gets the loaded text string
  140451. */
  140452. text: string;
  140453. /**
  140454. * Callback called when the task is successful
  140455. */
  140456. onSuccess: (task: TextFileAssetTask) => void;
  140457. /**
  140458. * Callback called when the task is successful
  140459. */
  140460. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140461. /**
  140462. * Creates a new TextFileAssetTask object
  140463. * @param name defines the name of the task
  140464. * @param url defines the location of the file to load
  140465. */
  140466. constructor(
  140467. /**
  140468. * Defines the name of the task
  140469. */
  140470. name: string,
  140471. /**
  140472. * Defines the location of the file to load
  140473. */
  140474. url: string);
  140475. /**
  140476. * Execute the current task
  140477. * @param scene defines the scene where you want your assets to be loaded
  140478. * @param onSuccess is a callback called when the task is successfully executed
  140479. * @param onError is a callback called if an error occurs
  140480. */
  140481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140482. }
  140483. /**
  140484. * Define a task used by AssetsManager to load binary data
  140485. */
  140486. export class BinaryFileAssetTask extends AbstractAssetTask {
  140487. /**
  140488. * Defines the name of the task
  140489. */
  140490. name: string;
  140491. /**
  140492. * Defines the location of the file to load
  140493. */
  140494. url: string;
  140495. /**
  140496. * Gets the lodaded data (as an array buffer)
  140497. */
  140498. data: ArrayBuffer;
  140499. /**
  140500. * Callback called when the task is successful
  140501. */
  140502. onSuccess: (task: BinaryFileAssetTask) => void;
  140503. /**
  140504. * Callback called when the task is successful
  140505. */
  140506. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140507. /**
  140508. * Creates a new BinaryFileAssetTask object
  140509. * @param name defines the name of the new task
  140510. * @param url defines the location of the file to load
  140511. */
  140512. constructor(
  140513. /**
  140514. * Defines the name of the task
  140515. */
  140516. name: string,
  140517. /**
  140518. * Defines the location of the file to load
  140519. */
  140520. url: string);
  140521. /**
  140522. * Execute the current task
  140523. * @param scene defines the scene where you want your assets to be loaded
  140524. * @param onSuccess is a callback called when the task is successfully executed
  140525. * @param onError is a callback called if an error occurs
  140526. */
  140527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140528. }
  140529. /**
  140530. * Define a task used by AssetsManager to load images
  140531. */
  140532. export class ImageAssetTask extends AbstractAssetTask {
  140533. /**
  140534. * Defines the name of the task
  140535. */
  140536. name: string;
  140537. /**
  140538. * Defines the location of the image to load
  140539. */
  140540. url: string;
  140541. /**
  140542. * Gets the loaded images
  140543. */
  140544. image: HTMLImageElement;
  140545. /**
  140546. * Callback called when the task is successful
  140547. */
  140548. onSuccess: (task: ImageAssetTask) => void;
  140549. /**
  140550. * Callback called when the task is successful
  140551. */
  140552. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140553. /**
  140554. * Creates a new ImageAssetTask
  140555. * @param name defines the name of the task
  140556. * @param url defines the location of the image to load
  140557. */
  140558. constructor(
  140559. /**
  140560. * Defines the name of the task
  140561. */
  140562. name: string,
  140563. /**
  140564. * Defines the location of the image to load
  140565. */
  140566. url: string);
  140567. /**
  140568. * Execute the current task
  140569. * @param scene defines the scene where you want your assets to be loaded
  140570. * @param onSuccess is a callback called when the task is successfully executed
  140571. * @param onError is a callback called if an error occurs
  140572. */
  140573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140574. }
  140575. /**
  140576. * Defines the interface used by texture loading tasks
  140577. */
  140578. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140579. /**
  140580. * Gets the loaded texture
  140581. */
  140582. texture: TEX;
  140583. }
  140584. /**
  140585. * Define a task used by AssetsManager to load 2D textures
  140586. */
  140587. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140588. /**
  140589. * Defines the name of the task
  140590. */
  140591. name: string;
  140592. /**
  140593. * Defines the location of the file to load
  140594. */
  140595. url: string;
  140596. /**
  140597. * Defines if mipmap should not be generated (default is false)
  140598. */
  140599. noMipmap?: boolean | undefined;
  140600. /**
  140601. * Defines if texture must be inverted on Y axis (default is false)
  140602. */
  140603. invertY?: boolean | undefined;
  140604. /**
  140605. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140606. */
  140607. samplingMode: number;
  140608. /**
  140609. * Gets the loaded texture
  140610. */
  140611. texture: Texture;
  140612. /**
  140613. * Callback called when the task is successful
  140614. */
  140615. onSuccess: (task: TextureAssetTask) => void;
  140616. /**
  140617. * Callback called when the task is successful
  140618. */
  140619. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140620. /**
  140621. * Creates a new TextureAssetTask object
  140622. * @param name defines the name of the task
  140623. * @param url defines the location of the file to load
  140624. * @param noMipmap defines if mipmap should not be generated (default is false)
  140625. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140626. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140627. */
  140628. constructor(
  140629. /**
  140630. * Defines the name of the task
  140631. */
  140632. name: string,
  140633. /**
  140634. * Defines the location of the file to load
  140635. */
  140636. url: string,
  140637. /**
  140638. * Defines if mipmap should not be generated (default is false)
  140639. */
  140640. noMipmap?: boolean | undefined,
  140641. /**
  140642. * Defines if texture must be inverted on Y axis (default is false)
  140643. */
  140644. invertY?: boolean | undefined,
  140645. /**
  140646. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140647. */
  140648. samplingMode?: number);
  140649. /**
  140650. * Execute the current task
  140651. * @param scene defines the scene where you want your assets to be loaded
  140652. * @param onSuccess is a callback called when the task is successfully executed
  140653. * @param onError is a callback called if an error occurs
  140654. */
  140655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140656. }
  140657. /**
  140658. * Define a task used by AssetsManager to load cube textures
  140659. */
  140660. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140661. /**
  140662. * Defines the name of the task
  140663. */
  140664. name: string;
  140665. /**
  140666. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140667. */
  140668. url: string;
  140669. /**
  140670. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140671. */
  140672. extensions?: string[] | undefined;
  140673. /**
  140674. * Defines if mipmaps should not be generated (default is false)
  140675. */
  140676. noMipmap?: boolean | undefined;
  140677. /**
  140678. * Defines the explicit list of files (undefined by default)
  140679. */
  140680. files?: string[] | undefined;
  140681. /**
  140682. * Gets the loaded texture
  140683. */
  140684. texture: CubeTexture;
  140685. /**
  140686. * Callback called when the task is successful
  140687. */
  140688. onSuccess: (task: CubeTextureAssetTask) => void;
  140689. /**
  140690. * Callback called when the task is successful
  140691. */
  140692. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140693. /**
  140694. * Creates a new CubeTextureAssetTask
  140695. * @param name defines the name of the task
  140696. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140697. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140698. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140699. * @param files defines the explicit list of files (undefined by default)
  140700. */
  140701. constructor(
  140702. /**
  140703. * Defines the name of the task
  140704. */
  140705. name: string,
  140706. /**
  140707. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140708. */
  140709. url: string,
  140710. /**
  140711. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140712. */
  140713. extensions?: string[] | undefined,
  140714. /**
  140715. * Defines if mipmaps should not be generated (default is false)
  140716. */
  140717. noMipmap?: boolean | undefined,
  140718. /**
  140719. * Defines the explicit list of files (undefined by default)
  140720. */
  140721. files?: string[] | undefined);
  140722. /**
  140723. * Execute the current task
  140724. * @param scene defines the scene where you want your assets to be loaded
  140725. * @param onSuccess is a callback called when the task is successfully executed
  140726. * @param onError is a callback called if an error occurs
  140727. */
  140728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140729. }
  140730. /**
  140731. * Define a task used by AssetsManager to load HDR cube textures
  140732. */
  140733. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140734. /**
  140735. * Defines the name of the task
  140736. */
  140737. name: string;
  140738. /**
  140739. * Defines the location of the file to load
  140740. */
  140741. url: string;
  140742. /**
  140743. * Defines the desired size (the more it increases the longer the generation will be)
  140744. */
  140745. size: number;
  140746. /**
  140747. * Defines if mipmaps should not be generated (default is false)
  140748. */
  140749. noMipmap: boolean;
  140750. /**
  140751. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140752. */
  140753. generateHarmonics: boolean;
  140754. /**
  140755. * 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)
  140756. */
  140757. gammaSpace: boolean;
  140758. /**
  140759. * Internal Use Only
  140760. */
  140761. reserved: boolean;
  140762. /**
  140763. * Gets the loaded texture
  140764. */
  140765. texture: HDRCubeTexture;
  140766. /**
  140767. * Callback called when the task is successful
  140768. */
  140769. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140770. /**
  140771. * Callback called when the task is successful
  140772. */
  140773. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140774. /**
  140775. * Creates a new HDRCubeTextureAssetTask object
  140776. * @param name defines the name of the task
  140777. * @param url defines the location of the file to load
  140778. * @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.
  140779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140780. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140781. * @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)
  140782. * @param reserved Internal use only
  140783. */
  140784. constructor(
  140785. /**
  140786. * Defines the name of the task
  140787. */
  140788. name: string,
  140789. /**
  140790. * Defines the location of the file to load
  140791. */
  140792. url: string,
  140793. /**
  140794. * Defines the desired size (the more it increases the longer the generation will be)
  140795. */
  140796. size: number,
  140797. /**
  140798. * Defines if mipmaps should not be generated (default is false)
  140799. */
  140800. noMipmap?: boolean,
  140801. /**
  140802. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140803. */
  140804. generateHarmonics?: boolean,
  140805. /**
  140806. * 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)
  140807. */
  140808. gammaSpace?: boolean,
  140809. /**
  140810. * Internal Use Only
  140811. */
  140812. reserved?: boolean);
  140813. /**
  140814. * Execute the current task
  140815. * @param scene defines the scene where you want your assets to be loaded
  140816. * @param onSuccess is a callback called when the task is successfully executed
  140817. * @param onError is a callback called if an error occurs
  140818. */
  140819. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140820. }
  140821. /**
  140822. * Define a task used by AssetsManager to load Equirectangular cube textures
  140823. */
  140824. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140825. /**
  140826. * Defines the name of the task
  140827. */
  140828. name: string;
  140829. /**
  140830. * Defines the location of the file to load
  140831. */
  140832. url: string;
  140833. /**
  140834. * Defines the desired size (the more it increases the longer the generation will be)
  140835. */
  140836. size: number;
  140837. /**
  140838. * Defines if mipmaps should not be generated (default is false)
  140839. */
  140840. noMipmap: boolean;
  140841. /**
  140842. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140843. * but the standard material would require them in Gamma space) (default is true)
  140844. */
  140845. gammaSpace: boolean;
  140846. /**
  140847. * Gets the loaded texture
  140848. */
  140849. texture: EquiRectangularCubeTexture;
  140850. /**
  140851. * Callback called when the task is successful
  140852. */
  140853. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140854. /**
  140855. * Callback called when the task is successful
  140856. */
  140857. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140858. /**
  140859. * Creates a new EquiRectangularCubeTextureAssetTask object
  140860. * @param name defines the name of the task
  140861. * @param url defines the location of the file to load
  140862. * @param size defines the desired size (the more it increases the longer the generation will be)
  140863. * If the size is omitted this implies you are using a preprocessed cubemap.
  140864. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140865. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140866. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140867. * (default is true)
  140868. */
  140869. constructor(
  140870. /**
  140871. * Defines the name of the task
  140872. */
  140873. name: string,
  140874. /**
  140875. * Defines the location of the file to load
  140876. */
  140877. url: string,
  140878. /**
  140879. * Defines the desired size (the more it increases the longer the generation will be)
  140880. */
  140881. size: number,
  140882. /**
  140883. * Defines if mipmaps should not be generated (default is false)
  140884. */
  140885. noMipmap?: boolean,
  140886. /**
  140887. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140888. * but the standard material would require them in Gamma space) (default is true)
  140889. */
  140890. gammaSpace?: boolean);
  140891. /**
  140892. * Execute the current task
  140893. * @param scene defines the scene where you want your assets to be loaded
  140894. * @param onSuccess is a callback called when the task is successfully executed
  140895. * @param onError is a callback called if an error occurs
  140896. */
  140897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140898. }
  140899. /**
  140900. * This class can be used to easily import assets into a scene
  140901. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140902. */
  140903. export class AssetsManager {
  140904. private _scene;
  140905. private _isLoading;
  140906. protected _tasks: AbstractAssetTask[];
  140907. protected _waitingTasksCount: number;
  140908. protected _totalTasksCount: number;
  140909. /**
  140910. * Callback called when all tasks are processed
  140911. */
  140912. onFinish: (tasks: AbstractAssetTask[]) => void;
  140913. /**
  140914. * Callback called when a task is successful
  140915. */
  140916. onTaskSuccess: (task: AbstractAssetTask) => void;
  140917. /**
  140918. * Callback called when a task had an error
  140919. */
  140920. onTaskError: (task: AbstractAssetTask) => void;
  140921. /**
  140922. * Callback called when a task is done (whatever the result is)
  140923. */
  140924. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140925. /**
  140926. * Observable called when all tasks are processed
  140927. */
  140928. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140929. /**
  140930. * Observable called when a task had an error
  140931. */
  140932. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140933. /**
  140934. * Observable called when all tasks were executed
  140935. */
  140936. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140937. /**
  140938. * Observable called when a task is done (whatever the result is)
  140939. */
  140940. onProgressObservable: Observable<IAssetsProgressEvent>;
  140941. /**
  140942. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140943. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140944. */
  140945. useDefaultLoadingScreen: boolean;
  140946. /**
  140947. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140948. * when all assets have been downloaded.
  140949. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140950. */
  140951. autoHideLoadingUI: boolean;
  140952. /**
  140953. * Creates a new AssetsManager
  140954. * @param scene defines the scene to work on
  140955. */
  140956. constructor(scene: Scene);
  140957. /**
  140958. * Add a MeshAssetTask to the list of active tasks
  140959. * @param taskName defines the name of the new task
  140960. * @param meshesNames defines the name of meshes to load
  140961. * @param rootUrl defines the root url to use to locate files
  140962. * @param sceneFilename defines the filename of the scene file
  140963. * @returns a new MeshAssetTask object
  140964. */
  140965. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140966. /**
  140967. * Add a TextFileAssetTask to the list of active tasks
  140968. * @param taskName defines the name of the new task
  140969. * @param url defines the url of the file to load
  140970. * @returns a new TextFileAssetTask object
  140971. */
  140972. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140973. /**
  140974. * Add a BinaryFileAssetTask to the list of active tasks
  140975. * @param taskName defines the name of the new task
  140976. * @param url defines the url of the file to load
  140977. * @returns a new BinaryFileAssetTask object
  140978. */
  140979. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140980. /**
  140981. * Add a ImageAssetTask to the list of active tasks
  140982. * @param taskName defines the name of the new task
  140983. * @param url defines the url of the file to load
  140984. * @returns a new ImageAssetTask object
  140985. */
  140986. addImageTask(taskName: string, url: string): ImageAssetTask;
  140987. /**
  140988. * Add a TextureAssetTask to the list of active tasks
  140989. * @param taskName defines the name of the new task
  140990. * @param url defines the url of the file to load
  140991. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140992. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140993. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140994. * @returns a new TextureAssetTask object
  140995. */
  140996. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140997. /**
  140998. * Add a CubeTextureAssetTask to the list of active tasks
  140999. * @param taskName defines the name of the new task
  141000. * @param url defines the url of the file to load
  141001. * @param extensions defines the extension to use to load the cube map (can be null)
  141002. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141003. * @param files defines the list of files to load (can be null)
  141004. * @returns a new CubeTextureAssetTask object
  141005. */
  141006. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141007. /**
  141008. *
  141009. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141010. * @param taskName defines the name of the new task
  141011. * @param url defines the url of the file to load
  141012. * @param size defines the size you want for the cubemap (can be null)
  141013. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141014. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141015. * @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)
  141016. * @param reserved Internal use only
  141017. * @returns a new HDRCubeTextureAssetTask object
  141018. */
  141019. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141020. /**
  141021. *
  141022. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141023. * @param taskName defines the name of the new task
  141024. * @param url defines the url of the file to load
  141025. * @param size defines the size you want for the cubemap (can be null)
  141026. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141027. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141028. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141029. * @returns a new EquiRectangularCubeTextureAssetTask object
  141030. */
  141031. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141032. /**
  141033. * Remove a task from the assets manager.
  141034. * @param task the task to remove
  141035. */
  141036. removeTask(task: AbstractAssetTask): void;
  141037. private _decreaseWaitingTasksCount;
  141038. private _runTask;
  141039. /**
  141040. * Reset the AssetsManager and remove all tasks
  141041. * @return the current instance of the AssetsManager
  141042. */
  141043. reset(): AssetsManager;
  141044. /**
  141045. * Start the loading process
  141046. * @return the current instance of the AssetsManager
  141047. */
  141048. load(): AssetsManager;
  141049. /**
  141050. * Start the loading process as an async operation
  141051. * @return a promise returning the list of failed tasks
  141052. */
  141053. loadAsync(): Promise<void>;
  141054. }
  141055. }
  141056. declare module BABYLON {
  141057. /**
  141058. * Wrapper class for promise with external resolve and reject.
  141059. */
  141060. export class Deferred<T> {
  141061. /**
  141062. * The promise associated with this deferred object.
  141063. */
  141064. readonly promise: Promise<T>;
  141065. private _resolve;
  141066. private _reject;
  141067. /**
  141068. * The resolve method of the promise associated with this deferred object.
  141069. */
  141070. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141071. /**
  141072. * The reject method of the promise associated with this deferred object.
  141073. */
  141074. get reject(): (reason?: any) => void;
  141075. /**
  141076. * Constructor for this deferred object.
  141077. */
  141078. constructor();
  141079. }
  141080. }
  141081. declare module BABYLON {
  141082. /**
  141083. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141084. */
  141085. export class MeshExploder {
  141086. private _centerMesh;
  141087. private _meshes;
  141088. private _meshesOrigins;
  141089. private _toCenterVectors;
  141090. private _scaledDirection;
  141091. private _newPosition;
  141092. private _centerPosition;
  141093. /**
  141094. * Explodes meshes from a center mesh.
  141095. * @param meshes The meshes to explode.
  141096. * @param centerMesh The mesh to be center of explosion.
  141097. */
  141098. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141099. private _setCenterMesh;
  141100. /**
  141101. * Get class name
  141102. * @returns "MeshExploder"
  141103. */
  141104. getClassName(): string;
  141105. /**
  141106. * "Exploded meshes"
  141107. * @returns Array of meshes with the centerMesh at index 0.
  141108. */
  141109. getMeshes(): Array<Mesh>;
  141110. /**
  141111. * Explodes meshes giving a specific direction
  141112. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141113. */
  141114. explode(direction?: number): void;
  141115. }
  141116. }
  141117. declare module BABYLON {
  141118. /**
  141119. * Class used to help managing file picking and drag'n'drop
  141120. */
  141121. export class FilesInput {
  141122. /**
  141123. * List of files ready to be loaded
  141124. */
  141125. static get FilesToLoad(): {
  141126. [key: string]: File;
  141127. };
  141128. /**
  141129. * Callback called when a file is processed
  141130. */
  141131. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141132. private _engine;
  141133. private _currentScene;
  141134. private _sceneLoadedCallback;
  141135. private _progressCallback;
  141136. private _additionalRenderLoopLogicCallback;
  141137. private _textureLoadingCallback;
  141138. private _startingProcessingFilesCallback;
  141139. private _onReloadCallback;
  141140. private _errorCallback;
  141141. private _elementToMonitor;
  141142. private _sceneFileToLoad;
  141143. private _filesToLoad;
  141144. /**
  141145. * Creates a new FilesInput
  141146. * @param engine defines the rendering engine
  141147. * @param scene defines the hosting scene
  141148. * @param sceneLoadedCallback callback called when scene is loaded
  141149. * @param progressCallback callback called to track progress
  141150. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141151. * @param textureLoadingCallback callback called when a texture is loading
  141152. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141153. * @param onReloadCallback callback called when a reload is requested
  141154. * @param errorCallback callback call if an error occurs
  141155. */
  141156. 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);
  141157. private _dragEnterHandler;
  141158. private _dragOverHandler;
  141159. private _dropHandler;
  141160. /**
  141161. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141162. * @param elementToMonitor defines the DOM element to track
  141163. */
  141164. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141165. /**
  141166. * Release all associated resources
  141167. */
  141168. dispose(): void;
  141169. private renderFunction;
  141170. private drag;
  141171. private drop;
  141172. private _traverseFolder;
  141173. private _processFiles;
  141174. /**
  141175. * Load files from a drop event
  141176. * @param event defines the drop event to use as source
  141177. */
  141178. loadFiles(event: any): void;
  141179. private _processReload;
  141180. /**
  141181. * Reload the current scene from the loaded files
  141182. */
  141183. reload(): void;
  141184. }
  141185. }
  141186. declare module BABYLON {
  141187. /**
  141188. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141190. */
  141191. export class SceneOptimization {
  141192. /**
  141193. * Defines the priority of this optimization (0 by default which means first in the list)
  141194. */
  141195. priority: number;
  141196. /**
  141197. * Gets a string describing the action executed by the current optimization
  141198. * @returns description string
  141199. */
  141200. getDescription(): string;
  141201. /**
  141202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141203. * @param scene defines the current scene where to apply this optimization
  141204. * @param optimizer defines the current optimizer
  141205. * @returns true if everything that can be done was applied
  141206. */
  141207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141208. /**
  141209. * Creates the SceneOptimization object
  141210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141211. * @param desc defines the description associated with the optimization
  141212. */
  141213. constructor(
  141214. /**
  141215. * Defines the priority of this optimization (0 by default which means first in the list)
  141216. */
  141217. priority?: number);
  141218. }
  141219. /**
  141220. * Defines an optimization used to reduce the size of render target textures
  141221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141222. */
  141223. export class TextureOptimization extends SceneOptimization {
  141224. /**
  141225. * Defines the priority of this optimization (0 by default which means first in the list)
  141226. */
  141227. priority: number;
  141228. /**
  141229. * 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
  141230. */
  141231. maximumSize: number;
  141232. /**
  141233. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141234. */
  141235. step: number;
  141236. /**
  141237. * Gets a string describing the action executed by the current optimization
  141238. * @returns description string
  141239. */
  141240. getDescription(): string;
  141241. /**
  141242. * Creates the TextureOptimization object
  141243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141244. * @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
  141245. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141246. */
  141247. constructor(
  141248. /**
  141249. * Defines the priority of this optimization (0 by default which means first in the list)
  141250. */
  141251. priority?: number,
  141252. /**
  141253. * 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
  141254. */
  141255. maximumSize?: number,
  141256. /**
  141257. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141258. */
  141259. step?: number);
  141260. /**
  141261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141262. * @param scene defines the current scene where to apply this optimization
  141263. * @param optimizer defines the current optimizer
  141264. * @returns true if everything that can be done was applied
  141265. */
  141266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141267. }
  141268. /**
  141269. * Defines an optimization used to increase or decrease the rendering resolution
  141270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141271. */
  141272. export class HardwareScalingOptimization extends SceneOptimization {
  141273. /**
  141274. * Defines the priority of this optimization (0 by default which means first in the list)
  141275. */
  141276. priority: number;
  141277. /**
  141278. * Defines the maximum scale to use (2 by default)
  141279. */
  141280. maximumScale: number;
  141281. /**
  141282. * Defines the step to use between two passes (0.5 by default)
  141283. */
  141284. step: number;
  141285. private _currentScale;
  141286. private _directionOffset;
  141287. /**
  141288. * Gets a string describing the action executed by the current optimization
  141289. * @return description string
  141290. */
  141291. getDescription(): string;
  141292. /**
  141293. * Creates the HardwareScalingOptimization object
  141294. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141295. * @param maximumScale defines the maximum scale to use (2 by default)
  141296. * @param step defines the step to use between two passes (0.5 by default)
  141297. */
  141298. constructor(
  141299. /**
  141300. * Defines the priority of this optimization (0 by default which means first in the list)
  141301. */
  141302. priority?: number,
  141303. /**
  141304. * Defines the maximum scale to use (2 by default)
  141305. */
  141306. maximumScale?: number,
  141307. /**
  141308. * Defines the step to use between two passes (0.5 by default)
  141309. */
  141310. step?: number);
  141311. /**
  141312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141313. * @param scene defines the current scene where to apply this optimization
  141314. * @param optimizer defines the current optimizer
  141315. * @returns true if everything that can be done was applied
  141316. */
  141317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141318. }
  141319. /**
  141320. * Defines an optimization used to remove shadows
  141321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141322. */
  141323. export class ShadowsOptimization extends SceneOptimization {
  141324. /**
  141325. * Gets a string describing the action executed by the current optimization
  141326. * @return description string
  141327. */
  141328. getDescription(): string;
  141329. /**
  141330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141331. * @param scene defines the current scene where to apply this optimization
  141332. * @param optimizer defines the current optimizer
  141333. * @returns true if everything that can be done was applied
  141334. */
  141335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141336. }
  141337. /**
  141338. * Defines an optimization used to turn post-processes off
  141339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141340. */
  141341. export class PostProcessesOptimization extends SceneOptimization {
  141342. /**
  141343. * Gets a string describing the action executed by the current optimization
  141344. * @return description string
  141345. */
  141346. getDescription(): string;
  141347. /**
  141348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141349. * @param scene defines the current scene where to apply this optimization
  141350. * @param optimizer defines the current optimizer
  141351. * @returns true if everything that can be done was applied
  141352. */
  141353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141354. }
  141355. /**
  141356. * Defines an optimization used to turn lens flares off
  141357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141358. */
  141359. export class LensFlaresOptimization extends SceneOptimization {
  141360. /**
  141361. * Gets a string describing the action executed by the current optimization
  141362. * @return description string
  141363. */
  141364. getDescription(): string;
  141365. /**
  141366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141367. * @param scene defines the current scene where to apply this optimization
  141368. * @param optimizer defines the current optimizer
  141369. * @returns true if everything that can be done was applied
  141370. */
  141371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141372. }
  141373. /**
  141374. * Defines an optimization based on user defined callback.
  141375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141376. */
  141377. export class CustomOptimization extends SceneOptimization {
  141378. /**
  141379. * Callback called to apply the custom optimization.
  141380. */
  141381. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141382. /**
  141383. * Callback called to get custom description
  141384. */
  141385. onGetDescription: () => string;
  141386. /**
  141387. * Gets a string describing the action executed by the current optimization
  141388. * @returns description string
  141389. */
  141390. getDescription(): string;
  141391. /**
  141392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141393. * @param scene defines the current scene where to apply this optimization
  141394. * @param optimizer defines the current optimizer
  141395. * @returns true if everything that can be done was applied
  141396. */
  141397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141398. }
  141399. /**
  141400. * Defines an optimization used to turn particles off
  141401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141402. */
  141403. export class ParticlesOptimization extends SceneOptimization {
  141404. /**
  141405. * Gets a string describing the action executed by the current optimization
  141406. * @return description string
  141407. */
  141408. getDescription(): string;
  141409. /**
  141410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141411. * @param scene defines the current scene where to apply this optimization
  141412. * @param optimizer defines the current optimizer
  141413. * @returns true if everything that can be done was applied
  141414. */
  141415. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141416. }
  141417. /**
  141418. * Defines an optimization used to turn render targets off
  141419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141420. */
  141421. export class RenderTargetsOptimization extends SceneOptimization {
  141422. /**
  141423. * Gets a string describing the action executed by the current optimization
  141424. * @return description string
  141425. */
  141426. getDescription(): string;
  141427. /**
  141428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141429. * @param scene defines the current scene where to apply this optimization
  141430. * @param optimizer defines the current optimizer
  141431. * @returns true if everything that can be done was applied
  141432. */
  141433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141434. }
  141435. /**
  141436. * Defines an optimization used to merge meshes with compatible materials
  141437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141438. */
  141439. export class MergeMeshesOptimization extends SceneOptimization {
  141440. private static _UpdateSelectionTree;
  141441. /**
  141442. * Gets or sets a boolean which defines if optimization octree has to be updated
  141443. */
  141444. static get UpdateSelectionTree(): boolean;
  141445. /**
  141446. * Gets or sets a boolean which defines if optimization octree has to be updated
  141447. */
  141448. static set UpdateSelectionTree(value: boolean);
  141449. /**
  141450. * Gets a string describing the action executed by the current optimization
  141451. * @return description string
  141452. */
  141453. getDescription(): string;
  141454. private _canBeMerged;
  141455. /**
  141456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141457. * @param scene defines the current scene where to apply this optimization
  141458. * @param optimizer defines the current optimizer
  141459. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141460. * @returns true if everything that can be done was applied
  141461. */
  141462. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141463. }
  141464. /**
  141465. * Defines a list of options used by SceneOptimizer
  141466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141467. */
  141468. export class SceneOptimizerOptions {
  141469. /**
  141470. * Defines the target frame rate to reach (60 by default)
  141471. */
  141472. targetFrameRate: number;
  141473. /**
  141474. * Defines the interval between two checkes (2000ms by default)
  141475. */
  141476. trackerDuration: number;
  141477. /**
  141478. * Gets the list of optimizations to apply
  141479. */
  141480. optimizations: SceneOptimization[];
  141481. /**
  141482. * Creates a new list of options used by SceneOptimizer
  141483. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141484. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141485. */
  141486. constructor(
  141487. /**
  141488. * Defines the target frame rate to reach (60 by default)
  141489. */
  141490. targetFrameRate?: number,
  141491. /**
  141492. * Defines the interval between two checkes (2000ms by default)
  141493. */
  141494. trackerDuration?: number);
  141495. /**
  141496. * Add a new optimization
  141497. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141498. * @returns the current SceneOptimizerOptions
  141499. */
  141500. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141501. /**
  141502. * Add a new custom optimization
  141503. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141504. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141505. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141506. * @returns the current SceneOptimizerOptions
  141507. */
  141508. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141509. /**
  141510. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141511. * @param targetFrameRate defines the target frame rate (60 by default)
  141512. * @returns a SceneOptimizerOptions object
  141513. */
  141514. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141515. /**
  141516. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141517. * @param targetFrameRate defines the target frame rate (60 by default)
  141518. * @returns a SceneOptimizerOptions object
  141519. */
  141520. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141521. /**
  141522. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141523. * @param targetFrameRate defines the target frame rate (60 by default)
  141524. * @returns a SceneOptimizerOptions object
  141525. */
  141526. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141527. }
  141528. /**
  141529. * Class used to run optimizations in order to reach a target frame rate
  141530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141531. */
  141532. export class SceneOptimizer implements IDisposable {
  141533. private _isRunning;
  141534. private _options;
  141535. private _scene;
  141536. private _currentPriorityLevel;
  141537. private _targetFrameRate;
  141538. private _trackerDuration;
  141539. private _currentFrameRate;
  141540. private _sceneDisposeObserver;
  141541. private _improvementMode;
  141542. /**
  141543. * Defines an observable called when the optimizer reaches the target frame rate
  141544. */
  141545. onSuccessObservable: Observable<SceneOptimizer>;
  141546. /**
  141547. * Defines an observable called when the optimizer enables an optimization
  141548. */
  141549. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141550. /**
  141551. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141552. */
  141553. onFailureObservable: Observable<SceneOptimizer>;
  141554. /**
  141555. * Gets a boolean indicating if the optimizer is in improvement mode
  141556. */
  141557. get isInImprovementMode(): boolean;
  141558. /**
  141559. * Gets the current priority level (0 at start)
  141560. */
  141561. get currentPriorityLevel(): number;
  141562. /**
  141563. * Gets the current frame rate checked by the SceneOptimizer
  141564. */
  141565. get currentFrameRate(): number;
  141566. /**
  141567. * Gets or sets the current target frame rate (60 by default)
  141568. */
  141569. get targetFrameRate(): number;
  141570. /**
  141571. * Gets or sets the current target frame rate (60 by default)
  141572. */
  141573. set targetFrameRate(value: number);
  141574. /**
  141575. * Gets or sets the current interval between two checks (every 2000ms by default)
  141576. */
  141577. get trackerDuration(): number;
  141578. /**
  141579. * Gets or sets the current interval between two checks (every 2000ms by default)
  141580. */
  141581. set trackerDuration(value: number);
  141582. /**
  141583. * Gets the list of active optimizations
  141584. */
  141585. get optimizations(): SceneOptimization[];
  141586. /**
  141587. * Creates a new SceneOptimizer
  141588. * @param scene defines the scene to work on
  141589. * @param options defines the options to use with the SceneOptimizer
  141590. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141591. * @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)
  141592. */
  141593. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141594. /**
  141595. * Stops the current optimizer
  141596. */
  141597. stop(): void;
  141598. /**
  141599. * Reset the optimizer to initial step (current priority level = 0)
  141600. */
  141601. reset(): void;
  141602. /**
  141603. * Start the optimizer. By default it will try to reach a specific framerate
  141604. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141605. */
  141606. start(): void;
  141607. private _checkCurrentState;
  141608. /**
  141609. * Release all resources
  141610. */
  141611. dispose(): void;
  141612. /**
  141613. * Helper function to create a SceneOptimizer with one single line of code
  141614. * @param scene defines the scene to work on
  141615. * @param options defines the options to use with the SceneOptimizer
  141616. * @param onSuccess defines a callback to call on success
  141617. * @param onFailure defines a callback to call on failure
  141618. * @returns the new SceneOptimizer object
  141619. */
  141620. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141621. }
  141622. }
  141623. declare module BABYLON {
  141624. /**
  141625. * Class used to serialize a scene into a string
  141626. */
  141627. export class SceneSerializer {
  141628. /**
  141629. * Clear cache used by a previous serialization
  141630. */
  141631. static ClearCache(): void;
  141632. /**
  141633. * Serialize a scene into a JSON compatible object
  141634. * @param scene defines the scene to serialize
  141635. * @returns a JSON compatible object
  141636. */
  141637. static Serialize(scene: Scene): any;
  141638. /**
  141639. * Serialize a mesh into a JSON compatible object
  141640. * @param toSerialize defines the mesh to serialize
  141641. * @param withParents defines if parents must be serialized as well
  141642. * @param withChildren defines if children must be serialized as well
  141643. * @returns a JSON compatible object
  141644. */
  141645. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141646. }
  141647. }
  141648. declare module BABYLON {
  141649. /**
  141650. * Class used to host texture specific utilities
  141651. */
  141652. export class TextureTools {
  141653. /**
  141654. * Uses the GPU to create a copy texture rescaled at a given size
  141655. * @param texture Texture to copy from
  141656. * @param width defines the desired width
  141657. * @param height defines the desired height
  141658. * @param useBilinearMode defines if bilinear mode has to be used
  141659. * @return the generated texture
  141660. */
  141661. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141662. }
  141663. }
  141664. declare module BABYLON {
  141665. /**
  141666. * This represents the different options available for the video capture.
  141667. */
  141668. export interface VideoRecorderOptions {
  141669. /** Defines the mime type of the video. */
  141670. mimeType: string;
  141671. /** Defines the FPS the video should be recorded at. */
  141672. fps: number;
  141673. /** Defines the chunk size for the recording data. */
  141674. recordChunckSize: number;
  141675. /** The audio tracks to attach to the recording. */
  141676. audioTracks?: MediaStreamTrack[];
  141677. }
  141678. /**
  141679. * This can help with recording videos from BabylonJS.
  141680. * This is based on the available WebRTC functionalities of the browser.
  141681. *
  141682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141683. */
  141684. export class VideoRecorder {
  141685. private static readonly _defaultOptions;
  141686. /**
  141687. * Returns whether or not the VideoRecorder is available in your browser.
  141688. * @param engine Defines the Babylon Engine.
  141689. * @returns true if supported otherwise false.
  141690. */
  141691. static IsSupported(engine: Engine): boolean;
  141692. private readonly _options;
  141693. private _canvas;
  141694. private _mediaRecorder;
  141695. private _recordedChunks;
  141696. private _fileName;
  141697. private _resolve;
  141698. private _reject;
  141699. /**
  141700. * True when a recording is already in progress.
  141701. */
  141702. get isRecording(): boolean;
  141703. /**
  141704. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141705. * @param engine Defines the BabylonJS Engine you wish to record.
  141706. * @param options Defines options that can be used to customize the capture.
  141707. */
  141708. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141709. /**
  141710. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141711. */
  141712. stopRecording(): void;
  141713. /**
  141714. * Starts recording the canvas for a max duration specified in parameters.
  141715. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141716. * If null no automatic download will start and you can rely on the promise to get the data back.
  141717. * @param maxDuration Defines the maximum recording time in seconds.
  141718. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141719. * @return A promise callback at the end of the recording with the video data in Blob.
  141720. */
  141721. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141722. /**
  141723. * Releases internal resources used during the recording.
  141724. */
  141725. dispose(): void;
  141726. private _handleDataAvailable;
  141727. private _handleError;
  141728. private _handleStop;
  141729. }
  141730. }
  141731. declare module BABYLON {
  141732. /**
  141733. * Class containing a set of static utilities functions for screenshots
  141734. */
  141735. export class ScreenshotTools {
  141736. /**
  141737. * Captures a screenshot of the current rendering
  141738. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141739. * @param engine defines the rendering engine
  141740. * @param camera defines the source camera
  141741. * @param size This parameter can be set to a single number or to an object with the
  141742. * following (optional) properties: precision, width, height. If a single number is passed,
  141743. * it will be used for both width and height. If an object is passed, the screenshot size
  141744. * will be derived from the parameters. The precision property is a multiplier allowing
  141745. * rendering at a higher or lower resolution
  141746. * @param successCallback defines the callback receives a single parameter which contains the
  141747. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141748. * src parameter of an <img> to display it
  141749. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141750. * Check your browser for supported MIME types
  141751. */
  141752. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141753. /**
  141754. * Captures a screenshot of the current rendering
  141755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141756. * @param engine defines the rendering engine
  141757. * @param camera defines the source camera
  141758. * @param size This parameter can be set to a single number or to an object with the
  141759. * following (optional) properties: precision, width, height. If a single number is passed,
  141760. * it will be used for both width and height. If an object is passed, the screenshot size
  141761. * will be derived from the parameters. The precision property is a multiplier allowing
  141762. * rendering at a higher or lower resolution
  141763. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141764. * Check your browser for supported MIME types
  141765. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141766. * to the src parameter of an <img> to display it
  141767. */
  141768. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141769. /**
  141770. * Generates an image screenshot from the specified camera.
  141771. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141772. * @param engine The engine to use for rendering
  141773. * @param camera The camera to use for rendering
  141774. * @param size This parameter can be set to a single number or to an object with the
  141775. * following (optional) properties: precision, width, height. If a single number is passed,
  141776. * it will be used for both width and height. If an object is passed, the screenshot size
  141777. * will be derived from the parameters. The precision property is a multiplier allowing
  141778. * rendering at a higher or lower resolution
  141779. * @param successCallback The callback receives a single parameter which contains the
  141780. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141781. * src parameter of an <img> to display it
  141782. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141783. * Check your browser for supported MIME types
  141784. * @param samples Texture samples (default: 1)
  141785. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141786. * @param fileName A name for for the downloaded file.
  141787. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141788. */
  141789. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141790. /**
  141791. * Generates an image screenshot from the specified camera.
  141792. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141793. * @param engine The engine to use for rendering
  141794. * @param camera The camera to use for rendering
  141795. * @param size This parameter can be set to a single number or to an object with the
  141796. * following (optional) properties: precision, width, height. If a single number is passed,
  141797. * it will be used for both width and height. If an object is passed, the screenshot size
  141798. * will be derived from the parameters. The precision property is a multiplier allowing
  141799. * rendering at a higher or lower resolution
  141800. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141801. * Check your browser for supported MIME types
  141802. * @param samples Texture samples (default: 1)
  141803. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141804. * @param fileName A name for for the downloaded file.
  141805. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141806. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141807. * to the src parameter of an <img> to display it
  141808. */
  141809. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141810. /**
  141811. * Gets height and width for screenshot size
  141812. * @private
  141813. */
  141814. private static _getScreenshotSize;
  141815. }
  141816. }
  141817. declare module BABYLON {
  141818. /**
  141819. * Interface for a data buffer
  141820. */
  141821. export interface IDataBuffer {
  141822. /**
  141823. * Reads bytes from the data buffer.
  141824. * @param byteOffset The byte offset to read
  141825. * @param byteLength The byte length to read
  141826. * @returns A promise that resolves when the bytes are read
  141827. */
  141828. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141829. /**
  141830. * The byte length of the buffer.
  141831. */
  141832. readonly byteLength: number;
  141833. }
  141834. /**
  141835. * Utility class for reading from a data buffer
  141836. */
  141837. export class DataReader {
  141838. /**
  141839. * The data buffer associated with this data reader.
  141840. */
  141841. readonly buffer: IDataBuffer;
  141842. /**
  141843. * The current byte offset from the beginning of the data buffer.
  141844. */
  141845. byteOffset: number;
  141846. private _dataView;
  141847. private _dataByteOffset;
  141848. /**
  141849. * Constructor
  141850. * @param buffer The buffer to read
  141851. */
  141852. constructor(buffer: IDataBuffer);
  141853. /**
  141854. * Loads the given byte length.
  141855. * @param byteLength The byte length to load
  141856. * @returns A promise that resolves when the load is complete
  141857. */
  141858. loadAsync(byteLength: number): Promise<void>;
  141859. /**
  141860. * Read a unsigned 32-bit integer from the currently loaded data range.
  141861. * @returns The 32-bit integer read
  141862. */
  141863. readUint32(): number;
  141864. /**
  141865. * Read a byte array from the currently loaded data range.
  141866. * @param byteLength The byte length to read
  141867. * @returns The byte array read
  141868. */
  141869. readUint8Array(byteLength: number): Uint8Array;
  141870. /**
  141871. * Read a string from the currently loaded data range.
  141872. * @param byteLength The byte length to read
  141873. * @returns The string read
  141874. */
  141875. readString(byteLength: number): string;
  141876. /**
  141877. * Skips the given byte length the currently loaded data range.
  141878. * @param byteLength The byte length to skip
  141879. */
  141880. skipBytes(byteLength: number): void;
  141881. }
  141882. }
  141883. declare module BABYLON {
  141884. /**
  141885. * Options used for hit testing
  141886. */
  141887. export interface IWebXRHitTestOptions {
  141888. /**
  141889. * Only test when user interacted with the scene. Default - hit test every frame
  141890. */
  141891. testOnPointerDownOnly?: boolean;
  141892. /**
  141893. * The node to use to transform the local results to world coordinates
  141894. */
  141895. worldParentNode?: TransformNode;
  141896. }
  141897. /**
  141898. * Interface defining the babylon result of raycasting/hit-test
  141899. */
  141900. export interface IWebXRHitResult {
  141901. /**
  141902. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141903. */
  141904. transformationMatrix: Matrix;
  141905. /**
  141906. * The native hit test result
  141907. */
  141908. xrHitResult: XRHitResult;
  141909. }
  141910. /**
  141911. * The currently-working hit-test module.
  141912. * Hit test (or Ray-casting) is used to interact with the real world.
  141913. * For further information read here - https://github.com/immersive-web/hit-test
  141914. */
  141915. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141916. /**
  141917. * options to use when constructing this feature
  141918. */
  141919. readonly options: IWebXRHitTestOptions;
  141920. private _direction;
  141921. private _mat;
  141922. private _onSelectEnabled;
  141923. private _origin;
  141924. /**
  141925. * The module's name
  141926. */
  141927. static readonly Name: string;
  141928. /**
  141929. * The (Babylon) version of this module.
  141930. * This is an integer representing the implementation version.
  141931. * This number does not correspond to the WebXR specs version
  141932. */
  141933. static readonly Version: number;
  141934. /**
  141935. * Populated with the last native XR Hit Results
  141936. */
  141937. lastNativeXRHitResults: XRHitResult[];
  141938. /**
  141939. * Triggered when new babylon (transformed) hit test results are available
  141940. */
  141941. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141942. /**
  141943. * Creates a new instance of the (legacy version) hit test feature
  141944. * @param _xrSessionManager an instance of WebXRSessionManager
  141945. * @param options options to use when constructing this feature
  141946. */
  141947. constructor(_xrSessionManager: WebXRSessionManager,
  141948. /**
  141949. * options to use when constructing this feature
  141950. */
  141951. options?: IWebXRHitTestOptions);
  141952. /**
  141953. * execute a hit test with an XR Ray
  141954. *
  141955. * @param xrSession a native xrSession that will execute this hit test
  141956. * @param xrRay the ray (position and direction) to use for ray-casting
  141957. * @param referenceSpace native XR reference space to use for the hit-test
  141958. * @param filter filter function that will filter the results
  141959. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141960. */
  141961. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141962. /**
  141963. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141964. * @param event the (select) event to use to select with
  141965. * @param referenceSpace the reference space to use for this hit test
  141966. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141967. */
  141968. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141969. /**
  141970. * attach this feature
  141971. * Will usually be called by the features manager
  141972. *
  141973. * @returns true if successful.
  141974. */
  141975. attach(): boolean;
  141976. /**
  141977. * detach this feature.
  141978. * Will usually be called by the features manager
  141979. *
  141980. * @returns true if successful.
  141981. */
  141982. detach(): boolean;
  141983. /**
  141984. * Dispose this feature and all of the resources attached
  141985. */
  141986. dispose(): void;
  141987. protected _onXRFrame(frame: XRFrame): void;
  141988. private _onHitTestResults;
  141989. private _onSelect;
  141990. }
  141991. }
  141992. declare module BABYLON {
  141993. /**
  141994. * Options used in the plane detector module
  141995. */
  141996. export interface IWebXRPlaneDetectorOptions {
  141997. /**
  141998. * The node to use to transform the local results to world coordinates
  141999. */
  142000. worldParentNode?: TransformNode;
  142001. }
  142002. /**
  142003. * A babylon interface for a WebXR plane.
  142004. * A Plane is actually a polygon, built from N points in space
  142005. *
  142006. * Supported in chrome 79, not supported in canary 81 ATM
  142007. */
  142008. export interface IWebXRPlane {
  142009. /**
  142010. * a babylon-assigned ID for this polygon
  142011. */
  142012. id: number;
  142013. /**
  142014. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142015. */
  142016. polygonDefinition: Array<Vector3>;
  142017. /**
  142018. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142019. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142020. */
  142021. transformationMatrix: Matrix;
  142022. /**
  142023. * the native xr-plane object
  142024. */
  142025. xrPlane: XRPlane;
  142026. }
  142027. /**
  142028. * The plane detector is used to detect planes in the real world when in AR
  142029. * For more information see https://github.com/immersive-web/real-world-geometry/
  142030. */
  142031. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142032. private _options;
  142033. private _detectedPlanes;
  142034. private _enabled;
  142035. private _lastFrameDetected;
  142036. /**
  142037. * The module's name
  142038. */
  142039. static readonly Name: string;
  142040. /**
  142041. * The (Babylon) version of this module.
  142042. * This is an integer representing the implementation version.
  142043. * This number does not correspond to the WebXR specs version
  142044. */
  142045. static readonly Version: number;
  142046. /**
  142047. * Observers registered here will be executed when a new plane was added to the session
  142048. */
  142049. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142050. /**
  142051. * Observers registered here will be executed when a plane is no longer detected in the session
  142052. */
  142053. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142054. /**
  142055. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142056. * This can execute N times every frame
  142057. */
  142058. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142059. /**
  142060. * construct a new Plane Detector
  142061. * @param _xrSessionManager an instance of xr Session manager
  142062. * @param _options configuration to use when constructing this feature
  142063. */
  142064. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142065. /**
  142066. * Dispose this feature and all of the resources attached
  142067. */
  142068. dispose(): void;
  142069. protected _onXRFrame(frame: XRFrame): void;
  142070. private _init;
  142071. private _updatePlaneWithXRPlane;
  142072. /**
  142073. * avoiding using Array.find for global support.
  142074. * @param xrPlane the plane to find in the array
  142075. */
  142076. private findIndexInPlaneArray;
  142077. }
  142078. }
  142079. declare module BABYLON {
  142080. /**
  142081. * Configuration options of the anchor system
  142082. */
  142083. export interface IWebXRAnchorSystemOptions {
  142084. /**
  142085. * Should a new anchor be added every time a select event is triggered
  142086. */
  142087. addAnchorOnSelect?: boolean;
  142088. /**
  142089. * should the anchor system use plane detection.
  142090. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142091. */
  142092. usePlaneDetection?: boolean;
  142093. /**
  142094. * a node that will be used to convert local to world coordinates
  142095. */
  142096. worldParentNode?: TransformNode;
  142097. }
  142098. /**
  142099. * A babylon container for an XR Anchor
  142100. */
  142101. export interface IWebXRAnchor {
  142102. /**
  142103. * A babylon-assigned ID for this anchor
  142104. */
  142105. id: number;
  142106. /**
  142107. * Transformation matrix to apply to an object attached to this anchor
  142108. */
  142109. transformationMatrix: Matrix;
  142110. /**
  142111. * The native anchor object
  142112. */
  142113. xrAnchor: XRAnchor;
  142114. }
  142115. /**
  142116. * An implementation of the anchor system of WebXR.
  142117. * Note that the current documented implementation is not available in any browser. Future implementations
  142118. * will use the frame to create an anchor and not the session or a detected plane
  142119. * For further information see https://github.com/immersive-web/anchors/
  142120. */
  142121. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142122. private _options;
  142123. private _enabled;
  142124. private _hitTestModule;
  142125. private _lastFrameDetected;
  142126. private _onSelect;
  142127. private _planeDetector;
  142128. private _trackedAnchors;
  142129. /**
  142130. * The module's name
  142131. */
  142132. static readonly Name: string;
  142133. /**
  142134. * The (Babylon) version of this module.
  142135. * This is an integer representing the implementation version.
  142136. * This number does not correspond to the WebXR specs version
  142137. */
  142138. static readonly Version: number;
  142139. /**
  142140. * Observers registered here will be executed when a new anchor was added to the session
  142141. */
  142142. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142143. /**
  142144. * Observers registered here will be executed when an anchor was removed from the session
  142145. */
  142146. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142147. /**
  142148. * Observers registered here will be executed when an existing anchor updates
  142149. * This can execute N times every frame
  142150. */
  142151. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142152. /**
  142153. * constructs a new anchor system
  142154. * @param _xrSessionManager an instance of WebXRSessionManager
  142155. * @param _options configuration object for this feature
  142156. */
  142157. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142158. /**
  142159. * Add anchor at a specific XR point.
  142160. *
  142161. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142162. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142163. * @returns a promise the fulfills when the anchor was created
  142164. */
  142165. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142166. /**
  142167. * attach this feature
  142168. * Will usually be called by the features manager
  142169. *
  142170. * @returns true if successful.
  142171. */
  142172. attach(): boolean;
  142173. /**
  142174. * detach this feature.
  142175. * Will usually be called by the features manager
  142176. *
  142177. * @returns true if successful.
  142178. */
  142179. detach(): boolean;
  142180. /**
  142181. * Dispose this feature and all of the resources attached
  142182. */
  142183. dispose(): void;
  142184. /**
  142185. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142186. * @param hitTestModule the hit-test module to use.
  142187. */
  142188. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142189. /**
  142190. * set the plane detector to use in order to create anchors from frames
  142191. * @param planeDetector the plane-detector module to use
  142192. * @param enable enable plane-anchors. default is true
  142193. */
  142194. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142195. protected _onXRFrame(frame: XRFrame): void;
  142196. /**
  142197. * avoiding using Array.find for global support.
  142198. * @param xrAnchor the plane to find in the array
  142199. */
  142200. private _findIndexInAnchorArray;
  142201. private _updateAnchorWithXRFrame;
  142202. }
  142203. }
  142204. declare module BABYLON {
  142205. /**
  142206. * Options interface for the background remover plugin
  142207. */
  142208. export interface IWebXRBackgroundRemoverOptions {
  142209. /**
  142210. * Further background meshes to disable when entering AR
  142211. */
  142212. backgroundMeshes?: AbstractMesh[];
  142213. /**
  142214. * flags to configure the removal of the environment helper.
  142215. * If not set, the entire background will be removed. If set, flags should be set as well.
  142216. */
  142217. environmentHelperRemovalFlags?: {
  142218. /**
  142219. * Should the skybox be removed (default false)
  142220. */
  142221. skyBox?: boolean;
  142222. /**
  142223. * Should the ground be removed (default false)
  142224. */
  142225. ground?: boolean;
  142226. };
  142227. /**
  142228. * don't disable the environment helper
  142229. */
  142230. ignoreEnvironmentHelper?: boolean;
  142231. }
  142232. /**
  142233. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142234. */
  142235. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142236. /**
  142237. * read-only options to be used in this module
  142238. */
  142239. readonly options: IWebXRBackgroundRemoverOptions;
  142240. /**
  142241. * The module's name
  142242. */
  142243. static readonly Name: string;
  142244. /**
  142245. * The (Babylon) version of this module.
  142246. * This is an integer representing the implementation version.
  142247. * This number does not correspond to the WebXR specs version
  142248. */
  142249. static readonly Version: number;
  142250. /**
  142251. * registered observers will be triggered when the background state changes
  142252. */
  142253. onBackgroundStateChangedObservable: Observable<boolean>;
  142254. /**
  142255. * constructs a new background remover module
  142256. * @param _xrSessionManager the session manager for this module
  142257. * @param options read-only options to be used in this module
  142258. */
  142259. constructor(_xrSessionManager: WebXRSessionManager,
  142260. /**
  142261. * read-only options to be used in this module
  142262. */
  142263. options?: IWebXRBackgroundRemoverOptions);
  142264. /**
  142265. * attach this feature
  142266. * Will usually be called by the features manager
  142267. *
  142268. * @returns true if successful.
  142269. */
  142270. attach(): boolean;
  142271. /**
  142272. * detach this feature.
  142273. * Will usually be called by the features manager
  142274. *
  142275. * @returns true if successful.
  142276. */
  142277. detach(): boolean;
  142278. /**
  142279. * Dispose this feature and all of the resources attached
  142280. */
  142281. dispose(): void;
  142282. protected _onXRFrame(_xrFrame: XRFrame): void;
  142283. private _setBackgroundState;
  142284. }
  142285. }
  142286. declare module BABYLON {
  142287. /**
  142288. * Options for the controller physics feature
  142289. */
  142290. export class IWebXRControllerPhysicsOptions {
  142291. /**
  142292. * Should the headset get its own impostor
  142293. */
  142294. enableHeadsetImpostor?: boolean;
  142295. /**
  142296. * Optional parameters for the headset impostor
  142297. */
  142298. headsetImpostorParams?: {
  142299. /**
  142300. * The type of impostor to create. Default is sphere
  142301. */
  142302. impostorType: number;
  142303. /**
  142304. * the size of the impostor. Defaults to 10cm
  142305. */
  142306. impostorSize?: number | {
  142307. width: number;
  142308. height: number;
  142309. depth: number;
  142310. };
  142311. /**
  142312. * Friction definitions
  142313. */
  142314. friction?: number;
  142315. /**
  142316. * Restitution
  142317. */
  142318. restitution?: number;
  142319. };
  142320. /**
  142321. * The physics properties of the future impostors
  142322. */
  142323. physicsProperties?: {
  142324. /**
  142325. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142326. * Note that this requires a physics engine that supports mesh impostors!
  142327. */
  142328. useControllerMesh?: boolean;
  142329. /**
  142330. * The type of impostor to create. Default is sphere
  142331. */
  142332. impostorType?: number;
  142333. /**
  142334. * the size of the impostor. Defaults to 10cm
  142335. */
  142336. impostorSize?: number | {
  142337. width: number;
  142338. height: number;
  142339. depth: number;
  142340. };
  142341. /**
  142342. * Friction definitions
  142343. */
  142344. friction?: number;
  142345. /**
  142346. * Restitution
  142347. */
  142348. restitution?: number;
  142349. };
  142350. /**
  142351. * the xr input to use with this pointer selection
  142352. */
  142353. xrInput: WebXRInput;
  142354. }
  142355. /**
  142356. * Add physics impostor to your webxr controllers,
  142357. * including naive calculation of their linear and angular velocity
  142358. */
  142359. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142360. private readonly _options;
  142361. private _attachController;
  142362. private _controllers;
  142363. private _debugMode;
  142364. private _delta;
  142365. private _headsetImpostor?;
  142366. private _headsetMesh?;
  142367. private _lastTimestamp;
  142368. private _tmpQuaternion;
  142369. private _tmpVector;
  142370. /**
  142371. * The module's name
  142372. */
  142373. static readonly Name: string;
  142374. /**
  142375. * The (Babylon) version of this module.
  142376. * This is an integer representing the implementation version.
  142377. * This number does not correspond to the webxr specs version
  142378. */
  142379. static readonly Version: number;
  142380. /**
  142381. * Construct a new Controller Physics Feature
  142382. * @param _xrSessionManager the corresponding xr session manager
  142383. * @param _options options to create this feature with
  142384. */
  142385. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142386. /**
  142387. * @hidden
  142388. * enable debugging - will show console outputs and the impostor mesh
  142389. */
  142390. _enablePhysicsDebug(): void;
  142391. /**
  142392. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142393. * @param xrController the controller to add
  142394. */
  142395. addController(xrController: WebXRInputSource): void;
  142396. /**
  142397. * attach this feature
  142398. * Will usually be called by the features manager
  142399. *
  142400. * @returns true if successful.
  142401. */
  142402. attach(): boolean;
  142403. /**
  142404. * detach this feature.
  142405. * Will usually be called by the features manager
  142406. *
  142407. * @returns true if successful.
  142408. */
  142409. detach(): boolean;
  142410. /**
  142411. * Get the headset impostor, if enabled
  142412. * @returns the impostor
  142413. */
  142414. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142415. /**
  142416. * Get the physics impostor of a specific controller.
  142417. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142418. * @param controller the controller or the controller id of which to get the impostor
  142419. * @returns the impostor or null
  142420. */
  142421. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142422. /**
  142423. * Update the physics properties provided in the constructor
  142424. * @param newProperties the new properties object
  142425. */
  142426. setPhysicsProperties(newProperties: {
  142427. impostorType?: number;
  142428. impostorSize?: number | {
  142429. width: number;
  142430. height: number;
  142431. depth: number;
  142432. };
  142433. friction?: number;
  142434. restitution?: number;
  142435. }): void;
  142436. protected _onXRFrame(_xrFrame: any): void;
  142437. private _detachController;
  142438. }
  142439. }
  142440. declare module BABYLON {
  142441. /**
  142442. * The motion controller class for all microsoft mixed reality controllers
  142443. */
  142444. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142445. protected readonly _mapping: {
  142446. defaultButton: {
  142447. "valueNodeName": string;
  142448. "unpressedNodeName": string;
  142449. "pressedNodeName": string;
  142450. };
  142451. defaultAxis: {
  142452. "valueNodeName": string;
  142453. "minNodeName": string;
  142454. "maxNodeName": string;
  142455. };
  142456. buttons: {
  142457. "xr-standard-trigger": {
  142458. "rootNodeName": string;
  142459. "componentProperty": string;
  142460. "states": string[];
  142461. };
  142462. "xr-standard-squeeze": {
  142463. "rootNodeName": string;
  142464. "componentProperty": string;
  142465. "states": string[];
  142466. };
  142467. "xr-standard-touchpad": {
  142468. "rootNodeName": string;
  142469. "labelAnchorNodeName": string;
  142470. "touchPointNodeName": string;
  142471. };
  142472. "xr-standard-thumbstick": {
  142473. "rootNodeName": string;
  142474. "componentProperty": string;
  142475. "states": string[];
  142476. };
  142477. };
  142478. axes: {
  142479. "xr-standard-touchpad": {
  142480. "x-axis": {
  142481. "rootNodeName": string;
  142482. };
  142483. "y-axis": {
  142484. "rootNodeName": string;
  142485. };
  142486. };
  142487. "xr-standard-thumbstick": {
  142488. "x-axis": {
  142489. "rootNodeName": string;
  142490. };
  142491. "y-axis": {
  142492. "rootNodeName": string;
  142493. };
  142494. };
  142495. };
  142496. };
  142497. /**
  142498. * The base url used to load the left and right controller models
  142499. */
  142500. static MODEL_BASE_URL: string;
  142501. /**
  142502. * The name of the left controller model file
  142503. */
  142504. static MODEL_LEFT_FILENAME: string;
  142505. /**
  142506. * The name of the right controller model file
  142507. */
  142508. static MODEL_RIGHT_FILENAME: string;
  142509. profileId: string;
  142510. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142511. protected _getFilenameAndPath(): {
  142512. filename: string;
  142513. path: string;
  142514. };
  142515. protected _getModelLoadingConstraints(): boolean;
  142516. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142517. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142518. protected _updateModel(): void;
  142519. }
  142520. }
  142521. declare module BABYLON {
  142522. /**
  142523. * The motion controller class for oculus touch (quest, rift).
  142524. * This class supports legacy mapping as well the standard xr mapping
  142525. */
  142526. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142527. private _forceLegacyControllers;
  142528. private _modelRootNode;
  142529. /**
  142530. * The base url used to load the left and right controller models
  142531. */
  142532. static MODEL_BASE_URL: string;
  142533. /**
  142534. * The name of the left controller model file
  142535. */
  142536. static MODEL_LEFT_FILENAME: string;
  142537. /**
  142538. * The name of the right controller model file
  142539. */
  142540. static MODEL_RIGHT_FILENAME: string;
  142541. /**
  142542. * Base Url for the Quest controller model.
  142543. */
  142544. static QUEST_MODEL_BASE_URL: string;
  142545. profileId: string;
  142546. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142547. protected _getFilenameAndPath(): {
  142548. filename: string;
  142549. path: string;
  142550. };
  142551. protected _getModelLoadingConstraints(): boolean;
  142552. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142553. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142554. protected _updateModel(): void;
  142555. /**
  142556. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142557. * between the touch and touch 2.
  142558. */
  142559. private _isQuest;
  142560. }
  142561. }
  142562. declare module BABYLON {
  142563. /**
  142564. * The motion controller class for the standard HTC-Vive controllers
  142565. */
  142566. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142567. private _modelRootNode;
  142568. /**
  142569. * The base url used to load the left and right controller models
  142570. */
  142571. static MODEL_BASE_URL: string;
  142572. /**
  142573. * File name for the controller model.
  142574. */
  142575. static MODEL_FILENAME: string;
  142576. profileId: string;
  142577. /**
  142578. * Create a new Vive motion controller object
  142579. * @param scene the scene to use to create this controller
  142580. * @param gamepadObject the corresponding gamepad object
  142581. * @param handness the handness of the controller
  142582. */
  142583. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142584. protected _getFilenameAndPath(): {
  142585. filename: string;
  142586. path: string;
  142587. };
  142588. protected _getModelLoadingConstraints(): boolean;
  142589. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142590. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142591. protected _updateModel(): void;
  142592. }
  142593. }
  142594. declare module BABYLON {
  142595. /**
  142596. * A cursor which tracks a point on a path
  142597. */
  142598. export class PathCursor {
  142599. private path;
  142600. /**
  142601. * Stores path cursor callbacks for when an onchange event is triggered
  142602. */
  142603. private _onchange;
  142604. /**
  142605. * The value of the path cursor
  142606. */
  142607. value: number;
  142608. /**
  142609. * The animation array of the path cursor
  142610. */
  142611. animations: Animation[];
  142612. /**
  142613. * Initializes the path cursor
  142614. * @param path The path to track
  142615. */
  142616. constructor(path: Path2);
  142617. /**
  142618. * Gets the cursor point on the path
  142619. * @returns A point on the path cursor at the cursor location
  142620. */
  142621. getPoint(): Vector3;
  142622. /**
  142623. * Moves the cursor ahead by the step amount
  142624. * @param step The amount to move the cursor forward
  142625. * @returns This path cursor
  142626. */
  142627. moveAhead(step?: number): PathCursor;
  142628. /**
  142629. * Moves the cursor behind by the step amount
  142630. * @param step The amount to move the cursor back
  142631. * @returns This path cursor
  142632. */
  142633. moveBack(step?: number): PathCursor;
  142634. /**
  142635. * Moves the cursor by the step amount
  142636. * If the step amount is greater than one, an exception is thrown
  142637. * @param step The amount to move the cursor
  142638. * @returns This path cursor
  142639. */
  142640. move(step: number): PathCursor;
  142641. /**
  142642. * Ensures that the value is limited between zero and one
  142643. * @returns This path cursor
  142644. */
  142645. private ensureLimits;
  142646. /**
  142647. * Runs onchange callbacks on change (used by the animation engine)
  142648. * @returns This path cursor
  142649. */
  142650. private raiseOnChange;
  142651. /**
  142652. * Executes a function on change
  142653. * @param f A path cursor onchange callback
  142654. * @returns This path cursor
  142655. */
  142656. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142657. }
  142658. }
  142659. declare module BABYLON {
  142660. /** @hidden */
  142661. export var blurPixelShader: {
  142662. name: string;
  142663. shader: string;
  142664. };
  142665. }
  142666. declare module BABYLON {
  142667. /** @hidden */
  142668. export var pointCloudVertexDeclaration: {
  142669. name: string;
  142670. shader: string;
  142671. };
  142672. }
  142673. // Mixins
  142674. interface Window {
  142675. mozIndexedDB: IDBFactory;
  142676. webkitIndexedDB: IDBFactory;
  142677. msIndexedDB: IDBFactory;
  142678. webkitURL: typeof URL;
  142679. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142680. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142681. WebGLRenderingContext: WebGLRenderingContext;
  142682. MSGesture: MSGesture;
  142683. CANNON: any;
  142684. AudioContext: AudioContext;
  142685. webkitAudioContext: AudioContext;
  142686. PointerEvent: any;
  142687. Math: Math;
  142688. Uint8Array: Uint8ArrayConstructor;
  142689. Float32Array: Float32ArrayConstructor;
  142690. mozURL: typeof URL;
  142691. msURL: typeof URL;
  142692. VRFrameData: any; // WebVR, from specs 1.1
  142693. DracoDecoderModule: any;
  142694. setImmediate(handler: (...args: any[]) => void): number;
  142695. }
  142696. interface HTMLCanvasElement {
  142697. requestPointerLock(): void;
  142698. msRequestPointerLock?(): void;
  142699. mozRequestPointerLock?(): void;
  142700. webkitRequestPointerLock?(): void;
  142701. /** Track wether a record is in progress */
  142702. isRecording: boolean;
  142703. /** Capture Stream method defined by some browsers */
  142704. captureStream(fps?: number): MediaStream;
  142705. }
  142706. interface CanvasRenderingContext2D {
  142707. msImageSmoothingEnabled: boolean;
  142708. }
  142709. interface MouseEvent {
  142710. mozMovementX: number;
  142711. mozMovementY: number;
  142712. webkitMovementX: number;
  142713. webkitMovementY: number;
  142714. msMovementX: number;
  142715. msMovementY: number;
  142716. }
  142717. interface Navigator {
  142718. mozGetVRDevices: (any: any) => any;
  142719. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142720. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142721. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142722. webkitGetGamepads(): Gamepad[];
  142723. msGetGamepads(): Gamepad[];
  142724. webkitGamepads(): Gamepad[];
  142725. }
  142726. interface HTMLVideoElement {
  142727. mozSrcObject: any;
  142728. }
  142729. interface Math {
  142730. fround(x: number): number;
  142731. imul(a: number, b: number): number;
  142732. }
  142733. interface WebGLRenderingContext {
  142734. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142735. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142736. vertexAttribDivisor(index: number, divisor: number): void;
  142737. createVertexArray(): any;
  142738. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142739. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142740. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142741. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142742. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142743. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142744. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142745. // Queries
  142746. createQuery(): WebGLQuery;
  142747. deleteQuery(query: WebGLQuery): void;
  142748. beginQuery(target: number, query: WebGLQuery): void;
  142749. endQuery(target: number): void;
  142750. getQueryParameter(query: WebGLQuery, pname: number): any;
  142751. getQuery(target: number, pname: number): any;
  142752. MAX_SAMPLES: number;
  142753. RGBA8: number;
  142754. READ_FRAMEBUFFER: number;
  142755. DRAW_FRAMEBUFFER: number;
  142756. UNIFORM_BUFFER: number;
  142757. HALF_FLOAT_OES: number;
  142758. RGBA16F: number;
  142759. RGBA32F: number;
  142760. R32F: number;
  142761. RG32F: number;
  142762. RGB32F: number;
  142763. R16F: number;
  142764. RG16F: number;
  142765. RGB16F: number;
  142766. RED: number;
  142767. RG: number;
  142768. R8: number;
  142769. RG8: number;
  142770. UNSIGNED_INT_24_8: number;
  142771. DEPTH24_STENCIL8: number;
  142772. MIN: number;
  142773. MAX: number;
  142774. /* Multiple Render Targets */
  142775. drawBuffers(buffers: number[]): void;
  142776. readBuffer(src: number): void;
  142777. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142778. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142779. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142780. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142781. // Occlusion Query
  142782. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142783. ANY_SAMPLES_PASSED: number;
  142784. QUERY_RESULT_AVAILABLE: number;
  142785. QUERY_RESULT: number;
  142786. }
  142787. interface WebGLProgram {
  142788. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142789. }
  142790. interface EXT_disjoint_timer_query {
  142791. QUERY_COUNTER_BITS_EXT: number;
  142792. TIME_ELAPSED_EXT: number;
  142793. TIMESTAMP_EXT: number;
  142794. GPU_DISJOINT_EXT: number;
  142795. QUERY_RESULT_EXT: number;
  142796. QUERY_RESULT_AVAILABLE_EXT: number;
  142797. queryCounterEXT(query: WebGLQuery, target: number): void;
  142798. createQueryEXT(): WebGLQuery;
  142799. beginQueryEXT(target: number, query: WebGLQuery): void;
  142800. endQueryEXT(target: number): void;
  142801. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142802. deleteQueryEXT(query: WebGLQuery): void;
  142803. }
  142804. interface WebGLUniformLocation {
  142805. _currentState: any;
  142806. }
  142807. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142808. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142809. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142810. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142811. interface WebGLRenderingContext {
  142812. readonly RASTERIZER_DISCARD: number;
  142813. readonly DEPTH_COMPONENT24: number;
  142814. readonly TEXTURE_3D: number;
  142815. readonly TEXTURE_2D_ARRAY: number;
  142816. readonly TEXTURE_COMPARE_FUNC: number;
  142817. readonly TEXTURE_COMPARE_MODE: number;
  142818. readonly COMPARE_REF_TO_TEXTURE: number;
  142819. readonly TEXTURE_WRAP_R: number;
  142820. readonly HALF_FLOAT: number;
  142821. readonly RGB8: number;
  142822. readonly RED_INTEGER: number;
  142823. readonly RG_INTEGER: number;
  142824. readonly RGB_INTEGER: number;
  142825. readonly RGBA_INTEGER: number;
  142826. readonly R8_SNORM: number;
  142827. readonly RG8_SNORM: number;
  142828. readonly RGB8_SNORM: number;
  142829. readonly RGBA8_SNORM: number;
  142830. readonly R8I: number;
  142831. readonly RG8I: number;
  142832. readonly RGB8I: number;
  142833. readonly RGBA8I: number;
  142834. readonly R8UI: number;
  142835. readonly RG8UI: number;
  142836. readonly RGB8UI: number;
  142837. readonly RGBA8UI: number;
  142838. readonly R16I: number;
  142839. readonly RG16I: number;
  142840. readonly RGB16I: number;
  142841. readonly RGBA16I: number;
  142842. readonly R16UI: number;
  142843. readonly RG16UI: number;
  142844. readonly RGB16UI: number;
  142845. readonly RGBA16UI: number;
  142846. readonly R32I: number;
  142847. readonly RG32I: number;
  142848. readonly RGB32I: number;
  142849. readonly RGBA32I: number;
  142850. readonly R32UI: number;
  142851. readonly RG32UI: number;
  142852. readonly RGB32UI: number;
  142853. readonly RGBA32UI: number;
  142854. readonly RGB10_A2UI: number;
  142855. readonly R11F_G11F_B10F: number;
  142856. readonly RGB9_E5: number;
  142857. readonly RGB10_A2: number;
  142858. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142859. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142860. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142861. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142862. readonly DEPTH_COMPONENT32F: number;
  142863. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142864. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142865. 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;
  142866. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142867. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142868. readonly TRANSFORM_FEEDBACK: number;
  142869. readonly INTERLEAVED_ATTRIBS: number;
  142870. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142871. createTransformFeedback(): WebGLTransformFeedback;
  142872. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142873. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142874. beginTransformFeedback(primitiveMode: number): void;
  142875. endTransformFeedback(): void;
  142876. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142877. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142878. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142879. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142880. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142881. }
  142882. interface ImageBitmap {
  142883. readonly width: number;
  142884. readonly height: number;
  142885. close(): void;
  142886. }
  142887. interface WebGLQuery extends WebGLObject {
  142888. }
  142889. declare var WebGLQuery: {
  142890. prototype: WebGLQuery;
  142891. new(): WebGLQuery;
  142892. };
  142893. interface WebGLSampler extends WebGLObject {
  142894. }
  142895. declare var WebGLSampler: {
  142896. prototype: WebGLSampler;
  142897. new(): WebGLSampler;
  142898. };
  142899. interface WebGLSync extends WebGLObject {
  142900. }
  142901. declare var WebGLSync: {
  142902. prototype: WebGLSync;
  142903. new(): WebGLSync;
  142904. };
  142905. interface WebGLTransformFeedback extends WebGLObject {
  142906. }
  142907. declare var WebGLTransformFeedback: {
  142908. prototype: WebGLTransformFeedback;
  142909. new(): WebGLTransformFeedback;
  142910. };
  142911. interface WebGLVertexArrayObject extends WebGLObject {
  142912. }
  142913. declare var WebGLVertexArrayObject: {
  142914. prototype: WebGLVertexArrayObject;
  142915. new(): WebGLVertexArrayObject;
  142916. };
  142917. // Type definitions for WebVR API
  142918. // Project: https://w3c.github.io/webvr/
  142919. // Definitions by: six a <https://github.com/lostfictions>
  142920. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142921. interface VRDisplay extends EventTarget {
  142922. /**
  142923. * Dictionary of capabilities describing the VRDisplay.
  142924. */
  142925. readonly capabilities: VRDisplayCapabilities;
  142926. /**
  142927. * z-depth defining the far plane of the eye view frustum
  142928. * enables mapping of values in the render target depth
  142929. * attachment to scene coordinates. Initially set to 10000.0.
  142930. */
  142931. depthFar: number;
  142932. /**
  142933. * z-depth defining the near plane of the eye view frustum
  142934. * enables mapping of values in the render target depth
  142935. * attachment to scene coordinates. Initially set to 0.01.
  142936. */
  142937. depthNear: number;
  142938. /**
  142939. * An identifier for this distinct VRDisplay. Used as an
  142940. * association point in the Gamepad API.
  142941. */
  142942. readonly displayId: number;
  142943. /**
  142944. * A display name, a user-readable name identifying it.
  142945. */
  142946. readonly displayName: string;
  142947. readonly isConnected: boolean;
  142948. readonly isPresenting: boolean;
  142949. /**
  142950. * If this VRDisplay supports room-scale experiences, the optional
  142951. * stage attribute contains details on the room-scale parameters.
  142952. */
  142953. readonly stageParameters: VRStageParameters | null;
  142954. /**
  142955. * Passing the value returned by `requestAnimationFrame` to
  142956. * `cancelAnimationFrame` will unregister the callback.
  142957. * @param handle Define the hanle of the request to cancel
  142958. */
  142959. cancelAnimationFrame(handle: number): void;
  142960. /**
  142961. * Stops presenting to the VRDisplay.
  142962. * @returns a promise to know when it stopped
  142963. */
  142964. exitPresent(): Promise<void>;
  142965. /**
  142966. * Return the current VREyeParameters for the given eye.
  142967. * @param whichEye Define the eye we want the parameter for
  142968. * @returns the eye parameters
  142969. */
  142970. getEyeParameters(whichEye: string): VREyeParameters;
  142971. /**
  142972. * Populates the passed VRFrameData with the information required to render
  142973. * the current frame.
  142974. * @param frameData Define the data structure to populate
  142975. * @returns true if ok otherwise false
  142976. */
  142977. getFrameData(frameData: VRFrameData): boolean;
  142978. /**
  142979. * Get the layers currently being presented.
  142980. * @returns the list of VR layers
  142981. */
  142982. getLayers(): VRLayer[];
  142983. /**
  142984. * Return a VRPose containing the future predicted pose of the VRDisplay
  142985. * when the current frame will be presented. The value returned will not
  142986. * change until JavaScript has returned control to the browser.
  142987. *
  142988. * The VRPose will contain the position, orientation, velocity,
  142989. * and acceleration of each of these properties.
  142990. * @returns the pose object
  142991. */
  142992. getPose(): VRPose;
  142993. /**
  142994. * Return the current instantaneous pose of the VRDisplay, with no
  142995. * prediction applied.
  142996. * @returns the current instantaneous pose
  142997. */
  142998. getImmediatePose(): VRPose;
  142999. /**
  143000. * The callback passed to `requestAnimationFrame` will be called
  143001. * any time a new frame should be rendered. When the VRDisplay is
  143002. * presenting the callback will be called at the native refresh
  143003. * rate of the HMD. When not presenting this function acts
  143004. * identically to how window.requestAnimationFrame acts. Content should
  143005. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143006. * asynchronously from other displays and at differing refresh rates.
  143007. * @param callback Define the eaction to run next frame
  143008. * @returns the request handle it
  143009. */
  143010. requestAnimationFrame(callback: FrameRequestCallback): number;
  143011. /**
  143012. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143013. * Repeat calls while already presenting will update the VRLayers being displayed.
  143014. * @param layers Define the list of layer to present
  143015. * @returns a promise to know when the request has been fulfilled
  143016. */
  143017. requestPresent(layers: VRLayer[]): Promise<void>;
  143018. /**
  143019. * Reset the pose for this display, treating its current position and
  143020. * orientation as the "origin/zero" values. VRPose.position,
  143021. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143022. * updated when calling resetPose(). This should be called in only
  143023. * sitting-space experiences.
  143024. */
  143025. resetPose(): void;
  143026. /**
  143027. * The VRLayer provided to the VRDisplay will be captured and presented
  143028. * in the HMD. Calling this function has the same effect on the source
  143029. * canvas as any other operation that uses its source image, and canvases
  143030. * created without preserveDrawingBuffer set to true will be cleared.
  143031. * @param pose Define the pose to submit
  143032. */
  143033. submitFrame(pose?: VRPose): void;
  143034. }
  143035. declare var VRDisplay: {
  143036. prototype: VRDisplay;
  143037. new(): VRDisplay;
  143038. };
  143039. interface VRLayer {
  143040. leftBounds?: number[] | Float32Array | null;
  143041. rightBounds?: number[] | Float32Array | null;
  143042. source?: HTMLCanvasElement | null;
  143043. }
  143044. interface VRDisplayCapabilities {
  143045. readonly canPresent: boolean;
  143046. readonly hasExternalDisplay: boolean;
  143047. readonly hasOrientation: boolean;
  143048. readonly hasPosition: boolean;
  143049. readonly maxLayers: number;
  143050. }
  143051. interface VREyeParameters {
  143052. /** @deprecated */
  143053. readonly fieldOfView: VRFieldOfView;
  143054. readonly offset: Float32Array;
  143055. readonly renderHeight: number;
  143056. readonly renderWidth: number;
  143057. }
  143058. interface VRFieldOfView {
  143059. readonly downDegrees: number;
  143060. readonly leftDegrees: number;
  143061. readonly rightDegrees: number;
  143062. readonly upDegrees: number;
  143063. }
  143064. interface VRFrameData {
  143065. readonly leftProjectionMatrix: Float32Array;
  143066. readonly leftViewMatrix: Float32Array;
  143067. readonly pose: VRPose;
  143068. readonly rightProjectionMatrix: Float32Array;
  143069. readonly rightViewMatrix: Float32Array;
  143070. readonly timestamp: number;
  143071. }
  143072. interface VRPose {
  143073. readonly angularAcceleration: Float32Array | null;
  143074. readonly angularVelocity: Float32Array | null;
  143075. readonly linearAcceleration: Float32Array | null;
  143076. readonly linearVelocity: Float32Array | null;
  143077. readonly orientation: Float32Array | null;
  143078. readonly position: Float32Array | null;
  143079. readonly timestamp: number;
  143080. }
  143081. interface VRStageParameters {
  143082. sittingToStandingTransform?: Float32Array;
  143083. sizeX?: number;
  143084. sizeY?: number;
  143085. }
  143086. interface Navigator {
  143087. getVRDisplays(): Promise<VRDisplay[]>;
  143088. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143089. }
  143090. interface Window {
  143091. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143092. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143093. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143094. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143095. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143096. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143097. }
  143098. interface Gamepad {
  143099. readonly displayId: number;
  143100. }
  143101. type XRSessionMode =
  143102. | "inline"
  143103. | "immersive-vr"
  143104. | "immersive-ar";
  143105. type XRReferenceSpaceType =
  143106. | "viewer"
  143107. | "local"
  143108. | "local-floor"
  143109. | "bounded-floor"
  143110. | "unbounded";
  143111. type XREnvironmentBlendMode =
  143112. | "opaque"
  143113. | "additive"
  143114. | "alpha-blend";
  143115. type XRVisibilityState =
  143116. | "visible"
  143117. | "visible-blurred"
  143118. | "hidden";
  143119. type XRHandedness =
  143120. | "none"
  143121. | "left"
  143122. | "right";
  143123. type XRTargetRayMode =
  143124. | "gaze"
  143125. | "tracked-pointer"
  143126. | "screen";
  143127. type XREye =
  143128. | "none"
  143129. | "left"
  143130. | "right";
  143131. interface XRSpace extends EventTarget {
  143132. }
  143133. interface XRRenderState {
  143134. depthNear?: number;
  143135. depthFar?: number;
  143136. inlineVerticalFieldOfView?: number;
  143137. baseLayer?: XRWebGLLayer;
  143138. }
  143139. interface XRInputSource {
  143140. handedness: XRHandedness;
  143141. targetRayMode: XRTargetRayMode;
  143142. targetRaySpace: XRSpace;
  143143. gripSpace: XRSpace | undefined;
  143144. gamepad: Gamepad | undefined;
  143145. profiles: Array<string>;
  143146. }
  143147. interface XRSessionInit {
  143148. optionalFeatures?: XRReferenceSpaceType[];
  143149. requiredFeatures?: XRReferenceSpaceType[];
  143150. }
  143151. interface XRSession extends XRAnchorCreator {
  143152. addEventListener: Function;
  143153. removeEventListener: Function;
  143154. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143155. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143156. requestAnimationFrame: Function;
  143157. end(): Promise<void>;
  143158. renderState: XRRenderState;
  143159. inputSources: Array<XRInputSource>;
  143160. // AR hit test
  143161. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143162. updateWorldTrackingState(options: {
  143163. planeDetectionState?: { enabled: boolean; }
  143164. }): void;
  143165. }
  143166. interface XRReferenceSpace extends XRSpace {
  143167. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143168. onreset: any;
  143169. }
  143170. type XRPlaneSet = Set<XRPlane>;
  143171. type XRAnchorSet = Set<XRAnchor>;
  143172. interface XRFrame {
  143173. session: XRSession;
  143174. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143175. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143176. // Anchors
  143177. trackedAnchors?: XRAnchorSet;
  143178. // Planes
  143179. worldInformation: {
  143180. detectedPlanes?: XRPlaneSet;
  143181. };
  143182. }
  143183. interface XRViewerPose extends XRPose {
  143184. views: Array<XRView>;
  143185. }
  143186. interface XRPose {
  143187. transform: XRRigidTransform;
  143188. emulatedPosition: boolean;
  143189. }
  143190. interface XRWebGLLayerOptions {
  143191. antialias?: boolean;
  143192. depth?: boolean;
  143193. stencil?: boolean;
  143194. alpha?: boolean;
  143195. multiview?: boolean;
  143196. framebufferScaleFactor?: number;
  143197. }
  143198. declare var XRWebGLLayer: {
  143199. prototype: XRWebGLLayer;
  143200. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143201. };
  143202. interface XRWebGLLayer {
  143203. framebuffer: WebGLFramebuffer;
  143204. framebufferWidth: number;
  143205. framebufferHeight: number;
  143206. getViewport: Function;
  143207. }
  143208. declare class XRRigidTransform {
  143209. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143210. position: DOMPointReadOnly;
  143211. orientation: DOMPointReadOnly;
  143212. matrix: Float32Array;
  143213. inverse: XRRigidTransform;
  143214. }
  143215. interface XRView {
  143216. eye: XREye;
  143217. projectionMatrix: Float32Array;
  143218. transform: XRRigidTransform;
  143219. }
  143220. interface XRInputSourceChangeEvent {
  143221. session: XRSession;
  143222. removed: Array<XRInputSource>;
  143223. added: Array<XRInputSource>;
  143224. }
  143225. interface XRInputSourceEvent extends Event {
  143226. readonly frame: XRFrame;
  143227. readonly inputSource: XRInputSource;
  143228. }
  143229. // Experimental(er) features
  143230. declare class XRRay {
  143231. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143232. origin: DOMPointReadOnly;
  143233. direction: DOMPointReadOnly;
  143234. matrix: Float32Array;
  143235. }
  143236. interface XRHitResult {
  143237. hitMatrix: Float32Array;
  143238. }
  143239. interface XRAnchor {
  143240. // remove?
  143241. id?: string;
  143242. anchorSpace: XRSpace;
  143243. lastChangedTime: number;
  143244. detach(): void;
  143245. }
  143246. interface XRPlane extends XRAnchorCreator {
  143247. orientation: "Horizontal" | "Vertical";
  143248. planeSpace: XRSpace;
  143249. polygon: Array<DOMPointReadOnly>;
  143250. lastChangedTime: number;
  143251. }
  143252. interface XRAnchorCreator {
  143253. // AR Anchors
  143254. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143255. }